public IUILayoutParam(AnchorStyles anchorStyle, Padding padding, System.Drawing.Size size, int zNear = -1000, int zFar = 1000) { // TODO: Complete member initialization this.Anchor = anchorStyle; this.Margin = padding; this.Size = size; this.zNear = zNear; this.zFar = zFar; }
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (msg) { case Win32.WM_MOVING: // 窗体移动的消息,控制窗体不会移出屏幕外 if (DataUtils.LastSelectItem != null) { DataUtils.LastSelectItem.Background = Brushes.Transparent; DataUtils.LastSelectItem = null; } if (this.SettingFlyout.IsOpen) { this.SettingFlyout.IsOpen = false; } int left = Marshal.ReadInt32(lParam, 0); int top = Marshal.ReadInt32(lParam, 4); int right = Marshal.ReadInt32(lParam, 8); int bottom = Marshal.ReadInt32(lParam, 12); left = Math.Min(Math.Max(0, left), Forms.Screen.PrimaryScreen.Bounds.Width - (int)this.Width); top = Math.Min(Math.Max(0, top), Forms.Screen.PrimaryScreen.Bounds.Height - (int)this.Height); right = Math.Min(Math.Max((int)this.Width, right), Forms.Screen.PrimaryScreen.Bounds.Width); bottom = Math.Min(Math.Max((int)this.Height, bottom), Forms.Screen.PrimaryScreen.Bounds.Height); Marshal.WriteInt32(lParam, 0, left); Marshal.WriteInt32(lParam, 4, top); Marshal.WriteInt32(lParam, 8, right); Marshal.WriteInt32(lParam, 12, bottom); _anchors = Forms.AnchorStyles.None; if (left <= OFFSET) { _anchors |= Forms.AnchorStyles.Left; } if (top <= OFFSET) { _anchors |= Forms.AnchorStyles.Top; } if (bottom >= Forms.Screen.PrimaryScreen.Bounds.Height - OFFSET) { _anchors |= Forms.AnchorStyles.Bottom; } if (right >= Forms.Screen.PrimaryScreen.Bounds.Width - OFFSET) { _anchors |= Forms.AnchorStyles.Right; } _timer.Enabled = _anchors != Forms.AnchorStyles.None; break; } // Handle the message. return(IntPtr.Zero); }