Ejemplo n.º 1
0
        private void                    panel_Draw_MouseUp(object aSender, MouseEventArgs aEventArgs)
        {
            if (aEventArgs.Button == MouseButtons.Left)
            {
                mMove = false;

                if (mCreate)
                {
                    mCreate = false;

                    mElements.Add(mNewElement);
                    listBox_Elements.Items.Add(mNewElement.Name);
                    mNewElement = null;
                }

                if (mSelectionWork)
                {
                    mSelectionWork = false;

                    mSelectionForm.Hide();
                    mSelectionForm.Dispose();
                    mSelectionForm = null;
                }

                updateMenu();
                redraw();

                return;
            }
        }
Ejemplo n.º 2
0
        protected override void             Dispose(bool disposing)
        {
            if (disposing)
            {
                if (mBitmap != null)
                {
                    mBitmap.Dispose();
                    mBitmap = null;
                }

                if (mElements != null)
                {
                    int lCount = mElements.Count;
                    if (lCount > 0)
                    {
                        for (int i = 0; i < lCount; i++)
                        {
                            mElements[i].Dispose();
                        }
                        mElements.Clear();
                    }
                    mElements = null;
                }

                if (mCopyBuffer != null)
                {
                    int lCount = mCopyBuffer.Count;
                    if (lCount > 0)
                    {
                        for (int i = 0; i < lCount; i++)
                        {
                            mCopyBuffer[i].Dispose();
                        }
                        mCopyBuffer.Clear();
                    }
                    mCopyBuffer = null;
                }

                if (mNewElement != null)
                {
                    mNewElement.Dispose();
                    mNewElement = null;
                }

                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Ejemplo n.º 3
0
        private void                    panel_Draw_MouseDown(object aSender, MouseEventArgs aEventArgs)
        {
            #region Selecting, Moving

            if (tsButton_Pointer.Checked)
            {
                int  lIndex = testHit(aEventArgs.Location);
                bool lCtrl  = (Form.ModifierKeys == Keys.Control);

                if (aEventArgs.Button == MouseButtons.Left)
                {
                    if (lIndex > -1)
                    {
                        bool lSelected = listBox_Elements.GetSelected(lIndex);
                        if (lSelected && lCtrl)
                        {
                            listBox_Elements.SetSelected(lIndex, false);
                        }
                        else
                        {
                            if (lSelected == false)
                            {
                                if (lCtrl == false)
                                {
                                    listBox_Elements.ClearSelected();
                                }

                                listBox_Elements.SetSelected(lIndex, true);
                            }

                            mMove          = true;
                            mMousePosition = aEventArgs.Location;
                        }
                    }
                    else
                    {
                        listBox_Elements.ClearSelected();

                        mMousePosition = Cursor.Position;

                        mSelectionForm = new Form();
                        mSelectionForm.FormBorderStyle = FormBorderStyle.None;
                        mSelectionForm.ShowInTaskbar   = false;
                        mSelectionForm.ShowIcon        = false;
                        mSelectionForm.BackColor       = Color.Gray;
                        mSelectionForm.Opacity         = 0.15;
                        mSelectionForm.TopMost         = true;

                        int lCount = mElements.Count;
                        mElementRect = new Rectangle[lCount];
                        for (int i = 0; i < lCount; i++)
                        {
                            mElementRect[i] = panel_Draw.RectangleToScreen(mElements[i].coverRect);
                        }

                        mSelectionWork = true;
                        mSelectionRect = new Rectangle(0, 0, 1, 1);
                        ThreadPool.QueueUserWorkItem((o) => { SelectionWork(); });
                    }
                }

                if (aEventArgs.Button == MouseButtons.Right)
                {
                    listBox_Elements.ClearSelected();
                    if (lIndex > -1)
                    {
                        listBox_Elements.SetSelected(lIndex, true);
                        tsButton_Setup_Click(this, EventArgs.Empty);
                    }
                }

                return;
            }

            #endregion

            #region Creating

            if (aEventArgs.Button == MouseButtons.Left)
            {
                mCreate = true;

                if (tsButton_Line.Checked)
                {
                    mNewElement = new ElementLine.ElementLine();
                }
                else if (tsButton_Rectangle.Checked)
                {
                    mNewElement = new ElementRectangle.ElementRectangle();
                }
                else if (tsButton_Ellipse.Checked)
                {
                    mNewElement = new ElementEllipse.ElementEllipse();
                }
                else if (tsButton_Text.Checked)
                {
                    mNewElement = new ElementText.ElementText();
                }

                mNewElement.move(aEventArgs.X, aEventArgs.Y);
                mMousePosition = aEventArgs.Location;

                return;
            }

            #endregion
        }