Esempio n. 1
0
 /// <summary>
 /// Mouse down.
 /// Left button down event is passed to active tool.
 /// Right button down event is handled in this class.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DrawArea_MouseDown(object sender, MouseEventArgs e)
 {
     //Trace.WriteLine("DrawArea_MouseDown");
     lastPoint = BackTrackMouse(e.Location);
     if (SnapEnable)
     {
         lastPoint.X = FittoSnap(e.X, SnapX);
         lastPoint.Y = FittoSnap(e.Y, SnapY);
     }
     // Trace.WriteLine("DrawArea_MouseDown1");
     if (e.Button == MouseButtons.Left)
     {
         tools[(int)activeTool].OnMouseDown(this, e);
     }
     else if (e.Button == MouseButtons.Right)
     {
         if (_panning)
         {
             _panning = false;
         }
         if (activeTool == DrawToolType.PolyLine || activeTool == DrawToolType.Polygon || activeTool == DrawToolType.Curve)
         {
             tools[(int)activeTool].OnMouseDown(this, e);
             ActiveTool = DrawToolType.Pointer;
         }
         else
         {
             ActiveTool = DrawToolType.Pointer;
             OnContextMenu(e);
         }
     }
     //Trace.WriteLine("DrawArea_MouseDown End");
 }
Esempio n. 2
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="docManager"></param>
        public void Initialize(NetBuilder owner, DocManager docManager)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);

            // Keep reference to owner form
            this.Owner      = owner;
            this.DocManager = docManager;

            // set default tool
            activeTool = DrawToolType.Pointer;

            // create list of graphic objects
            graphicsList = new GraphicsList();

            // Create undo manager
            undoManager = new UndoManager(graphicsList);

            // create array of drawing tools
            tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
            tools[(int)DrawToolType.Pointer]   = new ToolPointer();
            tools[(int)DrawToolType.Rectangle] = new ToolRectangle();
            tools[(int)DrawToolType.Ellipse]   = new ToolEllipse();
            tools[(int)DrawToolType.Triangle]  = new ToolTriangle();
            tools[(int)DrawToolType.Line]      = new ToolLine();
            tools[(int)DrawToolType.Polygon]   = new ToolPolygon();
        }
Esempio n. 3
0
        private void SetSystemFunction(DrawToolType tool)
        {
            switch (tool)
            {
            case DrawToolType.Line:
            case DrawToolType.Ellipse:
            case DrawToolType.Rectangle:
            case DrawToolType.Polygon:
            case DrawToolType.PolyLine:
                Program.SysConfig.Function = SystemFunction.Measure;
                this.Invalidate();
                break;

            case DrawToolType.Circle:
            case DrawToolType.MultipleCircle:
                Program.SysConfig.Function = SystemFunction.Laser;
                break;
                //case DrawToolType.Pointer:
                //    Program.SysConfig.Function = SystemFunction.Empty;
                //    break;
                //default:
                //    Program.SysConfig.Function = SystemFunction.Empty;
                //    break;
            }
        }
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner">Reference to the owner form</param>
        /// <param name="docManager">Reference to Document manager</param>
        public void Initialize(MainForm owner, DocManager docManager, Image initialImage, string initialImageAsFilePath, byte[] initialImageAsPngBytes)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            Invalidate();

            // Keep reference to owner form
            Owner      = owner;
            DocManager = docManager;

            // set default tool
            activeTool = DrawToolType.Pointer;

            // Create undo manager
            undoManager = new UndoManager(_layers);

            // create array of drawing tools
            tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
            tools[(int)DrawToolType.Pointer]   = new ToolPointer();
            tools[(int)DrawToolType.Rectangle] = new ToolRectangle();
            tools[(int)DrawToolType.Ellipse]   = new ToolEllipse();
            tools[(int)DrawToolType.Line]      = new ToolLine();
            tools[(int)DrawToolType.PolyLine]  = new ToolPolyLine();
            tools[(int)DrawToolType.Polygon]   = new ToolPolygon();
            tools[(int)DrawToolType.Text]      = new ToolText();
            tools[(int)DrawToolType.Image]     = new ToolImage();
            tools[(int)DrawToolType.Connector] = new ToolConnector();

            LineColor = Color.Red;
            FillColor = Color.White;
            LineWidth = 5;

            LoadInitialImage(initialImage, initialImageAsFilePath, initialImageAsPngBytes, null);
        }
Esempio n. 5
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="docManager"></param>
        public void Initialize(Form1 owner)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            // Keep reference to owner form
            this.Owner = owner;
            //this.DocManager = docManager;

            // set default tool
            activeTool = DrawToolType.Pointer;

            // create list of graphic objects
            graphicsList = new GraphicsList();

            collapsablePanels = new ArrayList();
            comments          = new List <AnnotationComments>();
            // create array of drawing tools
            tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
            tools[(int)DrawToolType.Pointer]   = new ToolPointer();
            tools[(int)DrawToolType.Rectangle] = new ToolRectangle();
            tools[(int)DrawToolType.Ellipse]   = new ToolEllipse();
            tools[(int)DrawToolType.Line]      = new ToolLine();
            tools[(int)DrawToolType.Polygon]   = new ToolPolygon();
        }
Esempio n. 6
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner">Reference to the owner form</param>
        /// <param name="docManager">Reference to Document manager</param>
        public void Initialize(MainForm owner, DocManager docManager)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            Invalidate();

            // Keep reference to owner form
            Owner      = owner;
            DocManager = docManager;

            // set default tool
            activeTool = FBDDrawToolType.Pointer;

            // Create undo manager
            undoManager = new UndoManager(_layers);

            // create array of drawing tools
            tools = new Tool[(int)FBDDrawToolType.NumberOfDrawTools];
            tools[(int)FBDDrawToolType.Pointer]   = new ToolPointer();
            tools[(int)FBDDrawToolType.Variable]  = new ToolVariable();
            tools[(int)FBDDrawToolType.FB]        = new ToolFB();
            tools[(int)FBDDrawToolType.FB]        = new ToolFunction();
            tools[(int)FBDDrawToolType.Connector] = new ToolConnection();
            tools[(int)FBDDrawToolType.Comment]   = new ToolComment();

            LineColor = Color.Black;
            FillColor = Color.White;
            LineWidth = -1;
        }
Esempio n. 7
0
        /// <summary>
        /// 이니셜라이저
        /// </summary>
        /// <param name="f"></param>
        public void Initialize(Form1 f, DocManager docManager)
        {
            this.ActiveTool = Q_Modeler.DrawArea.DrawToolType.Pointer;
//
//			this.Location = new System.Drawing.Point(24, 79);
            this.Name = "drawArea";
//			this.NetRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
//			this.Size = new System.Drawing.Size(272, 107);
//			this.TabIndex = 1;
//
            this.Mgr.Gudcon = new GudCon();
            this.Mgr.Gudsrt = new GudSrt();
            this.Mgr.Gudpnt = new GudPnt();

            this.Mgr.Gudsrt.GridpointX = 1;
            this.Mgr.Gudsrt.GridpointY = 1;

            this.Owner      = f;
            this.DocManager = docManager;

            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            Mgr.Flolist = new FLOList();

            tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
            tools[(int)DrawToolType.Pointer]    = new ToolPointer();
            tools[(int)DrawToolType.Hand]       = new ToolHand();
            tools[(int)DrawToolType.Buffer]     = new ToolBuffer();
            tools[(int)DrawToolType.Operation]  = new ToolOperation();
            tools[(int)DrawToolType.Resource]   = new ToolResource();
            tools[(int)DrawToolType.Calendar]   = new ToolCalendar();
            tools[(int)DrawToolType.Demand]     = new ToolDemand();
            tools[(int)DrawToolType.Connection] = new ToolConnection();
        }
Esempio n. 8
0
        public void Initialize()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            Invalidate();

            activeTool = DrawToolType.Pointer;

            DocManager = docManager;

            undoManager = new Undo_Redo(_layers);

            _image = new Bitmap(this.Width, this.Height);

            _resizing           = false;
            _cursorStartPoint   = Point.Empty;
            MouseIsInRightEdge  = false;
            MouseIsInBottomEdge = false;
            this.MouseDown     += (sender, e) => StartMovingOrResizing(e);
            this.MouseUp       += (sender, e) => StopDragOrResizing();
            this.MouseMove     += (sender, e) => MoveControl(e);

            tools = new Event[(int)DrawToolType.NumberOfDrawTools];
            tools[(int)DrawToolType.Pointer]      = new EventPointer();
            tools[(int)DrawToolType.Rectangle]    = new EventRectangle();
            tools[(int)DrawToolType.Ellipse]      = new EventEllipse();
            tools[(int)DrawToolType.Line]         = new EventLine();
            tools[(int)DrawToolType.Polygon]      = new EventPencil();
            tools[(int)DrawToolType.Text]         = new EventText();
            tools[(int)DrawToolType.Image]        = new EventImage();
            tools[(int)DrawToolType.SpecialShape] = new EventSpecialShape();
            LineColor = Color.Black;
            FillColor = Color.White;
            LineWidth = 2;
        }
Esempio n. 9
0
        /// <summary>
        /// Mouse down.
        /// Left button down event is passed to active tool.
        /// Right button down event is handled in this class.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DrawArea_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_tools[(int)_activeTool].IsComplete)
            {
                _tools[(int)_activeTool].OnMouseDown(this, e);
                if (e.Button == MouseButtons.Right)
                {
                    if (_tools[(int)_activeTool].IsComplete)
                    {
                        _activeTool = DrawToolType.Pointer;
                        ToolDone(sender, e);
                        Refresh();
                    }
                }
                return;
            }
            if (e.Button == MouseButtons.Left)
            {
                _tools[(int)_activeTool].OnMouseDown(this, e);
            }
            else if (e.Button == MouseButtons.Right)
            {
                OnContextMenu(e);
            }

            if (_graphicsList.IsAnythingSelected() && (!_tools[(int)_activeTool].IsComplete))
            {
                if (ItemsSelected != null)
                {
                    ItemsSelected(_graphicsList.GetAllSelected(), e);
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner"></param>
        public void Initialize(Control owner)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            // Keep reference to owner form
            Owner = owner;

            // set default tool
            _activeTool = DrawToolType.Pointer;

            // create list of graphic objects
            _graphicsList = new GraphicsList();

            // create array of drawing tools
            _tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
            _tools[(int)DrawToolType.Pointer]   = new ToolPointer();
            _tools[(int)DrawToolType.Rectangle] = new ToolRectangle();
            _tools[(int)DrawToolType.Ellipse]   = new ToolEllipse();
            _tools[(int)DrawToolType.Line]      = new ToolLine();
            _tools[(int)DrawToolType.Polygon]   = new ToolPolygon();
            _tools[(int)DrawToolType.Text]      = new ToolText();
            _tools[(int)DrawToolType.Bitmap]    = new ToolImage();
            _tools[(int)DrawToolType.Pan]       = new ToolPan();
            _tools[(int)DrawToolType.Path]      = new ToolPath();

            Graphics g = Owner.CreateGraphics();

            DrawObject.Dpi = new PointF(g.DpiX, g.DpiY);
        }
Esempio n. 11
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner">Reference to the owner form</param>
        /// <param name="docManager">Reference to Document manager</param>
        public void Initialize(Form owner, DocManager docManager)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            Invalidate();

            // Keep reference to owner form
            //HAMID
            //this.Owner = owner;
            this.DocManager = docManager;

            // set default tool
            activeTool = DrawToolType.Pointer;

            // Create undo manager
            undoManager = new UndoManager(_layers);

            // create array of drawing tools
            tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
            tools[(int)DrawToolType.Pointer]   = new ToolPointer();
            tools[(int)DrawToolType.Rectangle] = new ToolRectangle();
            tools[(int)DrawToolType.Ellipse]   = new ToolEllipse();
            tools[(int)DrawToolType.Line]      = new ToolLine();
            tools[(int)DrawToolType.PolyLine]  = new ToolPolyLine();
            tools[(int)DrawToolType.Polygon]   = new ToolPolygon();
            tools[(int)DrawToolType.Text]      = new ToolText();
            tools[(int)DrawToolType.Image]     = new ToolImage();

            LineColor = Color.White;
            FillColor = Color.Gray;
            LineWidth = -1;
        }
Esempio n. 12
0
 public static void ChangeDrawTool(DrawToolType newTool)
 {
     if (newTool != ActiveDrawTool)
     {
         ActiveDrawTool = newTool;
         //update editor selection display
         Form.updateSelectedDrawTool(ActiveDrawTool);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// 키이벤트 처리
        /// </summary>
        private void DrawArea_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            switch (e.KeyData)
            {
            case Keys.Escape:
                owner.CommandClose();
                break;

            case Keys.Delete:
                Mgr.Flolist.Delete();
                this.Refresh();
                break;

            case (Keys.Control | Keys.A):
                Mgr.Flolist.SelectAll();
                this.Refresh();
                break;

            case (Keys.Control | Keys.U):
                Mgr.Flolist.UnselectAll();
                this.Refresh();
                break;

            case (Keys.T):
                ActiveTool = DrawArea.DrawToolType.Pointer;
                break;

            case (Keys.H):
                ActiveTool = DrawArea.DrawToolType.Hand;
                break;

            case (Keys.C):
                ActiveTool = DrawArea.DrawToolType.Connection;
                break;

            case (Keys.B):
                ActiveTool = DrawArea.DrawToolType.Buffer;
                break;

            case (Keys.A):
                ActiveTool = DrawArea.DrawToolType.Operation;
                break;

            case (Keys.R):
                ActiveTool = DrawArea.DrawToolType.Resource;
                break;

            case (Keys.E):
                ActiveTool = DrawArea.DrawToolType.Calendar;
                break;

            case (Keys.D):
                ActiveTool = DrawArea.DrawToolType.Demand;
                break;
            }
        }
Esempio n. 14
0
        public void SetToolType(DrawToolType type)
        {
            Mouse.RemoveMouseDownHandler(this.DrawCanvas, this.polylineToolMouseDown);
            Mouse.RemoveMouseUpHandler(this, this.polylineToolMouseUp);
            Mouse.RemoveMouseMoveHandler(this, this.polylineToolMouseMove);
            this.DrawCanvas.Cursor = null;
            this.lastShape         = null;
            this.ToolType          = type;

            Mouse.AddMouseDownHandler(this.DrawCanvas, this.polylineToolMouseDown);
            Mouse.AddMouseUpHandler(this, this.polylineToolMouseUp);
            Mouse.AddMouseMoveHandler(this, this.polylineToolMouseMove);
            this.DrawCanvas.Cursor = Cursors.Cross;
        }
Esempio n. 15
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="docManager"></param>
        public void Initialize()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            // set default tool
            activeTool = DrawToolType.Pointer;

            // create list of graphic objects
            graphicsList = new GraphicsList();

            // create array of drawing tools
            tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
            tools[(int)DrawToolType.Pointer] = new ToolPointer();
        }
        public void Initialize()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);

            activeTool = DrawToolType.Pointer;

            graphicsList = new GraphicsList();

            tools = new Tool[(int)DrawToolType.NumberOfTools];
            tools[(int)DrawToolType.Pointer] = new ToolPointer();
            tools[(int)DrawToolType.File] = new ToolFile();
            tools[(int)DrawToolType.Database] = new ToolDatabase();
            //tools[(int)DrawToolType.Process] = new ToolLine();
            tools[(int)DrawToolType.Process] = new ToolRectangle();
            tools[(int)DrawToolType.Connector] = new ToolLine();
            // Evandro tools[(int)DrawToolType.Connector] = new ToolPolygon();
        }
        public void Initialize()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);

            activeTool = DrawToolType.Pointer;

            graphicsList = new GraphicsList();

            tools = new Tool[(int)DrawToolType.NumberOfTools];
            tools[(int)DrawToolType.Pointer]  = new ToolPointer();
            tools[(int)DrawToolType.File]     = new ToolFile();
            tools[(int)DrawToolType.Database] = new ToolDatabase();
            //tools[(int)DrawToolType.Process] = new ToolLine();
            tools[(int)DrawToolType.Process]   = new ToolRectangle();
            tools[(int)DrawToolType.Connector] = new ToolLine();
            // Evandro tools[(int)DrawToolType.Connector] = new ToolPolygon();
        }
Esempio n. 18
0
        /// <summary>


        public void Initialize(/*MainForm owner, DocManager docManager*/)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            Invalidate();

            // Keep reference to owner form
            //mainEWSForm = owner;
            //DocManager = docManager;

            // set default tool
            activeTool = DrawToolType.Pointer;

            // Create undo manager


            // create array of drawing tools



            tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
            tools[(int)DrawToolType.Pointer] = new ToolPointer();
#if EWSAPP
            tools[(int)DrawToolType.Rectangle]     = new ToolRectangle();
            tools[(int)DrawToolType.Ellipse]       = new ToolEllipse();
            tools[(int)DrawToolType.Line]          = new ToolLine();
            tools[(int)DrawToolType.PolyLine]      = new ToolPolyLine();
            tools[(int)DrawToolType.Text]          = new ToolText();
            tools[(int)DrawToolType.Polygon]       = new ToolPolygon();
            tools[(int)DrawToolType.Image]         = new ToolImage();
            tools[(int)DrawToolType.Variable]      = new ToolVariable();
            tools[(int)DrawToolType.Function]      = new ToolFunction(true);
            tools[(int)DrawToolType.FunctionBlock] = new ToolFunction(false);
            tools[(int)DrawToolType.Wire]          = new ToolWire();
            tools[(int)DrawToolType.Constant]      = new ToolConstant();
            tools[(int)DrawToolType.Comment]       = new ToolConstant();
            tools[(int)DrawToolType.Curve]         = new ToolCurve();
#endif
            LineColor = Color.Black;
            FillColor = Color.White;
            LineWidth = -1;
        }
Esempio n. 19
0
        private void DrawArea_Load(object sender, EventArgs e)
        {
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);
            this.ActiveTool       = DrawToolType.Pointer;
            this.GraphicsList     = new GraphicsList();
            this.GraphicsNodeList = new AdGraph();
            o    = new object[2];
            o[0] = this.GraphicsList;
            o[1] = this.GraphicsNodeList;

            tools = new ToolObject[(int)DrawToolType.NumberOfDrawEquipments];
            tools[(int)DrawToolType.Pointer]       = new ToolPointer();
            tools[(int)DrawToolType.Transformers2] = new ToolTransformer2();
            tools[(int)DrawToolType.Transformers3] = new ToolTransformer3();
            tools[(int)DrawToolType.Knife]         = new ToolKnife();
            tools[(int)DrawToolType.Capacitor]     = new ToolCapacitor();
            tools[(int)DrawToolType.Line]          = new ToolLine();
            tools[(int)DrawToolType.Power]         = new ToolPower();
            tools[(int)DrawToolType.Break]         = new ToolBreak();
        }
Esempio n. 20
0
        public void Initialize(Control owner)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            Owner       = owner;
            _activeTool = DrawToolType.Pointer;

            _graphicsList = new GraphicsList();

            _tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
            _tools[(int)DrawToolType.Pointer]   = new ToolPointer();
            _tools[(int)DrawToolType.Rectangle] = new ToolRectangle();
            _tools[(int)DrawToolType.Ellipse]   = new ToolEllipse();
            _tools[(int)DrawToolType.Line]      = new ToolLine();
            _tools[(int)DrawToolType.Polygon]   = new ToolPolygon();
            _tools[(int)DrawToolType.Text]      = new ToolText();
            _tools[(int)DrawToolType.Path]      = new ToolPath();

            Graphics g = Owner.CreateGraphics();

            DrawObject.Dpi = new PointF(g.DpiX, g.DpiY);
        }
Esempio n. 21
0
        /// <summary>
        ///   Initialization
        /// </summary>
        /// <param name="owner"> </param>
        /// <param name="docManager"> </param>
        public void Initialize(MainForm owner, DocManager docManager)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);

            // Keep reference to owner form
//            this.Owner = owner;
//            this.DocManager = docManager;

            // set default tool
            _activeTool = DrawToolType.Pointer;

            // create list of graphic objects
            _graphicsList = new GraphicsList();

            // Create undo manager
            _undoManager = new UndoManager(_graphicsList);

            // create array of drawing tools
            _tools = new Tool[(int) DrawToolType.NumberOfDrawTools];
            _tools[(int) DrawToolType.Pointer] = new ToolPointer();
            _tools[(int) DrawToolType.Rectangle] = new ToolRectangle();
            _tools[(int) DrawToolType.Ellipse] = new ToolEllipse();
            _tools[(int) DrawToolType.Line] = new ToolLine();
            _tools[(int) DrawToolType.Polygon] = new ToolPolygon();
        }
Esempio n. 22
0
		/// <summary>
		/// Initialization
		/// </summary>
		/// <param name="owner">Reference to the owner form</param>
		/// <param name="docManager">Reference to Document manager</param>
		public void Initialize(Form owner, DocManager docManager)
		{
			SetStyle(ControlStyles.AllPaintingInWmPaint |
				ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
			Invalidate();

			// Keep reference to owner form
            //HAMID
			//this.Owner = owner;
			this.DocManager = docManager;

			// set default tool
			activeTool = DrawToolType.Pointer;

			// Create undo manager
			undoManager = new UndoManager(_layers);

			// create array of drawing tools
            tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
			tools[(int)DrawToolType.Pointer]	= new ToolPointer();
			tools[(int)DrawToolType.Rectangle]	= new ToolRectangle();
			tools[(int)DrawToolType.Ellipse]		= new ToolEllipse();
			tools[(int)DrawToolType.Line]		= new ToolLine();
			tools[(int)DrawToolType.PolyLine]	= new ToolPolyLine();
			tools[(int)DrawToolType.Polygon]	= new ToolPolygon();
			tools[(int)DrawToolType.Text]		= new ToolText();
			tools[(int)DrawToolType.Image]		= new ToolImage();

			LineColor = Color.White;
			FillColor = Color.Gray;
			LineWidth = -1;
		}
Esempio n. 23
0
        public void updateSelectedDrawTool(DrawToolType tool)
        {
            switch (tool)
            {
            case DrawToolType.PENCIL:
                drawMenuPencilItem.Checked    = true;
                drawMenuRectangleItem.Checked = false;
                drawMenuEllipseItem.Checked   = false;
                drawMenuFloodFillItem.Checked = false;
                drawMenuSelectItem.Checked    = false;
                toolbarPencilItem.Checked     = true;
                toolbarRectangleItem.Checked  = false;
                toolbarEllipseItem.Checked    = false;
                toolbarFloodFillItem.Checked  = false;
                toolbarSelectItem.Checked     = false;
                break;

            case DrawToolType.RECTANGLE:
                drawMenuPencilItem.Checked    = false;
                drawMenuRectangleItem.Checked = true;
                drawMenuEllipseItem.Checked   = false;
                drawMenuFloodFillItem.Checked = false;
                drawMenuSelectItem.Checked    = false;
                toolbarPencilItem.Checked     = false;
                toolbarRectangleItem.Checked  = true;
                toolbarEllipseItem.Checked    = false;
                toolbarFloodFillItem.Checked  = false;
                toolbarSelectItem.Checked     = false;
                break;

            case DrawToolType.ELLIPSE:
                drawMenuPencilItem.Checked    = false;
                drawMenuRectangleItem.Checked = false;
                drawMenuEllipseItem.Checked   = true;
                drawMenuFloodFillItem.Checked = false;
                drawMenuSelectItem.Checked    = false;
                toolbarPencilItem.Checked     = false;
                toolbarRectangleItem.Checked  = false;
                toolbarEllipseItem.Checked    = true;
                toolbarFloodFillItem.Checked  = false;
                toolbarSelectItem.Checked     = false;
                break;

            case DrawToolType.FLOODFILL:
                drawMenuPencilItem.Checked    = false;
                drawMenuRectangleItem.Checked = false;
                drawMenuEllipseItem.Checked   = false;
                drawMenuFloodFillItem.Checked = true;
                drawMenuSelectItem.Checked    = false;
                toolbarPencilItem.Checked     = false;
                toolbarRectangleItem.Checked  = false;
                toolbarEllipseItem.Checked    = false;
                toolbarFloodFillItem.Checked  = true;
                toolbarSelectItem.Checked     = false;
                break;

            case DrawToolType.SELECT:
                drawMenuPencilItem.Checked    = false;
                drawMenuRectangleItem.Checked = false;
                drawMenuEllipseItem.Checked   = false;
                drawMenuFloodFillItem.Checked = false;
                drawMenuSelectItem.Checked    = true;
                toolbarPencilItem.Checked     = false;
                toolbarRectangleItem.Checked  = false;
                toolbarEllipseItem.Checked    = false;
                toolbarFloodFillItem.Checked  = false;
                toolbarSelectItem.Checked     = true;
                break;
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Initialization
        /// </summary>
        /// <param name="owner">Reference to the owner form</param>
        /// <param name="docManager">Reference to Document manager</param>
        public void Initialize(DocManager docManager)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint |
                 ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            Invalidate();
            // Keep reference to owner form
            //Owner = owner;
            DocManager = docManager;

            // set default tool
            activeTool = DrawToolType.Pointer;

            // Create undo manager
            undoManager = new UndoManager(_layers);

            // create array of drawing tools
            tools = new Tool[(int)DrawToolType.NumberOfDrawTools];
            tools[(int)DrawToolType.Pointer] = new ToolPointer();
            (tools[(int)DrawToolType.Pointer] as ToolPointer).parentContorl = this;
            //Owner.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FT_Status_Child_FormClosing);
            tools[(int)DrawToolType.Rectangle] = new ToolRectangle();
            tools[(int)DrawToolType.Ellipse] = new ToolEllipse();
            tools[(int)DrawToolType.Line] = new ToolLine();
            tools[(int)DrawToolType.PolyLine] = new ToolPolyLine();
            tools[(int)DrawToolType.Polygon] = new ToolPolygon();
            tools[(int)DrawToolType.Text] = new ToolText();
            tools[(int)DrawToolType.Image] = new ToolImage();
            tools[(int)DrawToolType.Connector] = new ToolConnector();
            tools[(int)DrawToolType.StationTrack] = new ToolStationTrack();
            tools[(int)DrawToolType.Turnout] = new ToolTurnout();
            tools[(int)DrawToolType.Template] = new ToolTemplate(null);
            // tools[(int)DrawToolType.SwitchMachine] = new ToolSwitchMachine();

            LineColor = Color.Black;
            FillColor = Color.White;
            LineWidth = -1;
        }
Esempio n. 25
0
        /// <summary>
        /// конструктор
        /// </summary>
        public DrawTool(Window Window, Canvas Workspace, Border CanvasBorder, Canvas Canvas, DrawToolType type)
        {
            this.canvas       = Canvas;
            this.window       = Window;
            this.workspace    = Workspace;
            this.canvasBorder = CanvasBorder;
            this.Selection    = new List <Shape>();

            this.border                  = (Border)XamlReader.Parse(DrawTool.BorderControlXaml);
            this.dotsControl             = (ItemsControl)XamlReader.Parse(DrawTool.DotsItemsControlXaml);
            this.dots                    = new DrawToolDots();
            this.dotsControl.Tag         = this.dots;
            this.dotsControl.ItemsSource = this.dots.Dots;
            this.border.Visibility       = Visibility.Hidden;

            this.workspace.Children.Add(this.border);
            this.canvas.Children.Add(this.dotsControl);
            this.SetToolType(type);
        }
Esempio n. 26
0
        /// <summary>
        /// Отвязка и привязка событий к мыше и клавиатуре в зависимости от выбранного типа интрумента
        /// </summary>
        public void SetToolType(DrawToolType type)
        {
            switch (this.ToolType)
            {
            case DrawToolType.Pointer:
                Mouse.RemoveMouseDownHandler(this.window, this.toolMouseDown);
                Mouse.RemoveMouseUpHandler(this.window, this.toolMouseUp);
                Mouse.RemoveMouseMoveHandler(this.window, this.toolMouseMove);
                Keyboard.RemoveKeyDownHandler(this.window, this.toolKeyDown);
                Keyboard.RemoveKeyUpHandler(this.window, this.toolKeyUp);
                Mouse.RemoveMouseDownHandler(this.dotsControl, this.dotsControl_MouseDown);
                Mouse.RemoveMouseUpHandler(this.dotsControl, this.dotsControl_MouseUp);
                Mouse.RemoveMouseMoveHandler(this.dotsControl, this.dotsControl_MouseMove);
                this.selectShapes(null);
                break;

            case DrawToolType.Polyline:
                Mouse.RemoveMouseDownHandler(this.canvas, this.polylineToolMouseDown);
                Mouse.RemoveMouseUpHandler(this.window, this.polylineToolMouseUp);
                Mouse.RemoveMouseMoveHandler(this.window, this.polylineToolMouseMove);
                this.canvas.Cursor = null;
                this.lastShape     = null;
                break;

            case DrawToolType.Rectangle:
                Mouse.RemoveMouseDownHandler(this.canvas, this.rectangleToolMouseDown);
                Mouse.RemoveMouseUpHandler(this.window, this.rectangleToolMouseMouseUp);
                Mouse.RemoveMouseMoveHandler(this.window, this.rectangleToolMouseMove);
                this.canvas.Cursor = null;
                this.lastShape     = null;
                break;

            case DrawToolType.Delete:
                Mouse.RemoveMouseDownHandler(this.canvas, this.deleteToolMouseDown);
                Mouse.RemoveMouseMoveHandler(this.window, this.deleteToolMouseMove);
                if (this.lastShape != null)
                {
                    this.lastShape.SetDeletingStyle(false);
                    this.lastShape = null;
                }
                break;
            }

            this.ToolType = type;

            switch (this.ToolType)
            {
            case DrawToolType.Pointer:
                Mouse.AddMouseDownHandler(this.dotsControl, this.dotsControl_MouseDown);
                Mouse.AddMouseUpHandler(this.dotsControl, this.dotsControl_MouseUp);
                Mouse.AddMouseDownHandler(this.window, this.toolMouseDown);
                Mouse.AddMouseUpHandler(this.window, this.toolMouseUp);
                Mouse.AddMouseMoveHandler(this.window, this.toolMouseMove);
                Mouse.AddMouseMoveHandler(this.dotsControl, this.dotsControl_MouseMove);
                Keyboard.AddKeyDownHandler(this.window, this.toolKeyDown);
                Keyboard.AddKeyUpHandler(this.window, this.toolKeyUp);
                break;

            case DrawToolType.Polyline:
                Mouse.AddMouseDownHandler(this.canvas, this.polylineToolMouseDown);
                Mouse.AddMouseUpHandler(this.window, this.polylineToolMouseUp);
                Mouse.AddMouseMoveHandler(this.window, this.polylineToolMouseMove);
                this.canvas.Cursor = Cursors.Cross;
                break;

            case DrawToolType.Rectangle:
                Mouse.AddMouseDownHandler(this.canvas, this.rectangleToolMouseDown);
                Mouse.AddMouseUpHandler(this.window, this.rectangleToolMouseMouseUp);
                Mouse.AddMouseMoveHandler(this.window, this.rectangleToolMouseMove);
                this.canvas.Cursor = Cursors.Cross;
                break;

            case DrawToolType.Delete:
                Mouse.AddMouseDownHandler(this.canvas, this.deleteToolMouseDown);
                Mouse.AddMouseMoveHandler(this.window, this.deleteToolMouseMove);
                break;
            }
        }