Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions Ink Canvas/Controls/FixedAspectRatioPanel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System.Windows;
using System.Windows.Controls;

namespace Ink_Canvas.Controls
{
/// <summary>
/// 在父容器可用空间内计算最大的固定宽高比矩形,
/// 子元素按真实布局尺寸排列(无任何缩放变换),多余空间居中留白。
/// </summary>
public class FixedAspectRatioPanel : Panel
{
public double AspectRatio
{
get => (double)GetValue(AspectRatioProperty);
set => SetValue(AspectRatioProperty, value);
}

public static readonly DependencyProperty AspectRatioProperty =
DependencyProperty.Register(
nameof(AspectRatio),
typeof(double),
typeof(FixedAspectRatioPanel),
new PropertyMetadata(16.0 / 9.0, (d, _) => ((FixedAspectRatioPanel)d).InvalidateMeasure()));

protected override Size MeasureOverride(Size availableSize)
{
double ratio = AspectRatio;
double contentWidth, contentHeight;

double widthByHeight = availableSize.Height * ratio;
if (widthByHeight <= availableSize.Width)
{
contentWidth = widthByHeight;
contentHeight = availableSize.Height;
}
else
{
contentWidth = availableSize.Width;
contentHeight = availableSize.Width / ratio;
}

if (double.IsInfinity(contentWidth)) contentWidth = 0;
if (double.IsInfinity(contentHeight)) contentHeight = 0;

foreach (UIElement child in InternalChildren)
child.Measure(new Size(contentWidth, contentHeight));

return new Size(contentWidth, contentHeight);
}

protected override Size ArrangeOverride(Size finalSize)
{
double ratio = AspectRatio;
double contentWidth, contentHeight;

double widthByHeight = finalSize.Height * ratio;
if (widthByHeight <= finalSize.Width)
{
contentWidth = widthByHeight;
contentHeight = finalSize.Height;
}
else
{
contentWidth = finalSize.Width;
contentHeight = finalSize.Width / ratio;
}

double left = (finalSize.Width - contentWidth) / 2;
double top = (finalSize.Height - contentHeight) / 2;

foreach (UIElement child in InternalChildren)
child.Arrange(new Rect(left, top, contentWidth, contentHeight));

return finalSize;
}
}
}
60 changes: 27 additions & 33 deletions Ink Canvas/Helpers/PPTUIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public class PPTUIManager
public int PPTButtonsDisplayOption { get; set; } = 2222;
public int PPTSButtonsOption { get; set; } = 221;
public int PPTBButtonsOption { get; set; } = 121;
public bool PPTLSButtonShowPageNumber { get; set; } = true;
public bool PPTRSButtonShowPageNumber { get; set; } = true;
public bool PPTLBButtonShowPageNumber { get; set; } = false;
public bool PPTRBButtonShowPageNumber { get; set; } = false;
public bool PPTLSButtonBlackBackground { get; set; } = false;
public bool PPTRSButtonBlackBackground { get; set; } = false;
public bool PPTLBButtonBlackBackground { get; set; } = false;
public bool PPTRBButtonBlackBackground { get; set; } = false;
public int PPTLSButtonPosition { get; set; } = 0;
public int PPTRSButtonPosition { get; set; } = 0;
public int PPTLBButtonPosition { get; set; } = 0;
Expand Down Expand Up @@ -256,7 +264,7 @@ public void UpdateNavigationPanelsVisibility()
_mainWindow.RightBottomPanelForPPTNavigation.Margin = new Thickness(0, 0, 6 + PPTRBButtonPosition, 6);

// 根据显示选项设置面板可见性
var displayOption = PPTButtonsDisplayOption.ToString();
var displayOption = PPTButtonsDisplayOption.ToString().PadLeft(4, '1');
if (displayOption.Length >= 4)
{
var options = displayOption.ToCharArray();
Expand Down Expand Up @@ -400,24 +408,17 @@ private void UpdateSideButtonStyles()
{
try
{
var sideOption = PPTSButtonsOption.ToString();
if (sideOption.Length < 3) return;

var options = sideOption.ToCharArray();

// 页码按钮显示
var pageButtonVisibility = options[0] == '2' ? Visibility.Visible : Visibility.Collapsed;
_mainWindow.LeftSidePanelForPPTNavigation.SetPageButtonVisibility(pageButtonVisibility);
_mainWindow.RightSidePanelForPPTNavigation.SetPageButtonVisibility(pageButtonVisibility);

// 透明度
// 左侧按钮
_mainWindow.LeftSidePanelForPPTNavigation.SetPageButtonVisibility(
PPTLSButtonShowPageNumber ? Visibility.Visible : Visibility.Collapsed);
_mainWindow.LeftSidePanelForPPTNavigation.SetBarOpacity(PPTLSButtonOpacity);
_mainWindow.RightSidePanelForPPTNavigation.SetBarOpacity(PPTRSButtonOpacity);
_mainWindow.LeftSidePanelForPPTNavigation.ApplyTheme(PPTLSButtonBlackBackground);

// 颜色主题
bool isDarkTheme = options[2] == '2';
_mainWindow.LeftSidePanelForPPTNavigation.ApplyTheme(isDarkTheme);
_mainWindow.RightSidePanelForPPTNavigation.ApplyTheme(isDarkTheme);
// 右侧按钮
_mainWindow.RightSidePanelForPPTNavigation.SetPageButtonVisibility(
PPTRSButtonShowPageNumber ? Visibility.Visible : Visibility.Collapsed);
_mainWindow.RightSidePanelForPPTNavigation.SetBarOpacity(PPTRSButtonOpacity);
_mainWindow.RightSidePanelForPPTNavigation.ApplyTheme(PPTRSButtonBlackBackground);
}
catch (Exception ex)
{
Expand All @@ -429,24 +430,17 @@ private void UpdateBottomButtonStyles()
{
try
{
var bottomOption = PPTBButtonsOption.ToString();
if (bottomOption.Length < 3) return;

var options = bottomOption.ToCharArray();

// 页码按钮显示
var pageButtonVisibility = options[0] == '2' ? Visibility.Visible : Visibility.Collapsed;
_mainWindow.LeftBottomPanelForPPTNavigation.SetPageButtonVisibility(pageButtonVisibility);
_mainWindow.RightBottomPanelForPPTNavigation.SetPageButtonVisibility(pageButtonVisibility);

// 透明度
// 左下按钮
_mainWindow.LeftBottomPanelForPPTNavigation.SetPageButtonVisibility(
PPTLBButtonShowPageNumber ? Visibility.Visible : Visibility.Collapsed);
_mainWindow.LeftBottomPanelForPPTNavigation.SetBarOpacity(PPTLBButtonOpacity);
_mainWindow.RightBottomPanelForPPTNavigation.SetBarOpacity(PPTRBButtonOpacity);
_mainWindow.LeftBottomPanelForPPTNavigation.ApplyTheme(PPTLBButtonBlackBackground);

// 颜色主题
bool isDarkTheme = options[2] == '2';
_mainWindow.LeftBottomPanelForPPTNavigation.ApplyTheme(isDarkTheme);
_mainWindow.RightBottomPanelForPPTNavigation.ApplyTheme(isDarkTheme);
// 右下按钮
_mainWindow.RightBottomPanelForPPTNavigation.SetPageButtonVisibility(
PPTRBButtonShowPageNumber ? Visibility.Visible : Visibility.Collapsed);
_mainWindow.RightBottomPanelForPPTNavigation.SetBarOpacity(PPTRBButtonOpacity);
_mainWindow.RightBottomPanelForPPTNavigation.ApplyTheme(PPTRBButtonBlackBackground);
}
catch (Exception ex)
{
Expand Down
14 changes: 14 additions & 0 deletions Ink Canvas/MainWindow_cs/MW_PPT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ public void InitializePPTManagers()

// 初始化UI管理器
_pptUIManager = new PPTUIManager(this);
Settings.PowerPointSettings.MigrateLegacyButtonOptions();
_pptUIManager.ShowPPTButton = Settings.PowerPointSettings.ShowPPTButton;
_pptUIManager.PPTButtonsDisplayOption = Settings.PowerPointSettings.PPTButtonsDisplayOption;
_pptUIManager.PPTSButtonsOption = Settings.PowerPointSettings.PPTSButtonsOption;
Expand All @@ -324,6 +325,19 @@ public void InitializePPTManagers()
_pptUIManager.PPTRBButtonPosition = Settings.PowerPointSettings.PPTRBButtonPosition;
_pptUIManager.EnablePPTButtonPageClickable = Settings.PowerPointSettings.EnablePPTButtonPageClickable;
_pptUIManager.EnablePPTButtonLongPressPageTurn = Settings.PowerPointSettings.EnablePPTButtonLongPressPageTurn;
_pptUIManager.PPTLSButtonOpacity = Settings.PowerPointSettings.PPTLSButtonOpacity;
_pptUIManager.PPTRSButtonOpacity = Settings.PowerPointSettings.PPTRSButtonOpacity;
_pptUIManager.PPTLBButtonOpacity = Settings.PowerPointSettings.PPTLBButtonOpacity;
_pptUIManager.PPTRBButtonOpacity = Settings.PowerPointSettings.PPTRBButtonOpacity;
_pptUIManager.PPTLSButtonShowPageNumber = Settings.PowerPointSettings.PPTLSButtonShowPageNumber;
_pptUIManager.PPTRSButtonShowPageNumber = Settings.PowerPointSettings.PPTRSButtonShowPageNumber;
_pptUIManager.PPTLBButtonShowPageNumber = Settings.PowerPointSettings.PPTLBButtonShowPageNumber;
_pptUIManager.PPTRBButtonShowPageNumber = Settings.PowerPointSettings.PPTRBButtonShowPageNumber;
_pptUIManager.PPTLSButtonBlackBackground = Settings.PowerPointSettings.PPTLSButtonBlackBackground;
_pptUIManager.PPTRSButtonBlackBackground = Settings.PowerPointSettings.PPTRSButtonBlackBackground;
_pptUIManager.PPTLBButtonBlackBackground = Settings.PowerPointSettings.PPTLBButtonBlackBackground;
_pptUIManager.PPTRBButtonBlackBackground = Settings.PowerPointSettings.PPTRBButtonBlackBackground;
_pptUIManager.PPTNavBarScale = Settings.PowerPointSettings.PPTNavBarScale;

LogHelper.WriteLogToFile("PPT管理器初始化完成", LogHelper.LogType.Event);
}
Expand Down
9 changes: 9 additions & 0 deletions Ink Canvas/MainWindow_cs/MW_Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ public void UpdatePPTUIManagerSettings()
{
if (_pptUIManager != null && IsInPPTPresentationMode)
{
Settings.PowerPointSettings.MigrateLegacyButtonOptions();
_pptUIManager.PPTButtonsDisplayOption = Settings.PowerPointSettings.PPTButtonsDisplayOption;
_pptUIManager.PPTSButtonsOption = Settings.PowerPointSettings.PPTSButtonsOption;
_pptUIManager.PPTBButtonsOption = Settings.PowerPointSettings.PPTBButtonsOption;
Expand All @@ -513,6 +514,14 @@ public void UpdatePPTUIManagerSettings()
_pptUIManager.PPTRSButtonOpacity = Settings.PowerPointSettings.PPTRSButtonOpacity;
_pptUIManager.PPTLBButtonOpacity = Settings.PowerPointSettings.PPTLBButtonOpacity;
_pptUIManager.PPTRBButtonOpacity = Settings.PowerPointSettings.PPTRBButtonOpacity;
_pptUIManager.PPTLSButtonShowPageNumber = Settings.PowerPointSettings.PPTLSButtonShowPageNumber;
_pptUIManager.PPTRSButtonShowPageNumber = Settings.PowerPointSettings.PPTRSButtonShowPageNumber;
_pptUIManager.PPTLBButtonShowPageNumber = Settings.PowerPointSettings.PPTLBButtonShowPageNumber;
_pptUIManager.PPTRBButtonShowPageNumber = Settings.PowerPointSettings.PPTRBButtonShowPageNumber;
_pptUIManager.PPTLSButtonBlackBackground = Settings.PowerPointSettings.PPTLSButtonBlackBackground;
_pptUIManager.PPTRSButtonBlackBackground = Settings.PowerPointSettings.PPTRSButtonBlackBackground;
_pptUIManager.PPTLBButtonBlackBackground = Settings.PowerPointSettings.PPTLBButtonBlackBackground;
_pptUIManager.PPTRBButtonBlackBackground = Settings.PowerPointSettings.PPTRBButtonBlackBackground;
_pptUIManager.PPTNavBarScale = Settings.PowerPointSettings.PPTNavBarScale;
_pptUIManager.UpdateNavigationPanelsVisibility();
_pptUIManager.UpdateNavigationButtonStyles();
Expand Down
10 changes: 10 additions & 0 deletions Ink Canvas/Properties/PPTStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Ink Canvas/Properties/PPTStrings.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@
<data name="FlipButtonsScale" xml:space="preserve">
<value>Page-turn button size</value>
</data>
<data name="FlipButtonsSettingHint" xml:space="preserve">
<value>Configure the position, appearance, and behavior of page-turn buttons</value>
</data>
<data name="Configure" xml:space="preserve">
<value>Configure</value>
</data>
<data name="GlobalSettings" xml:space="preserve">
<value>Global settings</value>
</data>
<data name="Positions" xml:space="preserve">
<value>Display positions</value>
</data>
<data name="EnablePositionButton" xml:space="preserve">
<value>Enable {0} button</value>
</data>
<data name="GoToFirstPageOnReenter" xml:space="preserve">
<value>Go to first slide when starting a slideshow</value>
</data>
Expand Down
15 changes: 15 additions & 0 deletions Ink Canvas/Properties/PPTStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@
<data name="FlipButtonsScale" xml:space="preserve">
<value>翻页按钮大小</value>
</data>
<data name="FlipButtonsSettingHint" xml:space="preserve">
<value>配置翻页按钮的位置、外观与行为</value>
</data>
<data name="Configure" xml:space="preserve">
<value>配置</value>
</data>
<data name="GlobalSettings" xml:space="preserve">
<value>全局设置</value>
</data>
<data name="Positions" xml:space="preserve">
<value>显示位置</value>
</data>
<data name="EnablePositionButton" xml:space="preserve">
<value>启用{0}按钮</value>
</data>
<data name="GoToFirstPageOnReenter" xml:space="preserve">
<value>进入放映时回到首页</value>
</data>
Expand Down
17 changes: 16 additions & 1 deletion Ink Canvas/Properties/PPTStrings.zh-ME.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
Expand Down Expand Up @@ -84,6 +84,21 @@
<data name="FlipButtonsScale" xml:space="preserve">
<value>翻页按钮大小</value>
</data>
<data name="FlipButtonsSettingHint" xml:space="preserve">
<value>配置翻页按钮的位置、外观和行为</value>
</data>
<data name="Configure" xml:space="preserve">
<value>配置</value>
</data>
<data name="GlobalSettings" xml:space="preserve">
<value>全局设置</value>
</data>
<data name="Positions" xml:space="preserve">
<value>显示位置</value>
</data>
<data name="EnablePositionButton" xml:space="preserve">
<value>启用{0}按钮</value>
</data>
<data name="GoToFirstPageOnReenter" xml:space="preserve">
<value>进放映时回到首页</value>
</data>
Expand Down
Loading