コード例 #1
0
ファイル: WindowControl.cs プロジェクト: waffle-iron/nequeo
        private static object OnCoerceIsActive(DependencyObject d, object basevalue)
        {
            WindowControl w = d as WindowControl;

            if (w != null && !w._setIsActiveInternal && !w.AllowPublicIsActiveChange)
            {
                throw new InvalidOperationException("Cannot set IsActive directly. This is handled by the underlying system");
            }

            return(basevalue);
        }
コード例 #2
0
        private void SetActiveWindow(WindowControl windowControl)
        {
            if (windowControl.IsActive)
            {
                return;
            }

            foreach (WindowControl window in this.Children)
            {
                window.SetIsActiveInternal(false);
            }
            windowControl.SetIsActiveInternal(true);
        }
コード例 #3
0
        private double GetRestrictedTop(WindowControl windowControl)
        {
            if (windowControl.Top < 0)
            {
                return(0);
            }

            if (((windowControl.Top + windowControl.ActualHeight) > this.ActualHeight) && (this.ActualHeight != 0))
            {
                double y = this.ActualHeight - windowControl.ActualHeight;
                return(y < 0 ? 0 : y);
            }

            return(windowControl.Top);
        }
コード例 #4
0
        private double GetRestrictedLeft(WindowControl windowControl)
        {
            if (windowControl.Left < 0)
            {
                return(0);
            }

            if (((windowControl.Left + windowControl.ActualWidth) > this.ActualWidth) && (this.ActualWidth != 0))
            {
                double x = this.ActualWidth - windowControl.ActualWidth;
                return(x < 0 ? 0 : x);
            }

            return(windowControl.Left);
        }
コード例 #5
0
 private void SetChildPos(WindowControl windowControl)
 {
     // A MessageBox with no X and Y will be centered.
     // A ChildWindow with WindowStartupLocation == Center will be centered.
     if (((windowControl is MessageBox) && (windowControl.Left == 0) && (windowControl.Top == 0)) ||
         ((windowControl is ChildWindow) && ((( ChildWindow )windowControl).WindowStartupLocation == WindowStartupLocation.Center)))
     {
         this.CenterChild(windowControl);
     }
     else
     {
         Canvas.SetLeft(windowControl, windowControl.Left);
         Canvas.SetTop(windowControl, windowControl.Top);
     }
 }
コード例 #6
0
ファイル: WindowControl.cs プロジェクト: waffle-iron/nequeo
        private static object OnCoerceWindowStyle(DependencyObject d, object basevalue)
        {
            if (basevalue == DependencyProperty.UnsetValue)
            {
                return(basevalue);
            }

            WindowControl windowControl = d as WindowControl;

            if (windowControl == null)
            {
                return(basevalue);
            }
            return(windowControl.OnCoerceWindowStyle(( WindowStyle )basevalue));
        }
コード例 #7
0
ファイル: WindowControl.cs プロジェクト: waffle-iron/nequeo
        private static object OnCoerceCloseButtonVisibility(DependencyObject d, object basevalue)
        {
            if (basevalue == DependencyProperty.UnsetValue)
            {
                return(basevalue);
            }

            WindowControl windowControl = d as WindowControl;

            if (windowControl == null)
            {
                return(basevalue);
            }
            return(windowControl.OnCoerceCloseButtonVisibility(( Visibility )basevalue));
        }
コード例 #8
0
        /// <summary>
        /// Register and unregister to children events.
        /// </summary>
        protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
        {
            base.OnVisualChildrenChanged(visualAdded, visualRemoved);

            if (visualAdded != null && !(visualAdded is WindowControl))
            {
                throw new InvalidOperationException("WindowContainer can only contain WindowControl types.");
            }

            if (visualRemoved != null)
            {
                WindowControl removedChild = ( WindowControl )visualRemoved;
                removedChild.LeftChanged -= new EventHandler <EventArgs>(this.Child_LeftChanged);
                removedChild.TopChanged  -= new EventHandler <EventArgs>(this.Child_TopChanged);
                removedChild.PreviewMouseLeftButtonDown   -= new MouseButtonEventHandler(this.Child_PreviewMouseLeftButtonDown);
                removedChild.IsVisibleChanged             -= new DependencyPropertyChangedEventHandler(this.Child_IsVisibleChanged);
                removedChild.IsKeyboardFocusWithinChanged -= new DependencyPropertyChangedEventHandler(this.Child_IsKeyboardFocusWithinChanged);
                if (removedChild is ChildWindow)
                {
                    (( ChildWindow )removedChild).IsModalChanged -= new EventHandler <EventArgs>(this.Child_IsModalChanged);
                }
            }

            if (visualAdded != null)
            {
                WindowControl addedChild = ( WindowControl )visualAdded;
                addedChild.LeftChanged += new EventHandler <EventArgs>(this.Child_LeftChanged);
                addedChild.TopChanged  += new EventHandler <EventArgs>(this.Child_TopChanged);
                addedChild.PreviewMouseLeftButtonDown   += new MouseButtonEventHandler(this.Child_PreviewMouseLeftButtonDown);
                addedChild.IsVisibleChanged             += new DependencyPropertyChangedEventHandler(this.Child_IsVisibleChanged);
                addedChild.IsKeyboardFocusWithinChanged += new DependencyPropertyChangedEventHandler(this.Child_IsKeyboardFocusWithinChanged);
                if (addedChild is ChildWindow)
                {
                    (( ChildWindow )addedChild).IsModalChanged += new EventHandler <EventArgs>(this.Child_IsModalChanged);
                }
            }
        }
コード例 #9
0
 private bool IsModalWindow(WindowControl windowControl)
 {
     return(((windowControl is MessageBox) && (windowControl.Visibility == Visibility.Visible)) ||
            ((windowControl is ChildWindow) && (( ChildWindow )windowControl).IsModal && (( ChildWindow )windowControl).WindowState == WindowState.Open));
 }