Merge branch 'master' of https://github.com/WXRIW/Ink-Canvas into feat/TimeMachine

# Conflicts:
#	Ink Canvas/MainWindow.xaml.cs
This commit is contained in:
Raspberry-Monster 2023-04-25 13:26:56 +08:00
commit 99fd5497f6
No known key found for this signature in database
GPG Key ID: 9A0D725BB122D507
5 changed files with 356 additions and 181 deletions

View File

@ -44,6 +44,20 @@ jobs:
msbuild /p:Configuration=Release /p:Platform="Any CPU" /p:GitFlow="Github Action"
env:
Configuration: ${{ matrix.configuration }}
- name: Build the solution (x64)
run: |
msbuild -t:restore /p:GitFlow="Github Action"
msbuild /p:Configuration=Release /p:Platform="x64" /p:GitFlow="Github Action"
env:
Configuration: ${{ matrix.configuration }}
- name: Build the solution (ARM64)
run: |
msbuild -t:restore /p:GitFlow="Github Action"
msbuild /p:Configuration=Release /p:Platform="ARM64" /p:GitFlow="Github Action"
env:
Configuration: ${{ matrix.configuration }}
# 上传编译成品
- name: Upload to artifact
@ -51,3 +65,15 @@ jobs:
with:
name: Ink-Canvas
path: Ink Canvas/bin/Release
- name: Upload to artifact (x64)
uses: actions/upload-artifact@main
with:
name: Ink-Canvas-x64
path: Ink Canvas/bin/x64/Release
- name: Upload to artifact (ARM64)
uses: actions/upload-artifact@main
with:
name: Ink-Canvas-ARM64
path: Ink Canvas/bin/ARM64/Release

View File

@ -1,20 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
# Visual Studio Version 17
VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ink Canvas", "Ink Canvas\Ink Canvas.csproj", "{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|ARM64.ActiveCfg = Debug|ARM64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|ARM64.Build.0 = Debug|ARM64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|x64.ActiveCfg = Debug|x64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Debug|x64.Build.0 = Debug|x64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|Any CPU.Build.0 = Release|Any CPU
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|ARM64.ActiveCfg = Release|ARM64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|ARM64.Build.0 = Release|ARM64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|x64.ActiveCfg = Release|x64
{8D0EDFC7-F974-4571-BC49-6F3A6653FE81}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -79,6 +79,46 @@
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>ARM64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
<OutputPath>bin\ARM64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="IACore">
<HintPath>.\IACore.dll</HintPath>
@ -91,10 +131,6 @@
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="netstandard" />
<Reference Include="OAUS.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>AutoUpdater\OAUS.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />

View File

@ -20,7 +20,7 @@
Closing="Window_Closing"
Closed="Window_Closed"
PreviewKeyDown="Main_Grid_PreviewKeyDown"
Height="1000" Width="1000"
Height="10000" Width="1000"
FontFamily="Microsoft YaHei UI"
MouseWheel="Window_MouseWheel"
Foreground="Black"
@ -433,7 +433,7 @@
<ui:ToggleSwitch Name="ToggleSwitchEnableTwoFingerRotationOnSelection" Header="允许双指旋转选中的墨迹" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchEnableTwoFingerRotation_Toggled"/>
</ui:SimpleStackPanel>
</GroupBox>
<GroupBox Header="墨迹识别 (Beta)">
<GroupBox Name="GroupBoxInkRecognition" Header="墨迹识别 (Beta)">
<ui:SimpleStackPanel Spacing="12">
<TextBlock Text="墨迹识别功能目前处于开发阶段,目前可实现智能识别圆、三角形、&#x000A;矩形,并自动转换为规范图形。" Foreground="#666666"/>
<ui:ToggleSwitch Name="ToggleSwitchEnableInkToShape" Header="启用墨迹识别" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchEnableInkToShape_Toggled" IsOn="True"/>

View File

@ -530,6 +530,10 @@ namespace Ink_Canvas
//加载设置
LoadSettings();
if (Environment.Is64BitProcess)
{
GroupBoxInkRecognition.Visibility = Visibility.Collapsed;
}
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
@ -5606,75 +5610,34 @@ namespace Ink_Canvas
try
{
inkCanvas.Opacity = 1;
if (Settings.InkToShape.IsInkToShapeEnabled)
if (Settings.InkToShape.IsInkToShapeEnabled && !Environment.Is64BitProcess)
{
try
void InkToShapeProcess()
{
newStrokes.Add(e.Stroke);
if (newStrokes.Count > 4) newStrokes.RemoveAt(0);
for (int i = 0; i < newStrokes.Count; i++)
try
{
if (!inkCanvas.Strokes.Contains(newStrokes[i])) newStrokes.RemoveAt(i--);
}
for (int i = 0; i < circles.Count; i++)
{
if (!inkCanvas.Strokes.Contains(circles[i].Stroke)) circles.RemoveAt(i);
}
var strokeReco = new StrokeCollection();
var result = InkRecognizeHelper.RecognizeShape(newStrokes);
for (int i = newStrokes.Count - 1; i >= 0; i--)
{
strokeReco.Add(newStrokes[i]);
var newResult = InkRecognizeHelper.RecognizeShape(strokeReco);
if (newResult.InkDrawingNode.GetShapeName() == "Circle" || newResult.InkDrawingNode.GetShapeName() == "Ellipse")
newStrokes.Add(e.Stroke);
if (newStrokes.Count > 4) newStrokes.RemoveAt(0);
for (int i = 0; i < newStrokes.Count; i++)
{
result = newResult;
break;
if (!inkCanvas.Strokes.Contains(newStrokes[i])) newStrokes.RemoveAt(i--);
}
//Label.Visibility = Visibility.Visible;
Label.Content = circles.Count.ToString() + "\n" + newResult.InkDrawingNode.GetShapeName();
}
if (result.InkDrawingNode.GetShapeName() == "Circle")
{
var shape = result.InkDrawingNode.GetShape();
if (shape.Width > 75)
for (int i = 0; i < circles.Count; i++)
{
foreach (Circle circle in circles)
if (!inkCanvas.Strokes.Contains(circles[i].Stroke)) circles.RemoveAt(i);
}
var strokeReco = new StrokeCollection();
var result = InkRecognizeHelper.RecognizeShape(newStrokes);
for (int i = newStrokes.Count - 1; i >= 0; i--)
{
strokeReco.Add(newStrokes[i]);
var newResult = InkRecognizeHelper.RecognizeShape(strokeReco);
if (newResult.InkDrawingNode.GetShapeName() == "Circle" || newResult.InkDrawingNode.GetShapeName() == "Ellipse")
{
//判断是否画同心圆
if (Math.Abs(result.Centroid.X - circle.Centroid.X) / shape.Width < 0.12 &&
Math.Abs(result.Centroid.Y - circle.Centroid.Y) / shape.Width < 0.12)
{
result.Centroid = circle.Centroid;
break;
}
else
{
double d = (result.Centroid.X - circle.Centroid.X) * (result.Centroid.X - circle.Centroid.X) +
(result.Centroid.Y - circle.Centroid.Y) * (result.Centroid.Y - circle.Centroid.Y);
d = Math.Sqrt(d);
//判断是否画外切圆
double x = shape.Width / 2.0 + circle.R - d;
if (Math.Abs(x) / shape.Width < 0.1)
{
double sinTheta = (result.Centroid.Y - circle.Centroid.Y) / d;
double cosTheta = (result.Centroid.X - circle.Centroid.X) / d;
double newX = result.Centroid.X + x * cosTheta;
double newY = result.Centroid.Y + x * sinTheta;
result.Centroid = new Point(newX, newY);
}
//判断是否画外切圆
x = Math.Abs(circle.R - shape.Width / 2.0) - d;
if (Math.Abs(x) / shape.Width < 0.1)
{
double sinTheta = (result.Centroid.Y - circle.Centroid.Y) / d;
double cosTheta = (result.Centroid.X - circle.Centroid.X) / d;
double newX = result.Centroid.X + x * cosTheta;
double newY = result.Centroid.Y + x * sinTheta;
result.Centroid = new Point(newX, newY);
}
}
result = newResult;
break;
}
<<<<<<< HEAD
Point iniP = new Point(result.Centroid.X - shape.Width / 2, result.Centroid.Y - shape.Height / 2);
Point endP = new Point(result.Centroid.X + shape.Width / 2, result.Centroid.Y + shape.Height / 2);
@ -5690,74 +5653,103 @@ namespace Ink_Canvas
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
inkCanvas.Strokes.Add(stroke);
newStrokes = new StrokeCollection();
=======
//Label.Visibility = Visibility.Visible;
Label.Content = circles.Count.ToString() + "\n" + newResult.InkDrawingNode.GetShapeName();
>>>>>>> ab83992ef82c63ba7a9d4ef428f11edc45718bb3
}
}
else if (result.InkDrawingNode.GetShapeName().Contains("Ellipse"))
{
var shape = result.InkDrawingNode.GetShape();
//var shape1 = result.InkDrawingNode.GetShape();
//shape1.Fill = Brushes.Gray;
//Canvas.Children.Add(shape1);
var p = result.InkDrawingNode.HotPoints;
double a = GetDistance(p[0], p[2]) / 2; //长半轴
double b = GetDistance(p[1], p[3]) / 2; //短半轴
if (a < b)
if (result.InkDrawingNode.GetShapeName() == "Circle")
{
double t = a;
a = b;
b = t;
}
result.Centroid = new Point((p[0].X + p[2].X) / 2, (p[0].Y + p[2].Y) / 2);
bool needRotation = true;
if (shape.Width > 75 || shape.Height > 75 && p.Count == 4)
{
Point iniP = new Point(result.Centroid.X - shape.Width / 2, result.Centroid.Y - shape.Height / 2);
Point endP = new Point(result.Centroid.X + shape.Width / 2, result.Centroid.Y + shape.Height / 2);
foreach (Circle circle in circles)
var shape = result.InkDrawingNode.GetShape();
if (shape.Width > 75)
{
//判断是否画同心椭圆
if (Math.Abs(result.Centroid.X - circle.Centroid.X) / a < 0.2 &&
Math.Abs(result.Centroid.Y - circle.Centroid.Y) / a < 0.2)
foreach (Circle circle in circles)
{
result.Centroid = circle.Centroid;
iniP = new Point(result.Centroid.X - shape.Width / 2, result.Centroid.Y - shape.Height / 2);
endP = new Point(result.Centroid.X + shape.Width / 2, result.Centroid.Y + shape.Height / 2);
//再判断是否与圆相切
if (Math.Abs(a - circle.R) / a < 0.2)
//判断是否画同心圆
if (Math.Abs(result.Centroid.X - circle.Centroid.X) / shape.Width < 0.12 &&
Math.Abs(result.Centroid.Y - circle.Centroid.Y) / shape.Width < 0.12)
{
if (shape.Width >= shape.Height)
result.Centroid = circle.Centroid;
break;
}
else
{
double d = (result.Centroid.X - circle.Centroid.X) * (result.Centroid.X - circle.Centroid.X) +
(result.Centroid.Y - circle.Centroid.Y) * (result.Centroid.Y - circle.Centroid.Y);
d = Math.Sqrt(d);
//判断是否画外切圆
double x = shape.Width / 2.0 + circle.R - d;
if (Math.Abs(x) / shape.Width < 0.1)
{
iniP.X = result.Centroid.X - circle.R;
endP.X = result.Centroid.X + circle.R;
iniP.Y = result.Centroid.Y - b;
endP.Y = result.Centroid.Y + b;
double sinTheta = (result.Centroid.Y - circle.Centroid.Y) / d;
double cosTheta = (result.Centroid.X - circle.Centroid.X) / d;
double newX = result.Centroid.X + x * cosTheta;
double newY = result.Centroid.Y + x * sinTheta;
result.Centroid = new Point(newX, newY);
}
else
//判断是否画外切圆
x = Math.Abs(circle.R - shape.Width / 2.0) - d;
if (Math.Abs(x) / shape.Width < 0.1)
{
iniP.Y = result.Centroid.Y - circle.R;
endP.Y = result.Centroid.Y + circle.R;
iniP.X = result.Centroid.X - a;
endP.X = result.Centroid.X + a;
double sinTheta = (result.Centroid.Y - circle.Centroid.Y) / d;
double cosTheta = (result.Centroid.X - circle.Centroid.X) / d;
double newX = result.Centroid.X + x * cosTheta;
double newY = result.Centroid.Y + x * sinTheta;
result.Centroid = new Point(newX, newY);
}
}
break;
}
else if (Math.Abs(result.Centroid.X - circle.Centroid.X) / a < 0.2)
{
double sinTheta = Math.Abs(circle.Centroid.Y - result.Centroid.Y) / circle.R;
double cosTheta = Math.Sqrt(1 - sinTheta * sinTheta);
double newA = circle.R * cosTheta;
if (circle.R * sinTheta / circle.R < 0.9 && a / b > 2 && Math.Abs(newA - a) / newA < 0.3)
{
iniP.X = circle.Centroid.X - newA;
endP.X = circle.Centroid.X + newA;
iniP.Y = result.Centroid.Y - newA / 5;
endP.Y = result.Centroid.Y + newA / 5;
Point iniP = new Point(result.Centroid.X - shape.Width / 2, result.Centroid.Y - shape.Height / 2);
Point endP = new Point(result.Centroid.X + shape.Width / 2, result.Centroid.Y + shape.Height / 2);
var pointList = GenerateEllipseGeometry(iniP, endP);
var point = new StylusPointCollection(pointList);
var stroke = new Stroke(point)
{
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
};
circles.Add(new Circle(result.Centroid, shape.Width / 2.0, stroke));
SetNewBackupOfStroke();
inkCanvas.Strokes.Add(stroke);
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
newStrokes = new StrokeCollection();
}
}
else if (result.InkDrawingNode.GetShapeName().Contains("Ellipse"))
{
var shape = result.InkDrawingNode.GetShape();
//var shape1 = result.InkDrawingNode.GetShape();
//shape1.Fill = Brushes.Gray;
//Canvas.Children.Add(shape1);
var p = result.InkDrawingNode.HotPoints;
double a = GetDistance(p[0], p[2]) / 2; //长半轴
double b = GetDistance(p[1], p[3]) / 2; //短半轴
if (a < b)
{
double t = a;
a = b;
b = t;
}
result.Centroid = new Point((p[0].X + p[2].X) / 2, (p[0].Y + p[2].Y) / 2);
bool needRotation = true;
if (shape.Width > 75 || shape.Height > 75 && p.Count == 4)
{
Point iniP = new Point(result.Centroid.X - shape.Width / 2, result.Centroid.Y - shape.Height / 2);
Point endP = new Point(result.Centroid.X + shape.Width / 2, result.Centroid.Y + shape.Height / 2);
foreach (Circle circle in circles)
{
//判断是否画同心椭圆
if (Math.Abs(result.Centroid.X - circle.Centroid.X) / a < 0.2 &&
Math.Abs(result.Centroid.Y - circle.Centroid.Y) / a < 0.2)
{
result.Centroid = circle.Centroid;
iniP = new Point(result.Centroid.X - shape.Width / 2, result.Centroid.Y - shape.Height / 2);
endP = new Point(result.Centroid.X + shape.Width / 2, result.Centroid.Y + shape.Height / 2);
<<<<<<< HEAD
double topB = endP.Y - iniP.Y;
SetNewBackupOfStroke();
@ -5782,79 +5774,155 @@ namespace Ink_Canvas
inkCanvas.Strokes.Add(_stroke.Clone());
inkCanvas.Strokes.Add(_generateDashedLineEllipseStrokeCollection);
return;
=======
//再判断是否与圆相切
if (Math.Abs(a - circle.R) / a < 0.2)
{
if (shape.Width >= shape.Height)
{
iniP.X = result.Centroid.X - circle.R;
endP.X = result.Centroid.X + circle.R;
iniP.Y = result.Centroid.Y - b;
endP.Y = result.Centroid.Y + b;
}
else
{
iniP.Y = result.Centroid.Y - circle.R;
endP.Y = result.Centroid.Y + circle.R;
iniP.X = result.Centroid.X - a;
endP.X = result.Centroid.X + a;
}
}
break;
>>>>>>> ab83992ef82c63ba7a9d4ef428f11edc45718bb3
}
}
else if (Math.Abs(result.Centroid.Y - circle.Centroid.Y) / a < 0.2)
{
double cosTheta = Math.Abs(circle.Centroid.X - result.Centroid.X) / circle.R;
double sinTheta = Math.Sqrt(1 - cosTheta * cosTheta);
double newA = circle.R * sinTheta;
if (circle.R * sinTheta / circle.R < 0.9 && a / b > 2 && Math.Abs(newA - a) / newA < 0.3)
else if (Math.Abs(result.Centroid.X - circle.Centroid.X) / a < 0.2)
{
iniP.X = result.Centroid.X - newA / 5;
endP.X = result.Centroid.X + newA / 5;
iniP.Y = circle.Centroid.Y - newA;
endP.Y = circle.Centroid.Y + newA;
needRotation = false;
double sinTheta = Math.Abs(circle.Centroid.Y - result.Centroid.Y) / circle.R;
double cosTheta = Math.Sqrt(1 - sinTheta * sinTheta);
double newA = circle.R * cosTheta;
if (circle.R * sinTheta / circle.R < 0.9 && a / b > 2 && Math.Abs(newA - a) / newA < 0.3)
{
iniP.X = circle.Centroid.X - newA;
endP.X = circle.Centroid.X + newA;
iniP.Y = result.Centroid.Y - newA / 5;
endP.Y = result.Centroid.Y + newA / 5;
double topB = endP.Y - iniP.Y;
SetNewBackupOfStroke();
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
newStrokes = new StrokeCollection();
var _pointList = GenerateEllipseGeometry(iniP, endP, false, true);
var _point = new StylusPointCollection(_pointList);
var _stroke = new Stroke(_point)
{
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
};
inkCanvas.Strokes.Add(_stroke.Clone());
inkCanvas.Strokes.Add(GenerateDashedLineEllipseStrokeCollection(iniP, endP, true, false));
return;
}
}
else if (Math.Abs(result.Centroid.Y - circle.Centroid.Y) / a < 0.2)
{
double cosTheta = Math.Abs(circle.Centroid.X - result.Centroid.X) / circle.R;
double sinTheta = Math.Sqrt(1 - cosTheta * cosTheta);
double newA = circle.R * sinTheta;
if (circle.R * sinTheta / circle.R < 0.9 && a / b > 2 && Math.Abs(newA - a) / newA < 0.3)
{
iniP.X = result.Centroid.X - newA / 5;
endP.X = result.Centroid.X + newA / 5;
iniP.Y = circle.Centroid.Y - newA;
endP.Y = circle.Centroid.Y + newA;
needRotation = false;
}
}
}
//纠正垂直与水平关系
var newPoints = FixPointsDirection(p[0], p[2]);
p[0] = newPoints[0];
p[2] = newPoints[1];
newPoints = FixPointsDirection(p[1], p[3]);
p[1] = newPoints[0];
p[3] = newPoints[1];
var pointList = GenerateEllipseGeometry(iniP, endP);
var point = new StylusPointCollection(pointList);
var stroke = new Stroke(point)
{
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
};
if (needRotation)
{
Matrix m = new Matrix();
FrameworkElement fe = e.Source as FrameworkElement;
double tanTheta = (p[2].Y - p[0].Y) / (p[2].X - p[0].X);
double theta = Math.Atan(tanTheta);
m.RotateAt(theta * 180.0 / Math.PI, result.Centroid.X, result.Centroid.Y);
stroke.Transform(m, false);
}
SetNewBackupOfStroke();
inkCanvas.Strokes.Add(stroke);
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
newStrokes = new StrokeCollection();
}
//纠正垂直与水平关系
var newPoints = FixPointsDirection(p[0], p[2]);
p[0] = newPoints[0];
p[2] = newPoints[1];
newPoints = FixPointsDirection(p[1], p[3]);
p[1] = newPoints[0];
p[3] = newPoints[1];
var pointList = GenerateEllipseGeometry(iniP, endP);
var point = new StylusPointCollection(pointList);
var stroke = new Stroke(point)
}
else if (result.InkDrawingNode.GetShapeName().Contains("Triangle"))
{
var shape = result.InkDrawingNode.GetShape();
var p = result.InkDrawingNode.HotPoints;
if ((Math.Max(Math.Max(p[0].X, p[1].X), p[2].X) - Math.Min(Math.Min(p[0].X, p[1].X), p[2].X) >= 100 ||
Math.Max(Math.Max(p[0].Y, p[1].Y), p[2].Y) - Math.Min(Math.Min(p[0].Y, p[1].Y), p[2].Y) >= 100) && result.InkDrawingNode.HotPoints.Count == 3)
{
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
};
//纠正垂直与水平关系
var newPoints = FixPointsDirection(p[0], p[1]);
p[0] = newPoints[0];
p[1] = newPoints[1];
newPoints = FixPointsDirection(p[0], p[2]);
p[0] = newPoints[0];
p[2] = newPoints[1];
newPoints = FixPointsDirection(p[1], p[2]);
p[1] = newPoints[0];
p[2] = newPoints[1];
if (needRotation)
{
Matrix m = new Matrix();
FrameworkElement fe = e.Source as FrameworkElement;
double tanTheta = (p[2].Y - p[0].Y) / (p[2].X - p[0].X);
double theta = Math.Atan(tanTheta);
m.RotateAt(theta * 180.0 / Math.PI, result.Centroid.X, result.Centroid.Y);
stroke.Transform(m, false);
var pointList = p.ToList();
//pointList.Add(p[0]);
var point = new StylusPointCollection(pointList);
var stroke = new Stroke(GenerateFakePressureTriangle(point))
{
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
};
SetNewBackupOfStroke();
inkCanvas.Strokes.Add(stroke);
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
newStrokes = new StrokeCollection();
}
<<<<<<< HEAD
SetNewBackupOfStroke();
IsEraseByShapeRecognition = true;
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
inkCanvas.Strokes.Add(stroke);
newStrokes = new StrokeCollection();
=======
>>>>>>> ab83992ef82c63ba7a9d4ef428f11edc45718bb3
}
}
else if (result.InkDrawingNode.GetShapeName().Contains("Triangle"))
{
var shape = result.InkDrawingNode.GetShape();
var p = result.InkDrawingNode.HotPoints;
if ((Math.Max(Math.Max(p[0].X, p[1].X), p[2].X) - Math.Min(Math.Min(p[0].X, p[1].X), p[2].X) >= 100 ||
Math.Max(Math.Max(p[0].Y, p[1].Y), p[2].Y) - Math.Min(Math.Min(p[0].Y, p[1].Y), p[2].Y) >= 100) && result.InkDrawingNode.HotPoints.Count == 3)
else if (result.InkDrawingNode.GetShapeName().Contains("Rectangle") ||
result.InkDrawingNode.GetShapeName().Contains("Diamond") ||
result.InkDrawingNode.GetShapeName().Contains("Parallelogram") ||
result.InkDrawingNode.GetShapeName().Contains("Square"))
{
//纠正垂直与水平关系
var newPoints = FixPointsDirection(p[0], p[1]);
p[0] = newPoints[0];
p[1] = newPoints[1];
newPoints = FixPointsDirection(p[0], p[2]);
p[0] = newPoints[0];
p[2] = newPoints[1];
newPoints = FixPointsDirection(p[1], p[2]);
p[1] = newPoints[0];
p[2] = newPoints[1];
var pointList = p.ToList();
//pointList.Add(p[0]);
var point = new StylusPointCollection(pointList);
var stroke = new Stroke(GenerateFakePressureTriangle(point))
var shape = result.InkDrawingNode.GetShape();
var p = result.InkDrawingNode.HotPoints;
if ((Math.Max(Math.Max(Math.Max(p[0].X, p[1].X), p[2].X), p[3].X) - Math.Min(Math.Min(Math.Min(p[0].X, p[1].X), p[2].X), p[3].X) >= 100 ||
Math.Max(Math.Max(Math.Max(p[0].Y, p[1].Y), p[2].Y), p[3].Y) - Math.Min(Math.Min(Math.Min(p[0].Y, p[1].Y), p[2].Y), p[3].Y) >= 100) && result.InkDrawingNode.HotPoints.Count == 4)
{
<<<<<<< HEAD
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
};
SetNewBackupOfStroke();
@ -5900,14 +5968,47 @@ namespace Ink_Canvas
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
inkCanvas.Strokes.Add(stroke);
newStrokes = new StrokeCollection();
=======
//纠正垂直与水平关系
var newPoints = FixPointsDirection(p[0], p[1]);
p[0] = newPoints[0];
p[1] = newPoints[1];
newPoints = FixPointsDirection(p[1], p[2]);
p[1] = newPoints[0];
p[2] = newPoints[1];
newPoints = FixPointsDirection(p[2], p[3]);
p[2] = newPoints[0];
p[3] = newPoints[1];
newPoints = FixPointsDirection(p[3], p[0]);
p[3] = newPoints[0];
p[0] = newPoints[1];
var pointList = p.ToList();
pointList.Add(p[0]);
var point = new StylusPointCollection(pointList);
var stroke = new Stroke(GenerateFakePressureRectangle(point))
{
DrawingAttributes = inkCanvas.DefaultDrawingAttributes.Clone()
};
SetNewBackupOfStroke();
inkCanvas.Strokes.Add(stroke);
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
newStrokes = new StrokeCollection();
}
>>>>>>> ab83992ef82c63ba7a9d4ef428f11edc45718bb3
}
}
catch { }
}
<<<<<<< HEAD
catch { }
finally
{
IsEraseByShapeRecognition = false;
}
=======
InkToShapeProcess();
>>>>>>> ab83992ef82c63ba7a9d4ef428f11edc45718bb3
}
// 检查是否是压感笔书写