/// ------------------------------------------------------------------------------------
 /// <summary>
 /// Displays a message box with the specified text, caption, buttons, icon, default
 /// button, options, and Help button, using the specified Help file, HelpNavigator, and
 /// Help topic.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public static DialogResult Show(IWin32Window owner, string text, string caption,
                                 MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton,
                                 MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param)
 {
     return(s_MsgBox.Show(owner, text, caption, buttons, icon, defaultButton,
                          options, helpFilePath, navigator, param));
 }
        public void Refactor()
        {
            QualifiedSelection?qualifiedSelection;

            using (var activePane = _vbe.ActiveCodePane)
            {
                if (activePane == null || activePane.IsWrappingNullReference)
                {
                    _messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage,
                                     RubberduckUI.ImplementInterface_Caption,
                                     System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                    return;
                }

                qualifiedSelection = activePane.GetQualifiedSelection();
                if (!qualifiedSelection.HasValue)
                {
                    _messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage,
                                     RubberduckUI.ImplementInterface_Caption,
                                     System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                    return;
                }
            }

            Refactor(qualifiedSelection.Value);
        }
Esempio n. 3
0
        private bool IsValidParamOrder()
        {
            var indexOfFirstOptionalParam = _model.Parameters.FindIndex(param => param.IsOptional);

            if (indexOfFirstOptionalParam >= 0)
            {
                for (var index = indexOfFirstOptionalParam + 1; index < _model.Parameters.Count; index++)
                {
                    if (!_model.Parameters.ElementAt(index).IsOptional)
                    {
                        _messageBox.Show(RubberduckUI.ReorderPresenter_OptionalParametersMustBeLastError, RubberduckUI.ReorderParamsDialog_TitleText, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }
                }
            }

            var indexOfParamArray = _model.Parameters.FindIndex(param => param.IsParamArray);

            if (indexOfParamArray >= 0 && indexOfParamArray != _model.Parameters.Count - 1)
            {
                _messageBox.Show(RubberduckUI.ReorderPresenter_ParamArrayError, RubberduckUI.ReorderParamsDialog_TitleText, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
        private void RequestHandler_QuitUrlVisited(string url)
        {
            if (settings.ConfirmQuitUrl)
            {
                var message   = text.Get(TextKey.MessageBox_BrowserQuitUrlConfirmation);
                var title     = text.Get(TextKey.MessageBox_BrowserQuitUrlConfirmationTitle);
                var result    = messageBox.Show(message, title, MessageBoxAction.YesNo, SebMessageBox.MessageBoxIcon.Question, this);
                var terminate = result == MessageBoxResult.Yes;

                if (terminate)
                {
                    logger.Info($"User confirmed termination via quit URL '{url}', forwarding request...");
                    Terminate();
                }
                else
                {
                    logger.Info($"User aborted termination via quit URL '{url}'.");
                }
            }
            else
            {
                logger.Info($"Automatically requesting termination due to quit URL '{url}'...");
                Terminate();
            }
        }
        private void Browser_ConfigurationDownloadRequested(string fileName, DownloadEventArgs args)
        {
            if (Settings.ConfigurationMode == ConfigurationMode.ConfigureClient)
            {
                logger.Info($"Received download request for configuration file '{fileName}'. Asking user to confirm the reconfiguration...");

                var message     = TextKey.MessageBox_ReconfigurationQuestion;
                var title       = TextKey.MessageBox_ReconfigurationQuestionTitle;
                var result      = messageBox.Show(message, title, MessageBoxAction.YesNo, MessageBoxIcon.Question, args.BrowserWindow);
                var reconfigure = result == MessageBoxResult.Yes;

                logger.Info($"The user chose to {(reconfigure ? "start" : "abort")} the reconfiguration.");

                if (reconfigure)
                {
                    args.AllowDownload = true;
                    args.Callback      = Browser_ConfigurationDownloadFinished;
                    args.DownloadPath  = Path.Combine(appConfig.DownloadDirectory, fileName);
                }
            }
            else
            {
                logger.Info($"Denied download request for configuration file '{fileName}' due to '{Settings.ConfigurationMode}' mode.");
                messageBox.Show(TextKey.MessageBox_ReconfigurationDenied, TextKey.MessageBox_ReconfigurationDeniedTitle, parent: args.BrowserWindow);
            }
        }
Esempio n. 6
0
        private void DownloadHandler_ConfigurationDownloadRequested(string fileName, DownloadEventArgs args)
        {
            if (settings.AllowConfigurationDownloads)
            {
                logger.Debug($"Forwarding download request for configuration file '{fileName}'.");
                ConfigurationDownloadRequested?.Invoke(fileName, args);

                if (args.AllowDownload)
                {
                    logger.Debug($"Download request for configuration file '{fileName}' was granted. Asking user to confirm the reconfiguration...");

                    var message = TextKey.MessageBox_ReconfigurationQuestion;
                    var title   = TextKey.MessageBox_ReconfigurationQuestionTitle;
                    var result  = messageBox.Show(message, title, MessageBoxAction.YesNo, MessageBoxIcon.Question, window);

                    args.AllowDownload = result == MessageBoxResult.Yes;
                    logger.Info($"The user chose to {(args.AllowDownload ? "start" : "abort")} the reconfiguration.");
                }
                else
                {
                    logger.Debug($"Download request for configuration file '{fileName}' was denied.");
                    messageBox.Show(TextKey.MessageBox_ReconfigurationDenied, TextKey.MessageBox_ReconfigurationDeniedTitle, parent: window);
                }
            }
            else
            {
                logger.Debug($"Discarded download request for configuration file '{fileName}'.");
            }
        }
Esempio n. 7
0
        private bool VerifyCompileOnDemand()
        {
            if (_vbeSettings.CompileOnDemand)
            {
                return(DialogResult.Yes == _messageBox.Show(RubberduckUI.Command_Reparse_CompileOnDemandEnabled,
                                                            RubberduckUI.Command_Reparse_CompileOnDemandEnabled_Caption, MessageBoxButtons.YesNo,
                                                            MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2));
            }

            return(true);
        }
Esempio n. 8
0
        public void Refactor()
        {
            var selection = _vbe.ActiveCodePane.GetQualifiedSelection();

            if (!selection.HasValue)
            {
                _messageBox.Show(RubberduckUI.PromoteVariable_InvalidSelection, RubberduckUI.IntroduceField_Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Refactor(selection.Value);
        }
Esempio n. 9
0
        public void Refactor()
        {
            var selection = _editor.GetSelection();

            if (!selection.HasValue)
            {
                _messageBox.Show(RubberduckUI.PromoteVariable_InvalidSelection, RubberduckUI.IntroduceParameter_Caption,
                                 MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Refactor(selection.Value);
        }
Esempio n. 10
0
        public void Refactor()
        {
            var selection = _editor.GetSelection();

            if (!selection.HasValue)
            {
                _messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage, RubberduckUI.ImplementInterface_Caption,
                                 System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                return;
            }

            Refactor(selection.Value);
        }
        private void Browser_ConfigurationDownloadFinished(bool success, string filePath = null)
        {
            if (success)
            {
                var communication = runtime.RequestReconfiguration(filePath);

                if (communication.Success)
                {
                    logger.Info($"Sent reconfiguration request for '{filePath}' to the runtime.");

                    splashScreen = uiFactory.CreateSplashScreen(appConfig);
                    splashScreen.SetIndeterminate();
                    splashScreen.UpdateStatus(TextKey.OperationStatus_InitializeSession, true);
                    splashScreen.Show();
                }
                else
                {
                    logger.Error($"Failed to communicate reconfiguration request for '{filePath}'!");
                    messageBox.Show(TextKey.MessageBox_ReconfigurationError, TextKey.MessageBox_ReconfigurationErrorTitle, icon: MessageBoxIcon.Error);
                }
            }
            else
            {
                logger.Error($"Failed to download configuration file '{filePath}'!");
                messageBox.Show(TextKey.MessageBox_ConfigurationDownloadError, TextKey.MessageBox_ConfigurationDownloadErrorTitle, icon: MessageBoxIcon.Error);
            }
        }
        public void Refactor()
        {
            var qualifiedSelection = _editor.GetSelection();

            if (qualifiedSelection != null)
            {
                Refactor(_declarations.FindVariable(qualifiedSelection.Value));
            }
            else
            {
                _messageBox.Show(RubberduckUI.MoveCloserToUsage_InvalidSelection, RubberduckUI.MoveCloserToUsage_Caption, MessageBoxButtons.OK,
                                 MessageBoxIcon.Exclamation);
            }
        }
        private void Rename()
        {
            var declaration = FindDeclarationForIdentifier();

            if (declaration != null)
            {
                var message = string.Format(RubberduckUI.RenameDialog_ConflictingNames, _model.NewName, declaration.IdentifierName);
                var rename  = _messageBox.Show(message, RubberduckUI.RenameDialog_Caption,
                                               MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                if (rename == DialogResult.No)
                {
                    return;
                }
            }

            // must rename usages first; if target is a module or a project,
            // then renaming the declaration first would invalidate the parse results.

            if (_model.Target.DeclarationType.HasFlag(DeclarationType.Property))
            {
                // properties can have more than 1 member.
                var members = _model.Declarations.Named(_model.Target.IdentifierName)
                              .Where(item => item.ProjectId == _model.Target.ProjectId &&
                                     item.ComponentName == _model.Target.ComponentName &&
                                     item.DeclarationType.HasFlag(DeclarationType.Property));
                foreach (var member in members)
                {
                    RenameUsages(member);
                }
            }
            else
            {
                RenameUsages(_model.Target);
            }

            if (ModuleDeclarationTypes.Contains(_model.Target.DeclarationType))
            {
                RenameModule();
            }
            else if (_model.Target.DeclarationType == DeclarationType.Project)
            {
                RenameProject();
            }
            else
            {
                RenameDeclaration(_model.Target, _model.NewName);
            }
        }
Esempio n. 14
0
    async void save_Click(object sender, EventArgs e)
    {
        var newSettings = new Settings
        {
            RunAtStartup     = startupCheckBox.Checked,
            AcceptAllHotKey  = acceptAllHotKey.HotKey,
            AcceptOpenHotKey = acceptOpenHotKey.HotKey
        };

        var errors = (await trySave(newSettings)).ToList();

        if (!errors.Any())
        {
            DialogResult = DialogResult.OK;
            return;
        }

        var builder = new StringBuilder();

        foreach (var error in errors)
        {
            builder.AppendLine($" * {error}");
        }

        messageBox.Show(builder.ToString(), "Errors", MessageBoxIcon.Error, MessageBoxButtons.OK);
    }
Esempio n. 15
0
 public void CreateDirectories()
 {
     MessageBox.Show("Creating URDF Package \"" +
                     PackageName + "\" at:\n" + WindowsPackageDirectory);
     if (!Directory.Exists(WindowsPackageDirectory))
     {
         Directory.CreateDirectory(WindowsPackageDirectory);
     }
     if (!Directory.Exists(WindowsMeshesDirectory))
     {
         Directory.CreateDirectory(WindowsMeshesDirectory);
     }
     if (!Directory.Exists(WindowsRobotsDirectory))
     {
         Directory.CreateDirectory(WindowsRobotsDirectory);
     }
     if (!Directory.Exists(WindowsTexturesDirectory))
     {
         Directory.CreateDirectory(WindowsTexturesDirectory);
     }
     if (!Directory.Exists(WindowsLaunchDirectory))
     {
         Directory.CreateDirectory(WindowsLaunchDirectory);
     }
     if (!Directory.Exists(WindowsConfigDirectory))
     {
         Directory.CreateDirectory(WindowsConfigDirectory);
     }
 }
        public void HandleError(string operation, Exception ex)
        {
            string message = string.Format("Could not {0} because {1}", operation, ex.Message);

            _logger.Error(ex, message);
            _messageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
        }
Esempio n. 17
0
        private void ReloadRequested()
        {
            if (WindowSettings.AllowReloading && WindowSettings.ShowReloadWarning)
            {
                var result = messageBox.Show(TextKey.MessageBox_ReloadConfirmation, TextKey.MessageBox_ReloadConfirmationTitle, MessageBoxAction.YesNo, MessageBoxIcon.Question, window);

                if (result == MessageBoxResult.Yes)
                {
                    logger.Debug("The user confirmed reloading the current page...");
                    control.Reload();
                }
                else
                {
                    logger.Debug("The user aborted reloading the current page.");
                }
            }
            else if (WindowSettings.AllowReloading)
            {
                logger.Debug("Reloading current page...");
                control.Reload();
            }
            else
            {
                logger.Debug("Blocked reload attempt, as the user is not allowed to reload web pages.");
            }
        }
Esempio n. 18
0
    public static void LaunchForException(string message, Exception exception)
    {
        if (recorded.Contains(message))
        {
            return;
        }
        recorded.Add(message);

        var result = messageBox?.Show(
            $@"An error occurred: {message}

Logged to: {Logging.Directory}

{exception.GetType().Name}: {exception.Message}

Open an issue on GitHub?",
            "DiffEngineTray Error",
            MessageBoxIcon.Error);

        if (result != true)
        {
            return;
        }

        var extraBody = WebUtility.UrlEncode($@"
 * Action: {message}
 * Exception:
```
{exception}
```");
        var url       = $"https://github.com/VerifyTests/DiffEngine/issues/new?title={message}&body={defaultBody}{extraBody}";

        LinkLauncher.LaunchUrl(url);
    }
Esempio n. 19
0
        protected override void OnExecute(object parameter)
        {
            var panel = _presenter.UserControl as SourceControlPanel;

            Debug.Assert(panel != null);

            var panelViewModel = panel.ViewModel;

            if (panelViewModel == null)
            {
                return;
            }

            panelViewModel.SetTab(SourceControlTab.Changes);
            var viewModel = panelViewModel.SelectedItem.ViewModel as ChangesPanelViewModel;

            if (viewModel == null)
            {
                return;
            }

            var fileName = GetFileName((ICodeExplorerDeclarationViewModel)parameter);
            var result   = _messageBox.Show(string.Format(RubberduckUI.SourceControl_UndoPrompt, fileName),
                                            RubberduckUI.SourceControl_UndoTitle, System.Windows.Forms.MessageBoxButtons.OKCancel,
                                            System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2);

            if (result != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            viewModel.UndoChangesToolbarButtonCommand.Execute(new FileStatusEntry(fileName, FileStatus.Modified));
            _presenter.Show();
        }
Esempio n. 20
0
        public async System.Threading.Tasks.Task OpenFileAsync(string assemblyName, string qualifiedClassName, int file, int line)
        {
            // Note : There may be more than one file; e.g. in the case of partial classes
            //remove CoverageReport
            var sourceFiles = coberturaUtil.GetSourceFiles(assemblyName, qualifiedClassName, file);

            if (!sourceFiles.Any())
            {
                var message = $"Source File(s) Not Found : [{ assemblyName }]{ qualifiedClassName }";
                logger.Log(message);
                messageBox.Show(message);
                return;
            }

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var Dte = (DTE)serviceProvider.GetService(typeof(DTE));

            Assumes.Present(Dte);
            Dte.MainWindow.Activate();

            foreach (var sourceFile in sourceFiles)
            {
                Dte.ItemOperations.OpenFile(sourceFile, Constants.vsViewKindCode);

                if (line != 0)
                {
                    ((TextSelection)Dte.ActiveDocument.Selection).GotoLine(line, false);
                }
            }
        }
        public ReorderParametersModel Show()
        {
            if (_model.TargetDeclaration == null)
            {
                return(null);
            }

            if (_model.Parameters.Count < 2)
            {
                var message = string.Format(RubberduckUI.ReorderPresenter_LessThanTwoParametersError, _model.TargetDeclaration.IdentifierName);
                _messageBox.Show(message, RubberduckUI.ReorderParamsDialog_TitleText, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }

            _view.Parameters = _model.Parameters;
            _view.InitializeParameterGrid();

            if (_view.ShowDialog() != DialogResult.OK)
            {
                return(null);
            }

            _model.Parameters = _view.Parameters;
            return(_model);
        }
        public ReorderParametersModel Show()
        {
            if (_model.TargetDeclaration == null)
            {
                return(null);
            }

            if (_model.Parameters.Count < 2)
            {
                var message = string.Format(RubberduckUI.ReorderPresenter_LessThanTwoParametersError, _model.TargetDeclaration.IdentifierName);
                _messageBox.Show(message, RubberduckUI.ReorderParamsDialog_TitleText, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }

            _view.ViewModel.Parameters = new ObservableCollection <Parameter>(_model.Parameters);

            _view.ShowDialog();
            if (_view.DialogResult != DialogResult.OK)
            {
                return(null);
            }

            _model.Parameters = _view.ViewModel.Parameters.ToList();
            return(_model);
        }
        public RemoveParametersModel Show()
        {
            if (_model.TargetDeclaration == null)
            {
                return(null);
            }

            if (_model.Parameters.Count == 0)
            {
                var message = string.Format(RubberduckUI.RemovePresenter_NoParametersError, _model.TargetDeclaration.IdentifierName);
                _messageBox.Show(message, RubberduckUI.RemoveParamsDialog_TitleText, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }

            if (_model.Parameters.Count == 1)
            {
                _model.Parameters[0].IsRemoved = true;
                return(_model);
            }

            _view.ViewModel.Parameters = _model.Parameters;
            _view.ShowDialog();
            if (_view.DialogResult != DialogResult.OK)
            {
                return(null);
            }

            _model.Parameters = _view.ViewModel.Parameters;
            return(_model);
        }
        public override void Execute(object parameter)
        {
            var message = string.Format("Do you want to export '{0}' before removing?", ((CodeExplorerComponentViewModel)parameter).Name);
            var result  = _messageBox.Show(message, "Rubberduck Export Prompt", MessageBoxButtons.YesNoCancel,
                                           MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            if (result == DialogResult.Yes && !ExportFile((CodeExplorerComponentViewModel)parameter))
            {
                return;
            }

            // No file export or file successfully exported--now remove it

            // I know this will never be null because of the CanExecute
            var declaration = ((CodeExplorerComponentViewModel)parameter).Declaration;

            var project = declaration.QualifiedName.QualifiedModuleName.Project;

            project.VBComponents.Remove(declaration.QualifiedName.QualifiedModuleName.Component);
        }
        private Declaration GetTarget()
        {
            var project   = _vbe.ActiveVBProject;
            var component = _vbe.SelectedVBComponent;

            {
                if (Vbe.SelectedVBComponent != null && Vbe.SelectedVBComponent.HasDesigner)
                {
                    var designer = ((dynamic)component.Target).Designer;

                    if (designer.selected.count == 1)
                    {
                        var control = designer.selected.item(0);
                        var result  = _state.AllUserDeclarations
                                      .FirstOrDefault(item => item.DeclarationType == DeclarationType.Control &&
                                                      project.HelpFile == item.ProjectId &&
                                                      item.ComponentName == component.Name &&
                                                      item.IdentifierName == control.Name);

                        Marshal.ReleaseComObject(control);
                        Marshal.ReleaseComObject(designer);
                        return(result);
                    }
                    else
                    {
                        var message = string.Format(RubberduckUI.RenameDialog_AmbiguousSelection);
                        _messageBox.Show(message, RubberduckUI.RenameDialog_Caption, MessageBoxButtons.OK,
                                         MessageBoxIcon.Exclamation);
                    }
                }
            }

            return(null);
        }
Esempio n. 26
0
        private void Exit()
        {
            var path    = fileSystem.Path.GetFullPath(settings.DataPath);
            var message = string.Format("Der angegebene Pfad zum Notenverzeichnis existiert nicht.\nPfad: {0}", path);

            messageBox.Show(message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
            exitable.Shutdown();
        }
Esempio n. 27
0
 	public bool SomeFunction()
 	{
 		MessageBoxResult mResult = _messageBox.Show("Displaying message");
 		bool result;
 		if(mResult == MessageBoxResult.OK)
 		{
 		    result = AnyFunction();
 		}
 		return result;
 	}
Esempio n. 28
0
        public void Refactor()
        {
            if (_vbe.ActiveCodePane == null)
            {
                _messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage, RubberduckUI.ImplementInterface_Caption,
                                 System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                return;
            }

            var qualifiedSelection = _vbe.ActiveCodePane.GetQualifiedSelection();

            if (!qualifiedSelection.HasValue)
            {
                _messageBox.Show(RubberduckUI.ImplementInterface_InvalidSelectionMessage, RubberduckUI.ImplementInterface_Caption,
                                 System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                return;
            }

            Refactor(qualifiedSelection.Value);
        }
Esempio n. 29
0
        /// <summary>
        /// TODO: LoadError.html is not used, as navigating back from it doesn't work! Remove page if no better solution can be found.
        /// </summary>
        private void Control_LoadFailed(int errorCode, string errorText, string url)
        {
            if (errorCode == (int)CefErrorCode.None)
            {
                logger.Info($"Request for '{url}' was successful.");
            }
            else if (errorCode == (int)CefErrorCode.Aborted)
            {
                logger.Info($"Request for '{url}' was aborted.");
            }
            else
            {
                var title   = text.Get(TextKey.Browser_LoadErrorPageTitle);
                var message = text.Get(TextKey.Browser_LoadErrorPageMessage).Replace("%%URL%%", url) + $" {errorText} ({errorCode})";

                logger.Warn($"Request for '{url}' failed: {errorText} ({errorCode}).");

                Task.Run(() => messageBox.Show(message, title, icon: MessageBoxIcon.Error, parent: window)).ContinueWith(_ => control.NavigateBackwards());
            }
        }
Esempio n. 30
0
        private void LoadConfig()
        {
            _config = _configService.LoadConfiguration();

            var currentCulture = RubberduckUI.Culture;

            try
            {
                CultureManager.UICulture = CultureInfo.GetCultureInfo(_config.UserSettings.GeneralSettings.Language.Code);
                RubberduckUI.Culture     = CultureInfo.CurrentUICulture;
                InspectionsUI.Culture    = CultureInfo.CurrentUICulture;
                _appMenus.Localize();
            }
            catch (CultureNotFoundException exception)
            {
                Logger.Error(exception, "Error Setting Culture for Rubberduck");
                _messageBox.Show(exception.Message, "Rubberduck", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _config.UserSettings.GeneralSettings.Language.Code = currentCulture.Name;
                _configService.SaveConfiguration(_config);
            }
        }
Esempio n. 31
0
 //todo really big and bad crutch, NEED TO FIX IT!!!!
 private static Result MessageBox_Show(string text, string title = null, Mode mode = Mode.Ok)
 {
     //not initialize by some DI and should be initialize here
     messageBox = new CustomMessageBox();
     return messageBox.Show(text, title, mode);
 }