コード例 #1
0
        private void Initialize()
        {
#if NETFX4
            // NOTE: Lack of contracts: SystemParameters2.Current must ensure non-null value
            Contract.Assume(SystemParameters2.Current != null);
#endif

            _chrome = new WindowChrome
            {
#if NETFX4
                CaptionHeight = SystemParameters2.Current.WindowCaptionHeight,
#elif NETFX45
                CaptionHeight = SystemParameters.WindowCaptionHeight,
#endif
                CornerRadius          = new CornerRadius(0d),
                GlassFrameThickness   = new Thickness(0d),
                NonClientFrameEdges   = NonClientFrameEdges.None,
                ResizeBorderThickness = Parameters.Window.GetResizeBorderThickness(this),
                UseAeroCaptionButtons = false
            };
            _chrome.Freeze();
            if (WindowChrome.GetWindowChrome(this) == null)
            {
                WindowChrome.SetWindowChrome(this, _chrome);
            }

            Initialized += OnInitializedInternal;
            Loaded      += OnLoadedInternal;

            var resizeBorderThicknessPropertyDescriptor = DependencyPropertyDescriptor.FromProperty(Parameters.Window.ResizeBorderThicknessProperty, typeof(Window));
            if (resizeBorderThicknessPropertyDescriptor != null)
            {
                resizeBorderThicknessPropertyDescriptor.AddValueChanged(this, OnResizeBorderThicknessChanged);
            }
        }
コード例 #2
0
ファイル: Window.cs プロジェクト: zalid/Elysium-Extra
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Window.SourceInitialized" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            if (this.HasDropShadow && !this.AllowsTransparency)
            {
                DropShadow(this);
            }

            this.handle   = new WindowInteropHelper(this).Handle;
            this.assembly = Assembly.GetAssembly(typeof(Elysium.Theme));

            Type monitorType = this.assembly.GetType("Elysium.Native.Monitor");

            this.monitorConstructor      = monitorType.GetConstructors(this.bindingFlags).First();
            this.monitorInvalidateMethod = monitorType.GetMethod("Invalidate", this.bindingFlags);
            this.monitorBoundsProperty   = monitorType.GetProperty("Bounds", this.bindingFlags);
            this.monitorWorkAreaProperty = monitorType.GetProperty("WorkArea", this.bindingFlags);

            Type taskbarType = this.assembly.GetType("Elysium.Native.Taskbar");

            this.taskbarInvalidateMethod = taskbarType.GetMethod("Invalidate", this.bindingFlags);
            this.taskbarPositionProperty = taskbarType.GetProperty("Position", this.bindingFlags);
            this.taskbarAutoHideProperty = taskbarType.GetProperty("AutoHide", this.bindingFlags);

            this.chromeField = typeof(Elysium.Controls.Window).GetField("_chrome", this.bindingFlags);

            WindowChrome chrome = (WindowChrome)this.chromeField.GetValue(this);

            chrome = new WindowChrome
            {
                CaptionHeight         = chrome.CaptionHeight,
                CornerRadius          = chrome.CornerRadius,
                GlassFrameThickness   = chrome.GlassFrameThickness,
                NonClientFrameEdges   = chrome.NonClientFrameEdges,
                ResizeBorderThickness = new Thickness(
                    chrome.ResizeBorderThickness.Left + this.Margin.Left,
                    chrome.ResizeBorderThickness.Top + this.Margin.Top,
                    chrome.ResizeBorderThickness.Right + this.Margin.Right,
                    chrome.ResizeBorderThickness.Bottom + this.Margin.Bottom),
                UseAeroCaptionButtons = chrome.UseAeroCaptionButtons
            };
            chrome.Freeze();
            WindowChrome.SetWindowChrome(this, chrome);

            // Use WindowProc as the callback method
            // to process all native window messages.
            HwndSource.FromHwnd(handle).AddHook(MaximizedSizeFixWindowProc);
        }
コード例 #3
0
 private void OnCaptionSizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (e.HeightChanged && Equals(WindowChrome.GetWindowChrome(this), _chrome))
     {
         _chrome = new WindowChrome
         {
             CaptionHeight         = e.NewSize.Height,
             CornerRadius          = _chrome.CornerRadius,
             GlassFrameThickness   = _chrome.GlassFrameThickness,
             NonClientFrameEdges   = _chrome.NonClientFrameEdges,
             ResizeBorderThickness = _chrome.ResizeBorderThickness,
             UseAeroCaptionButtons = _chrome.UseAeroCaptionButtons
         };
         if (_chrome.CanFreeze)
         {
             _chrome.Freeze();
         }
         WindowChrome.SetWindowChrome(this, _chrome);
     }
 }
コード例 #4
0
        private void Initialize()
        {
            _chrome = new WindowChrome
            {
                //CaptionHeight = SystemParameters.WindowCaptionHeight,
                CaptionHeight         = 30,
                CornerRadius          = new CornerRadius(0d),
                GlassFrameThickness   = new Thickness(0d),
                NonClientFrameEdges   = NonClientFrameEdges.None,
                ResizeBorderThickness = new Thickness(3),
                UseAeroCaptionButtons = false
            };
            if (_chrome.CanFreeze)
            {
                _chrome.Freeze();
            }
            if (WindowChrome.GetWindowChrome(this) == null)
            {
                WindowChrome.SetWindowChrome(this, _chrome);
            }

            Initialized += OnInitializedInternal;
            Loaded      += OnLoadedInternal;
        }
コード例 #5
0
        private void Initialize()
        {
            _chrome = new WindowChrome
                          {
                              //CaptionHeight = SystemParameters.WindowCaptionHeight,
                              CaptionHeight = 30,
                              CornerRadius = new CornerRadius(0d),
                              GlassFrameThickness = new Thickness(0d),
                              NonClientFrameEdges = NonClientFrameEdges.None,
                              ResizeBorderThickness = new Thickness(3),
                              UseAeroCaptionButtons = false
                          };
            if (_chrome.CanFreeze)
            {
                _chrome.Freeze();
            }
            if (WindowChrome.GetWindowChrome(this) == null)
            {
                WindowChrome.SetWindowChrome(this, _chrome);
            }

            Initialized += OnInitializedInternal;
            Loaded += OnLoadedInternal;
        }
コード例 #6
0
 private void OnCaptionSizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (e.HeightChanged && Equals(WindowChrome.GetWindowChrome(this), _chrome))
     {
         _chrome = new WindowChrome
                       {
                           CaptionHeight = e.NewSize.Height,
                           CornerRadius = _chrome.CornerRadius,
                           GlassFrameThickness = _chrome.GlassFrameThickness,
                           NonClientFrameEdges = _chrome.NonClientFrameEdges,
                           ResizeBorderThickness = _chrome.ResizeBorderThickness,
                           UseAeroCaptionButtons = _chrome.UseAeroCaptionButtons
                       };
         if (_chrome.CanFreeze)
         {
             _chrome.Freeze();
         }
         WindowChrome.SetWindowChrome(this, _chrome);
     }
 }