Esempio n. 1
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            if (Directory.Exists(directoryPath))
            {
                colorizer = ColorizerSerializer.Deserialize(directoryPath + @"\default.xml");
                formatter = WordFormatterSerializer.Deserialize(directoryPath + @"\basicformat.xml");
                formatter.Initialize(colorizer, this.Application);
            }
            else // if it's the first starting of this version of the Add-In with this user
            {
                Directory.CreateDirectory(directoryPath);

                colorizer = new Colorizer();
                colorizer.LoadPredefinedLanguages();
                colorizer.Initialize();

                formatter = new WordFormatter();
                formatter.Initialize(colorizer, this.Application);
                formatter.SetToDefault();
            }

            indentFixer = new WordIndentFixer(this.Application);
            codecleaner = new CodeCleaner(this.Application);

            Globals.Ribbons.WordCodeEditorToolsRibbon.InitializeAddIn(this);
        }
Esempio n. 2
0
        // Change whole language database

        private void button_LoadFile_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Do you want to save the current language database, before you load the new one?", "Syntax Highlighter", MessageBoxButtons.YesNoCancel);

            if (result == DialogResult.Yes)
            {
                button_SaveFile_Click(sender, EventArgs.Empty);
            }
            else if (result != DialogResult.Cancel)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.InitialDirectory = @"c:\";
                openFileDialog.Filter           = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    colorizer = ColorizerSerializer.Deserialize(openFileDialog.FileName);
                    this.InitializeLanguageList();
                    languageListChanged = true;
                    colorizerReassigned = true;
                }
            }
        }