Example #1
0
        public static void GoFullScreen(this Window window)
        {
            if (IsFullScreen(window))
            {
                return;
            }

            windowState = window.WindowState;
            windowStyle = window.WindowStyle;
            windowTopmost = window.Topmost;
            windowResizeMode = window.ResizeMode;
            windowRect.X = window.Left;
            windowRect.Y = window.Top;
            windowRect.Width = window.Width;
            windowRect.Height = window.Height;

            window.WindowState = WindowState.Maximized;
            window.WindowStyle = WindowStyle.None;
            windowTopmost = false;
            windowResizeMode = ResizeMode.NoResize;
            IntPtr handle = new WindowInteropHelper(window).Handle;
            Screen screen = Screen.FromHandle(handle);
            window.Width = screen.Bounds.Width;
            window.Height = screen.Bounds.Height;

            fullWindow = window;
        }
        public static void ToFullscreen(this Window window)
        {
            if (window.IsFullscreen())
            { 
                return; 
            }
   
            _windowState = window.WindowState;
            _windowStyle = window.WindowStyle;
            _windowTopMost = window.Topmost;
            _windowResizeMode = window.ResizeMode;
            _windowRect.X = window.Left;
            _windowRect.Y = window.Top;
            _windowRect.Width = window.Width;
            _windowRect.Height = window.Height;

            window.WindowState = WindowState.Normal; 
            window.WindowStyle = WindowStyle.None;
            window.ResizeMode = ResizeMode.NoResize;
            window.Topmost = true; 

          
            var handle = new WindowInteropHelper(window).Handle; 
            Screen screen = Screen.FromHandle(handle); 
            window.MaxWidth = screen.Bounds.Width;
            window.MaxHeight = screen.Bounds.Height;
            window.WindowState = WindowState.Maximized;
             
            window.Activated += new EventHandler(window_Activated);
            window.Deactivated += new EventHandler(window_Deactivated); 
            _fullWindow = window;
        }
Example #3
0
        public void AddPopupWindow(Control _TargetControl, Control _PopupControl, PopupEvent _PStyle,WindowStyle _WStyle, int _width, int _height,bool _ismouseclickhide)
        {
            PopupContent popup = new PopupContent();
            popup.TargetControl = _TargetControl;
            popup.PopupControl = _PopupControl;
            popup.PType = PopupType.Window;
            popup.PStyle = _PStyle;
            popup.WStyle = _WStyle;
            popup.Width = _width;
            popup.Height = _height;
            popup.IsMCHide = _ismouseclickhide;
            popup.WindowTitle = "";

            _PopupControl.Tag = this;

            if (popup.PStyle == PopupEvent.Click)
            {
                _TargetControl.Click += new EventHandler(_TargetControl_Click);
            }
            else if (popup.PStyle == PopupEvent.Mouse)
            {
                _TargetControl.MouseEnter += new EventHandler(_TargetControl_MouseEnter);
                _TargetControl.MouseLeave += new EventHandler(_TargetControl_MouseLeave);
            }
            else
            {

            }

            popupList.Add(popup);

            _PopupControl.Hide();
        }
Example #4
0
 public static void CheckIfWindowStyleIsFullscreen(WindowStyle w)
 {
     if (w.Equals(WindowStyle.Fullscreen))
         MessageBox.Show("Your windowstyle seems to be \"Fullscreen\".\n" +
                         "If you want to use this tool, change the\n" +
                         "Windowstyle to \"Windowed\" or \"Windowed Fullscreen\"\n" +
                         "to have the best experience!", "Windowstyle");
 }
Example #5
0
 RadioButton CreateRadioButton(string strText, WindowStyle winstyle)
 {
     RadioButton radio = new RadioButton();
     radio.Content = strText;
     radio.Tag = winstyle;
     radio.Margin = new Thickness(5);
     radio.IsChecked = (winstyle == WindowStyle);
     return radio;
 }
Example #6
0
		static void InitWithContentRectStyleMaskBackingDefer(ref IntPtr nativePointer, Rectangle contentRect, WindowStyle windowStyle, SafeNativeMethods.BackingStoreType bufferingType, bool deferCreation)
		{
			nativePointer = ObjectiveC.LP64 ?
				objc_msgSend_initWithContentRect_styleMask_backing_defer_64(
					nativePointer, Selectors.InitWithContentRectStyleMaskBackingDefer,
					contentRect, (long)windowStyle, (long)bufferingType, deferCreation) :
				objc_msgSend_initWithContentRect_styleMask_backing_defer_32(
					nativePointer, Selectors.InitWithContentRectStyleMaskBackingDefer,
					contentRect, (int)windowStyle, (int)bufferingType, deferCreation);
		}
Example #7
0
 public WindowProfile(string title, WindowStyle style, ExtendedWindowStyle extStyle, int x, int y, int width, int height)
 {
     Title = title;
     WindowStyle = style;
     ExtendedWindowStyle = extStyle;
     X = x;
     Y = y;
     Width = width;
     Height = height;
 }
 MenuItem CreateMenuItem(string str, WindowStyle style)
 {
     MenuItem item = new MenuItem();
     item.Header = str;
     item.Tag = style;
     item.IsChecked = (style == WindowStyle);
     item.Click += StyleOnClick;
     if (item.IsChecked)
         itemChecked = item;
     return item;
 }
 MenuItem CreateMenuItem(string str, WindowStyle style)
 {
     MenuItem item = new MenuItem();
     item.Header = str;
     item.Tag = style;
     item.IsChecked = (style == WindowStyle);
     item.Click += styleonclick;                         // 메뉴 생성과 동시에 같은 이벤트를 설정한다.
     if (item.IsChecked)
         itemchecked = item;
     return item;
 }
Example #10
0
        /// <summary>
        /// Sets the window's fullscreen state.
        /// </summary>
        /// <param name="fullScreen">True for fullscreen, false otherwise.</param>
        public void SetFullScreen( bool fullScreen = true )
        {
            if ( fullScreen == IsFullScreen )
                return;

            if ( fullScreen && !IsFullScreen )
            {
                oldState = Player.windowData.Window.WindowState;
                oldStyle = Player.windowData.Window.WindowStyle;
            }

            Player.windowData.Window.ResizeMode = fullScreen ? ResizeMode.NoResize : ResizeMode.CanResize;
            Player.windowData.Window.ShowTitleBar = !fullScreen;
            Player.windowData.Window.ShowCloseButton = !fullScreen;
            Player.windowData.Window.WindowStyle = fullScreen ? WindowStyle.None : oldStyle;
            Player.windowData.Window.WindowState = fullScreen ? WindowState.Maximized : oldState;

            IsFullScreen = fullScreen;
            OnFullscreenChanged?.Invoke( this, new OnFullscreenChangedEventArgs( IsFullScreen ) );
        }
Example #11
0
        /// <summary>  
        /// 进入全屏  
        /// </summary>  
        /// <param name="window"></param>  
        public static void GoFullscreen(this Window window)
        {
            //已经是全屏  
            if (window.IsFullscreen()) return;

            //存储窗体信息  
            _windowState = window.WindowState;
            _windowStyle = window.WindowStyle;
            _windowTopMost = window.Topmost;
            _windowResizeMode = window.ResizeMode;
            _windowRect.X = window.Left;
            _windowRect.Y = window.Top;
            _windowRect.Width = window.Width;
            _windowRect.Height = window.Height;


            //变成无边窗体  
            window.WindowState = WindowState.Normal;//假如已经是Maximized,就不能进入全屏,所以这里先调整状态  
            window.WindowStyle = WindowStyle.None;
            window.ResizeMode = ResizeMode.NoResize;
            window.Topmost = true;//最大化后总是在最上面  

            //获取窗口句柄   
            var handle = new WindowInteropHelper(window).Handle;

            //获取当前显示器屏幕  
            Screen screen = Screen.FromHandle(handle);

            //调整窗口最大化,全屏的关键代码就是下面3句  
            window.MaxWidth = screen.Bounds.Width;
            window.MaxHeight = screen.Bounds.Height;
            window.WindowState = WindowState.Maximized;


            //解决切换应用程序的问题  
            window.Activated += new EventHandler(window_Activated);
            window.Deactivated += new EventHandler(window_Deactivated);

            //记住成功最大化的窗体  
            _fullWindow = window;
        }
Example #12
0
 public WindowDelegate(NavigationWindow window)
 {
     _window = window;
     _dispatcher = window.Dispatcher;
     _scenes = new List<Scene>();
     _resources = new Dictionary<string, ResourceDictionary>();
     _sceneIndex = -1;
     _windowRect = new Rect();
     _dispatcher.Invoke(() =>
     {
         _windowTopmost = window.Topmost;
         _windowState = window.WindowState;
         _windowStyle = window.WindowStyle;
         _windowResizemode = window.ResizeMode;
         _windowRect.X = window.Left;
         _windowRect.Y = window.Top;
         _windowRect.Width = window.Width;
         _windowRect.Height = window.Height;
         window.LoadCompleted += (sender, e) => NavigateFinished();
     });
 }
Example #13
0
        /// <summary>
        /// ����ȫ��
        /// </summary>
        /// <param name="window"></param>
        public static void GoFullscreen(this Window window)
        {
            //�Ѿ���ȫ��
            if(window.IsFullscreen()) return;

            //�洢������Ϣ
            _windowState = window.WindowState;
            _windowStyle = window.WindowStyle;
            _windowTopMost = window.Topmost;
            _windowResizeMode = window.ResizeMode;
            _windowRect.X = window.Left;
            _windowRect.Y = window.Top;
            _windowRect.Height = window.Width;
            _windowRect.Height = window.Height;

            //����ޱߴ���
            window.WindowState = WindowState.Normal;//�����Ѿ���Maximized���Ͳ��ܽ���ȫ�������������ȵ���״̬
            window.WindowStyle = WindowStyle.None;
            window.ResizeMode = ResizeMode.NoResize;
            window.Topmost = true;//��󻯺�������������

            //��ȡ���ھ��
            var handle = new WindowInteropHelper(window).Handle;

            //��ȡ��ǰ��ʾ����Ļ
            Screen screen = Screen.FromHandle(handle);

            //�����������,ȫ���Ĺؼ������������3��
            window.MaxWidth = screen.Bounds.Width;
            window.MaxHeight = screen.Bounds.Height;
            window.WindowState = WindowState.Maximized;

            //����л�Ӧ�ó��������
            window.Activated += new EventHandler(window_Activated);
            window.Deactivated += new EventHandler(window_Deactivated);

            //��ס�ɹ���󻯵Ĵ���
            _fullWindow = window;
        }
        /// <summary>
        /// Get a new Material based on climate.
        /// </summary>
        /// <param name="key">Material key.</param>
        /// <param name="climate">New climate base.</param>
        /// <param name="season">New season.</param>
        /// <param name="windowStyle">New window style.</param>
        /// <returns>New material.</returns>
        public Material ChangeClimate(int key, ClimateBases climate, ClimateSeason season, WindowStyle windowStyle)
        {
            // Ready check
            if (!IsReady)
                return null;

            // Reverse key and apply climate
            int archive, record, frame;
            ReverseTextureKey(key, out archive, out record, out frame);
            archive = ClimateSwaps.ApplyClimate(archive, record, climate, season);

            // Get new material
            Material material;
            CachedMaterial cm = GetMaterialFromCache(archive, record, out material);

            // Handle windows
            if (cm.isWindow)
            {
                ChangeWindowEmissionColor(material, windowStyle);
            }

            return material;
        }
Example #15
0
 public void Initialize(IWindowFrameEventSink sink, PopupWindow.PopupType type)
 {
     Initialize();
     defaultWindowStyle = WindowStyle.ToolWindow;
     Decorated          = false;
 }
Example #16
0
 private void SetFullScreen()
 {
     _windowState = _window.WindowState;
     _windowStyle = _window.WindowStyle;
     _windowResizemode = _window.ResizeMode;
     _windowRect.X = _window.Left;
     _windowRect.Y = _window.Top;
     _windowRect.Width = _window.Width;
     _windowRect.Height = _window.Height;
     _window.WindowState = WindowState.Normal;
     _window.WindowStyle = WindowStyle.None;
     _window.ResizeMode = ResizeMode.NoResize;
     _window.Topmost = true;
     _window.Left = 0;
     _window.Top = 0;
     _window.Width = SystemParameters.PrimaryScreenWidth;
     _window.Height = SystemParameters.PrimaryScreenHeight;
     _window.Activated += Window_Active;
     _window.Deactivated += Window_Deactive;
 }
Example #17
0
        public ShellView()
        {
            InitializeComponent();

            default_window_style = WindowStyle;
        }
Example #18
0
 internal static extern IntPtr CreateWindowEx(
     ExtendedWindowStyle ExStyle,
     IntPtr ClassAtom,
     IntPtr WindowName,
     WindowStyle Style,
     int X, int Y,
     int Width, int Height,
     IntPtr HandleToParentWindow,
     IntPtr Menu,
     IntPtr Instance,
     IntPtr Param);
 public void AddStyle(WindowStyle style)
 {
     var oldStyle = GetStyle();
     var newStyle = (oldStyle | style);
     SetStyle(newStyle);
 }
Example #20
0
 public static T WindowStyle <T>(this T target, WindowStyle value) where T : Window
 {
     target.WindowStyle = value;
     return(target);
 }
Example #21
0
 public int SetShowCmd(WindowStyle showCmd)
 {
     return(psl.SetShowCmd((int)showCmd));
 }
Example #22
0
 public static extern int SetWindowLong(IntPtr hWnd, int nIndex, WindowStyle dwNewLong);
        /// <summary>
        /// Get a new Material based on climate.
        /// </summary>
        /// <param name="key">Material key.</param>
        /// <param name="climate">New climate base.</param>
        /// <param name="season">New season.</param>
        /// <param name="windowStyle">New window style.</param>
        /// <returns>New material.</returns>
        public Material ChangeClimate(int key, ClimateBases climate, ClimateSeason season, WindowStyle windowStyle)
        {
            // Ready check
            if (!IsReady)
            {
                return(null);
            }

            // Reverse key and apply climate
            int archive, record, frame;

            ReverseTextureKey(key, out archive, out record, out frame);
            archive = ClimateSwaps.ApplyClimate(archive, record, climate, season);

            // Get new material
            Material       material;
            CachedMaterial cm = GetMaterialFromCache(archive, record, out material);

            // Handle windows
            if (cm.isWindow)
            {
                ChangeWindowEmissionColor(material, windowStyle);
            }

            return(material);
        }
Example #24
0
 static extern void XPDrawWindow(int x1, int y1, int x2, int y2, WindowStyle style);
Example #25
0
 public static void DrawWindow(Rectangle rectangle, WindowStyle style)
 {
Example #26
0
        /// <summary>
        /// 创建桌面快捷方便方式
        /// </summary>
        /// <param name="name">快捷方便方式名称</param>
        /// <param name="exePath">执行文件路径(默认为调用的程序集路径)</param>
        /// <param name="iconPath">图标路径(默认使用执行文件的图标)</param>
        /// <param name="windowStyle">窗口风格(默认为普通窗口风格)</param>
        public static void CreateShortcut(string name, string exePath = "", string iconPath = "", WindowStyle windowStyle = WindowStyle.NORMAL)
        {
            WshShell     wshShell = new WshShell();
            IWshShortcut shortcut = wshShell.CreateShortcut(string.Format("{0}{1}{2}.lnk"
                                                                          , Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                                                                          , Path.DirectorySeparatorChar
                                                                          , name)) as IWshShortcut;

            shortcut.TargetPath       = (string.IsNullOrEmpty(exePath) ? Assembly.GetCallingAssembly().Location : exePath);
            shortcut.WorkingDirectory = Environment.CurrentDirectory;
            shortcut.WindowStyle      = (int)windowStyle;
            if (!string.IsNullOrEmpty(iconPath))
            {
                shortcut.IconLocation = iconPath;
            }
            shortcut.Save();
        }
 protected override object OnCoerceWindowStyle( WindowStyle newValue )
 {
   if( newValue != WindowStyle.SingleBorderWindow )
     throw new InvalidOperationException( "Window style on MessageBox is not available." );
   return newValue;
 }
Example #28
0
 protected virtual object OnCoerceWindowStyle(WindowStyle newValue)
 {
     return(newValue);
 }
Example #29
0
 internal static extern bool AdjustWindowRectEx(
     ref Win32Rectangle lpRect,
     WindowStyle dwStyle,
     [MarshalAs(UnmanagedType.Bool)] bool bMenu,
     ExtendedWindowStyle dwExStyle);
Example #30
0
 protected virtual void OnWindowStyleChanged(WindowStyle oldValue, WindowStyle newValue)
 {
 }
 public void RemoveStyle(WindowStyle style)
 {
     var oldStyle = GetStyle();
     var newStyle = ((uint)oldStyle & (~((uint)style)));
     SetStyle((WindowStyle)newStyle);
 }
Example #32
0
        unsafe IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam)
        {
            switch (message)
            {
                #region Size / Move / Style events

            case WindowMessage.ACTIVATE:
                // See http://msdn.microsoft.com/en-us/library/ms646274(VS.85).aspx (WM_ACTIVATE notification):
                // wParam: The low-order word specifies whether the window is being activated or deactivated.
                bool new_focused_state = Focused;
                focused = (wParam.ToInt64() & 0xFFFF) != 0;

                if (new_focused_state != Focused && FocusedChanged != null)
                {
                    FocusedChanged(this, EventArgs.Empty);
                }
                break;

            case WindowMessage.ENTERMENULOOP:
            case WindowMessage.ENTERSIZEMOVE:
            case WindowMessage.EXITMENULOOP:
            case WindowMessage.EXITSIZEMOVE:
                break;

            case WindowMessage.ERASEBKGND:
                return(new IntPtr(1));

            case WindowMessage.WINDOWPOSCHANGED:
                WindowPosition *pos = (WindowPosition *)lParam;
                if (window != null && pos->hwnd == window.handle)
                {
                    Point new_location = new Point(pos->x, pos->y);
                    if (Location != new_location)
                    {
                        bounds.Location = new_location;
                        if (Move != null)
                        {
                            Move(this, EventArgs.Empty);
                        }
                    }

                    Size new_size = new Size(pos->cx, pos->cy);
                    if (Size != new_size)
                    {
                        bounds.Width  = pos->cx;
                        bounds.Height = pos->cy;

                        Win32Rectangle rect;
                        API.GetClientRect(handle, out rect);
                        client_rectangle = rect.ToRectangle();

                        API.SetWindowPos(window.handle, IntPtr.Zero,
                                         bounds.X, bounds.Y, bounds.Width, bounds.Height,
                                         SetWindowPosFlags.NOZORDER | SetWindowPosFlags.NOOWNERZORDER |
                                         SetWindowPosFlags.NOACTIVATE | SetWindowPosFlags.NOSENDCHANGING);
                        if (suppress_resize <= 0 && Resize != null)
                        {
                            Resize(this, EventArgs.Empty);
                        }
                    }
                }
                break;

            case WindowMessage.STYLECHANGED:
                if (wParam.ToInt64() == (long)GWL.STYLE)
                {
                    WindowStyle style = ((StyleStruct *)lParam)->New;
                    if ((style & WindowStyle.Popup) != 0)
                    {
                        hiddenBorder = true;
                    }
                    else if ((style & WindowStyle.ThickFrame) != 0)
                    {
                        hiddenBorder = false;
                    }
                }
                break;

            case WindowMessage.SIZE:
                SizeMessage state     = (SizeMessage)wParam.ToInt64();
                WindowState new_state = windowState;
                switch (state)
                {
                case SizeMessage.RESTORED: new_state = WindowState.Normal; break;

                case SizeMessage.MINIMIZED: new_state = WindowState.Minimized; break;

                case SizeMessage.MAXIMIZED: new_state = hiddenBorder ?
                                                        WindowState.Fullscreen : WindowState.Maximized;
                    break;
                }

                if (new_state != windowState)
                {
                    windowState = new_state;
                    if (WindowStateChanged != null)
                    {
                        WindowStateChanged(this, EventArgs.Empty);
                    }
                }
                break;

                #endregion

                #region Input events

            case WindowMessage.CHAR:
                key_press.KeyChar = (char)wParam.ToInt64();

                if (KeyPress != null)
                {
                    KeyPress(this, key_press);
                }
                break;

            case WindowMessage.MOUSEMOVE:
                Point point = new Point(
                    (short)((uint)lParam.ToInt32() & 0x0000FFFF),
                    (short)(((uint)lParam.ToInt32() & 0xFFFF0000) >> 16));
                mouse.Position = point;

                if (mouse_outside_window)
                {
                    // Once we receive a mouse move event, it means that the mouse has
                    // re-entered the window.
                    mouse_outside_window = false;
                    EnableMouseTracking();

                    if (MouseEnter != null)
                    {
                        MouseEnter(this, EventArgs.Empty);
                    }
                }
                break;

            case WindowMessage.MOUSELEAVE:
                mouse_outside_window = true;
                // Mouse tracking is disabled automatically by the OS

                if (MouseLeave != null)
                {
                    MouseLeave(this, EventArgs.Empty);
                }
                // Set all mouse buttons to off when user leaves window, prevents them being stuck down.
                for (MouseButton btn = 0; btn < MouseButton.LastButton; btn++)
                {
                    mouse[btn] = false;
                }
                break;

            case WindowMessage.MOUSEWHEEL:
                // This is due to inconsistent behavior of the WParam value on 64bit arch, whese
                // wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000
                mouse.Wheel += ((long)wParam << 32 >> 48) / 120.0f;
                return(IntPtr.Zero);

            case WindowMessage.LBUTTONDOWN:
                mouse[MouseButton.Left] = true;
                break;

            case WindowMessage.MBUTTONDOWN:
                mouse[MouseButton.Middle] = true;
                break;

            case WindowMessage.RBUTTONDOWN:
                mouse[MouseButton.Right] = true;
                break;

            case WindowMessage.XBUTTONDOWN:
                keyboard[(((ulong)wParam.ToInt64() >> 16) & 0xFFFF) == 1 ? Key.XButton1 : Key.XButton2] = true;
                break;

            case WindowMessage.LBUTTONUP:
                mouse[MouseButton.Left] = false;
                break;

            case WindowMessage.MBUTTONUP:
                mouse[MouseButton.Middle] = false;
                break;

            case WindowMessage.RBUTTONUP:
                mouse[MouseButton.Right] = false;
                break;

            case WindowMessage.XBUTTONUP:
                keyboard[(((ulong)wParam.ToInt64() >> 16) & 0xFFFF) == 1 ? Key.XButton1 : Key.XButton2] = false;
                break;

            // Keyboard events:
            case WindowMessage.KEYDOWN:
            case WindowMessage.KEYUP:
            case WindowMessage.SYSKEYDOWN:
            case WindowMessage.SYSKEYUP:
                bool pressed = message == WindowMessage.KEYDOWN ||
                               message == WindowMessage.SYSKEYDOWN;

                // Shift/Control/Alt behave strangely when e.g. ShiftRight is held down and ShiftLeft is pressed
                // and released. It looks like neither key is released in this case, or that the wrong key is
                // released in the case of Control and Alt.
                // To combat this, we are going to release both keys when either is released. Hacky, but should work.
                // Win95 does not distinguish left/right key constants (GetAsyncKeyState returns 0).
                // In this case, both keys will be reported as pressed.

                bool extended = (lParam.ToInt64() & ExtendedBit) != 0;
                switch ((VirtualKeys)wParam)
                {
                case VirtualKeys.SHIFT:
                    // The behavior of this key is very strange. Unlike Control and Alt, there is no extended bit
                    // to distinguish between left and right keys. Moreover, pressing both keys and releasing one
                    // may result in both keys being held down (but not always).
                    bool lShiftDown = (API.GetKeyState((int)VirtualKeys.LSHIFT) >> 15) == 1;
                    bool rShiftDown = (API.GetKeyState((int)VirtualKeys.RSHIFT) >> 15) == 1;

                    if (!pressed || lShiftDown != rShiftDown)
                    {
                        Keyboard[Input.Key.ShiftLeft]  = lShiftDown;
                        Keyboard[Input.Key.ShiftRight] = rShiftDown;
                    }
                    return(IntPtr.Zero);

                case VirtualKeys.CONTROL:
                    if (extended)
                    {
                        keyboard[Input.Key.ControlRight] = pressed;
                    }
                    else
                    {
                        keyboard[Input.Key.ControlLeft] = pressed;
                    }
                    return(IntPtr.Zero);

                case VirtualKeys.MENU:
                    if (extended)
                    {
                        keyboard[Input.Key.AltRight] = pressed;
                    }
                    else
                    {
                        keyboard[Input.Key.AltLeft] = pressed;
                    }
                    return(IntPtr.Zero);

                case VirtualKeys.RETURN:
                    if (extended)
                    {
                        keyboard[Key.KeypadEnter] = pressed;
                    }
                    else
                    {
                        keyboard[Key.Enter] = pressed;
                    }
                    return(IntPtr.Zero);

                default:
                    Key tkKey;
                    if (!KeyMap.TryGetMappedKey((VirtualKeys)wParam, out tkKey))
                    {
                        Debug.Print("Virtual key {0} ({1}) not mapped.", (VirtualKeys)wParam, lParam.ToInt64());
                        break;
                    }
                    else
                    {
                        keyboard[tkKey] = pressed;
                    }
                    return(IntPtr.Zero);
                }
                break;

            case WindowMessage.SYSCHAR:
                return(IntPtr.Zero);

            case WindowMessage.KILLFOCUS:
                keyboard.ClearKeys();
                break;

                #endregion

                #region Creation / Destruction events

            case WindowMessage.CREATE:
                CreateStruct cs = (CreateStruct)Marshal.PtrToStructure(lParam, typeof(CreateStruct));
                if (cs.hwndParent == IntPtr.Zero)
                {
                    bounds.X      = cs.x;
                    bounds.Y      = cs.y;
                    bounds.Width  = cs.cx;
                    bounds.Height = cs.cy;

                    Win32Rectangle rect;
                    API.GetClientRect(handle, out rect);
                    client_rectangle = rect.ToRectangle();

                    invisible_since_creation = true;
                }
                break;

            case WindowMessage.CLOSE:
                System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs();

                if (Closing != null)
                {
                    Closing(this, e);
                }

                if (!e.Cancel)
                {
                    DestroyWindow();
                    break;
                }

                return(IntPtr.Zero);

            case WindowMessage.DESTROY:
                exists = false;

                API.UnregisterClass(ClassName, Instance);
                window.Dispose();

                if (Closed != null)
                {
                    Closed(this, EventArgs.Empty);
                }

                break;

                #endregion
            }
            return(API.DefWindowProc(handle, message, wParam, lParam));
        }
Example #33
0
        public void ShowWindow(Control _TargetForm, Control _PopupForm, int width, int height, WindowStyle _WStyle,string title)
        {
            Hide();
            
            PopupContent popup = new PopupContent();
            popup.TargetControl = _TargetForm;
            popup.PopupControl = _PopupForm;
            popup.PType = PopupType.Window;
            popup.PStyle = PopupEvent.Custom;
            popup.WStyle = _WStyle;
            popup.Width = _PopupForm.Width;
            popup.Height = _PopupForm.Height;
            popup.IsMCHide = true;//点击隐藏
            popup.WindowTitle = title;

            panelContainer.Tag = popup;
            if (width != -1)
                popup.Width = width;
            if (height != -1)
                popup.Height = height;

            panelContainer.Width = popup.Width;
            panelContainer.Height = popup.Height;

            if (popup.PopupControl is Form)
            {
                (popup.PopupControl as Form).TopLevel = false;
                (popup.PopupControl as Form).FormBorderStyle = FormBorderStyle.None;
                //(popup.PopupControl as Form).VisibleChanged += new EventHandler(Popup_VisibleChanged);
            }

             if (popup.PType == PopupType.Window)
            {

                panelContainer.Padding = new Padding(2);
                panelContainer.Controls.Add(popup.PopupControl);
                panelContainer.Controls.Add(picTitle);
                picTitle.Height = 20;
                picTitle.Dock = DockStyle.Top;

                popup.PopupControl.Dock = DockStyle.Fill;
                rect_close = new Rectangle(panelContainer.Width - 22, 0, 20, 20);
                rect_titletext = new Rectangle(0, 0, panelContainer.Width - 50, 18);
                popup.PopupControl.Show();       
            }

            if (popup.WStyle == WindowStyle.Default)
            {
                SetPopupCenter(_TargetForm);
                panelContainer.Show();

                if (popup.PopupControl is Form)
                {
                    (popup.PopupControl as Form).VisibleChanged += new EventHandler(Popup_VisibleChanged);
                }
            }
            else if (popup.WStyle == WindowStyle.Shadow)
            {
                SetPopupCenter(_TargetForm);
                panelContainer.Width = 0;
                panelContainer.Height = 0;
                Thread ts = new Thread(new ThreadStart(ShadowPanel));
                ts.IsBackground = true;
                ts.Priority = ThreadPriority.Normal;
                ts.Start();
            }
            else if (popup.WStyle == WindowStyle.Task)
            {
                SetPopupTask(_TargetForm);
                Thread ts = new Thread(new ThreadStart(TaskPanel));
                ts.IsBackground = true;
                ts.Priority = ThreadPriority.Normal;
                ts.Start();
            }

          

            if (doShow != null)
                doShow();

            BindParentEvent(_TargetForm, popup);
        }
Example #34
0
 public WindowStyle(WindowStyle style) : base(style)
 {
     TitleStyle       = style.TitleStyle != null ? new LabelStyle(style.TitleStyle) : null;
     CloseButtonStyle = style.CloseButtonStyle != null ? new ImageButtonStyle(style.CloseButtonStyle) : null;
 }
Example #35
0
        /// <summary>
        /// Rebuild materials back to default with no climate modifier.
        /// </summary>
        /// <param name="dfUnity">DaggerfallUnity singleton. Required for content readers and settings.</param>
        /// <param name="climate">Climate to set.</param>
        /// <param name="season">Season to set.</param>
        /// <param name="windowStyle">Style of window to set.</param>
        public void SetClimate(DaggerfallUnity dfUnity, ClimateBases climate, ClimateSeason season, WindowStyle windowStyle)
        {
            if (defaultTextures.Count == 0)
            {
                return;
            }

            // Get new material array
            Material[] materials = new Material[defaultTextures.Count];
            for (int i = 0; i < defaultTextures.Count; i++)
            {
                materials[i] = dfUnity.MaterialReader.ChangeClimate(defaultTextures[i], climate, season, windowStyle);
            }

            // Assign material array
            if (materials != null)
            {
                renderer.sharedMaterials = materials;
            }
        }
Example #36
0
 public TargetWindow(string title, WindowStyle style) : base(title, style)
 {
 }
Example #37
0
        private void dialog_Closed(object sender, EventArgs e)
        {
            var dia = sender as Dialog;

            if (dia.Tag != null)
            {
                dia.Tag = null;
                var arr = dia.PropertyArray;
                if (arr[0] != null)
                {
                    BackgroundColorIndex = (int)(arr[0]);
                    if (WindowStyle.ToString() == WindowStyle.None.ToString())
                    {
                        _backGround = ChangeBackgroundColor(Dialog.ColorArray[BackgroundColorIndex]);
                    }
                    else
                    {
                        Background  = ChangeBackgroundColor(Dialog.ColorArray[BackgroundColorIndex]);
                        _backGround = Background;
                    }
                }
                else
                {
                    BackgroundColorIndex = (BackgroundColorIndex != -1) ? BackgroundColorIndex : -1;
                }
                if (arr[1] != null)
                {
                    ForegroundColorIndex = (int)(arr[1]);
                    var rtb = LogicalTreeHelper.FindLogicalNode(this, "NoteBox") as RichTextBox;
                    rtb.SelectAll();
                    rtb.Selection.ApplyPropertyValue(ForegroundProperty,
                                                     Dialog.ColorArrayForeground[ForegroundColorIndex]);
                    rtb.Selection.Select(rtb.Document.ContentStart, rtb.Document.ContentStart);
                    _foreGround = Foreground;
                }
                else
                {
                    ForegroundColorIndex = (ForegroundColorIndex != -1) ? ForegroundColorIndex : -1;
                }
                if (arr[2] != null)
                {
                    Alarm = dia.Alarm;


                    var w       = this;
                    var m       = LogicalTreeHelper.FindLogicalNode(w, "AlwaysOnTop") as MenuItem;
                    var m1      = LogicalTreeHelper.FindLogicalNode(w, "alarm") as MenuItem;
                    var m3      = LogicalTreeHelper.FindLogicalNode(w, "DismissAlarm") as MenuItem;
                    var m2      = LogicalTreeHelper.FindLogicalNode(w, "AlarmIndicator") as Image;
                    var alarm   = w.Alarm;
                    var current = DateTime.Now;
                    m2.Visibility = (alarm.CompareTo(DateTime.Now) >= 0) ? (Visibility.Visible) : (Visibility.Hidden);

                    if (alarm.Date == current.Date)
                    {
                        var temp1 = alarm;
                        var temp2 = current;
                        temp1 = temp1.AddMinutes(30);
                        temp2 = temp2.AddMinutes(30);

                        if ((temp2.CompareTo(alarm) >= 0) && (temp1.CompareTo(current) >= 0))
                        {
                            w.Topmost         = true;
                            m.IsChecked       = true;
                            m1.IsEnabled      = true;
                            w.BorderBrush     = Brushes.Black;
                            w.BorderThickness = new Thickness(5);
                            m3.IsEnabled      = true;
                        }
                    }
                    else
                    {
                        w.Topmost    = w.TopmostWindow;
                        m.IsChecked  = w.Topmost;
                        m1.IsEnabled = (alarm.CompareTo(DateTime.Now) >= 0) ? true : false;
                        m3.IsEnabled = false;

                        w.BorderBrush     = Brushes.Transparent;
                        w.BorderThickness = new Thickness(0);
                    }
                }
                RepetitionNumber = dia.AlarmRepetition;
            }
        }
Example #38
0
        private unsafe IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam)
        {
            switch (message)
            {
            case WindowMessage.MOUSEMOVE:
                this.mouse.Position = new Point((int)(short)(lParam.ToInt32() & (int)ushort.MaxValue), (int)(short)((uint)(lParam.ToInt32() & -65536) >> 16));
                if (this.mouse_outside_window)
                {
                    this.mouse_outside_window = false;
                    this.EnableMouseTracking();
                    this.MouseEnter((object)this, EventArgs.Empty);
                    break;
                }
                else
                {
                    break;
                }

            case WindowMessage.LBUTTONDOWN:
                Functions.SetCapture(this.window.WindowHandle);
                this.mouse[MouseButton.Left] = true;
                break;

            case WindowMessage.LBUTTONUP:
                Functions.ReleaseCapture();
                this.mouse[MouseButton.Left] = false;
                break;

            case WindowMessage.RBUTTONDOWN:
                Functions.SetCapture(this.window.WindowHandle);
                this.mouse[MouseButton.Right] = true;
                break;

            case WindowMessage.RBUTTONUP:
                Functions.ReleaseCapture();
                this.mouse[MouseButton.Right] = false;
                break;

            case WindowMessage.MBUTTONDOWN:
                Functions.SetCapture(this.window.WindowHandle);
                this.mouse[MouseButton.Middle] = true;
                break;

            case WindowMessage.MBUTTONUP:
                Functions.ReleaseCapture();
                this.mouse[MouseButton.Middle] = false;
                break;

            case WindowMessage.MOUSEWHEEL:
                this.mouse.WheelPrecise += (float)((long)wParam << 32 >> 48) / 120f;
                break;

            case WindowMessage.XBUTTONDOWN:
                Functions.SetCapture(this.window.WindowHandle);
                this.mouse[((long)wParam.ToInt32() & 4294901760L) >> 16 != 32L ? MouseButton.Button1 : MouseButton.Button2] = true;
                break;

            case WindowMessage.XBUTTONUP:
                Functions.ReleaseCapture();
                this.mouse[((long)wParam.ToInt32() & 4294901760L) >> 16 != 32L ? MouseButton.Button1 : MouseButton.Button2] = false;
                break;

            case WindowMessage.ENTERMENULOOP:
            case WindowMessage.ENTERSIZEMOVE:
                this.StartTimer(handle);
                break;

            case WindowMessage.EXITMENULOOP:
            case WindowMessage.EXITSIZEMOVE:
                this.StopTimer(handle);
                break;

            case WindowMessage.MOUSELEAVE:
                this.mouse_outside_window = true;
                this.MouseLeave((object)this, EventArgs.Empty);
                break;

            case WindowMessage.STYLECHANGED:
                if (wParam.ToInt64() == -16L)
                {
                    WindowStyle windowStyle = ((StyleStruct *)(void *)lParam)->New;
                    if ((windowStyle & WindowStyle.Popup) != WindowStyle.Overlapped)
                    {
                        this.windowBorder = WindowBorder.Hidden;
                    }
                    else if ((windowStyle & WindowStyle.ThickFrame) != WindowStyle.Overlapped)
                    {
                        this.windowBorder = WindowBorder.Resizable;
                    }
                    else if ((windowStyle & ~(WindowStyle.ThickFrame | WindowStyle.TabStop)) != WindowStyle.Overlapped)
                    {
                        this.windowBorder = WindowBorder.Fixed;
                    }
                }
                if (!this.CursorVisible)
                {
                    this.GrabCursor();
                    break;
                }
                else
                {
                    break;
                }

            case WindowMessage.KEYDOWN:
            case WindowMessage.KEYUP:
            case WindowMessage.SYSKEYDOWN:
            case WindowMessage.SYSKEYUP:
                bool flag1 = message == WindowMessage.KEYDOWN || message == WindowMessage.SYSKEYDOWN;
                bool flag2 = (lParam.ToInt64() & 16777216L) != 0L;
                switch ((short)(int)wParam)
                {
                case (short)13:
                    if (flag2)
                    {
                        this.keyboard[Key.KeypadEnter] = flag1;
                    }
                    else
                    {
                        this.keyboard[Key.Enter] = flag1;
                    }
                    return(IntPtr.Zero);

                case (short)16:
                    if ((int)WinGLNative.ShiftRightScanCode != 0 && flag1)
                    {
                        if ((lParam.ToInt64() >> 16 & (long)byte.MaxValue) == (long)WinGLNative.ShiftRightScanCode)
                        {
                            this.keyboard[Key.ShiftRight] = flag1;
                        }
                        else
                        {
                            this.keyboard[Key.ShiftLeft] = flag1;
                        }
                    }
                    else
                    {
                        this.keyboard[Key.ShiftLeft] = this.keyboard[Key.ShiftRight] = flag1;
                    }
                    return(IntPtr.Zero);

                case (short)17:
                    if (flag2)
                    {
                        this.keyboard[Key.ControlRight] = flag1;
                    }
                    else
                    {
                        this.keyboard[Key.ControlLeft] = flag1;
                    }
                    return(IntPtr.Zero);

                case (short)18:
                    if (flag2)
                    {
                        this.keyboard[Key.AltRight] = flag1;
                    }
                    else
                    {
                        this.keyboard[Key.AltLeft] = flag1;
                    }
                    return(IntPtr.Zero);

                default:
                    if (WinGLNative.KeyMap.ContainsKey((VirtualKeys)(int)wParam))
                    {
                        this.keyboard[WinGLNative.KeyMap[(VirtualKeys)(int)wParam]] = flag1;
                        return(IntPtr.Zero);
                    }
                    else
                    {
                        break;
                    }
                }

            case WindowMessage.CHAR:
                this.key_press.KeyChar = IntPtr.Size != 4 ? (char)wParam.ToInt64() : (char)wParam.ToInt32();
                this.KeyPress((object)this, this.key_press);
                break;

            case WindowMessage.SYSCHAR:
                return(IntPtr.Zero);

            case WindowMessage.ERASEBKGND:
                return(new IntPtr(1));

            case WindowMessage.WINDOWPOSCHANGED:
                WindowPosition *windowPositionPtr = (WindowPosition *)(void *)lParam;
                if (this.window != null && windowPositionPtr->hwnd == this.window.WindowHandle)
                {
                    Point point = new Point(windowPositionPtr->x, windowPositionPtr->y);
                    if (this.Location != point)
                    {
                        this.bounds.Location = point;
                        this.Move((object)this, EventArgs.Empty);
                    }
                    if (this.Size != new Size(windowPositionPtr->cx, windowPositionPtr->cy))
                    {
                        this.bounds.Width  = windowPositionPtr->cx;
                        this.bounds.Height = windowPositionPtr->cy;
                        Win32Rectangle clientRectangle;
                        Functions.GetClientRect(handle, out clientRectangle);
                        this.client_rectangle = clientRectangle.ToRectangle();
                        Functions.SetWindowPos(this.child_window.WindowHandle, IntPtr.Zero, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, SetWindowPosFlags.NOZORDER | SetWindowPosFlags.NOACTIVATE | SetWindowPosFlags.NOOWNERZORDER | SetWindowPosFlags.NOSENDCHANGING);
                        if (this.suppress_resize <= 0)
                        {
                            this.Resize((object)this, EventArgs.Empty);
                        }
                    }
                    if (!this.CursorVisible)
                    {
                        this.GrabCursor();
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }

            case WindowMessage.CREATE:
                CreateStruct createStruct = (CreateStruct)Marshal.PtrToStructure(lParam, typeof(CreateStruct));
                if (createStruct.hwndParent == IntPtr.Zero)
                {
                    this.bounds.X      = createStruct.x;
                    this.bounds.Y      = createStruct.y;
                    this.bounds.Width  = createStruct.cx;
                    this.bounds.Height = createStruct.cy;
                    Win32Rectangle clientRectangle;
                    Functions.GetClientRect(handle, out clientRectangle);
                    this.client_rectangle         = clientRectangle.ToRectangle();
                    this.invisible_since_creation = true;
                    break;
                }
                else
                {
                    break;
                }

            case WindowMessage.DESTROY:
                this.exists = false;
                int num = (int)Functions.UnregisterClass(this.ClassName, this.Instance);
                this.window.Dispose();
                this.child_window.Dispose();
                this.Closed((object)this, EventArgs.Empty);
                break;

            case WindowMessage.SIZE:
                SizeMessage sizeMessage = (SizeMessage)wParam.ToInt64();
                WindowState windowState = this.windowState;
                switch (sizeMessage)
                {
                case SizeMessage.RESTORED:
                    windowState = this.borderless_maximized_window_state ? WindowState.Maximized : WindowState.Normal;
                    break;

                case SizeMessage.MINIMIZED:
                    windowState = WindowState.Minimized;
                    break;

                case SizeMessage.MAXIMIZED:
                    windowState = this.WindowBorder == WindowBorder.Hidden ? WindowState.Fullscreen : WindowState.Maximized;
                    break;
                }
                if (windowState != this.windowState)
                {
                    this.windowState = windowState;
                    this.WindowStateChanged((object)this, EventArgs.Empty);
                }
                if (!this.CursorVisible)
                {
                    this.GrabCursor();
                    break;
                }
                else
                {
                    break;
                }

            case WindowMessage.ACTIVATE:
                bool focused = this.Focused;
                this.focused = IntPtr.Size != 4 ? (wParam.ToInt64() & (long)ushort.MaxValue) != 0L : (wParam.ToInt32() & (int)ushort.MaxValue) != 0;
                if (focused != this.Focused)
                {
                    this.FocusedChanged((object)this, EventArgs.Empty);
                    break;
                }
                else
                {
                    break;
                }

            case WindowMessage.KILLFOCUS:
                this.keyboard.ClearKeys();
                break;

            case WindowMessage.CLOSE:
                CancelEventArgs e = new CancelEventArgs();
                this.Closing((object)this, e);
                if (e.Cancel)
                {
                    return(IntPtr.Zero);
                }
                this.DestroyWindow();
                break;
            }
            return(Functions.DefWindowProc(handle, message, wParam, lParam));
        }
Example #39
0
 public IGuiMainWindow CreateMainWindow(WindowStyle style)
 {
     return(new WpfMainWindow(style));
 }
 /// <summary>
 /// Sets the WindowStyle property. This dependency property
 /// indicates ....
 /// </summary>
 public static void SetWindowStyle(DependencyObject d, WindowStyle value)
 {
     d.SetValue(WindowStyleProperty, value);
 }
Example #41
0
 static extern IntPtr CreateWindowEx(
     WindowStyle dwExStyle,
     string lpClassName,
     string lpWindowName,
     UInt32 dwStyle,
     Int32 x,
     Int32 y,
     Int32 nWidth,
     Int32 nHeight,
     IntPtr hWndParent,
     IntPtr hMenu,
     IntPtr hInstance,
     IntPtr lpParam);
Example #42
0
 public void ShowWindow(Control _TargetForm, Control _PopupForm, int width, int height, WindowStyle _WStyle)
 {
     ShowWindow(_TargetForm, _PopupForm, width, height, _WStyle, "");
 }
 /// <summary>
 /// Change emission colour of window materials.
 /// </summary>
 /// <param name="material">Source material to change.</param>
 /// <param name="windowStyle">New window style.</param>
 public void ChangeWindowEmissionColor(Material material, WindowStyle windowStyle)
 {
     switch (windowStyle)
     {
         case WindowStyle.Day:
             material.SetColor("_EmissionColor", DayWindowColor * DayWindowIntensity);
             break;
         case WindowStyle.Night:
             material.SetColor("_EmissionColor", NightWindowColor * NightWindowIntensity);
             break;
         case WindowStyle.Fog:
             material.SetColor("_EmissionColor", FogWindowColor * FogWindowIntensity);
             break;
         case WindowStyle.Custom:
             material.SetColor("_EmissionColor", CustomWindowColor * CustomWindowIntensity);
             break;
         case WindowStyle.Disabled:
             material.SetColor("_EmissionColor", Color.black);
             break;
     }
 }
Example #44
0
 protected virtual object OnCoerceWindowStyle( WindowStyle newValue )
 {
   return newValue;
 }
Example #45
0
 internal static extern BOOL AdjustWindowRect([In, Out] ref Win32Rectangle lpRect, WindowStyle dwStyle, BOOL bMenu);
Example #46
0
 /// <summary>
 /// Creates a new Instance of UniForm.
 /// </summary>
 /// <param name="childForm">System.Windows.UIElement; The Content portion of the Window.</param>
 /// <param name="style">System.Windows.WindowStyle.</param>
 public UniForm(UIElement childForm, WindowStyle style) : this(style)
 {
     this.FormContent = childForm;
 }
Example #47
0
 internal static extern IntPtr CreateWindowEx(
     ExtendedWindowStyle ExStyle,
     [MarshalAs(UnmanagedType.LPTStr)] string className,
     [MarshalAs(UnmanagedType.LPTStr)] string windowName,
     WindowStyle Style,
     int X, int Y,
     int Width, int Height,
     IntPtr HandleToParentWindow,
     IntPtr Menu,
     IntPtr Instance,
     IntPtr Param);
Example #48
0
 internal static extern bool AdjustWindowRectEx(
     ref Win32Rectangle lpRect,
     WindowStyle dwStyle,
     [MarshalAs(UnmanagedType.Bool)] bool bMenu,
     ExtendedWindowStyle dwExStyle);
 public bool HasStyle(WindowStyle style)
 {
     return (GetStyle() & style) != 0;
 }
Example #50
0
        public async Task <TViewModel> CreateWindow <TUserControl, TViewModel>(bool singleton, string title = "", WindowStyle style = WindowStyle.SingleBorderWindow, bool closeOnOutsideClick = false) where TUserControl : UserControl where TViewModel : IViewModel
        {
            var match = _windowsRegistry.FirstOrDefault(win => win.Content is TUserControl);

            var window = (singleton) ? match ?? CreateWindowInternal <TUserControl>(title, style) : CreateWindowInternal <TUserControl>(title, style);

            return(await HandleCreateWindow <TUserControl, TViewModel>(window));
        }
 public void SetStyle(WindowStyle style)
 {
     var result = SetWindowLong(GetWindowLongOffset.GWL_STYLE, (long)style);
     if (result == 0)
     {
         throw new PInvokeException("Unable to set window style");
     }
 }
Example #52
0
 public override void SetWindowStyle(WindowStyle windowStyle)
 {
     Noesis_Win32Display_SetWindowStyle(CPtr, (int)windowStyle);
 }
Example #53
0
 public void ShowWindow(Control _TargetForm, Control _PopupForm, int width, int height, WindowStyle _WStyle)
 {
     ShowWindow(_TargetForm, _PopupForm, width, height, _WStyle, "");
 }
Example #54
0
        IntPtr CreateWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device, IntPtr parentHandle)
        {
            // Use win32 to create the native window.
            // Keep in mind that some construction code runs in the WM_CREATE message handler.

            // The style of a parent window is different than that of a child window.
            // Note: the child window should always be visible, even if the parent isn't.
            WindowStyle         style    = 0;
            ExtendedWindowStyle ex_style = 0;

            if (parentHandle == IntPtr.Zero)
            {
                style   |= WindowStyle.OverlappedWindow | WindowStyle.ClipChildren;
                ex_style = ParentStyleEx;
            }
            else
            {
                style   |= WindowStyle.Visible | WindowStyle.Child | WindowStyle.ClipSiblings;
                ex_style = ChildStyleEx;
            }

            // Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc).
            Win32Rectangle rect = new Win32Rectangle();

            rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height;
            Functions.AdjustWindowRectEx(ref rect, style, false, ex_style);

            // Create the window class that we will use for this window.
            // The current approach is to register a new class for each top-level WinGLWindow we create.
            if (!class_registered)
            {
                ExtendedWindowClass wc = new ExtendedWindowClass();
                wc.Size      = ExtendedWindowClass.SizeInBytes;
                wc.Style     = DefaultClassStyle;
                wc.Instance  = Instance;
                wc.WndProc   = WindowProcedureDelegate;
                wc.ClassName = ClassName;
                wc.Icon      = Icon != null ? Icon.Handle : IntPtr.Zero;
#warning "This seems to resize one of the 'large' icons, rather than using a small icon directly (multi-icon files). Investigate!"
                wc.IconSm = Icon != null ? new Icon(Icon, 16, 16).Handle : IntPtr.Zero;
                wc.Cursor = Functions.LoadCursor(CursorName.Arrow);
                ushort atom = Functions.RegisterClassEx(ref wc);

                if (atom == 0)
                {
                    throw new PlatformException(String.Format("Failed to register window class. Error: {0}", Marshal.GetLastWin32Error()));
                }

                class_registered = true;
            }

            IntPtr window_name = Marshal.StringToHGlobalAuto(title);
            IntPtr handle      = Functions.CreateWindowEx(
                ex_style, ClassName, window_name, style,
                rect.left, rect.top, rect.Width, rect.Height,
                parentHandle, IntPtr.Zero, Instance, IntPtr.Zero);

            if (handle == IntPtr.Zero)
            {
                throw new PlatformException(String.Format("Failed to create window. Error: {0}", Marshal.GetLastWin32Error()));
            }

            return(handle);
        }
Example #55
0
 public WpfMainWindow(WindowStyle style)
 {
     // nop
 }
Example #56
0
        IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam)
        {
            Point point;

            switch (message)
            {
                #region Size / Move / Style events

            case WindowMessage.ACTIVATE:
                // See http://msdn.microsoft.com/en-us/library/ms646274(VS.85).aspx (WM_ACTIVATE notification):
                // wParam: The low-order word specifies whether the window is being activated or deactivated.
                bool new_focused_state = Focused;
                if (IntPtr.Size == 4)
                {
                    focused = (wParam.ToInt32() & 0xFFFF) != 0;
                }
                else
                {
                    focused = (wParam.ToInt64() & 0xFFFF) != 0;
                }

                if (new_focused_state != Focused)
                {
                    FocusedChanged(this, EventArgs.Empty);
                }
                break;

            case WindowMessage.ENTERMENULOOP:
            case WindowMessage.ENTERSIZEMOVE:
                // Entering the modal size/move loop: we don't want rendering to
                // stop during this time, so we register a timer callback to continue
                // processing from time to time.
                StartTimer(handle);
                break;

            case WindowMessage.EXITMENULOOP:
            case WindowMessage.EXITSIZEMOVE:
                // ExitingmModal size/move loop: the timer callback is no longer
                // necessary.
                StopTimer(handle);
                break;

            case WindowMessage.ERASEBKGND:
                return(new IntPtr(1));

            case WindowMessage.WINDOWPOSCHANGED:
                unsafe
                {
                    WindowPosition *pos = (WindowPosition *)lParam;
                    if (window != null && pos->hwnd == window.WindowHandle)
                    {
                        Point new_location = new Point(pos->x, pos->y);
                        if (Location != new_location)
                        {
                            bounds.Location = new_location;
                            Move(this, EventArgs.Empty);
                        }

                        Size new_size = new Size(pos->cx, pos->cy);
                        if (Size != new_size)
                        {
                            bounds.Width  = pos->cx;
                            bounds.Height = pos->cy;

                            Win32Rectangle rect;
                            Functions.GetClientRect(handle, out rect);
                            client_rectangle = rect.ToRectangle();

                            Functions.SetWindowPos(child_window.WindowHandle, IntPtr.Zero, 0, 0, ClientRectangle.Width, ClientRectangle.Height,
                                                   SetWindowPosFlags.NOZORDER | SetWindowPosFlags.NOOWNERZORDER |
                                                   SetWindowPosFlags.NOACTIVATE | SetWindowPosFlags.NOSENDCHANGING);

                            if (suppress_resize <= 0)
                            {
                                Resize(this, EventArgs.Empty);
                            }
                        }
                    }
                }
                break;

            case WindowMessage.STYLECHANGED:
                unsafe
                {
                    if (wParam.ToInt64() == (long)GWL.STYLE)
                    {
                        WindowStyle style = ((StyleStruct *)lParam)->New;
                        if ((style & WindowStyle.Popup) != 0)
                        {
                            windowBorder = WindowBorder.Hidden;
                        }
                        else if ((style & WindowStyle.ThickFrame) != 0)
                        {
                            windowBorder = WindowBorder.Resizable;
                        }
                        else if ((style & ~(WindowStyle.ThickFrame | WindowStyle.MaximizeBox)) != 0)
                        {
                            windowBorder = WindowBorder.Fixed;
                        }
                    }
                }

                break;

            case WindowMessage.SIZE:
                SizeMessage state     = (SizeMessage)wParam.ToInt64();
                WindowState new_state = windowState;
                switch (state)
                {
                case SizeMessage.RESTORED: new_state = borderless_maximized_window_state ?
                                                       WindowState.Maximized : WindowState.Normal; break;

                case SizeMessage.MINIMIZED: new_state = WindowState.Minimized; break;

                case SizeMessage.MAXIMIZED: new_state = WindowBorder == WindowBorder.Hidden ?
                                                        WindowState.Fullscreen : WindowState.Maximized;
                    break;
                }

                if (new_state != windowState)
                {
                    windowState = new_state;
                    WindowStateChanged(this, EventArgs.Empty);
                }

                break;

                #endregion

                #region Input events

            case WindowMessage.CHAR:
                if (IntPtr.Size == 4)
                {
                    key_press.KeyChar = (char)wParam.ToInt32();
                }
                else
                {
                    key_press.KeyChar = (char)wParam.ToInt64();
                }

                KeyPress(this, key_press);
                break;

            case WindowMessage.MOUSEMOVE:
                point = new Point(
                    (short)((uint)lParam.ToInt32() & 0x0000FFFF),
                    (short)(((uint)lParam.ToInt32() & 0xFFFF0000) >> 16));
                mouse.Position = point;

                if (mouse_outside_window)
                {
                    // Once we receive a mouse move event, it means that the mouse has
                    // re-entered the window.
                    mouse_outside_window = false;
                    EnableMouseTracking();
                }

                if (this.client_rectangle.Contains(lastCursorPos) && !this.client_rectangle.Contains(point))
                {
                    if (!CursorVisible)
                    {
                        ShowCursor();
                    }
                    mouse.NotifyLeave();
                    MouseLeave(this, EventArgs.Empty);
                }
                if (!this.client_rectangle.Contains(lastCursorPos) && this.client_rectangle.Contains(point))
                {
                    if (!CursorVisible)
                    {
                        HideCursor();
                    }
                    mouse.NotifyEnter();
                    MouseEnter(this, EventArgs.Empty);
                }

                lastCursorPos = point;
                break;

            case WindowMessage.MOUSELEAVE:
                mouse_outside_window = true;
                // Mouse tracking is disabled automatically by the OS

                Functions.GetCursorPos(out point);
                point = this.PointToClient(point);

                if (this.client_rectangle.Contains(lastCursorPos) && !this.client_rectangle.Contains(point))
                {
                    if (!CursorVisible)
                    {
                        ShowCursor();
                    }
                    mouse.NotifyLeave();
                    MouseLeave(this, EventArgs.Empty);
                }

                lastCursorPos = point;
                break;

            case WindowMessage.MOUSEWHEEL:
                // This is due to inconsistent behavior of the WParam value on 64bit arch, whese
                // wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000
                mouse.WheelPrecise += ((long)wParam << 32 >> 48) / 120.0f;
                break;

            case WindowMessage.LBUTTONDOWN:
                Functions.SetCapture(window.WindowHandle);
                mouse[MouseButton.Left] = true;
                break;

            case WindowMessage.MBUTTONDOWN:
                Functions.SetCapture(window.WindowHandle);
                mouse[MouseButton.Middle] = true;
                break;

            case WindowMessage.RBUTTONDOWN:
                Functions.SetCapture(window.WindowHandle);
                mouse[MouseButton.Right] = true;
                break;

            case WindowMessage.XBUTTONDOWN:
                Functions.SetCapture(window.WindowHandle);
                mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) !=
                      (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = true;
                break;

            case WindowMessage.LBUTTONUP:
                Functions.ReleaseCapture();
                mouse[MouseButton.Left] = false;
                break;

            case WindowMessage.MBUTTONUP:
                Functions.ReleaseCapture();
                mouse[MouseButton.Middle] = false;
                break;

            case WindowMessage.RBUTTONUP:
                Functions.ReleaseCapture();
                mouse[MouseButton.Right] = false;
                break;

            case WindowMessage.XBUTTONUP:
                Functions.ReleaseCapture();
                mouse[((wParam.ToInt32() & 0xFFFF0000) >> 16) !=
                      (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = false;
                break;

            // Keyboard events:
            case WindowMessage.KEYDOWN:
            case WindowMessage.KEYUP:
            case WindowMessage.SYSKEYDOWN:
            case WindowMessage.SYSKEYUP:
                bool pressed =
                    message == WindowMessage.KEYDOWN ||
                    message == WindowMessage.SYSKEYDOWN;

                // Shift/Control/Alt behave strangely when e.g. ShiftRight is held down and ShiftLeft is pressed
                // and released. It looks like neither key is released in this case, or that the wrong key is
                // released in the case of Control and Alt.
                // To combat this, we are going to release both keys when either is released. Hacky, but should work.
                // Win95 does not distinguish left/right key constants (GetAsyncKeyState returns 0).
                // In this case, both keys will be reported as pressed.

                bool extended = (lParam.ToInt64() & ExtendedBit) != 0;
                switch ((VirtualKeys)wParam)
                {
                case VirtualKeys.SHIFT:
                    // The behavior of this key is very strange. Unlike Control and Alt, there is no extended bit
                    // to distinguish between left and right keys. Moreover, pressing both keys and releasing one
                    // may result in both keys being held down (but not always).
                    // The only reliable way to solve this was reported by BlueMonkMN at the forums: we should
                    // check the scancodes. It looks like GLFW does the same thing, so it should be reliable.

                    // Note: we release both keys when either shift is released.
                    // Otherwise, the state of one key might be stuck to pressed.
                    if (ShiftRightScanCode != 0 && pressed)
                    {
                        unchecked
                        {
                            if (((lParam.ToInt64() >> 16) & 0xFF) == ShiftRightScanCode)
                            {
                                keyboard[Input.Key.ShiftRight] = pressed;
                            }
                            else
                            {
                                keyboard[Input.Key.ShiftLeft] = pressed;
                            }
                        }
                    }
                    else
                    {
                        // Windows 9x and NT4.0 or key release event.
                        keyboard[Input.Key.ShiftLeft] = keyboard[Input.Key.ShiftRight] = pressed;
                    }
                    return(IntPtr.Zero);

                case VirtualKeys.CONTROL:
                    if (extended)
                    {
                        keyboard[Input.Key.ControlRight] = pressed;
                    }
                    else
                    {
                        keyboard[Input.Key.ControlLeft] = pressed;
                    }
                    return(IntPtr.Zero);

                case VirtualKeys.MENU:
                    if (extended)
                    {
                        keyboard[Input.Key.AltRight] = pressed;
                    }
                    else
                    {
                        keyboard[Input.Key.AltLeft] = pressed;
                    }
                    return(IntPtr.Zero);

                case VirtualKeys.RETURN:
                    if (extended)
                    {
                        keyboard[Key.KeypadEnter] = pressed;
                    }
                    else
                    {
                        keyboard[Key.Enter] = pressed;
                    }
                    return(IntPtr.Zero);

                default:
                    if (!KeyMap.ContainsKey((VirtualKeys)wParam))
                    {
                        Debug.Print("Virtual key {0} ({1}) not mapped.", (VirtualKeys)wParam, (long)lParam);
                        break;
                    }
                    else
                    {
                        keyboard[KeyMap[(VirtualKeys)wParam]] = pressed;
                    }
                    return(IntPtr.Zero);
                }
                break;

            case WindowMessage.SYSCHAR:
                return(IntPtr.Zero);

            case WindowMessage.KILLFOCUS:
                keyboard.ClearKeys();
                keyboard.NotifyLostFocus();
                break;

            case WindowMessage.SETFOCUS:
                keyboard.NotifyGotFocus();
                break;

                #endregion

                #region Creation / Destruction events

            case WindowMessage.CREATE:
                CreateStruct cs = (CreateStruct)Marshal.PtrToStructure(lParam, typeof(CreateStruct));
                if (cs.hwndParent == IntPtr.Zero)
                {
                    bounds.X      = cs.x;
                    bounds.Y      = cs.y;
                    bounds.Width  = cs.cx;
                    bounds.Height = cs.cy;

                    Win32Rectangle rect;
                    Functions.GetClientRect(handle, out rect);
                    client_rectangle = rect.ToRectangle();

                    invisible_since_creation = true;
                }
                break;

            case WindowMessage.CLOSE:
                System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs();

                Closing(this, e);

                if (!e.Cancel)
                {
                    DestroyWindow();
                    break;
                }

                return(IntPtr.Zero);

            case WindowMessage.DESTROY:
                exists = false;

                Functions.UnregisterClass(ClassName, Instance);
                window.Dispose();
                child_window.Dispose();

                Closed(this, EventArgs.Empty);

                break;

                #endregion
            }

            return(Functions.DefWindowProc(handle, message, wParam, lParam));
        }
Example #57
0
        public void ShowWindow(Control _TargetForm, Control _PopupForm, int width, int height, WindowStyle _WStyle, string title)
        {
            Hide();

            PopupContent popup = new PopupContent();

            popup.TargetControl = _TargetForm;
            popup.PopupControl  = _PopupForm;
            popup.PType         = PopupType.Window;
            popup.PStyle        = PopupEvent.Custom;
            popup.WStyle        = _WStyle;
            popup.Width         = _PopupForm.Width;
            popup.Height        = _PopupForm.Height;
            popup.IsMCHide      = true;//点击隐藏
            popup.WindowTitle   = title;

            panelContainer.Tag = popup;
            if (width != -1)
            {
                popup.Width = width;
            }
            if (height != -1)
            {
                popup.Height = height;
            }

            panelContainer.Width  = popup.Width;
            panelContainer.Height = popup.Height;

            if (popup.PopupControl is Form)
            {
                (popup.PopupControl as Form).TopLevel        = false;
                (popup.PopupControl as Form).FormBorderStyle = FormBorderStyle.None;
                //(popup.PopupControl as Form).VisibleChanged += new EventHandler(Popup_VisibleChanged);
            }

            if (popup.PType == PopupType.Window)
            {
                panelContainer.Padding = new Padding(2);
                panelContainer.Controls.Add(popup.PopupControl);
                panelContainer.Controls.Add(picTitle);
                picTitle.Height = 20;
                picTitle.Dock   = DockStyle.Top;

                popup.PopupControl.Dock = DockStyle.Fill;
                rect_close     = new Rectangle(panelContainer.Width - 22, 0, 20, 20);
                rect_titletext = new Rectangle(0, 0, panelContainer.Width - 50, 18);
                popup.PopupControl.Show();
            }

            if (popup.WStyle == WindowStyle.Default)
            {
                SetPopupCenter(_TargetForm);
                panelContainer.Show();

                if (popup.PopupControl is Form)
                {
                    (popup.PopupControl as Form).VisibleChanged += new EventHandler(Popup_VisibleChanged);
                }
            }
            else if (popup.WStyle == WindowStyle.Shadow)
            {
                SetPopupCenter(_TargetForm);
                panelContainer.Width  = 0;
                panelContainer.Height = 0;
                Thread ts = new Thread(new ThreadStart(ShadowPanel));
                ts.IsBackground = true;
                ts.Priority     = ThreadPriority.Normal;
                ts.Start();
            }
            else if (popup.WStyle == WindowStyle.Task)
            {
                SetPopupTask(_TargetForm);
                Thread ts = new Thread(new ThreadStart(TaskPanel));
                ts.IsBackground = true;
                ts.Priority     = ThreadPriority.Normal;
                ts.Start();
            }



            if (doShow != null)
            {
                doShow();
            }

            BindParentEvent(_TargetForm, popup);
        }
 public WindowStyleViewModel()
     : base()
 {
     m_selectedWindowStyle = WindowStyle.SingleBorderWindow;
 }
Example #59
0
 protected virtual void OnWindowStyleChanged( WindowStyle oldValue, WindowStyle newValue )
 {
 }
Example #60
0
        public void AddPopupWindow(Control _TargetControl, Control _PopupControl, PopupEvent _PStyle, WindowStyle _WStyle, int _width, int _height, bool _ismouseclickhide)
        {
            PopupContent popup = new PopupContent();

            popup.TargetControl = _TargetControl;
            popup.PopupControl  = _PopupControl;
            popup.PType         = PopupType.Window;
            popup.PStyle        = _PStyle;
            popup.WStyle        = _WStyle;
            popup.Width         = _width;
            popup.Height        = _height;
            popup.IsMCHide      = _ismouseclickhide;
            popup.WindowTitle   = "";

            _PopupControl.Tag = this;

            if (popup.PStyle == PopupEvent.Click)
            {
                _TargetControl.Click += new EventHandler(_TargetControl_Click);
            }
            else if (popup.PStyle == PopupEvent.Mouse)
            {
                _TargetControl.MouseEnter += new EventHandler(_TargetControl_MouseEnter);
                _TargetControl.MouseLeave += new EventHandler(_TargetControl_MouseLeave);
            }
            else
            {
            }

            popupList.Add(popup);

            _PopupControl.Hide();
        }