Beispiel #1
0
        private void OnClearLibraryClick(object sender, EventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

            Globals.Chem4WordV3.Telemetry.Write(module, "Action", "Triggered");

            try
            {
                if (Globals.Chem4WordV3.LibraryNames == null)
                {
                    Globals.Chem4WordV3.LoadLibrary();
                }

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("This will delete all the structures from the Library");
                sb.AppendLine("It will not delete any tags.");
                sb.AppendLine("");
                sb.AppendLine("Do you want to proceed?");
                sb.AppendLine("This cannot be undone.");
                DialogResult dr = AskUserYesNo(sb.ToString(), MessageBoxDefaultButton.Button2);
                if (dr == DialogResult.Yes)
                {
                    LibraryModel.DeleteAllChemistry();
                    Globals.Chem4WordV3.LibraryNames = LibraryModel.GetLibraryNames();

                    var app = Globals.Chem4WordV3.Application;
                    foreach (CustomTaskPane taskPane in Globals.Chem4WordV3.CustomTaskPanes)
                    {
                        if (app.ActiveWindow == taskPane.Window && taskPane.Title == Constants.LibraryTaskPaneTitle)
                        {
                            var custTaskPane = taskPane;
                            (custTaskPane.Control as LibraryHost)?.Refresh();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                new ReportError(Globals.Chem4WordV3.Telemetry, TopLeft, module, ex).ShowDialog();
            }
        }