示例#1
0
 private void MenuItem_Save_File_Click(object sender, RoutedEventArgs e)
 {
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     if (saveFileDialog.ShowDialog() == true)
     {
         if (this.w != null)
         {
             var t = this.w.AttachedShape;
             this.canvas.Children.Remove(this.w);
             this.w = new YobaDraw.SimpleShapeWrapControl(t);
         }
         var canvasXAML = XamlWriter.Save(this.canvas);
         using (StreamWriter sw = new StreamWriter(saveFileDialog.FileName))
         {
             sw.Write(canvasXAML);
             sw.Close();
         }
     }
 }
示例#2
0
        private void shape_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2)
            {
                this.canvas.Children.Remove(this.w);

                foreach (Shape item in this.canvas.Children)
                {
                    DoubleCollection _strokeDashArray = null;
                    Brush _stroke = null;
                    double _strokeThickness;
                    Brush _fill = null;

                    if (item.StrokeDashArray != null) _strokeDashArray = item.StrokeDashArray.Clone();
                    if (item.Stroke != null) _stroke = item.Stroke.Clone();
                    _strokeThickness = item.StrokeThickness;
                    if (item.Fill != null) _fill = item.Fill.Clone();

                    BindingOperations.ClearAllBindings(item);

                    item.Fill = _fill;
                    item.StrokeDashArray = _strokeDashArray;
                    item.Stroke = _stroke;
                    item.StrokeThickness = _strokeThickness;

                }
                var _shape = this.canvas.Children.OfType<Shape>().Where(item => item.Name == (sender as Shape).Name).Single();
                if (!Keyboard.IsKeyDown(Key.LeftCtrl))
                {
                    if (_shape.Stroke != null) this.lineSettings.CurrentBrush = _shape.Stroke.Clone();
                    if (_shape.StrokeDashArray != null) this.lineSettings.CurrentStrokeDashArray = _shape.StrokeDashArray.Clone();
                    this.lineSettings.CurrentStrokeThickness = _shape.StrokeThickness;
                    if (_shape.Fill != null) this.brushSettings.SelectedBrush = _shape.Fill.Clone();
                }
                _shape.SetBinding(Shape.StrokeProperty, strokeBinding);
                _shape.SetBinding(Shape.StrokeDashArrayProperty, strokeDashArrayBinding);
                _shape.SetBinding(Shape.StrokeThicknessProperty, strokeThicknessBinding);
                _shape.SetBinding(Shape.FillProperty, fillBinding);
                this.w = new YobaDraw.SimpleShapeWrapControl(_shape);
                Canvas.SetZIndex(w, 9999);
                this.canvas.Children.Add(w);
            }
        }
示例#3
0
 private void DeleteCommandExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     if (this.w != null)
     {
         var _shape = w.AttachedShape;
         this.canvas.Children.Remove(w);
         this.canvas.Children.Remove(_shape);
         this.w = null;
     }
 }