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); } }
public static void TransferLine(MouseEventArgs e) { foreach (Line currentLine in Form1._allLines) { if (currentLine.PointOnLineSegment(e.Location)) { if (currentLine.LineType == Types.Complex) { TightUper.ComplexTransfer(e, currentLine); break; } else if (currentLine.Fixed) { string message = "Элемент зафиксирован."; string caption = "Действие невозможно."; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result; result = MessageBox.Show(message, caption, buttons); } else { currentLine._deltaStart = new Point(currentLine.StartPoint.X - e.Location.X, currentLine.StartPoint.Y - e.Location.Y); currentLine._deltaEnd = new Point(currentLine.EndPoint.X - e.Location.X, currentLine.EndPoint.Y - e.Location.Y); Form1.WrapperForSelectedLines = currentLine; Form1.WrapperForSelectedLines.PenColor = Line.EDITORIAL_COLOR; break; } } } }
private void ComplexBTN_Click(object sender, EventArgs e) { if (TreeSelectedLines.Count > 1) { InfoPanel.currentActionInfo.Text = "Объединение"; TightUper.TightUp(TreeSelectedLines); TreeListControl.TreeSource.Refresh(); } else { string message = "Выделите 2 и более линий для объединения."; string caption = "Действие невозможно."; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result; result = MessageBox.Show(message, caption, buttons); } }
public static void SelectLine(MouseEventArgs e) { foreach (Line currentLine in Form1._allLines) { if (currentLine.PointOnLineSegment(e.Location)) { if (currentLine.LineType == Types.Single) { Form1.WrapperForSelectedLines = currentLine; if (Form1.TreeSelectedLines.Contains(currentLine)) { if (currentLine == Form1.WrapperForSelectedLines) { currentLine.PenColor = Line.GENERAL_COLOR; Form1.TreeSelectedLines.Remove(currentLine); } else { currentLine.PenColor = Line.GENERAL_COLOR; Form1.TreeSelectedLines.Remove(currentLine); break; } } else { currentLine.PenColor = Line.SELECTED_COLOR; Form1.TreeSelectedLines.Add(currentLine); InfoPanel.lineLenghtInfo.Text = currentLine.Length.ToString(); InfoPanel.startPointInfo.Text = currentLine.StartPoint.ToString(); InfoPanel.endPointInfo.Text = currentLine.EndPoint.ToString(); break; } } else if (currentLine.LineType == Types.Complex) { TightUper.SelectComplexes(currentLine); break; } } } }
/// <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 }