public void CanCreate_WpfDialogHost_Test() { var shell = new UIShell(); var host = shell.CreateDefaultWpfDialgHost(); Assert.Equal("WpfDialogHost", host.GetType().Name); }
static public void Main(string[] args) { if (Environment.GetEnvironmentVariable("APPVEYOR") != null) { return; } // Compiler.WixLocation = @"..\..\..\..\..\Wix_bin\bin"; if (args.Contains("/test")) //for demo only { UIShell.Play(ManagedUI.Default.InstallDialogs); return; } //Note if the property 'PASSWORD' is not preserved as deferred then it will not be available //from the Project_AfterInstall, which is a deferred custom action. var project = new ManagedProject("ManagedSetup", new User { Name = Defaults.UserName, Password = "******", Domain = "[DOMAIN]", PasswordNeverExpires = true, CreateUser = true }, new Binary("CUSTOM_LNG".ToId(), "WixUI_fi-FI.wxl"), new Property("PASSWORD", "pwd123") { IsDeferred = true }); project.SourceBaseDir = @"..\..\"; project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); //project.LocalizationFile = "MyProduct.en-us.wxl"; project.LocalizationFile = "WixUI_de-de.wxl"; project.Language = "de-de"; project.SetNetFxPrerequisite("NETFRAMEWORK35='#1'", "Please install .NET 3.5 first."); project.ManagedUI = new ManagedUI(); project.ManagedUI.InstallDialogs.Add <WelcomeDialog>() .Add <MyProduct.UserNameDialog>() .Add <ProgressDialog>() .Add <ExitDialog>(); //it effectively becomes a 'Repair' sequence project.ManagedUI.ModifyDialogs.Add <ProgressDialog>() .Add <ExitDialog>(); project.UILoaded += msi_UILoaded; project.BeforeInstall += msi_BeforeInstall; project.AfterInstall += Project_AfterInstall; project.PreserveTempFiles = true; project.DefaultRefAssemblies.Add(@"C:\Users\oleg.shilo\source\repos\WindowsFormsApp2\WixSharp Setup1\bin\Debug\WpfControlLibrary2.dll"); project.BuildMsi(); }
static public void Main(string[] args) { if (args.Contains("/test")) //for demo only { UIShell.Play(ManagedUI.Default.InstallDialogs); return; } //Note if the property 'PASSWORD' is not preserved as deferred then it will not be available //from the Project_AfterInstall, which is a deferred custom action. var project = new ManagedProject("ManagedSetup", new User { Name = Defaults.UserName, Password = "******", Domain = "[DOMAIN]", PasswordNeverExpires = true, CreateUser = true }, new Property("PASSWORD", "pwd123") { IsDeferred = true }); project.SourceBaseDir = @"..\..\"; project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); //project.LocalizationFile = "MyProduct.en-us.wxl"; project.LocalizationFile = "WixUI_de-de.wxl"; project.Language = "de-de"; project.SetNetFxPrerequisite("NETFRAMEWORK35='#1'", "Please install .NET 3.5 first."); project.ManagedUI = new ManagedUI(); project.ManagedUI.InstallDialogs.Add <WelcomeDialog>() .Add <MyProduct.UserNameDialog>() .Add <ProgressDialog>() .Add <ExitDialog>(); //it effectively becomes a 'Repair' sequence project.ManagedUI.ModifyDialogs.Add <ProgressDialog>() .Add <ExitDialog>(); project.UIInitialized += e => { Debug.Assert(false); Thread.CurrentThread.CurrentUICulture = new CultureInfo(project.Language); }; project.UILoaded += msi_UILoaded; project.BeforeInstall += msi_BeforeInstall; project.AfterInstall += Project_AfterInstall; project.PreserveTempFiles = true; project.BuildMsi(); }
// -------------------------------------------------------------------------------- /// <summary> /// This method shows up the property window. /// </summary> // -------------------------------------------------------------------------------- public static void ShowPropertiesWindow() { var propertyBrowser = new Guid(ToolWindowGuids.PropertyBrowser); IVsWindowFrame propFrame; UIShell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref propertyBrowser, out propFrame); if (propFrame != null) { propFrame.Show(); } }
static void TestDialogs() { UIShell.Play( "WixSharp_UI_INSTALLDIR=INSTALLDIR", // required by InstallDirDialog for initialization of the demo MSI session typeof(Custom.WelcomeDialog), typeof(Custom.LicenceDialog), typeof(Custom.InstallDirDialog), typeof(Custom.MaintenanceTypeDialog), typeof(Custom.SetupTypeDialog), typeof(Custom.FeaturesDialog), typeof(Custom.ProgressDialog), typeof(Custom.ExitDialog)); }
public override void ShowModal(System.Windows.Window dialog) { // get the owner of this dialog UIShell.GetDialogOwnerHwnd(out IntPtr hwnd); dialog.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; UIShell.EnableModeless(0); try { WindowHelper.ShowModal(dialog, hwnd); } finally { // This will take place after the window is closed. UIShell.EnableModeless(1); } }
public void ShowModal(System.Windows.Window dialog) { SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync(); UIShell.GetDialogOwnerHwnd(out IntPtr hwnd); dialog.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; UIShell.EnableModeless(0); try { WindowHelper.ShowModal(dialog, hwnd); } finally { UIShell.EnableModeless(1); } }
/// <summary> /// Populates the maps that map from name -> scope info and GUID -> scope info /// </summary> private void PopulateScopeMaps() { ShellSettingsManager settingsManager = new ShellSettingsManager(this.serviceProvider); SettingsStore settingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.Configuration); // First build map of all registered scopes if (settingsStore.CollectionExists(KeyBindingTableRegKeyName)) { int itemCount = settingsStore.GetSubCollectionCount(KeyBindingTableRegKeyName); foreach (string str in settingsStore.GetSubCollectionNames(KeyBindingTableRegKeyName)) { string collectionName = Path.Combine(KeyBindingTableRegKeyName, str); Guid scopeId; if (!Guid.TryParse(str, out scopeId)) { continue; } Guid owningPackage; uint resourceId; bool allowNavKeyBinding = false; if (scopeId == VSConstants.GUID_VSStandardCommandSet97) { owningPackage = CLSID_VsEnvironmentPackage; resourceId = ID_Intl_Base + 18; } else { if (!settingsStore.PropertyExists(collectionName, PackageRegPropertyName)) { continue; } if (!Guid.TryParse(settingsStore.GetString(collectionName, PackageRegPropertyName), out owningPackage)) { continue; } string resIdString = settingsStore.GetString(collectionName, string.Empty); if (resIdString.StartsWith("#")) { resIdString = resIdString.Substring(1); } if (!uint.TryParse(resIdString, out resourceId)) { continue; } if (settingsStore.PropertyExists(collectionName, AllowNavKeyBindingPropertyName)) { allowNavKeyBinding = settingsStore.GetUInt32(collectionName, AllowNavKeyBindingPropertyName) == 0 ? false : true; } } string scopeName; if (!ErrorHandler.Succeeded(Shell.LoadPackageString(ref owningPackage, resourceId, out scopeName))) { continue; } KeybindingScope scopeInfo = new KeybindingScope(scopeName, scopeId, allowNavKeyBinding); this.scopeGuidToScopeInfoMap[scopeId] = scopeInfo; this.scopeNameToScopeInfoMap[scopeName] = scopeInfo; } } IVsEnumGuids scopeEnum = UIShell.EnumKeyBindingScopes(); // Random GUID the shell also skips ("Source Code Text Editor" scope) Guid toSkip = new Guid("{72F42A10-B1C5-11d0-A8CD-00A0C921A4D2}"); Guid[] scopes = new Guid[1]; uint fetched = 0; while (scopeEnum.Next((uint)scopes.Length, scopes, out fetched) == VSConstants.S_OK && fetched != 0) { // We already have info for this scope if (scopeGuidToScopeInfoMap.ContainsKey(scopes[0])) { continue; } // The shell skips this as a possible binding scope if (scopes[0] == toSkip) { continue; } string path = Path.Combine("Editors", scopes[0].ToString("B")); // If it isn't a registered scope, see if it is an editor factory if (!settingsStore.CollectionExists(path)) { continue; } if (!settingsStore.PropertyExists(path, PackageRegPropertyName)) { continue; } Guid packageGuid; if (!Guid.TryParse(settingsStore.GetString(path, PackageRegPropertyName), out packageGuid)) { continue; } if (!settingsStore.PropertyExists(path, DisplayNameRegPropertyName)) { continue; } string displayNameResIdStr = settingsStore.GetString(path, DisplayNameRegPropertyName); if (displayNameResIdStr.StartsWith("#")) { displayNameResIdStr = displayNameResIdStr.Substring(1); } uint displayNameResId; if (!uint.TryParse(displayNameResIdStr, out displayNameResId)) { continue; } string displayName; if (!ErrorHandler.Succeeded(shell.LoadPackageString(ref packageGuid, displayNameResId, out displayName))) { continue; } // NOTE: Is false the right default value? KeybindingScope scopeInfo = new KeybindingScope(displayName, scopes[0], allowNavKeyBinding: false); this.scopeGuidToScopeInfoMap[scopes[0]] = scopeInfo; this.scopeNameToScopeInfoMap[displayName] = scopeInfo; } }
// -------------------------------------------------------------------------------- /// <summary> /// Changes the cursor to the hourglass cursor. /// </summary> // -------------------------------------------------------------------------------- public static void SetWaitCursor() { UIShell.SetWaitCursor(); }
// -------------------------------------------------------------------------------- /// <summary> /// Helper method used by editors that implement the IVsPersistDocData interface. /// </summary> /// <param name="grfSave">Specifies file Save options.</param> /// <param name="pPersistFile"> /// Pointer to the IUnknown interface of the file in which the doc data is to /// be saved. /// </param> /// <param name="pszUntitledPath"> /// File path to which the doc data for an as-yet unsaved document is to be saved. /// </param> /// <param name="pbstrDocumentNew">New document file name.</param> /// <param name="pfCanceled"> /// Set to true if the user aborts the save by clicking the Cancel button. /// </param> /// <returns> /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. /// </returns> // -------------------------------------------------------------------------------- public static int SaveDocDataToFile(VSSAVEFLAGS grfSave, object pPersistFile, string pszUntitledPath, out string pbstrDocumentNew, out int pfCanceled) { return(UIShell.SaveDocDataToFile(grfSave, pPersistFile, pszUntitledPath, out pbstrDocumentNew, out pfCanceled)); }
// -------------------------------------------------------------------------------- /// <summary> /// Asynchronously sends status update messages to command UI elements. /// </summary> // -------------------------------------------------------------------------------- public static void UpdateCommandUI() { UIShell.UpdateCommandUI(0); }
public VSDialogResult ShowDialog(string caption, string message, VSDialogButton button, VSDialogDefaultButton defaultButton, VSDialogIconMode iconMode, bool systemModal = false) { OLEMSGBUTTON buttonToUse = OLEMSGBUTTON.OLEMSGBUTTON_OK; switch (button) { case VSDialogButton.AbortRetryIgnore: buttonToUse = OLEMSGBUTTON.OLEMSGBUTTON_ABORTRETRYIGNORE; break; case VSDialogButton.Ok: buttonToUse = OLEMSGBUTTON.OLEMSGBUTTON_OK; break; case VSDialogButton.OkCancel: buttonToUse = OLEMSGBUTTON.OLEMSGBUTTON_OKCANCEL; break; case VSDialogButton.RetryCancel: buttonToUse = OLEMSGBUTTON.OLEMSGBUTTON_RETRYCANCEL; break; case VSDialogButton.YesAllNoCancel: buttonToUse = OLEMSGBUTTON.OLEMSGBUTTON_YESALLNOCANCEL; break; case VSDialogButton.YesNo: buttonToUse = OLEMSGBUTTON.OLEMSGBUTTON_YESNO; break; case VSDialogButton.YesNoCancel: buttonToUse = OLEMSGBUTTON.OLEMSGBUTTON_YESNOCANCEL; break; } OLEMSGDEFBUTTON defaultButtonToUse = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; switch (defaultButton) { case VSDialogDefaultButton.First: defaultButtonToUse = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST; break; case VSDialogDefaultButton.Second: defaultButtonToUse = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND; break; case VSDialogDefaultButton.Third: defaultButtonToUse = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_THIRD; break; case VSDialogDefaultButton.Fourth: defaultButtonToUse = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FOURTH; break; } OLEMSGICON msgIconToUse = OLEMSGICON.OLEMSGICON_INFO; switch (iconMode) { case VSDialogIconMode.Critical: msgIconToUse = OLEMSGICON.OLEMSGICON_CRITICAL; break; case VSDialogIconMode.Info: msgIconToUse = OLEMSGICON.OLEMSGICON_INFO; break; case VSDialogIconMode.NoIcon: msgIconToUse = OLEMSGICON.OLEMSGICON_NOICON; break; case VSDialogIconMode.Query: msgIconToUse = OLEMSGICON.OLEMSGICON_QUERY; break; case VSDialogIconMode.Warning: msgIconToUse = OLEMSGICON.OLEMSGICON_WARNING; break; } Guid clsid = Guid.Empty; int result; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(UIShell.ShowMessageBox( 0, ref clsid, caption, message, string.Empty, 0, buttonToUse, defaultButtonToUse, msgIconToUse, systemModal ? 1 : 0, out result)); switch (result) { case NativeMethods.IDABORT: return(VSDialogResult.Abort); case NativeMethods.IDCANCEL: return(VSDialogResult.Cancel); case NativeMethods.IDIGNORE: return(VSDialogResult.Ignore); case NativeMethods.IDNO: return(VSDialogResult.No); case NativeMethods.IDOK: return(VSDialogResult.Ok); case NativeMethods.IDRETRY: return(VSDialogResult.Retry); case NativeMethods.IDYES: return(VSDialogResult.Yes); default: return(VSDialogResult.Ok); } }