Exemple #1
0
        public void MarkTextAsError(int LineIndex, int CharPosStart, int CharLength)
        {
            if ((LineIndex < 0) ||
                (LineIndex >= SourceControl.LinesCount))
            {
                Debug.Log("MarkTextAsError lineindex out of bounds!");
                return;
            }
            // several warnings/errors in one line, mark the full line
            if ((LineIndex < m_LineInfos.Count) &&
                (m_LineInfos[LineIndex].HasCollapsedContent))
            {
                string lineText = SourceControl[LineIndex].Text;

                // find first non white space
                CharPosStart = 0;
                while ((CharPosStart < lineText.Length) &&
                       ((lineText[CharPosStart] == ' ') ||
                        (lineText[CharPosStart] == '\t')))
                {
                    ++CharPosStart;
                }
                CharLength = lineText.TrimEnd().Length - CharPosStart;
            }

            int startPos = SourceControl.VirtualPositionToPositionInLine(LineIndex, CharPosStart);

            var range = new FastColoredTextBoxNS.Range(SourceControl, new FastColoredTextBoxNS.Place(startPos, LineIndex), new FastColoredTextBoxNS.Place(startPos + CharLength, LineIndex));

            range.SetStyle(FastColoredTextBoxNS.StyleIndex.Style10);
        }
        public void MarkTextAsError(int LineIndex, int CharPosStart, int CharLength)
        {
            if ((LineIndex < 0) ||
                (LineIndex >= SourceControl.LinesCount))
            {
                Debug.Log("MarkTextAsError lineindex out of bounds!");
                return;
            }
            // several warnings/errors in one line, mark the full line
            if ((LineIndex < m_LineInfos.Count) &&
                (m_LineInfos[LineIndex].HasCollapsedContent))
            {
                string lineText = SourceControl[LineIndex].Text;

                // find first non white space
                CharPosStart = 0;
                while ((CharPosStart < lineText.Length) &&
                       ((lineText[CharPosStart] == ' ') ||
                        (lineText[CharPosStart] == '\t')))
                {
                    ++CharPosStart;
                }
                CharLength = lineText.TrimEnd().Length - CharPosStart;
            }

            int startPos = CharPosStart;

            if (SourceControl.AllowTabs)
            {
                // adjust offset in case of tabs (butt ugly hackaround)
                string origText = SourceControl[LineIndex].Text;

                if (CharPosStart < origText.Length)
                {
                    origText = SourceControl[LineIndex].Text.Substring(0, CharPosStart);
                }
                origText = SourceControl.ReTabifyLine(origText, SourceControl.TabLength);

                startPos = origText.Length;

                if ((startPos >= origText.Length) ||
                    (startPos + CharLength > origText.Length))
                {
                    startPos   = 0;
                    CharLength = origText.Length;
                }

                //startPos = rng.AdjustXPosForTabs( LineIndex, startPos );
            }

            var range = new FastColoredTextBoxNS.Range(SourceControl, new FastColoredTextBoxNS.Place(startPos, LineIndex), new FastColoredTextBoxNS.Place(startPos + CharLength, LineIndex));

            range.SetStyle(FastColoredTextBoxNS.StyleIndex.Style10);
        }
      private void simulationTimer_Tick(object sender, EventArgs e)
      {
          simuLine = VisuGCode.Simulation.Next(ref codeInfo);

          if ((simuLine >= 0) && (simuLine < fCTBCode.Lines.Count()))
          {
              lbInfo.Text = string.Format("Line {0}: {1}", (simuLine + 1), fCTBCode.Lines[simuLine]);
          }
          else
          {
              lbInfo.Text = string.Format("Line {0}", (simuLine + 1));
          }

          if (simuLine >= 0)
          {
              fCTBCode.Selection = fCTBCode.GetLine(simuLine);
              fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
              fCTBCode.BookmarkLine(simuLine);
              fCTBCode.DoCaretVisible();
              fCTBCodeClickedLineLast = simuLine;
              pictureBox1.Invalidate();   // avoid too much events

              label_wx.Text = string.Format("{0:0.000}", codeInfo.X);
              label_wy.Text = string.Format("{0:0.000}", codeInfo.Y);
              label_wz.Text = string.Format("{0:0.000}", codeInfo.Z);
              label_wa.Text = string.Format("{0:0.0}", codeInfo.A * 180 / Math.PI);
          }
          else
          {
              simuStop();
              simuLine = 0;     // Math.Abs(simuLine);
              VisuGCode.Simulation.Reset();
              FastColoredTextBoxNS.Range mySelection = fCTBCode.Range;
              FastColoredTextBoxNS.Place selStart;
              selStart.iLine     = 0;
              selStart.iChar     = 0;
              mySelection.Start  = selStart;
              mySelection.End    = selStart;
              fCTBCode.Selection = mySelection;

              fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
              fCTBCode.BookmarkLine(simuLine);
              fCTBCode.DoCaretVisible();
              fCTBCodeClickedLineLast = simuLine;
              VisuGCode.Simulation.pathSimulation.Reset();
              pictureBox1.Invalidate();   // avoid too much events
              lbInfo.Text = string.Format("Simulation finished");
              return;
          }
          pbFile.Value         = simuLine;
          lblFileProgress.Text = string.Format("{0} {1:0.0}%", Localization.getString("mainProgress"), (100 * simuLine / (fCTBCode.LinesCount - 2)));
          pictureBox1.Invalidate();
      }
Exemple #4
0
        /// <summary>
        /// Duplicate the line that the caret is currently on.
        /// </summary>
        private void TsBtn_Edit_DuplicateLine_Click(object sender, EventArgs e)
        {
            if (!Fctb_Main.Selection.IsEmpty)             // don't bother duplicating a multiline selection, that's what copy/paste is for
            {
                return;
            }

            FastColoredTextBoxNS.Range origSel = Fctb_Main.Selection;
            string line = Fctb_Main.GetLineText(Fctb_Main.Selection.ToLine);

            Fctb_Main.Selection.Start = Fctb_Main.GetLine(Fctb_Main.Selection.ToLine).End;
            Fctb_Main.InsertText("\r\n");
            Fctb_Main.InsertText(line);
            Fctb_Main.Selection = origSel;
        }
 private void HighlightVisibleRange(int skipRows)
 {
     try
     {
         //expand visible range (+- margin)
         var startLine = Math.Max(skipRows, textBox.VisibleRange.Start.iLine - 20);
         var endLine   = Math.Min(textBox.LinesCount - 1, textBox.VisibleRange.End.iLine + 100);
         if (startLine < endLine)
         {
             var range = new FastColoredTextBoxNS.Range(textBox, 0, startLine, 0, endLine);
             m_HighLighter?.Highlight(range);
             m_HighLighter?.SkipRows(skipRows);
         }
     }
     catch (Exception ex)
     {
         Logger.Warning(ex, "HighlightVisibleRange");
     }
 }
Exemple #6
0
 public static void Select(FastColoredTextBoxNS.Range range, System.Drawing.Color c)
 {
     try
     {
         if (enabled)
         {
             debugger.fastColoredTextBox1.Selection = range;
             debugger.fastColoredTextBox1.DoSelectionVisible();
             debugger.fastColoredTextBox1.SelectionColor = c;
             if (delay)
             {
                 System.Threading.Thread.Sleep(500);
                 //debugger.fastColoredTextBox1.Selection = new FastColoredTextBoxNS.Range(debugger.fastColoredTextBox1, 0, 0, 0, 0);
                 //debugger.fastColoredTextBox1.SelectionColor = System.Drawing.Color.Yellow;
             }
         }
     }
     catch
     {
         Program.WriteLine("ERROR: couldn't update sel in debugger", ConsoleColor.Red);
     }
 }
        public void MarkTextAsError(int LineIndex, int CharPosStart, int CharLength)
        {
            if ((LineIndex < 0) ||
                (LineIndex >= SourceControl.LinesCount))
            {
                Debug.Log("MarkTextAsError lineindex out of bounds!");
                return;
            }
            int startPos = CharPosStart;

            if (SourceControl.AllowTabs)
            {
                // adjust offset in case of tabs (butt ugly hackaround)
                string origText = SourceControl[LineIndex].Text;

                if (CharPosStart < origText.Length)
                {
                    origText = SourceControl[LineIndex].Text.Substring(0, CharPosStart);
                }
                origText = SourceControl.ReTabifyLine(origText, SourceControl.TabLength);

                startPos = origText.Length;

                if ((startPos >= origText.Length) ||
                    (startPos + CharLength > origText.Length))
                {
                    startPos   = 0;
                    CharLength = origText.Length;
                }

                //startPos = rng.AdjustXPosForTabs( LineIndex, startPos );
            }

            var range = new FastColoredTextBoxNS.Range(SourceControl, new FastColoredTextBoxNS.Place(startPos, LineIndex), new FastColoredTextBoxNS.Place(startPos + CharLength, LineIndex));

            range.SetStyle(FastColoredTextBoxNS.StyleIndex.Style10);
        }
Exemple #8
0
      private void simulationTimer_Tick(object sender, EventArgs e)
      {
          simuLine = VisuGCode.Simulation.Next();
          if (simuLine >= 0)
          {
              fCTBCode.Selection = fCTBCode.GetLine(simuLine);
              fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
              fCTBCode.BookmarkLine(simuLine);
              fCTBCode.DoCaretVisible();
              fCTBCodeClickedLineLast = simuLine;
              pictureBox1.Invalidate();   // avoid too much events
          }
          else
          {
              simuStop();
              simuLine = 0;     // Math.Abs(simuLine);
              VisuGCode.Simulation.Reset();
              FastColoredTextBoxNS.Range mySelection = fCTBCode.Range;
              FastColoredTextBoxNS.Place selStart;
              selStart.iLine     = 0;
              selStart.iChar     = 0;
              mySelection.Start  = selStart;
              mySelection.End    = selStart;
              fCTBCode.Selection = mySelection;

              fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
              fCTBCode.BookmarkLine(simuLine);
              fCTBCode.DoCaretVisible();
              fCTBCodeClickedLineLast = simuLine;
              pictureBox1.Invalidate();   // avoid too much events
              return;
          }
          pbFile.Value         = simuLine;
          lblFileProgress.Text = string.Format("{0} {1:0.0}%", Localization.getString("mainProgress"), (100 * simuLine / (fCTBCode.LinesCount - 2)));
          pictureBox1.Invalidate();
      }
Exemple #9
0
        public override void Draw(System.Drawing.Graphics gr, System.Drawing.Point position, FastColoredTextBoxNS.Range range)
        {
            base.Draw(gr, position, range);
            const int size = 2;
            var       end  = Math.Max(((range.End.iChar - range.Start.iChar) * range.tb.CharWidth) / size, size);

            position.Offset(0, range.tb.CharHeight - size);

            for (int i = 0; i < end; i++)
            {
                var start = position;
                position.Offset(size, size * (int)Math.Pow(-1, i));
                gr.DrawLine(_pen, start, position);
            }
        }