Ejemplo n.º 1
0
        private void ShowFirmwareFeatures(string feature)
        {
            MarlinMigrateHelper.BookmarkChangeNeeded(feature, fctbCurrentFirmware, fctbNewFirmware);

            // Old firmware
            string oldFeatureValue = MarlinMigrateHelper.GetFirmwareFeatureValue(fctbCurrentFirmware, feature);
            string newFeatureValue = MarlinMigrateHelper.GetFirmwareFeatureValue(fctbNewFirmware, feature);



            int oldRow = MarlinMigrateHelper.GetFirmwareFeatureRow(fctbCurrentFirmware, feature);
            int newRow = MarlinMigrateHelper.GetFirmwareFeatureRow(fctbNewFirmware, feature);

            txtBxCurrentFirmwareValue.Text = oldFeatureValue;

            if (newRow == 0)
            {
                MessageBox.Show(
                    @"It looks like feature " + feature + @" is obsolite in new firmware" + Environment.NewLine,
                    @"Obsolite feature", MessageBoxButtons.OK, MessageBoxIcon.Information);
                fctbCurrentFirmware.Navigate(oldRow);
                fctbCurrentFirmware.CurrentLineColor = Color.Red;
                fctbNewFirmware.CurrentLineColor     = Color.Transparent;
            }
            else
            {
                fctbCurrentFirmware.Navigate(oldRow);
                fctbCurrentFirmware.CurrentLineColor = oldFeatureValue == newFeatureValue ? Color.GreenYellow : Color.Magenta;
                fctbNewFirmware.Navigate(newRow);
                fctbNewFirmware.CurrentLineColor = oldFeatureValue == newFeatureValue ? Color.GreenYellow : Color.Magenta;
            }
        }
Ejemplo n.º 2
0
        private void LoadFiles(string filename)
        {
            fctbCurrentFirmware.DescriptionFile = "ArduinoSyntax.xml";
            fctbCurrentFirmware.Language        = Language.Custom;
            fctbCurrentFirmware.Font            = new Font("Consolas", 9.75f);

            fctbNewFirmware.DescriptionFile = "ArduinoSyntax.xml";
            fctbNewFirmware.Language        = Language.Custom;
            fctbNewFirmware.Font            = new Font("Consolas", 9.75f);



            MarlinMigrateHelper.FixCrLfProblems(Path.Combine(_configuration.CurrentFirmware, filename));
            MarlinMigrateHelper.FixCrLfProblems(Path.Combine(_configuration.NewFirmware, filename));



            if (File.Exists(Path.Combine(_configuration.CurrentFirmware, filename)))
            {
                DelegateFctbOpenFile(fctbCurrentFirmware, Path.Combine(_configuration.CurrentFirmware, filename), Encoding.UTF8);
            }
            fctbCurrentFirmware.Tag = new FileInfo(Path.Combine(_configuration.CurrentFirmware, filename));

            if (File.Exists(Path.Combine(_configuration.NewFirmware, filename)))
            {
                DelegateFctbOpenFile(fctbNewFirmware, Path.Combine(_configuration.NewFirmware, filename), Encoding.UTF8);
            }
            fctbNewFirmware.Tag = new FileInfo(Path.Combine(_configuration.NewFirmware, filename));
        }
Ejemplo n.º 3
0
        //private string GetFirmwareFeatureValue(FastColoredTextBox fctb, string feauture )
        //{
        //    if (string.IsNullOrEmpty(feauture)) return "";

        //    string featurevalue = "";
        //    string row = "";

        //    List<int> rows = new List<int>();
        //    rows = fctb.FindLines(@"\s*\#define\s*\b" + feauture + @"\b", RegexOptions.Multiline);

        //    foreach (int index in rows)
        //    {
        //        row = fctb.GetLineText(index).Trim();

        //        featurevalue = row.Substring(row.IndexOf(feauture, StringComparison.Ordinal));
        //        featurevalue = featurevalue.Replace(feauture, "");
        //        if (featurevalue.StartsWith("\""))
        //        {
        //            featurevalue = featurevalue.Substring(0, featurevalue.IndexOf("\"", 1, StringComparison.Ordinal) + 1);
        //        }

        //        if (row.StartsWith("#define")) break;
        //    }


        //    if (featurevalue.Contains("//")) featurevalue = featurevalue.Substring(0, featurevalue.IndexOf("//", StringComparison.Ordinal)).Trim();

        //    if(string.IsNullOrEmpty(featurevalue))
        //    {
        //        if (row.StartsWith(@"//")) featurevalue = "// Deactivated feature";
        //        else featurevalue = "// Activated feature";
        //    }


        //    return featurevalue.Trim();
        //}

        //private void BookmarkChangeNeeded(string feature)
        //{
        //    // Get the last occurance for the feature in current firmware
        //    int currentrow = MarlinMigrateHelper.GetFirmwareFeatureRow(fctbCurrentFirmware, feature);
        //    string currentValue = 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 = GetFirmwareFeatureValue(fctbNewFirmware, feature);
        //    string newLine = fctbNewFirmware.GetLineText(newrow).Trim();


        //    if ((newrow == 0) | currentValue != newValue )
        //    {
        //        fctbCurrentFirmware.BookmarkLine(currentrow);
        //        return;

        //    }

        //    //if (currentLine.StartsWith("//") && !newLine.StartsWith("//"))
        //    //{
        //    //    fctbCurrentFirmware.BookmarkLine(currentrow);
        //    //    return;
        //    //}
        //    //if (!currentLine.StartsWith("//") && newLine.StartsWith("//"))
        //    //{
        //    //    fctbCurrentFirmware.BookmarkLine(currentrow);
        //    //    return;
        //    //}


        //    fctbCurrentFirmware.UnbookmarkLine(currentrow);


        //}



        private void btnPassValue_Click(object sender, EventArgs e)
        {
            MarlinMigrateHelper.UpdateFeatureValue(cmbBxFirmwareFeatures.Text, fctbCurrentFirmware, fctbNewFirmware);

            ShowFirmwareFeatures(cmbBxFirmwareFeatures.Text);
            // Move the focus to cmbBxFirmwareFeatures => Next feature
            cmbBxFirmwareFeatures.Focus();
        }
Ejemplo n.º 4
0
        private void LoadFiles()
        {
            Configuration configuration = new Configuration();

            CheckIfNewFirmwareIsChanged();

            ResizedFrame();



            fctbCurrentFirmware.DescriptionFile = "ArduinoSyntax.xml";
            fctbCurrentFirmware.Language        = Language.Custom;
            fctbCurrentFirmware.Font            = new Font("Consolas", 9.75f);

            fctbNewFirmware.DescriptionFile = "ArduinoSyntax.xml";
            fctbNewFirmware.Language        = Language.Custom;
            fctbNewFirmware.Font            = new Font("Consolas", 9.75f);



            MarlinMigrateHelper.FixCrLfProblems(Path.Combine(configuration.CurrentFirmware, ConfigurationFilename));
            MarlinMigrateHelper.FixCrLfProblems(Path.Combine(configuration.NewFirmware, ConfigurationFilename));



            if (File.Exists(Path.Combine(configuration.CurrentFirmware, ConfigurationFilename)))
            {
                fctbCurrentFirmware.OpenFile(Path.Combine(configuration.CurrentFirmware, ConfigurationFilename), Encoding.UTF8);
            }
            fctbCurrentFirmware.Tag = Path.Combine(configuration.CurrentFirmware, ConfigurationFilename);

            if (File.Exists(Path.Combine(configuration.NewFirmware, ConfigurationFilename)))
            {
                fctbNewFirmware.OpenFile(Path.Combine(configuration.NewFirmware, ConfigurationFilename), Encoding.UTF8);
            }
            fctbNewFirmware.Tag = Path.Combine(configuration.NewFirmware, ConfigurationFilename);


            HighlightInvisibleChars(fctbCurrentFirmware.Range);
            HighlightInvisibleChars(fctbNewFirmware.Range);

            cmbBxFirmwareFeatures.Items.Clear();
            foreach (string feature in MarlinMigrateHelper.FindFirmwareFeatures(fctbCurrentFirmware))
            {
                cmbBxFirmwareFeatures.Items.Add(feature);
            }
            cmbBxFirmwareFeatures.Text = cmbBxFirmwareFeatures.Items[1].ToString();



            btnUpdateExtruderInFirmware.Text = $"Update and Save Firmware ({ConfigurationFilename})";
        }
        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);
        }
Ejemplo n.º 6
0
        private void Compare()
        {
            // Load all files in current firmware

            DelegateListBoxItemsClear(lstBxFileNames);
            string[] currentFirmwareFiles = Directory.GetFiles(_configuration.CurrentFirmware, "*.h");


            for (int index = 0; index < currentFirmwareFiles.Length; index++)
            {
                if (backgroundWorkerCompare.CancellationPending)
                {
                    break;
                }


                string   firmwareFile = currentFirmwareFiles[index];
                FileInfo fileInfo     = new FileInfo(firmwareFile);

                backgroundWorkerCompare.ReportProgress(Math.Min(100, (index * 100) / currentFirmwareFiles.Length));


                DelegateText(lblCurrentWorkingOnFile, $"Working on file: {fileInfo.Name} ({progressBarWorkingOnFile.Value} % )");


                LoadFiles(fileInfo.Name);



                if (MarlinMigrateHelper.IsFilesEqual(fctbCurrentFirmware, fctbNewFirmware))
                {
                    continue;                                                                         // No differance = Next file
                }
                foreach (string feature in MarlinMigrateHelper.FindFirmwareFeatures(fctbCurrentFirmware))
                {
                    MarlinMigrateHelper.BookmarkChangeNeeded(feature, fctbCurrentFirmware, fctbNewFirmware);
                    if (fctbCurrentFirmware.Bookmarks.Count != 0)
                    {
                        break;
                    }
                }

                if (fctbCurrentFirmware.Bookmarks.Count != 0)
                {
                    DelegateListBoxAdd(lstBxFileNames, fileInfo);
                }
            }
        }
Ejemplo n.º 7
0
        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]);


                // #Update Feature in Firmware BugFix
                // Find value in rows[0]
                // replace value with the new value
                MarlinMigrateHelper.UpdateFeatureValue(feature, value, fastColoredTextBoxNewFirmware);


                fastColoredTextBoxNewFirmware.DoAutoIndent(rows[0]);
                fastColoredTextBoxNewFirmware.DoAutoIndent(rows[0] + 1);
            }
        }
        public static void UpdateFeatureValue(string feature, string newValue, FastColoredTextBox fctbNewFirmware)
        {
            // Get the last occurance for the feature in new firmware
            int    currentRow   = MarlinMigrateHelper.GetFirmwareFeatureRow(fctbNewFirmware, feature);
            string currentValue = MarlinMigrateHelper.GetFirmwareFeatureValue(fctbNewFirmware, feature);
            string correntRow   = fctbNewFirmware.GetLineText(currentRow);



            fctbNewFirmware.Navigate(currentRow);
            List <int> removeRow = new List <int>();

            removeRow.Add(currentRow);
            fctbNewFirmware.RemoveLines(removeRow);
            fctbNewFirmware.Navigate(currentRow);
            fctbNewFirmware.InsertText(correntRow.ReplaceFirst(currentValue, newValue) + Environment.NewLine);



            fctbNewFirmware.DoAutoIndent(currentRow);
            fctbNewFirmware.DoAutoIndent(currentRow + 1);
        }