private void PluginViewModelOnOpenSettings(object sender, OpenPluginSettingsEventArgs openPluginSettingsEventArgs) { var propertiesEditable = openPluginSettingsEventArgs.PluginObject as IProvideEditableProperties; if (propertiesEditable != null) { WindowServiceInterface.Current.OpenWindowDialog(new PropertyGridSettingsViewModel(propertiesEditable), openPluginSettingsEventArgs.Plugin.PluginInfo.Name); return; } var provideBuilderSettings = openPluginSettingsEventArgs.PluginObject as IProvideBuilderSettings; if (provideBuilderSettings != null) { var firstBuilderProperty = provideBuilderSettings.BuilderSettings.FirstOrDefault()?.BuilderProperty; if (firstBuilderProperty != null) { ShowBuilderProperty?.Invoke(this, firstBuilderProperty); } return; } var provideWindowSettings = openPluginSettingsEventArgs.PluginObject as IProvideWindowSettings; provideWindowSettings?.ShowSettingsWindow(WindowServiceInterface.Current.GetCurrentWindow()); }
private async void BuildClient() { BuildLogger = new BuildLogger(); var builderProperties = BuilderSettingsManager.BuilderSettings.Where(x => !x.IsFromPlugin) .Select(x => x.BuilderProperty) .ToList(); foreach (var builderPropertyViewModel in BuilderSettingsManager.BuilderSettings) { var inputValidationResult = builderPropertyViewModel.BuilderPropertyView.ValidateInput(builderProperties, builderPropertyViewModel.BuilderProperty); builderPropertyViewModel.Failed = false; switch (inputValidationResult.ValidationState) { case ValidationState.Error: builderPropertyViewModel.Failed = true; if (inputValidationResult.Message[0] == '@') { builderPropertyViewModel.FailMessage = (string) Application.Current.Resources[inputValidationResult.Message.Substring(1)]; } else { builderPropertyViewModel.FailMessage = inputValidationResult.Message; } ShowBuilderProperty?.Invoke(this, builderPropertyViewModel.BuilderProperty); return; case ValidationState.WarningYesNo: if (WindowServiceInterface.Current.ShowMessageBox(inputValidationResult.Message, (string)Application.Current.Resources["Warning"], MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) == MessageBoxResult.Yes) { continue; } ShowBuilderProperty?.Invoke(this, builderPropertyViewModel.BuilderProperty); return; case ValidationState.Success: continue; } } var builderPlugins = _plugins.Where(x => x.IsBuildPlugin && x.IsSelected).Cast <BuilderPluginViewModel>().ToList(); var clientPlugins = _plugins.Where(x => !x.IsBuildPlugin && x.IsSelected).Cast <ClientPluginViewModel>().ToList(); var settingsList = builderProperties.AsReadOnly(); var builderArguments = new BuilderArguments(settingsList, $"{Application.Current.Resources["Executable"]}|*.exe|{Application.Current.Resources["Screensaver"]}|*.scr|Component Object Model|*.com"); foreach (var builderPlugin in builderPlugins) { builderArguments.CurrentBuildPlugin = builderPlugin.Plugin; builderPlugin.BuildPlugin.Prepare(builderArguments); } builderArguments.CurrentBuildPlugin = null; var builderEvents = builderArguments.BuildPluginEvents; if (builderEvents.Count > 0) { BuildLogger.Status(string.Format( (string)Application.Current.Resources["BuildStatusLoadedBuildPlugins"], builderEvents.Select(x => x.BuildPlugin).Distinct().Count(), builderEvents.Count)); } BuilderInformation builderInformation; if (builderArguments.SaveDialog == SaveDialogType.SaveFileDialog) { var sfd = new SaveFileDialog { AddExtension = true, CheckPathExists = true, Filter = builderArguments.SaveDialogFilter }; if (WindowServiceInterface.Current.ShowFileDialog(sfd) != true) { return; } builderInformation = new BuilderInformation(sfd.FileName, BuildLogger); } else { var fbd = new VistaFolderBrowserDialog { ShowNewFolderButton = true }; if (WindowServiceInterface.Current.ShowDialog(fbd.ShowDialog) != true) { return; } builderInformation = new BuilderInformation( FileExtensions.MakeUnique(Path.Combine(fbd.SelectedPath, "OrcusClient.exe")), BuildLogger); } ShowBuildTab?.Invoke(this, EventArgs.Empty); IsBuilding = true; var builder = new Builder(); var sw = Stopwatch.StartNew(); try { await Task.Run( () => builder.Build(builderInformation, builderProperties, builderEvents, clientPlugins.Select(x => x.ClientPlugin).ToList(), BuildLogger)); } catch (PluginException ex) { BuildLogger.Error(ex.LogMessage); BuildLogger.Error(string.Format((string)Application.Current.Resources["BuildStatusFailed"], sw.Elapsed.ToString("mm\\:ss\\.fff"))); return; } catch (Exception ex) { BuildLogger.Error(ex.ToString()); BuildLogger.Error(string.Format((string)Application.Current.Resources["BuildStatusFailed"], sw.Elapsed.ToString("mm\\:ss\\.fff"))); return; } finally { IsBuilding = false; } BuildLogger.Success(string.Format((string)Application.Current.Resources["BuildStatusSucceeded"], sw.Elapsed.ToString("mm\\:ss\\.fff"))); Process.Start("explorer.exe", $"/select, \"{builderInformation.AssemblyPath}\""); }