Пример #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);
            }
        }
Пример #2
0
        public static void FixLine(MouseEventArgs e)
        {
            foreach (Line currentLine in Form1.TreeSelectedLines)
            {
                if (currentLine.PointOnLineSegment(e.Location))
                {
                    if (!currentLine.Fixed)
                    {
                        currentLine.Fixed    = true;
                        currentLine.PenColor = Line.FIXED_COLOR;
                        TreeListControl.RefreshTreeList(currentLine);

                        Form1.TreeSelectedLines.Clear();
                        break;
                    }
                    else if (currentLine.Fixed)
                    {
                        currentLine.Fixed    = false;
                        currentLine.PenColor = Line.GENERAL_COLOR;
                        TreeListControl.RefreshTreeList(currentLine);

                        Form1.TreeSelectedLines.Clear();
                        break;
                    }
                }
            }
        }
Пример #3
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();
        }
Пример #4
0
        public static void DeleteComplex(Line lineInComplex)
        {
            ComplexLines cmplx = complexes.Find(x => x.Id == lineInComplex.ComplexID);

            foreach (Line ln in cmplx.Lines)
            {
                Form1._allLines.Remove(ln);
            }
            TreeListControl.RemoveInfoComplex(cmplx);
        }
Пример #5
0
        /// <summary>
        /// Заверщающий этап какого либо {ВЫБРАННОГО} действия
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void drawingPanel_MouseUp(object sender, MouseEventArgs e)
        {
            /*Завершение перемещения линии*/
            if (CURRENT_ACTION == Action.Transfer)
            {
                if (WrapperForSelectedLines != null)
                {
                    if (!WrapperForSelectedLines.Fixed)
                    {
                        WrapperForSelectedLines.PenColor = Line.GENERAL_COLOR;
                        drawingPanel.Refresh();

                        MyLogger.LogIt(
                            "Line's been transfered "
                            + WrapperForSelectedLines.Id.ToString() +
                            " |" + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()
                            + "|", MyLogger.Importance.Info
                            );
                        WrapperForSelectedLines = null;
                    }
                }
                else if (WrapperForComplexlines != null)
                {
                    WrapperForComplexlines = null;
                }
            }
            /*Завершение создания линии*/
            if (CURRENT_ACTION == Action.Draw)
            {
                Line line = _allLines.Last();
                Line.FinishDrawingLine(e, line);
                InfoPanel.lineLenghtInfo.Text = line.Length.ToString();

                /*Пополнение информационных таблиц*/
                TreeListControl.AddNewInfoLine(line);
                MyLogger.LogIt(
                    "Line's been made "
                    + line.Id.ToString() +
                    " |" + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString()
                    + "|", MyLogger.Importance.Info
                    );
            }
        }
Пример #6
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
        }