Exemple #1
0
        private ShouldCancel PersistUnsavedChanges(bool PromptFirst)
        {
            var UnsavedResults = PropertyChain_.Where(x => x.Key != null && x.Value.GetHasUnsavedChanges());

            if (UnsavedResults.Count() == 0)
            {
                return(ShouldCancel.No);
            }

            bool ShouldSave = false;

            if (PromptFirst)
            {
                var Response = MessageBox.Show(
                    "You have unsaved changes!  Do you want to save before loading a new file?",
                    "clang-tidy",
                    MessageBoxButtons.YesNoCancel);

                ShouldSave = (Response == DialogResult.Yes);
                if (Response == DialogResult.Cancel)
                {
                    return(ShouldCancel.Yes);
                }
            }
            else
            {
                ShouldSave = true;
            }

            if (ShouldSave)
            {
                foreach (var Result in UnsavedResults)
                {
                    ClangTidyConfigParser.SerializeClangTidyFile(Result.Value, Result.Key);
                    Result.Value.SetHasUnsavedChanges(false);
                }
            }
            return(ShouldCancel.No);
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            ShouldCancel Cancel = PersistUnsavedChanges(true);

            if (Cancel == ShouldCancel.Yes)
            {
                return;
            }

            using (OpenFileDialog D = new OpenFileDialog())
            {
                D.Filter          = "Clang Tidy files|.clang-tidy";
                D.CheckPathExists = true;
                D.CheckFileExists = true;

                if (D.ShowDialog() == DialogResult.OK)
                {
                    PropertyChain_.Clear();
                    PropertyChain_ = ClangTidyConfigParser.ParseConfigurationChain(D.FileName);
                    textBox1.Text  = D.FileName;
                    reloadPropertyChain();
                }
            }
        }