private void ShowStatus(string message) { HideStatus(); var currentTreeView = CurrentTreeView; if (null != currentTreeView) { // dpi/scaling may have changed since the last time we showed a status using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { _statusLabel = new Label { BackColor = currentTreeView.TreeViewControl.BackColor, Size = currentTreeView.ClientSize, Location = new Point( currentTreeView.Left + SystemInformation.Border3DSize.Width, currentTreeView.Top + SystemInformation.Border3DSize.Height), TextAlign = ContentAlignment.MiddleCenter, Anchor = currentTreeView.Anchor, Text = message }; var tabPage = AddUpdateDeleteTabControl.SelectedTab; tabPage.Controls.Add(_statusLabel); tabPage.Controls.SetChildIndex(_statusLabel, 0); } } }
static void Main() { DpiAwareness.EnableDefault(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMainConvertor()); }
public object?LaunchGame(IGameRunner runner, string sessionId, int region, int expansionLevel, bool isSteamServiceAccount, string additionalArguments, DirectoryInfo gamePath, bool isDx11, ClientLanguage language, bool encryptArguments, DpiAwareness dpiAwareness) { Log.Information( $"XivGame::LaunchGame(steamServiceAccount:{isSteamServiceAccount}, args:{additionalArguments})"); var exePath = Path.Combine(gamePath.FullName, "game", "ffxiv_dx11.exe"); if (!isDx11) { exePath = Path.Combine(gamePath.FullName, "game", "ffxiv.exe"); } var environment = new Dictionary <string, string>(); var argumentBuilder = new ArgumentBuilder() .Append("DEV.DataPathType", "1") .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString()) .Append("DEV.TestSID", sessionId) .Append("DEV.UseSqPack", "1") .Append("SYS.Region", region.ToString()) .Append("language", ((int)language).ToString()) .Append("resetConfig", "0") .Append("ver", Repository.Ffxiv.GetVer(gamePath)); if (isSteamServiceAccount) { // These environment variable and arguments seems to be set when ffxivboot is started with "-issteam" (27.08.2019) environment.Add("IS_FFXIV_LAUNCH_FROM_STEAM", "1"); argumentBuilder.Append("IsSteam", "1"); } // This is a bit of a hack; ideally additionalArguments would be a dictionary or some KeyValue structure if (!string.IsNullOrEmpty(additionalArguments)) { var regex = new Regex(@"\s*(?<key>[^=]+)\s*=\s*(?<value>[^\s]+)\s*", RegexOptions.Compiled); foreach (Match match in regex.Matches(additionalArguments)) { argumentBuilder.Append(match.Groups["key"].Value, match.Groups["value"].Value); } } if (!File.Exists(exePath)) { throw new BinaryNotPresentException(exePath); } var workingDir = Path.Combine(gamePath.FullName, "game"); var arguments = encryptArguments ? argumentBuilder.BuildEncrypted() : argumentBuilder.Build(); return(runner.Start(exePath, workingDir, arguments, environment, dpiAwareness)); }
private static void Main() { Settings.Initialize(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { Application.Run(new MainHidden()); } }
// <summary> // Helper to hide the status message Label control // </summary> public void HideStatus() { if (_statusLabel != null) { using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { Controls.Remove(_statusLabel); _statusLabel = null; } } }
static Application() { if (MonitorAware) { DpiAwareness.SetDpiAware(DpiAwareness.ProcessDpiAwareness.MonitorAware); } else { DpiAwareness.SetDpiAware(DpiAwareness.ProcessDpiAwareness.SystemAware); } }
// <summary> // Helper to hide the status message Label control // </summary> private void HideStatus() { if (_statusLabel != null) { using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { AddUpdateDeleteTabControl.SelectedTab.Controls.Remove(_statusLabel); _statusLabel = null; } } }
public static void RunNewForm() { using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { Type.GetType("Clipboard_Cycler.Program").GetMethod($"RunForm{Settings.Mode}").Invoke(null, null); } if (FormThread != null) { FormThread.SetApartmentState(ApartmentState.STA); FormThread.Start(); } }
public MappingDetailsWindowContainer(MappingDetailsWindow toolWindow, Control mainControl) { Debug.Assert(toolWindow != null, "toolWindow is null."); Debug.Assert(mainControl != null, "mainControl is null."); _toolWindow = toolWindow; InitializeComponent(); // ensure the colors for the watermark LinkLabel are correct by VS UX SetWatermarkThemedColors(); // hide the watermark watermarkLabel.Visible = false; watermarkLabel.LinkClicked += watermarkLabel_LinkClicked; // add main control hosted in the tool window _mainControl = mainControl; mainControl.TabIndex = 0; mainControl.Bounds = new Rectangle(1, 1, 50, 50); mainControl.Anchor = AnchorStyles.Left | AnchorStyles.Top; mainControl.Dock = DockStyle.Fill; contentsPanel.Controls.Add(mainControl); // adjust control sizes var colorHintStripWidth = 3; toolbar.ImageScalingSize = DpiAwareness.LogicalToDeviceSize(toolbar, toolbar.ImageScalingSize); foreach (var button in toolbar.Items.OfType <ToolStripButton>()) { button.Size = DpiAwareness.LogicalToDeviceSize(toolbar, button.Size); } colorHintStripWidth = DpiAwareness.LogicalToDeviceUnits(contentsPanel, colorHintStripWidth); contentsPanel.Padding = new Padding(colorHintStripWidth, 0, 0, 0); // By default set mainControl as a top control contentsPanel.Controls.SetChildIndex(mainControl, 0); // protect against unhandled exceptions in message loop. WindowTarget = new SafeWindowTarget(_toolWindow, WindowTarget); SafeWindowTarget.ReplaceWindowTargetRecursive(_toolWindow, Controls, false); // set color table for toolbar to use system colors toolbar.Renderer = GetToolbarRenderer(); SetToolbarThemedColors(); UpdateToolbar(); }
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider) { IDialogVisualizerService modalService = windowService ?? throw new ApplicationException("This debugger does not support modal visualizers"); WinForms.IWin32Window parentWindow = windowService as WinForms.IWin32Window ?? throw new ApplicationException("This debugger does not support modal visualizers"); using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.PerMonitorAwareV2)) { Grid2VisualizerWindow window = new Grid2VisualizerWindow((IVisualizerObjectProvider2)objectProvider); window.SetOwner(parentWindow.Handle); window.RemoveIcon(); window.RemoveMinButton(); window.ShowDialog(); } }
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider) { if (windowService == null) { throw new ArgumentNullException(nameof(windowService), "This debugger does not support modal visualizers."); } if (objectProvider == null) { throw new ArgumentNullException(nameof(objectProvider)); } #if VS16 using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) #endif using (var imageForm = new ImageForm(objectProvider)) { windowService.ShowDialog(imageForm); } }
public SccHistoryToolWindow() : base(null) { // set the window title this.Caption = Resources.SccHistoryToolWindow_Caption; // set the icon for the frame #if VS2008 this.BitmapResourceID = 507; // CommandId.ibmpHistoryToolWindowsImage; // bitmap strip resource ID this.BitmapIndex = 0; // index in the bitmap strip #else this.BitmapResourceID = 508; // CommandId.ibmpHistoryToolWindowsImage; // bitmap strip resource ID this.BitmapIndex = 0; // index in the bitmap strip #endif using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { control = new SccHistoryToolWindowControl(); } }
public LabelsToolWindow() : base(null) { // set the window title this.Caption = Resources.LabelsToolWindowControl_Caption; //// set the CommandID for the window ToolBar //this.ToolBar = new CommandID(GuidList.guidP4VsProviderCmdSet, CommandId.imnuToolWindowToolbarMenu); // set the icon for the frame this.BitmapResourceID = CommandId.ibmpToolWindowsImages; // bitmap strip resource ID this.BitmapIndex = CommandId.iconlabels; // index in the bitmap strip using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { control = new LabelsToolWindowControl(); control.Dock = DockStyle.Fill; } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { // Create the window with the unused ID. using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { var obj = new frmExtension(); obj.Show(); } //string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName); //string title = "CreateCrud"; //// Show a message box to prove we were here //VsShellUtilities.ShowMessageBox( // this.ServiceProvider, // message, // title, // OLEMSGICON.OLEMSGICON_INFO, // OLEMSGBUTTON.OLEMSGBUTTON_OK, // OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); }
public frmMain() { DpiAwareness.Set(DpiAwareness.Mode.SystemDpiAware); InitializeComponent(); #if DEBUG openFile("..\\..\\test.asm"); #else openToolStripMenuItem_Click(null, null); #endif BringToFront(); defaultFont = new Font(txtEAX.Font, FontStyle.Regular); changedFont = new Font(txtEAX.Font, FontStyle.Bold); txtMarked = new TextBox[] { txtEAX, txtEBX, txtECX, txtEDX, txtESP, txtEBP, txtCarry, txtOverflow, txtParity, txtSign, txtZero }; foreach (TextBox txt in txtMarked) { txt.TextChanged += ((sender, e) => { (sender as TextBox).Font = changedFont; }); } }
public JobsToolWindow() : base(null) { // set the window title this.Caption = Resources.JobsToolWindow_Caption; // set the CommandID for the window ToolBar //this.ToolBar = new CommandID(GuidList.guidP4VsProviderCmdSet, CommandId.imnuToolWindowToolbarMenu); // set the icon for the frame #if VS2008 this.BitmapResourceID = 507; // bitmap strip resource ID this.BitmapIndex = 4; // index in the bitmap strip #else this.BitmapResourceID = 508; // bitmap strip resource ID this.BitmapIndex = 4; // index in the bitmap strip #endif using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { control = new JobsToolWindowControl(); control.Dock = DockStyle.Fill; } }
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider) { if (windowService is null) { throw new ArgumentNullException("windowService"); } if (objectProvider is null) { throw new ArgumentNullException("objectProvider"); } //var page = new UWPForm(); //var rootFrame = Windows.UI.Xaml.Window.Current.Content as Windows.UI.Xaml.Controls.Frame; //rootFrame.Content = page; using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) using (var imageForm = new ImageForm(objectProvider)) { windowService.ShowDialog(imageForm); } }
public void ShowStatus(string message) { HideStatus(); // dpi/scaling may have changed since the last time we showed a status using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { _statusLabel = new Label { BackColor = TreeViewControl.BackColor, Size = ClientSize, Location = new Point( Left + SystemInformation.Border3DSize.Width, Top + SystemInformation.Border3DSize.Height), TextAlign = ContentAlignment.MiddleCenter, Anchor = Anchor, Text = message }; Controls.Add(_statusLabel); Controls.SetChildIndex(_statusLabel, 0); } }
public static extern int SetProcessDpiAwareness(DpiAwareness processDpiAwareness);
public static extern int SetProcessDpiAwareness( [MarshalAs(UnmanagedType.I4)] DpiAwareness PROCESS_DPI_AWARENESS);
private static extern HResult SetProcessDpiAwareness(DpiAwareness dpiAwareness);
private static extern int GetProcessDpiAwareness(IntPtr processHandle, out DpiAwareness value);
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { _targetPath = replacementsDictionary["$destinationdirectory$"]; _projectName = replacementsDictionary["$projectname$"]; ValidateProjectName(); if (runKind == WizardRunKind.AsMultiProject) { _dte = (DTE2)automationObject; } using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) { using DialogParentWindow owner = new DialogParentWindow(IntPtr.Zero, enableModeless: true, VisualStudioServiceProvider); using UnoOptions targetPlatformWizardPicker = new UnoOptions(VisualStudioServiceProvider); switch (targetPlatformWizardPicker.ShowDialog(owner)) { case DialogResult.OK: _useWebAssembly = targetPlatformWizardPicker.UseWebAssembly; _useiOS = targetPlatformWizardPicker.UseiOS; _useAndroid = targetPlatformWizardPicker.UseAndroid; _useCatalyst = targetPlatformWizardPicker.UseCatalyst; _useAppKit = targetPlatformWizardPicker.UseAppKit; _useGtk = targetPlatformWizardPicker.UseGtk; _useFramebuffer = targetPlatformWizardPicker.UseFramebuffer; _useWpf = targetPlatformWizardPicker.UseWpf; _useWinUI = targetPlatformWizardPicker.UseWinUI; replacementsDictionary["$UseWebAssembly$"] = _useWebAssembly.ToString(); replacementsDictionary["$UseIOS$"] = _useiOS.ToString(); replacementsDictionary["$UseAndroid$"] = _useAndroid.ToString(); replacementsDictionary["$UseCatalyst$"] = _useCatalyst.ToString(); replacementsDictionary["$UseAppKit$"] = _useAppKit.ToString(); replacementsDictionary["$UseGtk$"] = _useGtk.ToString(); replacementsDictionary["$UseFrameBuffer$"] = _useFramebuffer.ToString(); replacementsDictionary["$UseWPF$"] = _useWpf.ToString(); replacementsDictionary["$UseWinUI$"] = _useWinUI.ToString(); replacementsDictionary["$ext_safeprojectname$"] = replacementsDictionary["$safeprojectname$"]; _replacementDictionary = replacementsDictionary.ToDictionary(p => p.Key, p => p.Value); var version = GetVisualStudioReleaseVersion(); if (version < new Version(17, 3) && (_useiOS || _useAndroid || _useCatalyst || _useAppKit)) { MessageBox.Show("iOS, Android, Mac Catalyst, and mac AppKit are only supported starting from Visual Studio 17.3 Preview 1 or later.", "Unable to create the solution"); throw new WizardCancelledException(); } break; case DialogResult.Abort: MessageBox.Show("Aborted" /*targetPlatformWizardPicker.Error*/); throw new WizardCancelledException(); default: throw new WizardBackoutException(); } } }
public static extern bool SetProcessDpiAwareness(DpiAwareness awareness);
public static extern void GetProcessDpiAwareness(IntPtr hProcess, out DpiAwareness awareness);
public static extern HResult GetProcessDpiAwareness(IntPtr processHandle, out DpiAwareness value);
private static extern IntPtr SetProcessDpiAwareness([In] DpiAwareness dpiAwareness);
public MainWindow() { InitializeComponent(); double primaryMonitorDPI = 96f; var colors = new Brush[] { Brushes.Green, Brushes.Blue, Brushes.Red }; var screens = System.Windows.Forms.Screen.AllScreens; List <ScreenInfo> screenInfoList = new List <ScreenInfo>(); workAreaWindows = new List <OverlayWindow>(); var monitors = MonitorsInfo.GetMonitors(); for (int i = 0; i < screens.Length; i++) { if (screens[i].Primary) { double monitorDPI; DpiAwareness.GetMonitorDpi(monitors[i].MonitorHandle, out monitorDPI, out monitorDPI); primaryMonitorDPI = monitorDPI; break; } } for (int i = 0; i < screens.Length; i++) { var monitor = monitors[i]; ScreenInfo screenInfo = new ScreenInfo(); var window = new OverlayWindow { Opacity = 0.8, Background = colors[i % colors.Length], BorderBrush = Brushes.White, BorderThickness = new Thickness(4, 4, 4, 4) }; // get monitor dpi double monitorDPI; DpiAwareness.GetMonitorDpi(monitors[i].MonitorHandle, out monitorDPI, out monitorDPI); screenInfo.MonitorDPI = (int)monitorDPI; // resolution screenInfo.Resolution = new Rect(monitor.MonitorInfo.monitor.left, monitor.MonitorInfo.monitor.top, monitor.MonitorInfo.monitor.width, monitor.MonitorInfo.monitor.height); // work area Rect workedArea = new Rect(monitor.MonitorInfo.work.left, monitor.MonitorInfo.work.top, monitor.MonitorInfo.work.width, monitor.MonitorInfo.work.height); double scalePosition = 96f / primaryMonitorDPI; workedArea.X *= scalePosition; workedArea.Y *= scalePosition; double scaleSize = 96f / monitorDPI; workedArea.Width *= scaleSize; workedArea.Height *= scaleSize; screenInfo.WorkArea = workedArea; screenInfo.WindowDPI = window.GetDpiX(); screenInfoList.Add(screenInfo); // open window window.Left = workedArea.X; window.Top = workedArea.Y; window.Width = workedArea.Width; window.Height = workedArea.Height; workAreaWindows.Add(window); window.Show(); } MonitorList.ItemsSource = screenInfoList; }
public static extern HResult SetProcessDpiAwareness(DpiAwareness dpiAwareness);
public object?Start(string path, string workingDirectory, string arguments, IDictionary <string, string> environment, DpiAwareness dpiAwareness) { var gameProcess = NativeAclFix.LaunchGame(workingDirectory, path, arguments, environment, dpiAwareness, process => { if (this.dalamudOk && this.loadMethod == DalamudLoadMethod.EntryPoint) { Log.Verbose("[WindowsGameRunner] Now running OEP rewrite"); this.dalamudLauncher.Run(process.Id); } }); if (this.dalamudOk && this.loadMethod == DalamudLoadMethod.DllInject) { Log.Verbose("[WindowsGameRunner] Now running DLL inject"); this.dalamudLauncher.Run(gameProcess.Id); } return(gameProcess); }