Exemplo n.º 1
0
        protected override void PerformFinalActionsBeforeWatsonDump()
        {
            if (this.ExpressionInformationService == null)
            {
                return;
            }
            MessageBoxArgs args = new MessageBoxArgs()
            {
                Message = StringTable.ApplicationUnrecoverableErrorDialogMessage,
                Button  = MessageBoxButton.YesNo,
                Image   = MessageBoxImage.Hand
            };
            MessageBoxResult       messageBoxResult = MessageBoxResult.No;
            IMessageDisplayService service1         = this.Services.GetService <IMessageDisplayService>();

            if (service1 != null)
            {
                messageBoxResult = service1.ShowMessage(args);
            }
            IProjectManager service2 = this.Services.GetService <IProjectManager>();
            IViewService    service3 = this.Services.GetService <IViewService>();

            if (service3 != null)
            {
                foreach (IView view in (IEnumerable <IView>)service3.Views)
                {
                    SilverlightSceneView silverlightSceneView = view as SilverlightSceneView;
                    if (silverlightSceneView != null)
                    {
                        silverlightSceneView.SuspendUpdatesForViewShutdown();
                    }
                }
            }
            if (service2 == null || service2.CurrentSolution == null)
            {
                return;
            }
            bool flag = false;

            foreach (IProject project in service2.CurrentSolution.Projects)
            {
                foreach (IProjectItem projectItem in (IEnumerable <IProjectItem>)project.Items)
                {
                    if (projectItem.IsDirty)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    break;
                }
            }
            if (!flag || messageBoxResult != MessageBoxResult.Yes)
            {
                return;
            }
            service2.CurrentSolution.Save(false);
        }
Exemplo n.º 2
0
    private void SafeSetAndPreviewFile(string file)
    {
        try
        {
            ModInfo modInfo;
            using (ZipArchive zip = ZipFile.OpenRead(file))
            {
                ZipArchiveEntry entry = zip.GetEntry(ModManager.ModInfoFileName);
                if (entry == null)
                {
                    throw new Exception("Failed to load mod because ModInfoFile not found.");
                }
                using (Stream modInfoStream = entry.Open())
                {
                    if (!ModInfo.TryLoadFrom(XDocument.Load(modInfoStream), out modInfo))
                    {
                        throw new Exception("Failed to load mod because failed to load ModInfo from ModInfoFile.");
                    }
                }
            }

            ModInfo = modInfo;
            File    = file;
        }
        catch (Exception e)
        {
            _dialogService.ShowMessageBox(MessageBoxArgs.Ok(
                                              title: "Unable to load mod",
                                              message: e.Message,
                                              type: MessageBoxType.Error
                                              ));
        }
    }
Exemplo n.º 3
0
        public override void Execute()
        {
            string project = this.Project;

            if (!string.IsNullOrEmpty(project))
            {
                if (PathHelper.FileExists(project) || PathHelper.DirectoryExists(project))
                {
                    if (this.Solution() != null && this.Solution().DocumentReference.Path == project)
                    {
                        return;
                    }
                    if (this.ProjectManager().CloseSolution())
                    {
                        this.ProjectManager().OpenSolution(DocumentReference.Create(project), true, true);
                    }
                }
                else
                {
                    MessageBoxArgs messageBoxArg  = new MessageBoxArgs();
                    CultureInfo    currentCulture = CultureInfo.CurrentCulture;
                    string         openRecentProjectNotFoundDialogMessage = StringTable.OpenRecentProjectNotFoundDialogMessage;
                    object[]       objArray = new object[] { project };
                    messageBoxArg.Message = string.Format(currentCulture, openRecentProjectNotFoundDialogMessage, objArray);
                    messageBoxArg.Button  = MessageBoxButton.YesNo;
                    messageBoxArg.Image   = MessageBoxImage.Hand;
                    if (base.Services.MessageDisplayService().ShowMessage(messageBoxArg) == MessageBoxResult.Yes)
                    {
                        ((ProjectManager)this.ProjectManager()).RemoveRecentProject(project);
                        return;
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static TriggerActionNode CreateDefaultAction(SceneViewModel viewModel, string defaultStoryboardName)
        {
            StoryboardTimelineSceneNode timelineSceneNode = viewModel.AnimationEditor.GetFirstActiveStoryboard(false);

            if (timelineSceneNode == null)
            {
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Message = StringTable.MissingDefaultStoryboardMessage,
                    Button  = MessageBoxButton.OKCancel,
                    Image   = MessageBoxImage.Asterisk
                };
                if (viewModel.DesignerContext.MessageDisplayService.ShowMessage(args) == MessageBoxResult.OK)
                {
                    timelineSceneNode = viewModel.AnimationEditor.CreateNewTimeline(viewModel.ActiveStoryboardContainer, defaultStoryboardName);
                }
            }
            if (timelineSceneNode == null)
            {
                return((TriggerActionNode)null);
            }
            TimelineActionNode timelineActionNode = (TimelineActionNode)BeginActionNode.Factory.Instantiate(viewModel);

            timelineActionNode.TargetTimeline = timelineSceneNode;
            return((TriggerActionNode)timelineActionNode);
        }
Exemplo n.º 5
0
    public MainWindowViewModel(
        IDialogService dialogService,
        IPluginLoader pluginLoader,
        IThemeService themeService,
        IModSelectionViewModel modSelectionViewModel,
        IMainEditorViewModel mainEditorViewModel)
    {
        _themeService = themeService;
        // Initial load of plugins to create cache and alert user of failures
        pluginLoader.LoadPlugins(out var failures);
        if (failures?.AnyFailures == true)
        {
            dialogService.ShowMessageBox(MessageBoxArgs.Ok(
                                             title: "Plugin Load Failures",
                                             message: $"Unable to load some of the plugins, details:\n\n{failures}",
                                             type: MessageBoxType.Warning
                                             ));
        }

        _modSelectionVm      = modSelectionViewModel;
        _mainEditorViewModel = mainEditorViewModel;
        CurrentVm            = _modSelectionVm;

        _modSelectionVm.ModSelected += OnModSelected;

        BackButtonCommand  = new RelayCommand(OnBackButtonPressed);
        ToggleThemeCommand = new RelayCommand(ToggleTheme);
    }
Exemplo n.º 6
0
        public static void SaveLogAndPromptUser(ProjectUpgradeLogger upgradeLogger, IServiceProvider serviceProvider, string basePath, bool success)
        {
            if (upgradeLogger.IsEmpty)
            {
                return;
            }
            string str = UpgradeWizard.SafelyCreateLogFileWithFallback(upgradeLogger, basePath);

            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            success = success & !upgradeLogger.HasErrors;
            if (!success)
            {
                IMessageDisplayService service        = (IMessageDisplayService)serviceProvider.GetService(typeof(IMessageDisplayService));
                MessageBoxArgs         messageBoxArg  = new MessageBoxArgs();
                CultureInfo            currentCulture = CultureInfo.CurrentCulture;
                string   upgradeErrorsMessage         = StringTable.UpgradeErrorsMessage;
                object[] objArray = new object[] { basePath };
                messageBoxArg.Message          = string.Format(currentCulture, upgradeErrorsMessage, objArray);
                messageBoxArg.HyperlinkMessage = StringTable.UpgradeErrorsLinkMessage;
                messageBoxArg.HyperlinkUri     = new Uri(str, UriKind.Absolute);
                messageBoxArg.Button           = MessageBoxButton.OK;
                messageBoxArg.Image            = MessageBoxImage.Hand;
                messageBoxArg.AutomationId     = "UpgradeWarningDialog";
                service.ShowMessage(messageBoxArg);
            }
        }
Exemplo n.º 7
0
        internal static void AddItemsToDocument(SceneView view, IEnumerable <IProjectItem> importedItems, Point dropPoint, ISceneInsertionPoint insertionPoint)
        {
            bool flag = false;

            if (importedItems == null || !Enumerable.Any <IProjectItem>(importedItems))
            {
                return;
            }
            using (SceneEditTransaction editTransaction = view.ViewModel.CreateEditTransaction(StringTable.DropElementsIntoSceneUndo))
            {
                foreach (IProjectItem projectItem in importedItems)
                {
                    if (FileDropToolBehavior.CanInsertTo(view, projectItem, insertionPoint))
                    {
                        FileDropToolBehavior.AddToDocument(view, projectItem, dropPoint, insertionPoint);
                    }
                    else
                    {
                        flag = true;
                    }
                }
                editTransaction.Commit();
            }
            if (!flag)
            {
                return;
            }
            MessageBoxArgs args = new MessageBoxArgs()
            {
                Message = StringTable.DragInsertionContainedIllegalItemsMessage,
                Button  = MessageBoxButton.OK,
                Image   = MessageBoxImage.Exclamation
            };
            int num = (int)view.ViewModel.DesignerContext.MessageDisplayService.ShowMessage(args);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Starts a <see cref="MessageBox"/> in a new thread. Will not show new <see cref="MessageBox"/> if an identical <see cref="MessageBox"/> already exists.
        /// </summary>
        /// <param name="text">
        /// Text to display in <see cref="MessageBox"/>.
        /// </param>
        /// <param name="caption">
        /// Caption text of <see cref="MessageBox"/>.
        /// </param>
        /// <param name="icon">
        /// <see cref="MessageBoxIcon"/> to display in <see cref="MessageBox"/>.
        /// </param>
        public static void Show(string text, string caption, MessageBoxIcon icon)
        {
            MessageBoxArgs messageBoxArgs = new MessageBoxArgs {
                Text = text, Caption = caption, Icon = icon
            };

            foreach (MessageBoxArgs ExistingMessage in ExistingMessages)
            {
                if (ExistingMessage.Equivalent(messageBoxArgs))
                {
                    switch (icon)
                    {
                    case (MessageBoxIcon.Asterisk): System.Media.SystemSounds.Asterisk.Play(); break;               // enum = Information

                    case (MessageBoxIcon.Exclamation): System.Media.SystemSounds.Exclamation.Play(); break;         // enum = Warning

                    case (MessageBoxIcon.Hand): System.Media.SystemSounds.Hand.Play(); break;                       // enum = Error = Stop

                    case (MessageBoxIcon.Question): System.Media.SystemSounds.Question.Play(); break;

                    default: break;
                    }
                    return;
                }
            }
            ExistingMessages.Add(messageBoxArgs);
            BackgroundWorker backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
            backgroundWorker.RunWorkerAsync(new MessageBoxArgs {
                Text = text, Caption = caption, Icon = icon
            });
        }
Exemplo n.º 9
0
    /// <summary>
    /// If any softlocks exist, notify the user of them
    /// </summary>
    private void NotifyUserIfNecessary()
    {
        int totalCount = guaranteedCount + conditionalCount + probableCount + probableConditionalCount;

        if (totalCount <= 0)
        {
            _dialogService.ShowMessageBox(MessageBoxArgs.Ok(
                                              "Validation Passed",
                                              "There is no known softlock causes in your mod!"
                                              ));
            return;
        }

        string result = new StringBuilder()
                        .AppendLine($"Total softlock/crash causes found: {totalCount}")
                        .AppendLine()
                        .AppendLine($"Guaranteed: {guaranteedCount}")
                        .AppendLine($"Conditional: {conditionalCount}")
                        .AppendLine($"Probable: {probableCount}")
                        .AppendLine($"ProbableConditional: {probableConditionalCount}")
                        .AppendLine()
                        .AppendLine(_reportBuilder.ToString())
                        .ToString();

        var tempFile = Path.GetTempFileName();

        File.WriteAllText(tempFile, result);
        var proc = Process.Start("notepad.exe", tempFile);

        // Wait for idle stopped working after windows 11 notpad update, so have to do this hack
        Thread.Sleep(1000);
        File.Delete(tempFile);
    }
Exemplo n.º 10
0
        protected override bool IsValidAssemblyReference(string fullAssemblyPath, bool verifyFileExists)
        {
            bool flag = true;

            try
            {
                if (PathHelper.FileOrDirectoryExists(fullAssemblyPath))
                {
                    flag = SilverlightProjectHelper.IsSilverlightAssembly(fullAssemblyPath);
                }
            }
            catch (BadImageFormatException badImageFormatException)
            {
                flag = true;
            }
            if (!flag)
            {
                MessageBoxArgs messageBoxArg    = new MessageBoxArgs();
                CultureInfo    invariantCulture = CultureInfo.InvariantCulture;
                string         addReferenceNotBuiltAgainstSilverlightErrorMessage = StringTable.AddReferenceNotBuiltAgainstSilverlightErrorMessage;
                object[]       fileOrDirectoryName = new object[] { PathHelper.GetFileOrDirectoryName(fullAssemblyPath) };
                messageBoxArg.Message = string.Format(invariantCulture, addReferenceNotBuiltAgainstSilverlightErrorMessage, fileOrDirectoryName);
                messageBoxArg.Button  = MessageBoxButton.OK;
                messageBoxArg.Image   = MessageBoxImage.Exclamation;
                MessageBoxArgs messageBoxArg1 = messageBoxArg;
                base.Services.MessageDisplayService().ShowMessage(messageBoxArg1);
            }
            if (!flag)
            {
                return(false);
            }
            return(base.IsValidAssemblyReference(fullAssemblyPath, verifyFileExists));
        }
Exemplo n.º 11
0
    private void ExportMod(ModInfo mod)
    {
        if (!_dialogService.ExportMod(mod, out string folder))
        {
            return;
        }
        Exception error = null;

        _dialogService.ProgressDialog(progress =>
        {
            progress.Report(new ProgressInfo("Exporting mod..."));
            try
            {
                _modService.Export(mod, folder);
            }
            catch (Exception e)
            {
                error = e;
                return;
            }
            progress.Report(new ProgressInfo("Export Complete!", 100));
        });

        if (error != null)
        {
            _dialogService.ShowMessageBox(MessageBoxArgs.Ok(
                                              title: "Error Exporting Mod",
                                              message: error.ToString(),
                                              type: MessageBoxType.Error
                                              ));
        }
    }
Exemplo n.º 12
0
        public bool Upgrade()
        {
            bool?nullable;

            if (ConversionSupressor.IsSupressed)
            {
                return(true);
            }
            bool   hasErrors = false;
            string str       = null;

            UpgradeWizard.UpgradeResponse upgrade = this.converter.PromptToUpgrade(this.versionMapping, out nullable, ref str, out this.proposedUpgrades);
            if (upgrade != UpgradeWizard.UpgradeResponse.Upgrade)
            {
                hasErrors = upgrade == UpgradeWizard.UpgradeResponse.DontUpgrade;
            }
            else
            {
                using (ProjectUpgradeLogger projectUpgradeLogger = new ProjectUpgradeLogger())
                {
                    hasErrors = true;
                    using (IDisposable disposable = TemporaryCursor.SetWaitCursor())
                    {
                        foreach (UpgradeAction proposedUpgrade in this.proposedUpgrades)
                        {
                            if (proposedUpgrade.DoUpgrade())
                            {
                                continue;
                            }
                            hasErrors = false;
                        }
                    }
                    hasErrors = hasErrors & !projectUpgradeLogger.HasErrors;
                    if (hasErrors && this.solutionUpgradedAction != null)
                    {
                        this.solutionUpgradedAction();
                    }
                    if (hasErrors && !string.IsNullOrEmpty(str))
                    {
                        MessageBoxArgs messageBoxArg = new MessageBoxArgs()
                        {
                            Message          = StringTable.UpgradeUpgradeAndBackupSuccess,
                            Button           = MessageBoxButton.OK,
                            Image            = MessageBoxImage.Asterisk,
                            AutomationId     = "BackupAndUpgradeCompletedDialog",
                            HyperlinkMessage = StringTable.UpgradeBackupFolderLink,
                            HyperlinkUri     = new Uri(str)
                        };
                        this.serviceProvider.MessageDisplayService().ShowMessage(messageBoxArg);
                    }
                    UpgradeWizard.SaveLogAndPromptUser(projectUpgradeLogger, this.serviceProvider, this.solution.DocumentReference.Path, hasErrors);
                }
            }
            if (nullable.HasValue && nullable.Value)
            {
                this.converter.IsEnabled = false;
            }
            return(hasErrors);
        }
Exemplo n.º 13
0
        public void Handle(MessageBoxArgs args)
        {
            var messageBox = IoC.Get <MessageBoxViewModel>();

            messageBox.SetArgs(args);
            ActivateItem(messageBox);
            messageBox.Deactivated += delegate { args.OnClose(messageBox.Result); };
        }
Exemplo n.º 14
0
    public Core.Services.MessageBoxResult ShowMessageBox(MessageBoxArgs options)
    {
        var dialog = new Dialogs.MessageBoxDialog(options)
        {
            Owner = Application.Current.MainWindow
        };

        dialog.ShowDialog();
        return(dialog.Result);
    }
Exemplo n.º 15
0
        protected override bool Initialize()
        {
            bool startupItem;

            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.ProjectPopulate, "InitializeExistingProject");
            string path = base.DocumentReference.Path;

            if (Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories).CountIsMoreThan <string>(1000))
            {
                MessageBoxArgs messageBoxArg = new MessageBoxArgs()
                {
                    Message = StringTable.FolderOpenTooManyFilesWarning,
                    Button  = MessageBoxButton.YesNo,
                    Image   = MessageBoxImage.Exclamation
                };
                if (base.Services.ShowSuppressibleWarning(messageBoxArg, "WebsiteTooLargeWarning", MessageBoxResult.Yes) == MessageBoxResult.No)
                {
                    return(false);
                }
            }
            this.LoadDirectory(path, null);
            if (this.StartupItem == null)
            {
                bool             flag             = false;
                VSWebsitesHelper vSWebsitesHelper = new VSWebsitesHelper();
                if (vSWebsitesHelper != null)
                {
                    VSWebsitesWebsite vSWebsitesWebsite = vSWebsitesHelper.FindWebsite(path);
                    if (vSWebsitesWebsite != null)
                    {
                        if (vSWebsitesWebsite.StartPage == null)
                        {
                            startupItem = true;
                        }
                        else
                        {
                            this.StartupItem = base.FindItem(Microsoft.Expression.Framework.Documents.DocumentReference.Create(vSWebsitesWebsite.StartPageFullPath));
                            startupItem      = this.StartupItem != null;
                        }
                        if (startupItem && vSWebsitesWebsite.VwdPort != 0)
                        {
                            this.cachedVswdPort = new int?(vSWebsitesWebsite.VwdPort);
                        }
                        flag = true;
                    }
                }
                if (!flag)
                {
                    this.StartupItem = base.FindItem(Microsoft.Expression.Framework.Documents.DocumentReference.Create(Microsoft.Expression.Framework.Documents.PathHelper.ResolveCombinedPath(path, "default.html")));
                }
            }
            PerformanceUtility.EndPerformanceSequence(PerformanceEvent.ProjectPopulate, "InitializeExistingProject");
            return(true);
        }
        public static bool PromptUserYesNo(this IServiceProvider source, string text)
        {
            MessageBoxArgs messageBoxArg = new MessageBoxArgs()
            {
                Message = text,
                Button  = MessageBoxButton.YesNo,
                Image   = MessageBoxImage.Exclamation
            };

            return(source.MessageDisplayService().ShowMessage(messageBoxArg) == MessageBoxResult.Yes);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Background worker to display message box in new thread.
        /// </summary>
        private static void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            MessageBoxArgs messageBoxArgs = e.Argument as MessageBoxArgs;

            MessageBox.Show(messageBoxArgs.Text, messageBoxArgs.Caption, MessageBoxButtons.OK, messageBoxArgs.Icon);
            for (int i = 0; i < ExistingMessages.Count; i++)        // remove from ExistingMessages once collided
            {
                if (ExistingMessages[i].Equivalent(messageBoxArgs))
                {
                    ExistingMessages.Remove(ExistingMessages[i]);
                }
            }
        }
Exemplo n.º 18
0
    public MessageBoxDialog(MessageBoxArgs args)
    {
        InitializeComponent();
        DataContext = args;

        DialogWindowBorder.BorderBrush = args.Type switch
        {
            MessageBoxType.Information => new SolidColorBrush(Color.FromRgb(63, 63, 63)),
            MessageBoxType.Warning => new SolidColorBrush(Color.FromRgb(242, 194, 0)),
            MessageBoxType.Error => new SolidColorBrush(Color.FromRgb(216, 6, 18)),
            _ => new SolidColorBrush(Color.FromRgb(63, 63, 63)),
        };
    }
Exemplo n.º 19
0
        public void Open(MessageBoxArgs args)
        {
            // update message box
            MessageText = args.messageText;
            YesText     = args.yesText;
            NoText      = args.noText;

            // save callback
            currentCallback = args.callback;

            // show message box
            IsVisible = true;
        }
Exemplo n.º 20
0
        public static bool PromptToOverwrite(DocumentReference documentReference, IServiceProvider serviceProvider)
        {
            MessageBoxArgs messageBoxArg  = new MessageBoxArgs();
            CultureInfo    currentCulture = CultureInfo.CurrentCulture;
            string         overwriteReadOnlyFileDialogMessage = StringTable.OverwriteReadOnlyFileDialogMessage;

            object[] path = new object[] { documentReference.Path };
            messageBoxArg.Message      = string.Format(currentCulture, overwriteReadOnlyFileDialogMessage, path);
            messageBoxArg.Button       = MessageBoxButton.YesNo;
            messageBoxArg.Image        = MessageBoxImage.Exclamation;
            messageBoxArg.AutomationId = "OverwriteReadOnlyProjectDialog";
            return(serviceProvider.MessageDisplayService().ShowMessage(messageBoxArg) == MessageBoxResult.Yes);
        }
Exemplo n.º 21
0
 private void RunPlugin(ModInfo mod, PluginInfo chosen)
 {
     try
     {
         chosen.Plugin.Run(new PluginContext(_modKernelFactory.Create(mod)));
     }
     catch (Exception e)
     {
         _dialogService.ShowMessageBox(MessageBoxArgs.Ok(
                                           title: $"Error running {chosen.Name}",
                                           message: $"An error was encountered while running the plugin {chosen.Name} (v{chosen.Version} by {chosen.Author}). Details:\n\n" + e.ToString(),
                                           type: MessageBoxType.Error
                                           ));
     }
 }
Exemplo n.º 22
0
        private void RefreshSolution()
        {
            MessageBoxResult messageBoxResult;

            if (this.SolutionFileInformation != null && this.SolutionFileInformation.HasChanged())
            {
                string solutionChangedDialogMessage = StringTable.SolutionChangedDialogMessage;
                string path = base.DocumentReference.Path;
                if (!SolutionBase.IsReloadPromptEnabled())
                {
                    messageBoxResult = MessageBoxResult.Yes;
                }
                else
                {
                    MessageBoxArgs messageBoxArg        = new MessageBoxArgs();
                    CultureInfo    currentCulture       = CultureInfo.CurrentCulture;
                    object[]       shortApplicationName = new object[] { path, this.Services.ExpressionInformationService().ShortApplicationName };
                    messageBoxArg.Message = string.Format(currentCulture, solutionChangedDialogMessage, shortApplicationName);
                    messageBoxArg.Button  = MessageBoxButton.YesNo;
                    messageBoxArg.Image   = MessageBoxImage.Exclamation;
                    MessageBoxArgs messageBoxArg1 = messageBoxArg;
                    messageBoxResult = this.Services.MessageDisplayService().ShowMessage(messageBoxArg1);
                }
                if (messageBoxResult == MessageBoxResult.Yes && this.Save(false))
                {
                    this.Services.ExceptionHandler(() => {
                        this.CloseAllProjects();
                        ((ProjectManager)this.Services.ProjectManager()).OnSolutionClosed(new SolutionEventArgs(this));
                        this.LoadInternal();
                        ((ProjectManager)this.Services.ProjectManager()).OnSolutionOpened(new SolutionEventArgs(this));
                        this.reloadDocuments = true;
                        if (this.IsUnderSourceControl)
                        {
                            ISourceControlProvider sourceControlProvider = this.Services.SourceControlProvider();
                            if (sourceControlProvider != null)
                            {
                                sourceControlProvider.OpenProject(base.DocumentReference.Path, false);
                            }
                        }
                        if (this.Services.ProjectManager().ItemSelectionSet.Count == 0)
                        {
                            this.Services.ProjectManager().ItemSelectionSet.SetSelection(this);
                        }
                    }, () => string.Format(CultureInfo.CurrentCulture, StringTable.DialogRefreshFailedMessage, new object[] { base.DocumentReference.Path }));
                }
                this.UpdateFileInformation();
            }
        }
Exemplo n.º 23
0
        private void ShowMefComposeError()
        {
            IConfigurationService        service1 = this.Services.GetService <IConfigurationService>();
            IMessageDisplayService       service2 = this.Services.GetService <IMessageDisplayService>();
            IMessageLoggingService       service3 = this.Services.GetService <IMessageLoggingService>();
            IExpressionMefHostingService service4 = this.Services.GetService <IExpressionMefHostingService>();

            if (this.mefExceptionToShow == null && Enumerable.Count <Exception>(service4.CompositionExceptions) <= 0)
            {
                return;
            }
            bool doNotAskAgain = service1 != null && (bool)service1["MEFHosting"].GetProperty("DoNotWarnAboutMefCompositionException", (object)false);

            if (!doNotAskAgain && service3 != null && (service4 != null && Enumerable.Count <Exception>(service4.CompositionExceptions) > 0))
            {
                foreach (Exception exception in service4.CompositionExceptions)
                {
                    service3.WriteLine(exception.Message);
                }
            }
            service4.ClearCompositionExceptions();
            if (!doNotAskAgain && service3 != null && (this.mefExceptionToShow != null && !string.IsNullOrEmpty(this.mefExceptionToShow.Message)))
            {
                service3.WriteLine(this.mefExceptionToShow.Message);
            }
            this.mefExceptionToShow = (Exception)null;
            if (doNotAskAgain || service2 == null)
            {
                return;
            }
            string         str  = Path.Combine(Path.GetDirectoryName(this.GetType().Module.FullyQualifiedName), "extensions");
            MessageBoxArgs args = new MessageBoxArgs()
            {
                Message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.MefCompositionException, new object[1]
                {
                    (object)str
                }),
                Button = MessageBoxButton.OK,
                Image  = MessageBoxImage.Exclamation
            };
            int num = (int)service2.ShowMessage(args, out doNotAskAgain);

            if (!doNotAskAgain || service1 == null)
            {
                return;
            }
            service1["MEFHosting"].SetProperty("DoNotWarnAboutMefCompositionException", (object)true);
        }
Exemplo n.º 24
0
        public static bool PromptUserAndSaveDocument(IDocument document, bool saveAsOnFailure, IMessageDisplayService messageManager)
        {
            bool flag = false;

            if (document.IsDirty)
            {
                IDictionary <MessageChoice, string> dictionary = (IDictionary <MessageChoice, string>) new Dictionary <MessageChoice, string>()
                {
                    {
                        MessageChoice.Yes,
                        StringTable.SaveChangesYesResponse
                    },
                    {
                        MessageChoice.No,
                        StringTable.SaveChangesNoResponse
                    }
                };
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.SaveChangesTo, new object[1]
                    {
                        (object)document.DocumentReference.DisplayName
                    }),
                    Button        = MessageBoxButton.YesNoCancel,
                    Image         = MessageBoxImage.Exclamation,
                    TextOverrides = dictionary
                };
                switch (messageManager.ShowMessage(args))
                {
                case MessageBoxResult.Yes:
                    flag = DocumentUtilities.SaveDocument(document, saveAsOnFailure, messageManager);
                    break;

                case MessageBoxResult.No:
                    flag = true;
                    break;
                }
            }
            else
            {
                flag = true;
            }
            return(flag);
        }
Exemplo n.º 25
0
        private void Project_ProjectChanged(object o, ProjectEventArgs e)
        {
            MessageBoxResult messageBoxResult;

            if (this.IsDisposed)
            {
                return;
            }
            if (e.Project == null)
            {
                return;
            }
            string projectChangedDialogMessage = StringTable.ProjectChangedDialogMessage;
            string path = e.Project.DocumentReference.Path;

            if (!SolutionBase.IsReloadPromptEnabled())
            {
                messageBoxResult = MessageBoxResult.Yes;
            }
            else
            {
                MessageBoxArgs messageBoxArg        = new MessageBoxArgs();
                CultureInfo    currentCulture       = CultureInfo.CurrentCulture;
                object[]       shortApplicationName = new object[] { path, this.Services.ExpressionInformationService().ShortApplicationName };
                messageBoxArg.Message = string.Format(currentCulture, projectChangedDialogMessage, shortApplicationName);
                messageBoxArg.Button  = MessageBoxButton.YesNo;
                messageBoxArg.Image   = MessageBoxImage.Exclamation;
                MessageBoxArgs messageBoxArg1 = messageBoxArg;
                messageBoxResult = this.Services.MessageDisplayService().ShowMessage(messageBoxArg1);
            }
            if (messageBoxResult == MessageBoxResult.Yes)
            {
                IProject project = e.Project;
                if (project != null && this.Save(false) && this.RefreshProject(project) && this.Services.ProjectManager().ItemSelectionSet.Count == 0)
                {
                    this.Services.ProjectManager().ItemSelectionSet.SetSelection(this);
                }
            }
        }
Exemplo n.º 26
0
 /// <summary>
 /// Starts a <see cref="MessageBox"/> in a new thread. Will not show new <see cref="MessageBox"/> if an identical <see cref="MessageBox"/> already exists.
 /// </summary>
 /// <param name="text">
 /// Text to display in <see cref="MessageBox"/>.
 /// </param>
 /// <param name="caption">
 /// Caption text of <see cref="MessageBox"/>.
 /// </param>
 /// <param name="icon">
 /// <see cref="MessageBoxIcon"/> to display in <see cref="MessageBox"/>.
 /// </param>
 public static void Show(string text, string caption, MessageBoxIcon icon)
 {
     MessageBoxArgs messageBoxArgs = new MessageBoxArgs { Text = text, Caption = caption, Icon = icon };
     foreach(MessageBoxArgs ExistingMessage in ExistingMessages)
     {
         if (ExistingMessage.Equivalent(messageBoxArgs))
         {
             switch (icon)
             {
                 case (MessageBoxIcon.Asterisk): System.Media.SystemSounds.Asterisk.Play(); break;           // enum = Information
                 case (MessageBoxIcon.Exclamation): System.Media.SystemSounds.Exclamation.Play(); break;     // enum = Warning
                 case (MessageBoxIcon.Hand): System.Media.SystemSounds.Hand.Play(); break;                   // enum = Error = Stop
                 case (MessageBoxIcon.Question): System.Media.SystemSounds.Question.Play(); break;
                 default: break;
             }
             return;
         }
     }
     ExistingMessages.Add(messageBoxArgs);
     BackgroundWorker backgroundWorker = new BackgroundWorker();
     backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
     backgroundWorker.RunWorkerAsync(new MessageBoxArgs { Text = text, Caption = caption, Icon = icon });
 }
Exemplo n.º 27
0
    public MainEditorViewModel(
        IDialogService dialogService,
        IModPatchingService modPatcher,
        ISettingService settingService,
        IPluginLoader pluginLoader,
        IModServiceGetterFactory modKernelFactory,
        IEnumerable <EditorModule> modules)
    {
        _modKernelFactory         = modKernelFactory;
        _dialogService            = dialogService;
        _modPatcher               = modPatcher;
        _settingService           = settingService;
        _editorModuleOrderSetting = _settingService.Get <EditorModuleOrderSetting>();

        PluginItems = pluginLoader.LoadPlugins(out var loadFailures);
        if (loadFailures?.AnyFailures == true)
        {
            _dialogService.ShowMessageBox(MessageBoxArgs.Ok("Failed to load some plugins", loadFailures?.ToString()));
        }

        CommitRomCommand = new RelayCommand(CommitRom);

        RegisterModules(modules);
    }
Exemplo n.º 28
0
    private void PatchRom(ModInfo mod)
    {
        if (!_dialogService.CommitToRom(mod, out string romPath, out var patchOpt))
        {
            return;
        }

        if (!_modPatcher.CanPatch(mod, romPath, patchOpt, out string reason))
        {
            _dialogService.ShowMessageBox(MessageBoxArgs.Ok("Unable to patch sprites", reason));
            return;
        }

        Exception error = null;

        _dialogService.ProgressDialog(progress =>
        {
            try
            {
                _modPatcher.Patch(mod, romPath, patchOpt, progress);
            }
            catch (Exception e)
            {
                error = e;
            }
        });

        if (error != null)
        {
            _dialogService.ShowMessageBox(MessageBoxArgs.Ok(
                                              title: "Error Writing To Rom",
                                              message: error.ToString(),
                                              type: MessageBoxType.Error
                                              ));
        }
    }
Exemplo n.º 29
0
    private void CreateModBasedOn(ModInfo mod)
    {
        if (!_dialogService.CreateModBasedOn(mod, out ModInfo newModInfo))
        {
            return;
        }
        Exception error = null;

        _dialogService.ProgressDialog(progress =>
        {
            progress.Report(new ProgressInfo("Creating mod..."));
            ModInfo newMod;
            try
            {
                newMod = _modService.CreateBasedOn(mod, newModInfo.Name, newModInfo.Version, newModInfo.Author);
            }
            catch (Exception e)
            {
                error = e;
                return;
            }

            progress.Report(new ProgressInfo("Updating mod list...", 60));
            _parentVm.RefreshModItems();
            progress.Report(new ProgressInfo("Mod Creating Complete!", 100));
        });

        if (error != null)
        {
            _dialogService.ShowMessageBox(MessageBoxArgs.Ok(
                                              title: "Error Creating Mod",
                                              message: error.ToString(),
                                              type: MessageBoxType.Error
                                              ));
        }
    }
Exemplo n.º 30
0
        public static bool EnsureSilverlightToolkitTypeAvailable(ITypeResolver typeResolver, ITypeId targetType, IMessageDisplayService messageDisplayService, string installHelperMessage, string upgradeHelperMessage)
        {
            bool flag = typeResolver.EnsureAssemblyReferenced("System.Windows.Controls.Toolkit");

            if (!flag)
            {
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Message          = installHelperMessage,
                    HyperlinkMessage = StringTable.SilverlightToolkitInstallHyperlinkMessage,
                    HyperlinkUri     = new Uri("http://go.microsoft.com/fwlink/?LinkId=183538", UriKind.Absolute),
                    Button           = MessageBoxButton.OK,
                    Image            = MessageBoxImage.Exclamation,
                    AutomationId     = "ToolkitNotInstalled"
                };
                int num = (int)messageDisplayService.ShowMessage(args);
            }
            else
            {
                flag = typeResolver.PlatformMetadata.IsSupported(typeResolver, targetType);
                if (!flag)
                {
                    MessageBoxArgs args = new MessageBoxArgs()
                    {
                        Message          = upgradeHelperMessage,
                        HyperlinkMessage = StringTable.SilverlightToolkitUpdateHyperlinkMessage,
                        HyperlinkUri     = new Uri("http://go.microsoft.com/fwlink/?LinkId=183538", UriKind.Absolute),
                        Button           = MessageBoxButton.OK,
                        Image            = MessageBoxImage.Exclamation,
                        AutomationId     = "ToolkitIncorrectVersion"
                    };
                    int num = (int)messageDisplayService.ShowMessage(args);
                }
            }
            return(flag);
        }
Exemplo n.º 31
0
        public static bool SaveDocument(IDocument document, bool saveAsOnFailure, bool forceSave, IMessageDisplayService messageManager)
        {
            bool flag = false;

            if (!forceSave)
            {
                if (!document.IsDirty)
                {
                    flag = true;
                    goto label_12;
                }
            }
            try
            {
                if (document.Container != null)
                {
                    document.Container.BeginCheckDocumentStatus(document);
                }
                FileAttributes fileAttributes = !PathHelper.FileExists(document.DocumentReference.Path) ? FileAttributes.Normal : File.GetAttributes(document.DocumentReference.Path);
                if ((fileAttributes & FileAttributes.ReadOnly) != (FileAttributes)0)
                {
                    MessageBoxArgs args = new MessageBoxArgs()
                    {
                        Message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.OverwriteConfirmationMessage, new object[1]
                        {
                            (object)document.DocumentReference.DisplayName
                        }),
                        Button = MessageBoxButton.YesNoCancel,
                        Image  = MessageBoxImage.Exclamation
                    };
                    switch (messageManager.ShowMessage(args))
                    {
                    case MessageBoxResult.Yes:
                        File.SetAttributes(document.DocumentReference.Path, fileAttributes & ~FileAttributes.ReadOnly);
                        flag = document.Save();
                        break;

                    case MessageBoxResult.No:
                        flag = true;
                        break;
                    }
                }
                else
                {
                    flag = document.Save();
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                flag = false;
                messageManager.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.SaveAccessError, new object[2]
                {
                    (object)document.DocumentReference.DisplayName,
                    (object)ex.Message
                }));
                int num = saveAsOnFailure ? 1 : 0;
            }
            catch (IOException ex)
            {
                flag = false;
                messageManager.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.SaveAccessError, new object[2]
                {
                    (object)document.DocumentReference.DisplayName,
                    (object)ex.Message
                }));
                int num = saveAsOnFailure ? 1 : 0;
            }
label_12:
            return(flag);
        }
Exemplo n.º 32
0
 public bool Equivalent(MessageBoxArgs messageBoxArgs)
 {
     return Text == messageBoxArgs.Text && Caption == messageBoxArgs.Caption && Icon == messageBoxArgs.Icon;
 }