Example #1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this._panMode    = false;
            drawArea.Panning = this._panMode;

            int           x       = drawArea.TheLayers.ActiveLayerIndex;
            CommandDelete command = new CommandDelete(drawArea.TheLayers);

            if (drawArea.TheLayers[x].Graphics.DeleteSelection())
            {
                drawArea.Refresh();
                drawArea.AddCommandToHistory(command);
            }
        }
Example #2
0
        public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title            = "Select an Image to insert into map";
            ofd.Filter           = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|Fireworks (*.png)|*.png|GIF (*.gif)|*.gif|Icon (*.ico)|*.ico|All files|*.*";
            ofd.FilterIndex      = 6;
            ofd.InitialDirectory = Environment.SpecialFolder.MyPictures.ToString();
            int al = drawArea.TheLayers.ActiveLayerIndex;

            while (true)
            {
                var dlgResult = ofd.ShowDialog();
                if (dlgResult != DialogResult.OK)
                {
                    drawArea.TheLayers[al].Graphics.RemoveAt(0);
                    break;
                }
                else
                {
                    try
                    {
                        ((DrawImage)drawArea.TheLayers[al].Graphics[0]).TheImage = (Bitmap)Bitmap.FromFile(ofd.FileName);
                        drawArea.AddCommandToHistory(new CommandAdd(drawArea.TheLayers[al].Graphics[0]));
                        break;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Can not load file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            ofd.Dispose();
            base.OnMouseUp(drawArea, e);
        }
        /// <summary>
        /// Right mouse button is released
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e)
        {
            int al = drawArea.TheLayers.ActiveLayerIndex;

            if (selectMode == SelectionMode.NetSelection)
            {
                // Group selection
                drawArea.TheLayers[al].Graphics.SelectInRectangle(drawArea.NetRectangle);

                selectMode = SelectionMode.None;
                drawArea.DrawNetRectangle = false;
            }

            if (resizedObject != null)
            {
                // after resizing
                resizedObject.Normalize();
                resizedObject = null;
            }

            drawArea.Capture = false;
            drawArea.Refresh();

            if (commandChangeState != null && wasMove)
            {
                // Keep state after moving/resizing and add command to history
                commandChangeState.NewState(drawArea.TheLayers);
                drawArea.AddCommandToHistory(commandChangeState);
                commandChangeState = null;
            }
            lastPoint = drawArea.BackTrackMouse(e.Location);
        }
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            TextDialog td = new TextDialog();

            td.TopLevel      = true;
            td.TopMost       = true;
            td.TheColor      = drawArea.LineColor;
            td.TheText       = _lastText ?? "";
            td.TheFont       = _lastFont ?? new Font(FontFamily.GenericSansSerif, 12, FontStyle.Regular);
            td.Zoom          = drawArea.Zoom;
            td.StartPosition = FormStartPosition.Manual;
            Point pnlLocationOnScreen = drawArea.MyParent.pnlDrawArea.PointToScreen(new Point(0, 0));
            Point pp = e.Location;

            pp = new Point(
                pnlLocationOnScreen.X + pp.X                                                                                         //hit point on screen
                - 18 - SystemInformation.Border3DSize.Width - SystemInformation.SizingBorderWidth                                    //-text box location
                + drawArea.Left                                                                                                      //+scroll amount
                ,
                pnlLocationOnScreen.Y + pp.Y                                                                                         //hit point on screen
                - 18 - SystemInformation.Border3DSize.Height - SystemInformation.SizingBorderWidth - SystemInformation.CaptionHeight //-text box location
                + drawArea.Top                                                                                                       //+scroll amount
                );
            td.Location = pp;
            if (td.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(td.Text))
            {
                _lastText = td.TheText;
                _lastFont = td.TheFont;
                string t = td.TheText;
                Color  c = td.TheColor;
                Font   f = td.TheFont;
                Point  p = drawArea.MyParent.PointToClient(td.Location);
                p = new Point(p.X + 17 - drawArea.Left, p.Y + 15 - drawArea.Top);
                p = drawArea.BackTrackMouse(p);
                AddNewObject(drawArea, new DrawText(p.X, p.Y, t, f, c));

                int al = drawArea.TheLayers.ActiveLayerIndex;
                drawArea.AddCommandToHistory(new CommandAdd(drawArea.TheLayers[al].Graphics[0]));

                drawArea.ActiveTool = DrawArea.DrawToolType.Pointer;
            }
        }
Example #5
0
        public void InsertImage(DrawArea drawArea, Image image, bool moveToBack, bool isInitialImage, DrawImage paradigm)
        {
            //theImage.Save("D:\\im.bmp", ImageFormat.Bmp);
            if (paradigm == null)
            {
                paradigm = new DrawImage(0, 0, isInitialImage);
            }
            //else
            //{
            //	paradigm.TheImage = (Bitmap)image;
            //}
            AddNewObject(drawArea, paradigm);
            int al = drawArea.TheLayers.ActiveLayerIndex;

            drawArea.TheLayers[al].Graphics[0].MoveHandleTo(new Point(image.Width, image.Height), 5);
            ((DrawImage)drawArea.TheLayers[al].Graphics[0]).TheImage = (Bitmap)image;
            drawArea.AddCommandToHistory(new CommandAdd(drawArea.TheLayers[al].Graphics[0]));
            if (moveToBack)
            {
                drawArea.TheLayers[al].Graphics.MoveSelectionToBack();
            }
            drawArea.TheLayers[al].Graphics.UnselectAll();
        }