Browse Source

fixed some bugs

TiReischl 5 years ago
parent
commit
913b731abc

+ 3 - 3
SketchAssistant/SketchAssistantWPF/MainWindow.xaml

@@ -178,11 +178,11 @@
             </Button>
         </ToolBar>
         <local:CustomCanvas x:Name="LeftCanvas" Background="SlateGray" Grid.Column="2" Grid.Row="1" Height="auto" Grid.ColumnSpan="3"/>
-        <Canvas Name="CanvasSeperator" Grid.Column="5" Grid.Row="1" Background="LightGray"/>
+        <Canvas Name="CanvasSeperator" Grid.Column="5" Grid.Row="1" Background="LightGray" />
         <InkCanvas x:Name="RightCanvas" Background="SlateGray" Grid.Column="6" Grid.Row="1" Height="auto"
-            MouseDown="RightCanvas_MouseDown" MouseUp="RightCanvas_MouseUp" MouseMove="RightCanvas_MouseMove" Grid.ColumnSpan="2" 
+            PreviewMouseDown="RightCanvas_MouseDown" MouseUp="RightCanvas_MouseUp" MouseMove="RightCanvas_MouseMove" Grid.ColumnSpan="2" 
                    MouseLeave="RightCanvas_MouseLeave" MouseEnter="RightCanvas_MouseEnter" TouchEnter="RightCanvas_TouchEnter" 
-                   TouchLeave="RightCanvas_TouchLeave"/>
+                   TouchLeave="RightCanvas_TouchLeave" StrokeCollected="RightCanvas_StrokeCollection"/>
 
 
         <DockPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="8">

+ 20 - 0
SketchAssistant/SketchAssistantWPF/MainWindow.xaml.cs

@@ -18,6 +18,7 @@ using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
 using System.Windows.Threading;
+using System.Windows.Ink;
 
 namespace SketchAssistantWPF
 {
@@ -87,6 +88,10 @@ namespace SketchAssistantWPF
         /// Point collections for debugging.
         /// </summary>
         DebugData debugDat = new DebugData();
+        /// <summary>
+        /// Stores Lines drawn on RightCanvas.
+        /// </summary>
+        StrokeCollection strokeCollection = new StrokeCollection();
 
         /********************************************/
         /*** WINDOW SPECIFIC FUNCTIONS START HERE ***/
@@ -101,6 +106,15 @@ namespace SketchAssistantWPF
                 new Tuple<int, int>((int)RightCanvas.ActualWidth, (int)RightCanvas.ActualHeight));
         }
 
+        /// <summary>
+        /// Collects all Strokes on RightCanvas
+        /// </summary>
+        public void RightCanvas_StrokeCollection(object sender, InkCanvasStrokeCollectedEventArgs e)
+        {
+            strokeCollection.Add(e.Stroke);
+            System.Diagnostics.Debug.WriteLine(strokeCollection.Count);
+        }
+
         /// <summary>
         /// Redo an Action.
         /// </summary>
@@ -150,6 +164,12 @@ namespace SketchAssistantWPF
         private void RightCanvas_MouseUp(object sender, MouseButtonEventArgs e)
         {
             ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up);
+            if (strokeCollection.Count >= 1)
+            {
+                RightCanvas.Strokes.RemoveAt(0);
+                strokeCollection.RemoveAt(0);
+                System.Diagnostics.Debug.WriteLine(strokeCollection.Count);
+            }
             //System.Diagnostics.Debug.WriteLine("ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up);");
         }