Browse Source

added InkCanvas

TiReischl 5 years ago
parent
commit
2ee664d386

+ 4 - 2
SketchAssistant/SketchAssistantWPF/MainWindow.xaml

@@ -179,8 +179,10 @@
         </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"/>
-        <local:CustomCanvas 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" MouseLeave="RightCanvas_MouseLeave" MouseEnter="RightCanvas_MouseEnter" TouchEnter="RightCanvas_TouchEnter" TouchLeave="RightCanvas_TouchLeave"/>
+        <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" 
+                   MouseLeave="RightCanvas_MouseLeave" MouseEnter="RightCanvas_MouseEnter" TouchEnter="RightCanvas_TouchEnter" 
+                   TouchLeave="RightCanvas_TouchLeave"/>
 
 
         <DockPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="8">

+ 23 - 10
SketchAssistant/SketchAssistantWPF/MainWindow.xaml.cs

@@ -123,6 +123,7 @@ namespace SketchAssistantWPF
         private void DeleteButton_Click(object sender, RoutedEventArgs e)
         {
             ProgramPresenter.ChangeState(false);
+            RightCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
         }
 
         /// <summary>
@@ -131,6 +132,7 @@ namespace SketchAssistantWPF
         private void DrawButton_Click(object sender, RoutedEventArgs e)
         {
             ProgramPresenter.ChangeState(true);
+            RightCanvas.EditingMode = InkCanvasEditingMode.Ink;
         }
 
         /// <summary>
@@ -208,6 +210,7 @@ namespace SketchAssistantWPF
         private void CanvasButton_Click(object sender, RoutedEventArgs e)
         {
             ProgramPresenter.NewCanvas();
+            RightCanvas.Strokes.Clear();
         }
 
         /// <summary>
@@ -513,24 +516,34 @@ namespace SketchAssistantWPF
         public void SetCanvasState(string canvasName, bool active)
         {
             Canvas canvas;
-            switch (canvasName){
+            InkCanvas inkCanvas;
+            switch (canvasName)
+            {
                 case ("LeftCanvas"):
                     canvas = LeftCanvas;
+                    if (active)
+                    {
+                        canvas.Background = Brushes.White;
+                    }
+                    else
+                    {
+                        canvas.Background = Brushes.SlateGray;
+                    }
                     break;
                 case ("RightCanvas"):
-                    canvas = RightCanvas;
+                    inkCanvas = RightCanvas;
+                    if (active)
+                    {
+                        inkCanvas.Background = Brushes.White;
+                    }
+                    else
+                    {
+                        inkCanvas.Background = Brushes.SlateGray;
+                    }
                     break;
                 default:
                     throw new InvalidOperationException("Unknown canvas name, Check that the canvas passed is either LeftCanvas or RightCanvas");
             }
-            if (active)
-            {
-                canvas.Background = Brushes.White;
-            }
-            else
-            {
-                canvas.Background = Brushes.SlateGray;
-            }
         }
 
         /************************/