public static ProgressDialog GetProgressDialog(string text, DoWorkEventHandler action, bool testUI) { ProgressDialog dialog = new ProgressDialog(text, action); Window window; if (false) //Settings.UseCustomWindowDecorations) { window = new DecoratableWindow(); window.SetResourceReference(DecoratableWindow.StyleProperty, typeof(DecoratableWindow)); } else { window = new Window(); } window.Content = dialog; window.SizeToContent = SizeToContent.WidthAndHeight; window.Resources = dialog.Resources;//.MergedDictionaries.Add() //Application.Current.Resources.MergedDictionaries[0].MergedDictionaries[1] = ShaleAccents.Sky.Dictionary; if (testUI) { dialog.SetProgress(50); window.Show(); } return(dialog); }
public static void ShowClipboardFallback(string instruction, string content, string title) { ClipboardFallback fallback = new ClipboardFallback(instruction, content); Window window = null; if (Settings.UseCustomWindowDecorations) { window = new DecoratableWindow(); } else { window = new Window(); } window.Title = title; window.Content = fallback; window.SizeToContent = SizeToContent.WidthAndHeight; window.ShowDialog(); }
protected override void OnStartup(StartupEventArgs e) { if (Settings.ForceSoftwareRendering) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } MessageDisplay.ErrorOccurred += (sender, args) => { App_Exit(this, null); CommonUI.MessageDisplay.ShowException(args.Exception); }; MessageDisplay.MessageBoxShown += (sneder, args) => Dispatcher.BeginInvoke(new Action(() => CommonUI.MessageDisplay.ShowMessageBox(args.Content, args.Title))); MessageDisplay.DebugMessageSent += (sneder, args) => Dispatcher.BeginInvoke(new Action(() => CommonUI.MessageDisplay.ShowMessageBox(args.Content, args.Title))); Settings.EnsureDllsAreExtracted(); CommonUI.Updater.CheckForUpdates(); Settings.ManagerInstallLocationPath = Directory.GetParent(System.Reflection.Assembly.GetEntryAssembly().Location).ToString(); Exit += App_Exit; if (CommonUI.VersionValidation.IsConfigVersionCompatible(true, out Version previousModMgrVersion)) { if (ServantCommands.RunLkImporter() == null) { if (Permissions.IsAtleastWindowsVista() && (!Permissions.IsAdministrator())) { if (Permissions.AreAnyOtherModManagersRunning()) { if (Environment.GetCommandLineArgs().Length > 1) { List <string> files = new List <string>(); foreach (string s in Environment.GetCommandLineArgs().Skip(1)) { string path = s.Trim('\"', ' '); if (File.Exists(path)) { files.Add(path); } } string draggedFilesPath = Path.Combine(Settings.TempFolderPath, "draggedFiles"); File.WriteAllLines(draggedFilesPath, files); Permissions.GrantAccessFile(draggedFilesPath); } else { MessageBox.Show(Settings.GetLanguageString("CloseSporeModManagerFirst")); } Process.GetCurrentProcess().Kill(); } /*foreach (Process proc in Process.GetProcessesByName("SporeMods.DragServant").ToList()) * proc.Kill();*/ string parentDirectoryPath = Directory.GetParent(System.Reflection.Assembly.GetEntryAssembly().Location).ToString(); Process p = Process.Start(Path.Combine(parentDirectoryPath, "SporeMods.DragServant.exe"), Process.GetCurrentProcess().Id.ToString()); string args = Permissions.GetProcessCommandLineArgs(); args += " " + DragServantIdArg + p.Id; if (!Environment.GetCommandLineArgs().Contains(UpdaterService.IgnoreUpdatesArg)) { args += " " + UpdaterService.IgnoreUpdatesArg; } try { while (p.MainWindowHandle == IntPtr.Zero) { } Permissions.RerunAsAdministrator(args); } catch (Exception ex) { //MessageBox.Show(ex.GetType().FullName + "\n\n" + ex.Message + "\n\n" + ex.StackTrace, "Fatal error"); foreach (Process proc in Process.GetProcessesByName("SporeMods.DragServant").ToList()) { proc.Kill(); } Application.Current.Shutdown(); } } else// if (Permissions.IsAdministrator()) { string[] clArgs = Environment.GetCommandLineArgs(); foreach (string arg in clArgs) { string targ = arg.Trim(" ".ToCharArray()); if (targ.StartsWith(DragServantIdArg)) { DragServantProcess = Process.GetProcessById(int.Parse(targ.Replace(DragServantIdArg, string.Empty))); break; } } bool proceed = true; if (Permissions.IsAtleastWindowsVista() && (DragServantProcess == null)) { proceed = false; if (Settings.NonEssentialIsRunningUnderWine) { proceed = true; } else if (MessageBox.Show(Settings.GetLanguageString(1, "DontRunAsAdmin").Replace("%APPNAME%", "Spore Mod Manager"), String.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { proceed = true; } } else if ((!Permissions.IsAtleastWindowsVista()) && (DragServantProcess == null)) { DragServantProcess = Process.Start(Path.Combine(Directory.GetParent(System.Reflection.Assembly.GetEntryAssembly().Location).ToString(), "SporeMods.DragServant.exe")); } if (proceed) { base.OnStartup(e); //ModInstallation.DoFirstRunVerification(); Window window; ManagerContent content = new ManagerContent(); if (Settings.UseCustomWindowDecorations) { window = new Mechanism.Wpf.Core.Windows.DecoratableWindow() { Content = content, TitlebarHeight = 61 }; } else { window = new Window() { Content = content }; } window.MinWidth = 700; window.MinHeight = 400; window.Width = 800; window.Height = 450; MainWindow = window; window.ContentRendered += (sneder, args) => content.MainWindow_OnContentRendered(args); window.Activated += content.MainWindow_IsActiveChanged; window.Deactivated += content.MainWindow_IsActiveChanged; window.SizeChanged += content.MainWindow_SizeChanged; window.PreviewKeyDown += content.MainWindow_PreviewKeyDown; window.Closing += content.MainWindow_Closing; window.Show(); } else { Application.Current.Shutdown(); } } } } }