コード例 #1
0
        private void EraseLibrary_OnClick(object sender, RoutedEventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

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

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

                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.");
                Forms.DialogResult dr =
                    UserInteractions.AskUserYesNo(sb.ToString(), Forms.MessageBoxDefaultButton.Button2);
                if (dr == Forms.DialogResult.Yes)
                {
                    var lib = new Database.Library();
                    lib.DeleteAllChemistry();
                    Globals.Chem4WordV3.LoadNamesFromLibrary();
                    UserInteractions.InformUser("Your library has been cleared.");
                }
            }
            catch (Exception ex)
            {
                new ReportError(Globals.Chem4WordV3.Telemetry, TopLeft, module, ex).ShowDialog();
            }
        }
コード例 #2
0
        private void EraseLibrary_OnClick(object sender, RoutedEventArgs e)
        {
            string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

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

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

                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.");
                Forms.DialogResult dr =
                    UserInteractions.AskUserYesNo(sb.ToString(), Forms.MessageBoxDefaultButton.Button2);
                if (dr == Forms.DialogResult.Yes)
                {
                    var lib = new Database.Library();
                    lib.DeleteAllChemistry();
                    Globals.Chem4WordV3.LoadNamesFromLibrary();

                    // Close the existing Library Pane
#if DEBUG
                    Debugger.Break();
#endif
                    //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();
            }
        }