private void UpdateFeature(FastColoredTextBox fastColoredTextBoxNewFirmware, string feature, string value)
        {
            List <int> rows = new List <int>();


            rows = fastColoredTextBoxNewFirmware.FindLines(@"^\s*\#define\s*" + feature,
                                                           RegexOptions.Singleline);
            if (rows.Count > 0)
            {
                fastColoredTextBoxNewFirmware.Navigate(rows[0]);
                fastColoredTextBoxNewFirmware.CommentSelected("//");
                fastColoredTextBoxNewFirmware.Navigate(rows[0] + 1);
                fastColoredTextBoxNewFirmware.InsertText(
                    string.Format("#define {0} {1} // Created by Marlin3DprinterTool {2} {3}\n",
                                  feature,
                                  value,
                                  DateTime.Now.ToShortDateString(),
                                  DateTime.Now.ToShortTimeString())


                    );

                fastColoredTextBoxNewFirmware.DoAutoIndent(rows[0]);
                fastColoredTextBoxNewFirmware.DoAutoIndent(rows[0] + 1);
            }
        }
Exemplo n.º 2
0
 private void Comment_ToolStripButton_Click(object sender, EventArgs e)
 {
     if (tabControlCode.TabCount > 0)
     {
         FastColoredTextBox textBox = tabControlCode.SelectedTab.Controls[0] as FastColoredTextBox;
         textBox.CommentSelected();
     }
 }
        public static void UpdateFeatureValue(string feature, FastColoredTextBox fctbCurrentFirmware, FastColoredTextBox fctbNewFirmware)
        {
            // Get the last occurance for the feature in current firmware
            int    currentrow   = MarlinMigrateHelper.GetFirmwareFeatureRow(fctbCurrentFirmware, feature);
            string currentValue = MarlinMigrateHelper.GetFirmwareFeatureValue(fctbCurrentFirmware, feature);
            string currentLine  = fctbCurrentFirmware.GetLineText(currentrow).Trim();

            // Get the last occurance for the feature in new firmware
            int    newrow   = MarlinMigrateHelper.GetFirmwareFeatureRow(fctbNewFirmware, feature);
            string newValue = MarlinMigrateHelper.GetFirmwareFeatureValue(fctbNewFirmware, feature);
            string newLine  = fctbNewFirmware.GetLineText(newrow).Trim();


            //TODO: Fix Startwith
            if (currentLine.StartsWith("//"))
            {
                if (!newLine.StartsWith("//"))
                {
                    fctbNewFirmware.Navigate(newrow);
                    fctbNewFirmware.CommentSelected("//");
                }
            }

            //TODO: Fix Startwith
            if (!currentLine.StartsWith("//"))
            {
                if (newLine.StartsWith("//"))
                {
                    fctbNewFirmware.Navigate(newrow);
                    fctbNewFirmware.RemoveLinePrefix("//");
                }
            }

            //TODO: Fix Startwith
            if (!currentValue.StartsWith("//"))
            {
                string originalLine = fctbNewFirmware.GetLineText(newrow);
                fctbNewFirmware.Navigate(newrow);
                List <int> removeRow = new List <int>();

                removeRow.Add(newrow);
                fctbNewFirmware.RemoveLines(removeRow);
                fctbNewFirmware.Navigate(newrow);
                fctbNewFirmware.InsertText(originalLine.ReplaceFirst(newValue, currentValue) + Environment.NewLine);
            }

            fctbNewFirmware.DoAutoIndent(newrow);
            fctbNewFirmware.DoAutoIndent(newrow + 1);
        }
Exemplo n.º 4
0
        private void commentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FastColoredTextBox fctb = ((FastColoredTextBox)(tabControl1.SelectedTab.Controls[0]));

            fctb.CommentSelected();
        }