예제 #1
0
        /// <summary>
        /// Dependency property event once the MdiChild's Buttons property has changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void ButtonsValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            MdiContainer mdiContainer = (MdiContainer)sender;
            Panel        panel        = (Panel)e.NewValue;

            mdiContainer._buttons.Child = panel;
            mdiContainer.MdiChildTitleChanged(mdiContainer, new RoutedEventArgs());
        }
예제 #2
0
        /// <summary>
        /// Dependency property event once the focused mdi child has changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void ActiveMdiChildValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            MdiContainer mdiContainer = (MdiContainer)sender;
            MdiChild     newChild     = (MdiChild)e.NewValue,
                         oldChild     = (MdiChild)e.OldValue;

            if (newChild == null || newChild == oldChild)
            {
                return;
            }

            if (oldChild != null && oldChild.WindowState == WindowState.Maximized)
            {
                newChild.WindowState = WindowState.Maximized;
            }

            int maxZindex = 0;

            for (int i = 0; i < mdiContainer.Children.Count; i++)
            {
                int zindex = Panel.GetZIndex(mdiContainer.Children[i]);
                if (zindex > maxZindex)
                {
                    maxZindex = zindex;
                }
                if (mdiContainer.Children[i] != newChild)
                {
                    mdiContainer.Children[i].Focused = false;
                }
                else
                {
                    newChild.Focused = true;
                }
            }

            Panel.SetZIndex(newChild, maxZindex + 1);

            if (mdiContainer.MdiChildTitleChanged != null)
            {
                mdiContainer.MdiChildTitleChanged(mdiContainer, new RoutedEventArgs());
            }
        }