Fix bug and add fake pen pressure
This commit is contained in:
parent
4901759fe0
commit
d1fe3d462a
@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<runtime>
|
|
||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
|
||||||
<dependentAssembly>
|
|
||||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
|
||||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
|
||||||
</dependentAssembly>
|
|
||||||
<dependentAssembly>
|
|
||||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
|
||||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
|
||||||
</dependentAssembly>
|
|
||||||
</assemblyBinding>
|
|
||||||
</runtime>
|
|
||||||
</configuration>
|
|
@ -87,6 +87,9 @@
|
|||||||
<Compile Include="ChangeLogWindow.xaml.cs">
|
<Compile Include="ChangeLogWindow.xaml.cs">
|
||||||
<DependentUpon>ChangeLogWindow.xaml</DependentUpon>
|
<DependentUpon>ChangeLogWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="RestoreHiddenSlidesWindow.xaml.cs">
|
||||||
|
<DependentUpon>RestoreHiddenSlidesWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Settings.cs" />
|
<Compile Include="Settings.cs" />
|
||||||
<Compile Include="SettingsPage.xaml.cs">
|
<Compile Include="SettingsPage.xaml.cs">
|
||||||
<DependentUpon>SettingsPage.xaml</DependentUpon>
|
<DependentUpon>SettingsPage.xaml</DependentUpon>
|
||||||
@ -108,6 +111,10 @@
|
|||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Page Include="RestoreHiddenSlidesWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="SettingsPage.xaml">
|
<Page Include="SettingsPage.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
</DrawingAttributes>
|
</DrawingAttributes>
|
||||||
</InkCanvas.DefaultDrawingAttributes>-->
|
</InkCanvas.DefaultDrawingAttributes>-->
|
||||||
</InkCanvas>
|
</InkCanvas>
|
||||||
<Grid Name="GridInkCanvasSelectionCover" IsManipulationEnabled="True"
|
<Grid Name="GridInkCanvasSelectionCover" MouseUp="GridInkCanvasSelectionCover_MouseUp" IsManipulationEnabled="True"
|
||||||
ManipulationStarting="GridInkCanvasSelectionCover_ManipulationStarting"
|
ManipulationStarting="GridInkCanvasSelectionCover_ManipulationStarting"
|
||||||
ManipulationCompleted="GridInkCanvasSelectionCover_ManipulationCompleted"
|
ManipulationCompleted="GridInkCanvasSelectionCover_ManipulationCompleted"
|
||||||
ManipulationDelta="GridInkCanvasSelectionCover_ManipulationDelta"
|
ManipulationDelta="GridInkCanvasSelectionCover_ManipulationDelta"
|
||||||
@ -253,7 +253,9 @@
|
|||||||
Width="120" Margin="10"
|
Width="120" Margin="10"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Content="关闭"
|
Content="关闭"
|
||||||
Click="BtnSettings_Click"/>
|
Click="BtnSettings_Click"
|
||||||
|
Foreground="Black"
|
||||||
|
Background="{Binding ElementName=BtnExit, Path=Background}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
@ -605,6 +605,8 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
#region Touch Events
|
#region Touch Events
|
||||||
|
|
||||||
|
int lastTouchDownTime = 0, lastTouchUpTime = 0;
|
||||||
|
|
||||||
bool isTouchDown = false; Point iniP = new Point(0, 0);
|
bool isTouchDown = false; Point iniP = new Point(0, 0);
|
||||||
bool isLastTouchEraser = false;
|
bool isLastTouchEraser = false;
|
||||||
private void Main_Grid_TouchDown(object sender, TouchEventArgs e)
|
private void Main_Grid_TouchDown(object sender, TouchEventArgs e)
|
||||||
@ -718,7 +720,7 @@ namespace Ink_Canvas
|
|||||||
private MatrixTransform imageTransform;
|
private MatrixTransform imageTransform;
|
||||||
private void Main_Grid_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
|
private void Main_Grid_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
|
||||||
{
|
{
|
||||||
if ((dec.Count >= 2 && (Settings.Gesture.IsEnableTwoFingerGestureInPresentationMode || StackPanelPPTControls.Visibility != Visibility.Visible)) || isSingleFingerDragMode)
|
if ((dec.Count >= 2 && (Settings.Gesture.IsEnableTwoFingerGestureInPresentationMode || StackPanelPPTControls.Visibility != Visibility.Visible || StackPanelPPTButtons.Visibility == Visibility.Collapsed)) || isSingleFingerDragMode)
|
||||||
{
|
{
|
||||||
ManipulationDelta md = e.DeltaManipulation;
|
ManipulationDelta md = e.DeltaManipulation;
|
||||||
Vector trans = md.Translation; // 获得位移矢量
|
Vector trans = md.Translation; // 获得位移矢量
|
||||||
@ -856,6 +858,8 @@ namespace Ink_Canvas
|
|||||||
BtnExit.Foreground = Brushes.White;
|
BtnExit.Foreground = Brushes.White;
|
||||||
GridBackgroundCover.Background = new SolidColorBrush(StringToColor("#FF1A1A1A"));
|
GridBackgroundCover.Background = new SolidColorBrush(StringToColor("#FF1A1A1A"));
|
||||||
BtnColorBlack.Background = Brushes.White;
|
BtnColorBlack.Background = Brushes.White;
|
||||||
|
BtnColorGreen.Background = new SolidColorBrush(StringToColor("#FF1ED760"));
|
||||||
|
BtnColorYellow.Background = new SolidColorBrush(StringToColor("#FFFFC000"));
|
||||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
|
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
|
||||||
if (inkColor == 0)
|
if (inkColor == 0)
|
||||||
{
|
{
|
||||||
@ -880,6 +884,8 @@ namespace Ink_Canvas
|
|||||||
BtnExit.Foreground = Brushes.Black;
|
BtnExit.Foreground = Brushes.Black;
|
||||||
GridBackgroundCover.Background = new SolidColorBrush(StringToColor("#FFF2F2F2"));
|
GridBackgroundCover.Background = new SolidColorBrush(StringToColor("#FFF2F2F2"));
|
||||||
BtnColorBlack.Background = Brushes.Black;
|
BtnColorBlack.Background = Brushes.Black;
|
||||||
|
BtnColorGreen.Background = new SolidColorBrush(StringToColor("#FF169141"));
|
||||||
|
BtnColorYellow.Background = new SolidColorBrush(StringToColor("#FFF38B00"));
|
||||||
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
|
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
|
||||||
if (inkColor == 0)
|
if (inkColor == 0)
|
||||||
{
|
{
|
||||||
@ -988,6 +994,7 @@ namespace Ink_Canvas
|
|||||||
Main_Grid.Background = Brushes.Transparent;
|
Main_Grid.Background = Brushes.Transparent;
|
||||||
inkCanvas.Visibility = Visibility.Collapsed;
|
inkCanvas.Visibility = Visibility.Collapsed;
|
||||||
GridBackgroundCoverHolder.Visibility = Visibility.Collapsed;
|
GridBackgroundCoverHolder.Visibility = Visibility.Collapsed;
|
||||||
|
if (currentMode != 0) SaveStrokes();
|
||||||
if (BtnSwitchTheme.Content.ToString() == "浅色")
|
if (BtnSwitchTheme.Content.ToString() == "浅色")
|
||||||
{
|
{
|
||||||
BtnSwitch.Content = "黑板";
|
BtnSwitch.Content = "黑板";
|
||||||
@ -1017,11 +1024,11 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
#region PowerPoint
|
#region PowerPoint
|
||||||
|
|
||||||
Microsoft.Office.Interop.PowerPoint.Application pptApplication = null;
|
public static Microsoft.Office.Interop.PowerPoint.Application pptApplication = null;
|
||||||
Microsoft.Office.Interop.PowerPoint.Presentation presentation = null;
|
public static Microsoft.Office.Interop.PowerPoint.Presentation presentation = null;
|
||||||
Microsoft.Office.Interop.PowerPoint.Slides slides = null;
|
public static Microsoft.Office.Interop.PowerPoint.Slides slides = null;
|
||||||
Microsoft.Office.Interop.PowerPoint.Slide slide = null;
|
public static Microsoft.Office.Interop.PowerPoint.Slide slide = null;
|
||||||
int slidescount = 0;
|
public static int slidescount = 0;
|
||||||
private void BtnCheckPPT_Click(object sender, RoutedEventArgs e)
|
private void BtnCheckPPT_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1117,8 +1124,24 @@ namespace Ink_Canvas
|
|||||||
if (pptApplication == null) throw new Exception();
|
if (pptApplication == null) throw new Exception();
|
||||||
//BtnCheckPPT.Visibility = Visibility.Collapsed;
|
//BtnCheckPPT.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
|
//检查是否有隐藏幻灯片
|
||||||
|
bool isHaveHiddenSlide = false;
|
||||||
|
foreach (Slide slide in slides)
|
||||||
|
{
|
||||||
|
if (slide.SlideShowTransition.Hidden == Microsoft.Office.Core.MsoTriState.msoTrue)
|
||||||
|
{
|
||||||
|
isHaveHiddenSlide = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
|
if (isHaveHiddenSlide)
|
||||||
|
{
|
||||||
|
new RestoreHiddenSlidesWindow().ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
BtnPPTSlideShow.Visibility = Visibility.Visible;
|
BtnPPTSlideShow.Visibility = Visibility.Visible;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1234,7 +1257,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
private void Main_Grid_PreviewKeyDown(object sender, KeyEventArgs e)
|
private void Main_Grid_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (StackPanelPPTControls.Visibility != Visibility.Visible) return;
|
if (StackPanelPPTControls.Visibility != Visibility.Visible || currentMode != 0) return;
|
||||||
|
|
||||||
if (e.Key == Key.Down || e.Key == Key.PageDown || e.Key == Key.Right)
|
if (e.Key == Key.Down || e.Key == Key.PageDown || e.Key == Key.Right)
|
||||||
{
|
{
|
||||||
@ -2304,25 +2327,32 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
#endregion Whiteboard Controls
|
#endregion Whiteboard Controls
|
||||||
|
|
||||||
|
//此函数中的所有代码版权所有 WXRIW,在其他项目中使用前必须提前联系(wxriw@outlook.com),谢谢!
|
||||||
private void inkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
|
private void inkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!ToggleSwitchSimulatePressure.IsOn) return;
|
//Label.Visibility = Visibility.Visible;
|
||||||
|
//Label.Content = e.Stroke.StylusPoints.Count.ToString();
|
||||||
|
//if (!ToggleSwitchSimulatePressure.IsOn) return;
|
||||||
|
int mode = 1;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
StylusPointCollection stylusPoints = new StylusPointCollection();
|
StylusPointCollection stylusPoints = new StylusPointCollection();
|
||||||
int n = e.Stroke.StylusPoints.Count - 1;
|
int n = e.Stroke.StylusPoints.Count - 1;
|
||||||
string s = "";
|
string s = "";
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i <= n; i++)
|
||||||
{
|
{
|
||||||
double speed = GetPointSpeed(e.Stroke.StylusPoints[Math.Max(i - 1, 0)].ToPoint(), e.Stroke.StylusPoints[i].ToPoint(), e.Stroke.StylusPoints[Math.Min(i + 1, n)].ToPoint());
|
double speed = GetPointSpeed(e.Stroke.StylusPoints[Math.Max(i - 1, 0)].ToPoint(), e.Stroke.StylusPoints[i].ToPoint(), e.Stroke.StylusPoints[Math.Min(i + 1, n)].ToPoint());
|
||||||
s += speed.ToString() + "\t";
|
s += speed.ToString() + "\t";
|
||||||
StylusPoint point = new StylusPoint();
|
StylusPoint point = new StylusPoint();
|
||||||
if (speed >= 0.5)
|
if (speed >= 0.25)
|
||||||
{
|
{
|
||||||
point.PressureFactor = (float)(0.5 - 0.3 * (Math.Min(speed, 1) - 0.5) / 0.5);
|
point.PressureFactor = (float)(0.5 - 0.3 * (Math.Min(speed, 1.5) - 0.3) / 1.2);
|
||||||
}
|
}
|
||||||
else if(speed >= 0.05)
|
else if (speed >= 0.05)
|
||||||
{
|
{
|
||||||
point.PressureFactor = (float)0.5;
|
point.PressureFactor = (float)0.5;
|
||||||
}
|
}
|
||||||
@ -2334,14 +2364,118 @@ namespace Ink_Canvas
|
|||||||
point.Y = e.Stroke.StylusPoints[i].Y;
|
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||||
stylusPoints.Add(point);
|
stylusPoints.Add(point);
|
||||||
}
|
}
|
||||||
Label.Visibility = Visibility.Visible;
|
//Label.Visibility = Visibility.Visible;
|
||||||
Label.Content = s;
|
//Label.Content = s;
|
||||||
e.Stroke.StylusPoints = stylusPoints;
|
e.Stroke.StylusPoints = stylusPoints;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StylusPointCollection stylusPoints = new StylusPointCollection();
|
||||||
|
int n = e.Stroke.StylusPoints.Count - 1;
|
||||||
|
double pressure = 0.1;
|
||||||
|
int x = 8;
|
||||||
|
if(n >= x)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < n - x; i++)
|
||||||
|
{
|
||||||
|
StylusPoint point = new StylusPoint();
|
||||||
|
|
||||||
|
point.PressureFactor = (float)0.5;
|
||||||
|
point.X = e.Stroke.StylusPoints[i].X;
|
||||||
|
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||||
|
stylusPoints.Add(point);
|
||||||
|
}
|
||||||
|
for (int i = n - x; i <= n; i++)
|
||||||
|
{
|
||||||
|
StylusPoint point = new StylusPoint();
|
||||||
|
|
||||||
|
point.PressureFactor = (float)((0.5 - pressure) * (n - i) / x + pressure);
|
||||||
|
point.X = e.Stroke.StylusPoints[i].X;
|
||||||
|
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||||
|
stylusPoints.Add(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= n; i++)
|
||||||
|
{
|
||||||
|
StylusPoint point = new StylusPoint();
|
||||||
|
|
||||||
|
point.PressureFactor = (float)(0.4 * (n - i) / n + pressure);
|
||||||
|
point.X = e.Stroke.StylusPoints[i].X;
|
||||||
|
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||||
|
stylusPoints.Add(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.Stroke.StylusPoints = stylusPoints;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
try
|
||||||
|
{
|
||||||
|
StylusPointCollection stylusPoints = new StylusPointCollection();
|
||||||
|
int n = e.Stroke.StylusPoints.Count - 1;
|
||||||
|
double pressure = 0.1;
|
||||||
|
int x = 8;
|
||||||
|
if (lastTouchDownTime < lastTouchUpTime)
|
||||||
|
{
|
||||||
|
double k = (lastTouchUpTime - lastTouchDownTime) / (n + 1); // 每个点之间间隔 k 毫秒
|
||||||
|
Label.Visibility = Visibility.Visible;
|
||||||
|
Label.Content = k.ToString();
|
||||||
|
x = (int)(1000 / k); // 取 1000 ms 内的点
|
||||||
|
}
|
||||||
|
|
||||||
|
if(n >= x)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < n - x; i++)
|
||||||
|
{
|
||||||
|
StylusPoint point = new StylusPoint();
|
||||||
|
|
||||||
|
point.PressureFactor = (float)0.5;
|
||||||
|
point.X = e.Stroke.StylusPoints[i].X;
|
||||||
|
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||||
|
stylusPoints.Add(point);
|
||||||
|
}
|
||||||
|
for (int i = n - x; i <= n; i++)
|
||||||
|
{
|
||||||
|
StylusPoint point = new StylusPoint();
|
||||||
|
|
||||||
|
point.PressureFactor = (float)((0.5 - pressure) * (n - i) / x + pressure);
|
||||||
|
point.X = e.Stroke.StylusPoints[i].X;
|
||||||
|
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||||
|
stylusPoints.Add(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= n; i++)
|
||||||
|
{
|
||||||
|
StylusPoint point = new StylusPoint();
|
||||||
|
|
||||||
|
point.PressureFactor = (float)(0.4 * (n - i) / n + pressure);
|
||||||
|
point.X = e.Stroke.StylusPoints[i].X;
|
||||||
|
point.Y = e.Stroke.StylusPoints[i].Y;
|
||||||
|
stylusPoints.Add(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.Stroke.StylusPoints = stylusPoints;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetPointSpeed(Point point1, Point point2, Point point3)
|
public double GetPointSpeed(Point point1, Point point2, Point point3)
|
||||||
@ -2429,6 +2563,11 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GridInkCanvasSelectionCover_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
private void BtnClear_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
private void BtnClear_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
//BtnClear_Click(BtnClear, null);
|
//BtnClear_Click(BtnClear, null);
|
||||||
@ -2448,115 +2587,115 @@ namespace Ink_Canvas
|
|||||||
// A StylusPlugin that renders ink with a linear gradient brush effect.
|
// A StylusPlugin that renders ink with a linear gradient brush effect.
|
||||||
class CustomDynamicRenderer : DynamicRenderer
|
class CustomDynamicRenderer : DynamicRenderer
|
||||||
{
|
{
|
||||||
//[ThreadStatic]
|
[ThreadStatic]
|
||||||
//static private Brush brush = null;
|
static private Brush brush = null;
|
||||||
|
|
||||||
//[ThreadStatic]
|
[ThreadStatic]
|
||||||
//static private Pen pen = null;
|
static private Pen pen = null;
|
||||||
|
|
||||||
//private Point prevPoint;
|
private Point prevPoint;
|
||||||
|
|
||||||
//protected override void OnStylusDown(RawStylusInput rawStylusInput)
|
protected override void OnStylusDown(RawStylusInput rawStylusInput)
|
||||||
|
{
|
||||||
|
// Allocate memory to store the previous point to draw from.
|
||||||
|
prevPoint = new Point(double.NegativeInfinity, double.NegativeInfinity);
|
||||||
|
base.OnStylusDown(rawStylusInput);
|
||||||
|
}
|
||||||
|
//protected override void OnDraw(System.Windows.Media.DrawingContext drawingContext, System.Windows.Input.StylusPointCollection stylusPoints, System.Windows.Media.Geometry geometry, System.Windows.Media.Brush fillBrush)
|
||||||
//{
|
//{
|
||||||
// // Allocate memory to store the previous point to draw from.
|
|
||||||
// prevPoint = new Point(double.NegativeInfinity, double.NegativeInfinity);
|
|
||||||
// base.OnStylusDown(rawStylusInput);
|
|
||||||
//}
|
|
||||||
protected override void OnDraw(System.Windows.Media.DrawingContext drawingContext, System.Windows.Input.StylusPointCollection stylusPoints, System.Windows.Media.Geometry geometry, System.Windows.Media.Brush fillBrush)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
ImageSource img = new BitmapImage(new Uri("pack://application:,,,/Resources/maobi.png"));
|
// ImageSource img = new BitmapImage(new Uri("pack://application:,,,/Resources/maobi.png"));
|
||||||
|
|
||||||
//前一个点的绘制。
|
// //前一个点的绘制。
|
||||||
Point prevPoint = new Point(double.NegativeInfinity,
|
// Point prevPoint = new Point(double.NegativeInfinity,
|
||||||
double.NegativeInfinity);
|
// double.NegativeInfinity);
|
||||||
|
|
||||||
|
|
||||||
var w = Global.StrokeWidth + 15; //输出时笔刷的实际大小
|
// var w = Global.StrokeWidth + 15; //输出时笔刷的实际大小
|
||||||
|
|
||||||
|
|
||||||
Point pt = new Point(0, 0);
|
// Point pt = new Point(0, 0);
|
||||||
Vector v = new Vector(); //前一个点与当前点的距离
|
// Vector v = new Vector(); //前一个点与当前点的距离
|
||||||
var subtractY = 0d; //当前点处前一点的Y偏移
|
// var subtractY = 0d; //当前点处前一点的Y偏移
|
||||||
var subtractX = 0d; //当前点处前一点的X偏移
|
// var subtractX = 0d; //当前点处前一点的X偏移
|
||||||
var pointWidth = Global.StrokeWidth;
|
// var pointWidth = Global.StrokeWidth;
|
||||||
double x = 0, y = 0;
|
// double x = 0, y = 0;
|
||||||
for (int i = 0; i < stylusPoints.Count; i++)
|
|
||||||
{
|
|
||||||
pt = (Point)stylusPoints[i];
|
|
||||||
v = Point.Subtract(prevPoint, pt);
|
|
||||||
|
|
||||||
Debug.WriteLine("X " + pt.X + "\t" + pt.Y);
|
|
||||||
|
|
||||||
subtractY = (pt.Y - prevPoint.Y) / v.Length; //设置stylusPoints两个点之间需要填充的XY偏移
|
|
||||||
subtractX = (pt.X - prevPoint.X) / v.Length;
|
|
||||||
|
|
||||||
if (w - v.Length < Global.StrokeWidth) //控制笔刷大小
|
|
||||||
{
|
|
||||||
pointWidth = Global.StrokeWidth;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pointWidth = w - v.Length; //在两个点距离越大的时候,笔刷所展示的大小越小
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (double j = 0; j < v.Length; j = j + 1d) //填充stylusPoints两个点之间
|
|
||||||
{
|
|
||||||
x = 0; y = 0;
|
|
||||||
|
|
||||||
if (prevPoint.X == double.NegativeInfinity || prevPoint.Y == double.NegativeInfinity || double.PositiveInfinity == prevPoint.X || double.PositiveInfinity == prevPoint.Y)
|
|
||||||
{
|
|
||||||
y = pt.Y;
|
|
||||||
x = pt.X;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
y = prevPoint.Y + subtractY;
|
|
||||||
x = prevPoint.X + subtractX;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawingContext.DrawImage(img, new Rect(x - pointWidth / 2, y - pointWidth / 2, pointWidth, pointWidth)); //在当前点画笔刷图片
|
|
||||||
prevPoint = new Point(x, y);
|
|
||||||
|
|
||||||
|
|
||||||
if (double.IsNegativeInfinity(v.Length) || double.IsPositiveInfinity(v.Length))
|
|
||||||
{ break; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stylusPoints = null;
|
|
||||||
}
|
|
||||||
//protected override void OnDraw(DrawingContext drawingContext,
|
|
||||||
// StylusPointCollection stylusPoints,
|
|
||||||
// Geometry geometry, Brush fillBrush)
|
|
||||||
//{
|
|
||||||
// // Create a new Brush, if necessary.
|
|
||||||
// //brush ??= new LinearGradientBrush(Colors.Red, Colors.Blue, 20d);
|
|
||||||
|
|
||||||
// // Create a new Pen, if necessary.
|
|
||||||
// //pen ??= new Pen(brush, 2d);
|
|
||||||
|
|
||||||
// // Draw linear gradient ellipses between
|
|
||||||
// // all the StylusPoints that have come in.
|
|
||||||
// for (int i = 0; i < stylusPoints.Count; i++)
|
// for (int i = 0; i < stylusPoints.Count; i++)
|
||||||
// {
|
// {
|
||||||
// Point pt = (Point)stylusPoints[i];
|
// pt = (Point)stylusPoints[i];
|
||||||
// Vector v = Point.Subtract(prevPoint, pt);
|
// v = Point.Subtract(prevPoint, pt);
|
||||||
|
|
||||||
// // Only draw if we are at least 4 units away
|
// Debug.WriteLine("X " + pt.X + "\t" + pt.Y);
|
||||||
// // from the end of the last ellipse. Otherwise,
|
|
||||||
// // we're just redrawing and wasting cycles.
|
// subtractY = (pt.Y - prevPoint.Y) / v.Length; //设置stylusPoints两个点之间需要填充的XY偏移
|
||||||
// if (v.Length > 4)
|
// subtractX = (pt.X - prevPoint.X) / v.Length;
|
||||||
|
|
||||||
|
// if (w - v.Length < Global.StrokeWidth) //控制笔刷大小
|
||||||
// {
|
// {
|
||||||
// // Set the thickness of the stroke based
|
// pointWidth = Global.StrokeWidth;
|
||||||
// // on how hard the user pressed.
|
// }
|
||||||
// double radius = stylusPoints[i].PressureFactor * 10d;
|
// else
|
||||||
// drawingContext.DrawEllipse(brush, pen, pt, radius, radius);
|
// {
|
||||||
// prevPoint = pt;
|
// pointWidth = w - v.Length; //在两个点距离越大的时候,笔刷所展示的大小越小
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// for (double j = 0; j < v.Length; j = j + 1d) //填充stylusPoints两个点之间
|
||||||
|
// {
|
||||||
|
// x = 0; y = 0;
|
||||||
|
|
||||||
|
// if (prevPoint.X == double.NegativeInfinity || prevPoint.Y == double.NegativeInfinity || double.PositiveInfinity == prevPoint.X || double.PositiveInfinity == prevPoint.Y)
|
||||||
|
// {
|
||||||
|
// y = pt.Y;
|
||||||
|
// x = pt.X;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// y = prevPoint.Y + subtractY;
|
||||||
|
// x = prevPoint.X + subtractX;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// drawingContext.DrawImage(img, new Rect(x - pointWidth / 2, y - pointWidth / 2, pointWidth, pointWidth)); //在当前点画笔刷图片
|
||||||
|
// prevPoint = new Point(x, y);
|
||||||
|
|
||||||
|
|
||||||
|
// if (double.IsNegativeInfinity(v.Length) || double.IsPositiveInfinity(v.Length))
|
||||||
|
// { break; }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
// stylusPoints = null;
|
||||||
//}
|
//}
|
||||||
|
protected override void OnDraw(DrawingContext drawingContext,
|
||||||
|
StylusPointCollection stylusPoints,
|
||||||
|
Geometry geometry, Brush fillBrush)
|
||||||
|
{
|
||||||
|
// Create a new Brush, if necessary.
|
||||||
|
//brush ??= new LinearGradientBrush(Colors.Red, Colors.Blue, 20d);
|
||||||
|
|
||||||
|
// Create a new Pen, if necessary.
|
||||||
|
//pen ??= new Pen(brush, 2d);
|
||||||
|
|
||||||
|
// Draw linear gradient ellipses between
|
||||||
|
// all the StylusPoints that have come in.
|
||||||
|
for (int i = 0; i < stylusPoints.Count; i++)
|
||||||
|
{
|
||||||
|
Point pt = (Point)stylusPoints[i];
|
||||||
|
Vector v = Point.Subtract(prevPoint, pt);
|
||||||
|
|
||||||
|
// Only draw if we are at least 4 units away
|
||||||
|
// from the end of the last ellipse. Otherwise,
|
||||||
|
// we're just redrawing and wasting cycles.
|
||||||
|
if (v.Length > 4)
|
||||||
|
{
|
||||||
|
// Set the thickness of the stroke based
|
||||||
|
// on how hard the user pressed.
|
||||||
|
double radius = stylusPoints[i].PressureFactor * 10d;
|
||||||
|
drawingContext.DrawEllipse(brush, pen, pt, radius, radius);
|
||||||
|
prevPoint = pt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class Global
|
public class Global
|
||||||
{
|
{
|
||||||
@ -2573,18 +2712,18 @@ namespace Ink_Canvas
|
|||||||
this.DynamicRenderer = customRenderer;
|
this.DynamicRenderer = customRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//protected override void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
|
protected override void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
|
||||||
//{
|
{
|
||||||
// //// Remove the original stroke and add a custom stroke.
|
// Remove the original stroke and add a custom stroke.
|
||||||
// //this.Strokes.Remove(e.Stroke);
|
this.Strokes.Remove(e.Stroke);
|
||||||
// //CustomStroke customStroke = new CustomStroke(e.Stroke.StylusPoints);
|
CustomStroke customStroke = new CustomStroke(e.Stroke.StylusPoints);
|
||||||
// //this.Strokes.Add(customStroke);
|
this.Strokes.Add(customStroke);
|
||||||
|
|
||||||
// // Pass the custom stroke to base class' OnStrokeCollected method.
|
// Pass the custom stroke to base class' OnStrokeCollected method.
|
||||||
// InkCanvasStrokeCollectedEventArgs args =
|
InkCanvasStrokeCollectedEventArgs args =
|
||||||
// new InkCanvasStrokeCollectedEventArgs(customStroke);
|
new InkCanvasStrokeCollectedEventArgs(customStroke);
|
||||||
// base.OnStrokeCollected(args);
|
base.OnStrokeCollected(args);
|
||||||
//}
|
}
|
||||||
}// A class for rendering custom strokes
|
}// A class for rendering custom strokes
|
||||||
class CustomStroke : Stroke
|
class CustomStroke : Stroke
|
||||||
{
|
{
|
||||||
@ -2663,33 +2802,33 @@ namespace Ink_Canvas
|
|||||||
// }
|
// }
|
||||||
// stylusPoints = null;
|
// stylusPoints = null;
|
||||||
//}
|
//}
|
||||||
//protected override void DrawCore(DrawingContext drawingContext,
|
protected override void DrawCore(DrawingContext drawingContext,
|
||||||
// DrawingAttributes drawingAttributes)
|
DrawingAttributes drawingAttributes)
|
||||||
//{
|
{
|
||||||
// // Allocate memory to store the previous point to draw from.
|
// Allocate memory to store the previous point to draw from.
|
||||||
// Point prevPoint = new Point(double.NegativeInfinity,
|
Point prevPoint = new Point(double.NegativeInfinity,
|
||||||
// double.NegativeInfinity);
|
double.NegativeInfinity);
|
||||||
|
|
||||||
// // Draw linear gradient ellipses between
|
// Draw linear gradient ellipses between
|
||||||
// // all the StylusPoints in the Stroke.
|
// all the StylusPoints in the Stroke.
|
||||||
// for (int i = 0; i < this.StylusPoints.Count; i++)
|
for (int i = 0; i < this.StylusPoints.Count; i++)
|
||||||
// {
|
{
|
||||||
// Point pt = (Point)this.StylusPoints[i];
|
Point pt = (Point)this.StylusPoints[i];
|
||||||
// Vector v = Point.Subtract(prevPoint, pt);
|
Vector v = Point.Subtract(prevPoint, pt);
|
||||||
|
|
||||||
// // Only draw if we are at least 4 units away
|
// Only draw if we are at least 4 units away
|
||||||
// // from the end of the last ellipse. Otherwise,
|
// from the end of the last ellipse. Otherwise,
|
||||||
// // we're just redrawing and wasting cycles.
|
// we're just redrawing and wasting cycles.
|
||||||
// if (v.Length > 4)
|
if (v.Length > 4)
|
||||||
// {
|
{
|
||||||
// // Set the thickness of the stroke
|
// Set the thickness of the stroke
|
||||||
// // based on how hard the user pressed.
|
// based on how hard the user pressed.
|
||||||
// double radius = this.StylusPoints[i].PressureFactor * 10d;
|
double radius = this.StylusPoints[i].PressureFactor * 10d;
|
||||||
// drawingContext.DrawEllipse(brush, pen, pt, radius, radius);
|
drawingContext.DrawEllipse(brush, pen, pt, radius, radius);
|
||||||
// prevPoint = pt;
|
prevPoint = pt;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
26
Ink Canvas/RestoreHiddenSlidesWindow.xaml
Normal file
26
Ink Canvas/RestoreHiddenSlidesWindow.xaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<Window x:Class="Ink_Canvas.RestoreHiddenSlidesWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:Ink_Canvas" xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||||
|
mc:Ignorable="d" Topmost="True" WindowStartupLocation="CenterScreen" ui:WindowHelper.UseModernWindowStyle="True"
|
||||||
|
ResizeMode="NoResize"
|
||||||
|
Title="演示文档设置 - Ink Canvas 画板" Height="160" Width="450" FontFamily="Microsoft YaHei UI">
|
||||||
|
<Grid>
|
||||||
|
<Grid Margin="10">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="40"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Viewbox HorizontalAlignment="Left" Margin="10" Height="30">
|
||||||
|
<ui:SymbolIcon Symbol="SlideShow" Foreground="{Binding ElementName=Label, Path=Foreground}"/>
|
||||||
|
</Viewbox>
|
||||||
|
<Label Name="Label" Content="检测到此演示文档中包含隐藏的幻灯片,是否取消隐藏?" Margin="60,20,0,20" VerticalAlignment="Center"/>
|
||||||
|
<ui:SimpleStackPanel Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Horizontal" Spacing="10">
|
||||||
|
<Button Margin="0" Content="是" Width="100" FontFamily="Microsoft YaHei UI" Click="ButtonYes_Click"/>
|
||||||
|
<Button Margin="0" Content="否" Width="100" FontFamily="Microsoft YaHei UI" Click="ButtonNo_Click"/>
|
||||||
|
</ui:SimpleStackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
48
Ink Canvas/RestoreHiddenSlidesWindow.xaml.cs
Normal file
48
Ink Canvas/RestoreHiddenSlidesWindow.xaml.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using Microsoft.Office.Interop.PowerPoint;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Application = System.Windows.Application;
|
||||||
|
|
||||||
|
namespace Ink_Canvas
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for RestoreHiddenSlidesWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class RestoreHiddenSlidesWindow : Window
|
||||||
|
{
|
||||||
|
public RestoreHiddenSlidesWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonYes_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
foreach (Slide slide in MainWindow.slides)
|
||||||
|
{
|
||||||
|
if (slide.SlideShowTransition.Hidden == Microsoft.Office.Core.MsoTriState.msoTrue)
|
||||||
|
{
|
||||||
|
slide.SlideShowTransition.Hidden = Microsoft.Office.Core.MsoTriState.msoFalse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonNo_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user