Exemple #1
0
        public static void DeleteLine(MouseEventArgs e)
        {
            try
            {
                foreach (Line currentLine in Form1._allLines)
                {
                    if (currentLine.PointOnLineSegment(e.Location))
                    {
                        if (currentLine.LineType == Types.Complex)
                        {
                            TightUper.DeleteComplex(currentLine);
                            break;
                        }
                        else if (!currentLine.Fixed && currentLine.LineType == Types.Single)
                        {
                            Form1._allLines.Remove(currentLine);
                            TreeListControl.RemoveInfoLine(currentLine);

                            MyLogger.LogIt("Trying to dele fixed line!", MyLogger.Importance.Warrning);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MyLogger.LogIt(ex.Message, MyLogger.Importance.Fatal);
            }
        }
Exemple #2
0
        public static void TightUp(List <Line> lines)
        {
            int          complexId   = complexes.Count + 1;
            ComplexLines complexLine = new ComplexLines(complexId);

            foreach (Line itemToTight in lines)
            {
                itemToTight.Complex   = true;
                itemToTight.LineType  = Line.Types.Complex;
                itemToTight.ComplexID = complexId;
                itemToTight.PenColor  = ComplexLines.COMPLEX_COLOR;

                complexLine.Lines.Add(itemToTight);
                if (!complexLine.Vertexes.Contains(itemToTight.StartPoint))
                {
                    complexLine.Vertexes.Add(itemToTight.StartPoint);
                }
                if (!complexLine.Vertexes.Contains(itemToTight.EndPoint))
                {
                    complexLine.Vertexes.Add(itemToTight.EndPoint);
                }

                TreeListControl.RemoveInfoLine(itemToTight);
            }
            complexes.Add(complexLine);
            TreeListControl.AddNewInfoComplex(complexLine);
            Form1.TreeSelectedLines.Clear();
        }
Exemple #3
0
        /// <summary>
        /// Обработчик клавиш-команд, шорткаты
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="keyData"></param>
        /// <returns></returns>
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            #region CLosing and MassDelete
            if (keyData == Keys.Escape)
            {
                return(true);
            }
            if (keyData == Keys.Delete)
            {
                if (TreeSelectedLines.Count > 0)
                {
                    foreach (var line in TreeSelectedLines)
                    {
                        TreeListControl.RemoveInfoLine(line);
                        _allLines.Remove(line);
                    }
                    drawingPanel.Refresh();
                    TreeListControl.TreeSource.Refresh();
                }
            }
            #endregion

            #region Manage ShortCuts
            //шорткаты
            if (keyData == Keys.P)
            {
                CURRENT_ACTION = Action.MakeParallelTo;
                InfoPanel.currentActionInfo.Text = "Параллельность к.";
            }

            if (keyData == Keys.U && TreeSelectedLines.Count > 1)
            {
                TightUper.TightUp(TreeSelectedLines);
                TreeListControl.TreeSource.Refresh();
            }

            if (keyData == Keys.D)
            {
                CURRENT_ACTION = Action.Draw;
                InfoPanel.currentActionInfo.Text = "Рисование.";
            }

            if (keyData == Keys.C)
            {
                CURRENT_ACTION = Action.Delete;
                InfoPanel.currentActionInfo.Text = "Удаление.";
            }

            if (keyData == Keys.S)
            {
                CURRENT_ACTION = Action.Select;
                InfoPanel.currentActionInfo.Text = "Выбор.";
            }

            if (keyData == Keys.T)
            {
                CURRENT_ACTION = Action.Transfer;
                InfoPanel.currentActionInfo.Text = "Перемещение.";
            }

            if (keyData == Keys.F)
            {
                CURRENT_ACTION = Action.Fix;
                InfoPanel.currentActionInfo.Text = "Фиксация";
            }

            if (keyData == Keys.Q)
            {
                CURRENT_ACTION = Action.AlignHorizontally;
                InfoPanel.currentActionInfo.Text = "Выровнять гор.";
            }
            if (keyData == Keys.W)
            {
                CURRENT_ACTION = Action.AlignVertically;
                InfoPanel.currentActionInfo.Text = "Выровнять верт.";
            }
            if (keyData == Keys.E)
            {
                CURRENT_ACTION = Action.MakeParallelTo;
                InfoPanel.currentActionInfo.Text = "Параллельность к.";
            }

            if (keyData == Keys.O)
            {
                CURRENT_ACTION = Action.MakeOrthogonal;
                InfoPanel.currentActionInfo.Text = "Ортогональность к.";

                string            message = "Линия которая будет повернута, затем относительно которой будет повернута.";
                string            caption = "Виберите линию.";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                DialogResult      result;
                result = MessageBox.Show(message, caption, buttons);
            }

            if (keyData == Keys.A)
            {
                CURRENT_ACTION = Action.Angle;
                InfoPanel.currentActionInfo.Text = "Угол.";
            }

            if (keyData == Keys.N)
            {
                CURRENT_ACTION = Action.FixPoint;
                InfoPanel.currentActionInfo.Text = "Фиксация точки";
            }

            return(base.ProcessCmdKey(ref msg, keyData));

            #endregion
        }