private void CheckClose(Editor txtBox) { if (txtBox != null && txtBox.IsModified) { var messageBoxResult = MessageBox.Show(string.Format("Save changes for file '{0}'?", txtBox.Filename), "miRobotEditor", MessageBoxButton.YesNoCancel); if (messageBoxResult != MessageBoxResult.Cancel) { if (messageBoxResult == MessageBoxResult.Yes) { Save(txtBox); } } } }
public bool CommentLine(Editor kukaTextEditor, DocumentLine documentLine) { return CommentLine(kukaTextEditor.Document, documentLine); }
public bool CommentLines(Editor kukaTextEditor, int startLine, int endLine) { if (endLine > kukaTextEditor.Document.LineCount) { throw new ArgumentOutOfRangeException("endLine", "End line must not be lager than the line count"); } if (endLine < startLine) { throw new ArgumentException("The start line must be smaller than the end line"); } var flag = false; for (var i = startLine; i <= endLine; i++) { var documentLine = kukaTextEditor.Document.Lines[i - 1]; flag |= CommentLine(kukaTextEditor.Document, documentLine); } return flag; }
public bool UncommentLine(Editor kukaTextEditor, DocumentLine documentLine) { if (kukaTextEditor == null) { throw new ArgumentNullException("kukaTextEditor"); } if (documentLine == null) { throw new ArgumentNullException("documentLine"); } var text = kukaTextEditor.Document.GetText(documentLine); var num = text.IndexOf(commentMarker, StringComparison.Ordinal); if (num <= -1) { return false; } var num2 = 0; var text2 = text; for (var i = 0; i < text2.Length; i++) { var c = text2[i]; if (c == commentMarker[num2]) { num2++; if (num2 >= commentMarker.Length) { kukaTextEditor.Document.Remove(documentLine.Offset + num, commentMarker.Length); return true; } } else { if (!IsWhitespace(c)) { break; } } } return false; }
public bool UncommentSelection(Editor kukaTextEditor) { if (kukaTextEditor == null) { throw new ArgumentNullException("kukaTextEditor"); } bool result; using (kukaTextEditor.Document.RunUpdate()) { var flag = false; if (kukaTextEditor.SelectionLength > 0) { var lineByOffset = kukaTextEditor.Document.GetLineByOffset(kukaTextEditor.SelectionStart); var lineByOffset2 = kukaTextEditor.Document.GetLineByOffset(kukaTextEditor.SelectionStart + kukaTextEditor.SelectionLength); for (var i = lineByOffset.LineNumber - 1; i <= lineByOffset2.LineNumber - 1; i++) { var documentLine = kukaTextEditor.Document.Lines[i]; flag |= UncommentLine(kukaTextEditor, documentLine); } result = flag; } else { if (CommentCarretLineIfNoSelection) { var lineByOffset3 = kukaTextEditor.Document.GetLineByOffset(kukaTextEditor.SelectionStart); result = UncommentLine(kukaTextEditor, lineByOffset3); } else { result = false; } } } return result; }
public bool CommentLines(Editor kukaTextEditor, IEnumerable<DocumentLine> documentLines) { if (kukaTextEditor == null) { throw new ArgumentNullException("kukaTextEditor"); } var flag = false; foreach (var current in documentLines) { flag |= CommentLine(kukaTextEditor.Document, current); } return flag; }
public static Editor ReversePath(Editor editor) { var collection = new Collection<Collection<string>>(); for (var i = 0; i <= editor.Document.Lines.Count - 1; i++) { if ( editor.Document.Lines[i].ToString() .ToUpperInvariant() .IndexOf(";FOLD LIN", StringComparison.OrdinalIgnoreCase) > -1 | editor.Document.Lines[i].ToString() .ToUpperInvariant() .IndexOf(";FOLD PTP", StringComparison.OrdinalIgnoreCase) > -1) { collection.Add(GetPositionFromFile(i, editor)); } } editor.Text = string.Empty; for (var j = collection.Count - 1; j >= 0; j--) { for (var k = 0; k < collection[j].Count; k++) { var collection2 = collection[j]; editor.AppendText(collection2[k] + "\r\n"); } } return editor; }
// ReSharper disable once UnusedParameter.Local private string ShiftProgram(Editor doc, ShiftViewModel shift) { var stopwatch = new Stopwatch(); stopwatch.Start(); var num = Convert.ToDouble(ShiftViewModel.Instance.DiffValues.X); var num2 = Convert.ToDouble(ShiftViewModel.Instance.DiffValues.Y); var num3 = Convert.ToDouble(ShiftViewModel.Instance.DiffValues.Z); var regex = new Regex(ShiftRegex, RegexOptions.IgnoreCase); var matchCollection = regex.Matches(doc.Text); var count = matchCollection.Count; var num5 = (double)((count > 0) ? (100 / count) : count); foreach (Match match in regex.Matches(doc.Text)) { // ReSharper disable UnusedVariable var num6 = Convert.ToDouble(match.Groups[3].Value) + num; var num7 = Convert.ToDouble(match.Groups[4].Value) + num2; var num8 = Convert.ToDouble(match.Groups[5].Value) + num3; // ReSharper restore UnusedVariable switch (RobotType) { case Typlanguage.KUKA: doc.ReplaceAll(); break; case Typlanguage.ABB: doc.ReplaceAll(); break; } } Thread.Sleep(500); stopwatch.Stop(); Console.WriteLine("{0}ms to parse shift", stopwatch.ElapsedMilliseconds); return doc.Text; }
internal void Save(Editor txtBox) { if (txtBox.Filename == null) { txtBox.SaveAs(); } else { txtBox.Save(FileName); } IsDirty = false; }
// ReSharper restore ExplicitCallerInfoArgument public GotoViewModel(Editor editor) { Editor = editor; }