Пример #1
0
 void DoClose()
 {
     if (Closed != null)
     {
         Closed(this, EventArgs.Empty);
     }
     LayoutMask.RemoveBox(this);
     if (this.Content is Border)
     {
         (this.Content as Border).Child = null;
     }
     //注销Mainpage的GotFocus事件
     if (Application.Current.RootVisual != null &&
         Application.Current.RootVisual is UserControl &&
         (Application.Current.RootVisual as UserControl).Content is Panel &&
         (Application.Current.RootVisual as UserControl).Content == this.m_container)
     {
         UIElementCollection collection = ((Application.Current.RootVisual as UserControl).Content as Panel).Children;
         foreach (var item in collection)
         {
             if (item.GetType().Name == "MainPage")
             {
                 var control = item as UserControl;
                 if (control != null && m_attachedRootVisualListener)
                 {
                     control.GotFocus            -= new RoutedEventHandler(control_GotFocus);
                     m_attachedRootVisualListener = false;
                 }
                 break;
             }
         }
     }
 }
Пример #2
0
        public PopupBox(Panel layoutRoot)
            : this()
        {
            this.DefaultStyleKey = typeof(PopupBox);
            m_container          = layoutRoot;
            LayoutMask           = new LayoutMask(m_container);

            if (this.m_container is Grid)
            {
                Grid container = this.m_container as Grid;

                if (container.RowDefinitions.Count > 1)
                {
                    Grid.SetRowSpan(this.LayoutMask.MaskPanel, container.RowDefinitions.Count);
                }

                if (container.ColumnDefinitions.Count > 1)
                {
                    Grid.SetColumnSpan(this.LayoutMask.MaskPanel, container.ColumnDefinitions.Count);
                }
            }

            m_translate = new TranslateTransform();
            m_tf        = new TransformGroup();
            m_tf.Children.Add(m_translate);
            this.RenderTransform = m_tf;
            this.KeyDown        += new KeyEventHandler(PopupBox_KeyDown);
        }
Пример #3
0
 public void Show(bool isModal)
 {
     IsModal = isModal;
     if (LayoutMask != null)
     {
         LayoutMask.AddBox(this);
         if (this.Current != null)
         {
             Current.Tag = LayoutMask.MaskPanel;
         }
         this.Focus();
     }
     Canvas.SetZIndex(this, LayoutMask.MaxZIndex + 3000);
     OnShowed(EventArgs.Empty);
     DoShow();
 }