/// <summary> /// 添加对话窗方法 /// </summary> /// <param name="dialog"></param> public void AddDialog(ModalDialogBase dialog) { if (!Dialogs.Any()) { dialog.IsShown = true; } Dialogs.Add(dialog); }
/// <summary> /// Shows the modal window of the MSI UI. This method is called by the <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI" /> /// when it is initialized at runtime. /// </summary> /// <param name="msiRuntime">The MSI runtime.</param> /// <param name="ui">The MSI external/embedded UI.</param> public void ShowModal(MsiRuntime msiRuntime, IManagedUI ui) { //Debug.Assert(false); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); UI = ui; MsiRuntime = msiRuntime; ActionResult result = ManagedProject.InvokeClientHandlers(MsiRuntime.Session, "UIInitialized"); MsiRuntime.Data.MergeReplace(MsiRuntime.Session["WIXSHARP_RUNTIME_DATA"]); //data may be changed in the client handler if (result == ActionResult.Success) { if (MsiRuntime.Session.IsInstalling()) { Dialogs = ui.InstallDialogs; } else if (MsiRuntime.Session.IsRepairing()) { Dialogs = ui.ModifyDialogs; } if (Dialogs.Any()) { shellView = new ShellView(); shellView.Load += (s, e) => { MsiRuntime.Session["WIXSHARP_MANAGED_UI_HANDLE"] = MsiRuntime.Data["WIXSHARP_MANAGED_UI_HANDLE"] = shellView.Handle.ToString(); try { var data = MsiRuntime.Session.GetEmbeddedData("ui_shell_icon"); using (var stream = new System.IO.MemoryStream(data)) shellView.Icon = new Icon(stream); } catch { } ManagedProject.InvokeClientHandlers(MsiRuntime.Session, "UILoaded", (IShellView)shellView); MsiRuntime.Data.MergeReplace(MsiRuntime.Session["WIXSHARP_RUNTIME_DATA"]);; //data may be changed in the client handler }; GoNext(); shellView.ShowDialog(); } else { this.StartExecute(); while (!finished) { Thread.Sleep(1000); } } } else { MsiRuntime.Session.Log("UIInitialized returned " + result); } }
/// <summary> /// Shows the modal window of the MSI UI. This method is called by the <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI" /> /// when it is initialized at runtime. /// </summary> /// <param name="msiRuntime">The MSI runtime.</param> /// <param name="ui">The MSI external/embedded UI.</param> public void ShowModal(MsiRuntime msiRuntime, IManagedUI ui) { //Debug.Assert(false); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); UI = ui; MsiRuntime = msiRuntime; ActionResult result = ManagedProject.InvokeClientHandlers(MsiRuntime.Session, "UIInitialized"); if (result == ActionResult.Success) { if (MsiRuntime.Session.IsInstalling()) { Dialogs = ui.InstallDialogs; } else if (MsiRuntime.Session.IsRepairing()) { Dialogs = ui.ModifyDialogs; } if (Dialogs.Any()) { shellView = new ShellView(); shellView.Load += (s, e) => { ManagedProject.InvokeClientHandlers(MsiRuntime.Session, "UILoaded", (IShellView)shellView); }; GoNext(); shellView.ShowDialog(); } else { this.StartExecute(); while (!finished) { Thread.Sleep(1000); } } } else { MsiRuntime.Session.Log("UIInitialized returned " + result); } }
/// <summary> /// Shows the modal window of the MSI UI. This method is called by the <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI" /> /// when it is initialized at runtime. /// </summary> /// <param name="msiRuntime">The MSI runtime.</param> /// <param name="ui">The MSI external/embedded UI.</param> public void ShowModal(MsiRuntime msiRuntime, IManagedUI ui) { // Debug.Assert(false); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); UI = ui; MsiRuntime = msiRuntime; Tasks.UILocalize = text => text.LocalizeWith(msiRuntime.Localize); UACRevealer.Enabled = !MsiRuntime.Session.Property("UAC_REVEALER_ENABLED").IsEmpty(); if (MsiRuntime.Session.IsInstalling()) { Dialogs = ui.InstallDialogs; } else if (MsiRuntime.Session.IsRepairing()) { Dialogs = ui.ModifyDialogs; } if (Dialogs.Any()) { shellView = new ShellView { Shell = this } } ; try { int culture = msiRuntime.Session.Property("ProductLanguage").ToInt(); if (culture != 0) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); } } catch { } ActionResult result = ManagedProject.InvokeClientHandlers(MsiRuntime.Session, "UIInitialized", shellView as IShellView); MsiRuntime.Data.MergeReplace(MsiRuntime.Session["WIXSHARP_RUNTIME_DATA"]); //data may be changed in the client handler if (result != ActionResult.Failure) { if (shellView != null) { shellView.Load += (s, e) => { MsiRuntime.Session["WIXSHARP_MANAGED_UI_HANDLE"] = MsiRuntime.Data["WIXSHARP_MANAGED_UI_HANDLE"] = shellView.Handle.ToString(); try { var data = MsiRuntime.Session.GetEmbeddedData("ui_shell_icon"); using (var stream = new System.IO.MemoryStream(data)) shellView.Icon = new Icon(stream); } catch { } result = ManagedProject.InvokeClientHandlers(MsiRuntime.Session, "UILoaded", (IShellView)shellView); if (result != ActionResult.Success) { // aborting UI dialogs sequence from here is not possible as this event is // simply called when Shell is loaded but not when dialogs are progressing in the sequence. MsiRuntime.Session.Log("UILoaded returned " + result); } MsiRuntime.Data.MergeReplace(MsiRuntime.Session["WIXSHARP_RUNTIME_DATA"]);; //data may be changed in the client handler }; if (result == ActionResult.SkipRemainingActions) { result = ActionResult.Success; if (Dialogs.Contains(typeof(UI.Forms.ProgressDialog))) { GoTo <UI.Forms.ProgressDialog>(); } else { GoToLast(); } } else if (result == ActionResult.UserExit) { GoToLast(); } else { GoNext(); } shellView.ShowDialog(); } else { this.StartExecute(); while (!finished) { Thread.Sleep(1000); } } } else { MsiRuntime.Session.Log("UIInitialized returned " + result); } }