public void UnprotectWorkbook(IRibbonControl ribbonControl)
        {
            var wb   = App.ActiveWorkbook;
            var path = wb.FullName;

            logger.Debug($"UnprotectWorkbook {path}");

            var extension = path.Split('.').LastOrDefault();

            if (extension != "xlsx" && extension != "xlsm")
            {
                dialogService.ShowError(UIStrings.CannotUnlockPleaseSaveAsXml);
                return;
            }

            if (!dialogService.Ask(UIStrings.UnsavedChangesWillBeLostPrompt, UIStrings.Warning))
            {
                return;
            }

            wb.Close(false);


            var wbUnprotector = GetService <IWbUnprotector>();

            wbUnprotector.UnprotectWorkbookWithAllWorksheets(path);

            App.Workbooks.Open(path);
        }
Example #2
0
        private void RefreshGridDataContext()
        {
            if (!Root.RunCommitEditing())
            {
                return;
            }

            if (Root.MainItems.IsDirty)
            {
                if (dialogService.Ask("Имеются изменения!\nОбновить?") == InternalDialogResult.OK)
                {
                    InitializeDataContext();
                    RaiseCanExecuteCommand();
                    DialogResult = InternalDialogResult.Refresh;
                }
            }
        }
        private bool AskSaveCancel()
        {
            var result = _dialogService.Ask(Ressources.AskSave);

            if (result == null)
            {
                return(true);
            }

            if (result.Value)
            {
                Save(null);
            }

            return(false);
        }