void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 13 "..\..\MainWindow.xaml"
                ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.FileNewCommand);

            #line default
            #line hidden
                return;

            case 2:

            #line 14 "..\..\MainWindow.xaml"
                ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.FilePrintCommand);

            #line default
            #line hidden
                return;

            case 3:

            #line 15 "..\..\MainWindow.xaml"
                ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.FileCloseCommand);

            #line default
            #line hidden
                return;

            case 4:

            #line 16 "..\..\MainWindow.xaml"
                ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.FileSaveCommand);

            #line default
            #line hidden
                return;

            case 5:

            #line 17 "..\..\MainWindow.xaml"
                ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.FileSaveAsCommand);

            #line default
            #line hidden
                return;

            case 6:

            #line 18 "..\..\MainWindow.xaml"
                ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.FileOpenCommand);

            #line default
            #line hidden
                return;

            case 7:

            #line 19 "..\..\MainWindow.xaml"
                ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.EditUndoCommand);

            #line default
            #line hidden
                return;

            case 8:

            #line 20 "..\..\MainWindow.xaml"
                ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.EditRedoCommand);

            #line default
            #line hidden
                return;

            case 9:

            #line 21 "..\..\MainWindow.xaml"
                ((System.Windows.Input.CommandBinding)(target)).Executed += new System.Windows.Input.ExecutedRoutedEventHandler(this.HelpCommand);

            #line default
            #line hidden
                return;

            case 10:
                this.menuFileRecentFiles = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 11:
                this.menuEdit = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 12:
                this.menuEditSelectAll = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 13:
                this.menuEditUnselectAll = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 14:
                this.menuEditDelete = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 15:
                this.menuEditDeleteAll = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 16:
                this.menuEditMoveToFront = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 17:
                this.menuEditMoveToBack = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 18:
                this.menuEditUndo = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 19:
                this.menuEditRedo = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 20:
                this.menuEditSetProperties = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 21:
                this.menuTools = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 22:
                this.menuToolsPointer = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 23:
                this.menuToolsRectangle = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 24:
                this.menuToolsEllipse = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 25:
                this.menuToolsLine = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 26:
                this.menuToolsPencil = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 27:
                this.menuToolsText = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 28:
                this.buttonToolPointer = ((System.Windows.Controls.Primitives.ToggleButton)(target));
                return;

            case 29:
                this.buttonToolRectangle = ((System.Windows.Controls.Primitives.ToggleButton)(target));
                return;

            case 30:
                this.buttonToolEllipse = ((System.Windows.Controls.Primitives.ToggleButton)(target));
                return;

            case 31:
                this.buttonToolLine = ((System.Windows.Controls.Primitives.ToggleButton)(target));
                return;

            case 32:
                this.buttonToolPencil = ((System.Windows.Controls.Primitives.ToggleButton)(target));
                return;

            case 33:
                this.buttonToolEraser = ((System.Windows.Controls.Primitives.ToggleButton)(target));
                return;

            case 34:
                this.buttonToolText = ((System.Windows.Controls.Primitives.ToggleButton)(target));
                return;

            case 35:
                this.buttonPropertiesFont = ((System.Windows.Controls.Button)(target));
                return;

            case 36:
                this.buttonPropertiesColor = ((System.Windows.Controls.Button)(target));
                return;

            case 37:
                this.comboPropertiesLineWidth = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 38:
                this.drawingCanvas = ((DrawToolsLib.DrawingCanvas)(target));

            #line 246 "..\..\MainWindow.xaml"
                this.drawingCanvas.TouchDown += new System.EventHandler <System.Windows.Input.TouchEventArgs>(this.OnTouchDownHandler);

            #line default
            #line hidden

            #line 247 "..\..\MainWindow.xaml"
                this.drawingCanvas.TouchMove += new System.EventHandler <System.Windows.Input.TouchEventArgs>(this.OnTouchMoveHandler);

            #line default
            #line hidden

            #line 248 "..\..\MainWindow.xaml"
                this.drawingCanvas.TouchUp += new System.EventHandler <System.Windows.Input.TouchEventArgs>(this.OnTouchUpHandler);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
        /// <summary>
        /// Handle mouse down.
        /// Start moving, resizing or group selection.
        /// </summary>
        public override void OnMouseDown(DrawingCanvas drawingCanvas, MouseButtonEventArgs e)
        {
            commandChangeState = null;
            wasMove            = false;


            Point point = e.GetPosition(drawingCanvas);

            selectMode = SelectionMode.None;

            GraphicsBase o;
            GraphicsBase movedObject = null;
            int          handleNumber;

            // Test for resizing (only if control is selected, cursor is on the handle)
            for (int i = drawingCanvas.GraphicsList.Count - 1; i >= 0; i--)
            {
                o = drawingCanvas[i];

                if (o.IsSelected)
                {
                    handleNumber = o.MakeHitTest(point);

                    if (handleNumber > 0)
                    {
                        selectMode = SelectionMode.Size;

                        // keep resized object in class member
                        resizedObject       = o;
                        resizedObjectHandle = handleNumber;

                        // Since we want to resize only one object, unselect all other objects
                        HelperFunctions.UnselectAll(drawingCanvas);
                        o.IsSelected = true;

                        commandChangeState = new CommandChangeState(drawingCanvas);

                        break;
                    }
                }
            }

            // Test for move (cursor is on the object)
            if (selectMode == SelectionMode.None)
            {
                for (int i = drawingCanvas.GraphicsList.Count - 1; i >= 0; i--)
                {
                    o = drawingCanvas[i];

                    if (o.MakeHitTest(point) == 0)
                    {
                        movedObject = o;
                        break;
                    }
                }

                if (movedObject != null)
                {
                    selectMode = SelectionMode.Move;

                    // Unselect all if Ctrl is not pressed and clicked object is not selected yet
                    if (Keyboard.Modifiers != ModifierKeys.Control && !movedObject.IsSelected)
                    {
                        HelperFunctions.UnselectAll(drawingCanvas);
                    }

                    // Select clicked object
                    movedObject.IsSelected = true;

                    // Set move cursor
                    drawingCanvas.Cursor = Cursors.SizeAll;

                    commandChangeState = new CommandChangeState(drawingCanvas);
                }
            }

            // Click on background
            if (selectMode == SelectionMode.None)
            {
                // Unselect all if Ctrl is not pressed
                if (Keyboard.Modifiers != ModifierKeys.Control)
                {
                    HelperFunctions.UnselectAll(drawingCanvas);
                }

                // Group selection. Create selection rectangle.
                GraphicsSelectionRectangle r = new GraphicsSelectionRectangle(
                    point.X, point.Y,
                    point.X + 1, point.Y + 1,
                    drawingCanvas.ActualScale);

                r.Clip = new RectangleGeometry(new Rect(0, 0, drawingCanvas.ActualWidth, drawingCanvas.ActualHeight));

                drawingCanvas.GraphicsList.Add(r);

                selectMode = SelectionMode.GroupSelection;
            }


            lastPoint = point;

            // Capture mouse until MouseUp event is received
            drawingCanvas.CaptureMouse();
        }
Beispiel #3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.ScrollImageViewer = ((System.Windows.Controls.ScrollViewer)(target));

            #line 18 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.ScrollImageViewer.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.ScrollImageViewer_PreviewKeyDown);

            #line default
            #line hidden
                return;

            case 2:
                this.gridViewer = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.gridContainer = ((System.Windows.Controls.Grid)(target));

            #line 22 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.gridContainer.PreviewMouseMove += new System.Windows.Input.MouseEventHandler(this.OnPreviewMouseMove);

            #line default
            #line hidden
                return;

            case 4:
                this.imageCanvas = ((VirtualCanvasLib.VirtualCanvas)(target));
                return;

            case 5:
                this.annotationCanvas = ((DrawToolsLib.DrawingCanvas)(target));
                return;

            case 6:
                this.magnifierCanvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 7:
                this.magnifierEllipse = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 8:
                this.vbMagnifier = ((System.Windows.Media.VisualBrush)(target));
                return;

            case 9:
                this.labelImageCanvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 10:
                this.zoombarCanvas = ((System.Windows.Controls.Canvas)(target));
                return;

            case 11:
                this.btnZoomFit = ((System.Windows.Controls.Button)(target));

            #line 61 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.btnZoomFit.Click += new System.Windows.RoutedEventHandler(this.btnZoomFit_Click);

            #line default
            #line hidden
                return;

            case 12:
                this.btnZoom1x = ((System.Windows.Controls.Button)(target));

            #line 66 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.btnZoom1x.Click += new System.Windows.RoutedEventHandler(this.btnZoom1x_Click);

            #line default
            #line hidden
                return;

            case 13:
                this.btnZoom2x = ((System.Windows.Controls.Button)(target));

            #line 71 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.btnZoom2x.Click += new System.Windows.RoutedEventHandler(this.btnZoom2x_Click);

            #line default
            #line hidden
                return;

            case 14:
                this.btnZoom4x = ((System.Windows.Controls.Button)(target));

            #line 76 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.btnZoom4x.Click += new System.Windows.RoutedEventHandler(this.btnZoom4x_Click);

            #line default
            #line hidden
                return;

            case 15:
                this.btnZoom5x = ((System.Windows.Controls.Button)(target));

            #line 81 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.btnZoom5x.Click += new System.Windows.RoutedEventHandler(this.btnZoom5x_Click);

            #line default
            #line hidden
                return;

            case 16:
                this.btnZoom10x = ((System.Windows.Controls.Button)(target));

            #line 86 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.btnZoom10x.Click += new System.Windows.RoutedEventHandler(this.btnZoom10x_Click);

            #line default
            #line hidden
                return;

            case 17:
                this.btnZoom20x = ((System.Windows.Controls.Button)(target));

            #line 91 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.btnZoom20x.Click += new System.Windows.RoutedEventHandler(this.btnZoom20x_Click);

            #line default
            #line hidden
                return;

            case 18:
                this.zoomSlider = ((System.Windows.Controls.Slider)(target));

            #line 98 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.zoomSlider.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.zoomSlider_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 19:
                this.lbZoom = ((System.Windows.Controls.Label)(target));
                return;

            case 20:
                this.thumbnailCanvas = ((System.Windows.Controls.Canvas)(target));

            #line 106 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.thumbnailCanvas.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.thumbnailCanvas_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 21:
                this.thumbnailBorder = ((System.Windows.Controls.Border)(target));
                return;

            case 22:
                this.thumbnailZoomRectThumb = ((System.Windows.Controls.Primitives.Thumb)(target));

            #line 110 "..\..\..\ImageViewer\ImageViewer.xaml"
                this.thumbnailZoomRectThumb.DragDelta += new System.Windows.Controls.Primitives.DragDeltaEventHandler(this.thumbnailZoomRectThumb_DragDelta);

            #line default
            #line hidden
                return;

            case 23:
                this.ThumbnailImage_Brush = ((System.Windows.Media.ImageBrush)(target));
                return;
            }
            this._contentLoaded = true;
        }
        /// <summary>
        /// Handle mouse move.
        /// Se cursor, move/resize, make group selection.
        /// </summary>
        public override void OnMouseMove(DrawingCanvas drawingCanvas, MouseEventArgs e)
        {
            // Exclude all cases except left button on/off.
            if (e.MiddleButton == MouseButtonState.Pressed ||
                e.RightButton == MouseButtonState.Pressed)
            {
                drawingCanvas.Cursor = HelperFunctions.DefaultCursor;
                return;
            }

            Point point = e.GetPosition(drawingCanvas);

            // Set cursor when left button is not pressed
            if (e.LeftButton == MouseButtonState.Released)
            {
                Cursor cursor = null;

                for (int i = 0; i < drawingCanvas.Count; i++)
                {
                    int n = drawingCanvas[i].MakeHitTest(point);

                    if (n > 0)
                    {
                        cursor = drawingCanvas[i].GetHandleCursor(n);
                        break;
                    }
                }

                if (cursor == null)
                {
                    cursor = HelperFunctions.DefaultCursor;
                }

                drawingCanvas.Cursor = cursor;

                return;
            }

            if (!drawingCanvas.IsMouseCaptured)
            {
                return;
            }

            wasMove = true;

            // Find difference between previous and current position
            double dx = point.X - lastPoint.X;
            double dy = point.Y - lastPoint.Y;

            lastPoint = point;

            // Resize
            if (selectMode == SelectionMode.Size)
            {
                if (resizedObject != null)
                {
                    resizedObject.MoveHandleTo(point, resizedObjectHandle);
                }
            }

            // Move
            if (selectMode == SelectionMode.Move)
            {
                foreach (GraphicsBase o in drawingCanvas.Selection)
                {
                    o.Move(dx, dy);
                }
            }

            // Group selection
            if (selectMode == SelectionMode.GroupSelection)
            {
                // Resize selection rectangle
                drawingCanvas[drawingCanvas.Count - 1].MoveHandleTo(
                    point, 5);
            }
        }
 /// <summary>
 /// Set cursor
 /// </summary>
 public override void SetCursor(DrawingCanvas drawingCanvas)
 {
     drawingCanvas.Cursor = HelperFunctions.DefaultCursor;
 }
Beispiel #6
0
 public abstract void SetCursor(DrawingCanvas drawingCanvas);
 public override void OnKeyUp(DrawingCanvas drawingCanvas, KeyboardEventArgs e)
 {
 }
Beispiel #8
0
 public abstract void OnMouseMove(DrawingCanvas drawingCanvas, MouseEventArgs e);
Beispiel #9
0
 public abstract void OnMouseUp(DrawingCanvas drawingCanvas, MouseButtonEventArgs e);
Beispiel #10
0
 // This command is used to make Redo operation.
 // It makes original command again.
 public abstract void Redo(DrawingCanvas drawingCanvas);
 /// <summary>
 /// Restore order to its state after change.
 /// </summary>
 public override void Redo(DrawingCanvas drawingCanvas)
 {
     ChangeOrder(drawingCanvas.GraphicsList, listAfter);
 }
 /// <summary>
 /// Restore order to its state before change.
 /// </summary>
 public override void Undo(DrawingCanvas drawingCanvas)
 {
     ChangeOrder(drawingCanvas.GraphicsList, listBefore);
 }
 // Call this function AFTER operation.
 public void NewState(DrawingCanvas drawingCanvas)
 {
     FillList(drawingCanvas.GraphicsList, ref listAfter);
 }
 // Create this command BEFORE operation.
 public CommandChangeOrder(DrawingCanvas drawingCanvas)
 {
     FillList(drawingCanvas.GraphicsList, ref listBefore);
 }