private void OnLoaded(object sender, RoutedEventArgs e) { var point = GetWindowPosition(ActualWidth.RoundToInt(), ActualHeight.RoundToInt()); Left = point.X; Top = point.Y; }
/// <summary> /// Initializes a new instance of the <see cref="AppPage"/> class. /// </summary> public AppPage() { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } // When this page is part of the visual tree make two changes: // 1) Map application view state to visual state for the page // 2) Handle keyboard and mouse navigation requests Loaded += (sender, e) => { StartLayoutUpdates(sender, e); // Keyboard and mouse navigation only apply when occupying the entire window if (ActualHeight.Equals(Window.Current.Bounds.Height) && ActualWidth.Equals(Window.Current.Bounds.Width)) { // Listen to the window directly so focus isn't required Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += CoreDispatcher_AcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed; } }; // Undo the same changes when the page is no longer visible Unloaded += (sender, e) => { StopLayoutUpdates(sender, e); Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= CoreDispatcher_AcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed -= CoreWindow_PointerPressed; }; }
public override int GetHashCode() { var hashCode = -1295356442; hashCode = hashCode * -1521134295 + RawPixelWidth.GetHashCode(); hashCode = hashCode * -1521134295 + ActualWidth.GetHashCode(); hashCode = hashCode * -1521134295 + ActualHeight.GetHashCode(); return(hashCode); }
private void HandleMouseUp([NotNull] object sender, [NotNull] MouseButtonEventArgs e) { Debug.ArgumentNotNull(sender, nameof(sender)); Debug.ArgumentNotNull(e, nameof(e)); IsMouseDown = false; Mouse.Capture(null); e.Handled = true; AppHost.Settings.Set("ContentEditor\\InfoPane", "Height", ActualHeight.ToString()); }
/// <summary> /// 切换鼠标指针为默认状态 /// </summary> private void MainWindow_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Cursor = ((TextBlock)CursorDictionary["CursorPointer"]).Cursor; var dictionary = new Dictionary <string, string> { { "Width", ActualWidth.ToString(CultureInfo.InvariantCulture) }, { "Height", ActualHeight.ToString(CultureInfo.InvariantCulture) } }; IniFileIo.IniFileWrite("DedicatedServerConfigure", "Window", dictionary); }
private void ResizeWindow(ResizeDirection direction) { SendMessage(_hwndSource.Handle, WmSyscommand, (IntPtr)(61440 + direction), IntPtr.Zero); var systemWorkAreaRect = SystemParameters.WorkArea; if (Width == systemWorkAreaRect.Width && Height == systemWorkAreaRect.Height) { UiBtnMaximized.Visibility = Visibility.Collapsed; UiBtnNormal.Visibility = Visibility.Visible; } else { UiBtnMaximized.Visibility = Visibility.Visible; UiBtnNormal.Visibility = Visibility.Collapsed; } var dictionary = new Dictionary <string, string> { { "Width", ActualWidth.ToString(CultureInfo.InvariantCulture) }, { "Height", ActualHeight.ToString(CultureInfo.InvariantCulture) } }; IniFileIo.IniFileWrite("DedicatedServerConfigure", "Window", dictionary); }
private void SaveConfig() { var isMaximized = WindowState == WindowState.Maximized; ConfigSevice.SetConfig(ConfigKey.WindowMaximized, isMaximized ? "1":"0"); if (!isMaximized) { ConfigSevice.SetConfig(ConfigKey.WindowSize, string.Format("{0},{1}", ActualWidth.ToString("F"), ActualHeight.ToString("F"))); } ConfigSevice.SetConfig(ConfigKey.WindowOpacity, Opacity.ToString("F")); ConfigSevice.SetConfig(ConfigKey.Background, (BdBackground.Background as SolidColorBrush).Color.ToString()); ConfigSevice.SetConfig(ConfigKey.FontSize, sFontSize.Value.ToString("F")); ConfigSevice.SetConfig(ConfigKey.FontBrightness, sBrightness.Value.ToString("F")); }