Пример #1
0
 private void ResizeGripMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     beginPoint = e.GetPosition(this);
     dragging   = true;
     // Ensure object receives all mouse events.
     ResizeGrip.CaptureMouse();
 }
Пример #2
0
        private void GetInnerElementReferences()
        {
            var scrollViewer = (_listBox.Template.FindName("Border", _listBox) as Border).Child as ScrollViewer;

            _resizeGrip = scrollViewer.Template.FindName("ResizeGrip", scrollViewer) as ResizeGrip;
            _scrollBar  = scrollViewer.Template.FindName("PART_VerticalScrollBar", scrollViewer) as ScrollBar;
        }
Пример #3
0
        private void GetInnerElementReferences()
        {
            var border = (Border)_listBox.Template.FindName("Border", _listBox);

            _scrollViewer = (ScrollViewer)border.Child;
            _resizeGrip   = _scrollViewer.Template.FindName("ResizeGrip", _scrollViewer) as ResizeGrip;
            _scrollBar    = _scrollViewer.Template.FindName("PART_VerticalScrollBar", _scrollViewer) as ScrollBar;
        }
 private bool TrySetResizeGripHeight(ResizeGrip element, double height)
 {
     if (height <= 0)
     {
         return(false);
     }
     element.Height = height;
     return(true);
 }
Пример #5
0
 void _contentWindow_ContentRendered(object sender, EventArgs e)
 {
     _resizeGrip = _contentWindow.FindChildInVisualTree <ResizeGrip>();
     // hack to make sure the border is shown after content is shown
     _contentShown = true;
     if (_borderWindow != null)
     {
         _borderWindow.RepositionToContent(new WindowInteropHelper(_contentWindow).Handle, _hideOverride);
     }
 }
Пример #6
0
        private object CloseWindow(object obj)
        {
            if ((_win.Top != 100) || (_win.Left != 100) || (_win.ActualWidth != 400) || (_win.ActualHeight != 400))
            {
                throw new ApplicationException("Window: T/L/W/H did not pick up from explicit properties");
            }

            //verify whether the new style's been applied before closing
            Border border = VisualTreeHelper.GetChild(_win, 0) as Border;

            if (border == null)
            {
                throw new ApplicationException("Window Styling: The first visual child of Window is not Border");
            }

            DockPanel dockpanel = VisualTreeHelper.GetChild(border, 0)  as DockPanel;

            if (dockpanel == null)
            {
                throw new ApplicationException("Window Styling: The first visual child of Border is not DockPanel");
            }

            Button button = VisualTreeHelper.GetChild(dockpanel, 0) as Button;

            if (button == null)
            {
                throw new ApplicationException("Window Styling: The first visual child of the dockpanel is not Button");
            }

            DockPanel bottomDockPanel = VisualTreeHelper.GetChild(dockpanel, 1) as DockPanel;

            if (bottomDockPanel == null)
            {
                throw new ApplicationException("Window Styling: The second visual child of the dockpanel is not the BottomDockPanel");
            }

            ContentPresenter cp = VisualTreeHelper.GetChild(dockpanel, 2) as ContentPresenter;

            if (cp == null)
            {
                throw new ApplicationException("Window Styling: The third visual child of the dockpanel is not ContentPresenter");
            }

            ResizeGrip rg = VisualTreeHelper.GetChild(bottomDockPanel, 0) as ResizeGrip;

            if (rg == null)
            {
                throw new ApplicationException("Window Styling: The first visual child of the BottomDockPanel is not the ResizeGrip");
            }
            _win.Close();

            return(null);
        }
Пример #7
0
 protected void RestoreClick(object sender, RoutedEventArgs e)
 {
     ResizeGrip ResGrp = GetTemplateChild("ResGrp") as ResizeGrip;
     Border BorderShadow = GetTemplateChild("BorderShadow") as Border;
     this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight - (int)BorderShadow.Margin.Bottom + (int)BorderShadow.BorderThickness.Bottom;
     Button SpB = (Button)sender;
     SpB.Content = (WindowState == WindowState.Normal) ? 2 : 1;
     if (WindowState == WindowState.Normal)
     {
         ResGrp.Opacity = 0;
         WindowState = WindowState.Maximized;
     }
     else
     {
         ResGrp.Opacity = 1;
         WindowState = WindowState.Normal;
     };
 }
Пример #8
0
 protected void RestoreClickHeadr(object sender, MouseButtonEventArgs e)
 {
     if (e.ClickCount == 2)
     {
         Border BorderShadow = GetTemplateChild("BorderShadow") as Border;
         ResizeGrip ResGrp = GetTemplateChild("ResGrp") as ResizeGrip;
         this.MaxHeight = SystemParameters.PrimaryScreenHeight + (int)BorderShadow.Margin.Bottom + (int)BorderShadow.Margin.Top + (int)BorderShadow.BorderThickness.Bottom + (int)BorderShadow.Margin.Top;
         if (WindowState == WindowState.Normal)
         {
             ResGrp.Opacity = 0;
             WindowState = WindowState.Maximized;
         }
         else
         {
             ResGrp.Opacity = 1;
             WindowState = WindowState.Normal;
         };
     }
 }
Пример #9
0
        private void HideMargin()
        {
            ControlTemplate baseWindowTemplate = (ControlTemplate)App.Current.Resources["BaseWindowControlTemplate"];
            Border          borderTitle        = (Border)baseWindowTemplate.FindName("BorderTitle", this);
            Border          borderMain         = (Border)baseWindowTemplate.FindName("BorderMain", this);
            ResizeGrip      windowResizeGrip   = (ResizeGrip)baseWindowTemplate.FindName("WindowResizeGrip", this);

            if (WinState == JvedioWindowState.Normal)
            {
                if (borderTitle != null)
                {
                    borderTitle.Margin = new Thickness(2, 2, 2, 0);
                }
                if (borderMain != null)
                {
                    borderMain.Margin = new Thickness(2, 0, 2, 2);
                }
                if (windowResizeGrip != null)
                {
                    windowResizeGrip.Visibility = Visibility.Visible;
                }
            }
            else if (WinState == JvedioWindowState.Maximized || this.WindowState == WindowState.Maximized)
            {
                if (borderTitle != null)
                {
                    borderTitle.Margin = new Thickness(0);
                }
                if (borderMain != null)
                {
                    borderMain.Margin = new Thickness(0);
                }
                if (windowResizeGrip != null)
                {
                    windowResizeGrip.Visibility = Visibility.Collapsed;
                }
            }
        }
 public static IObservable <EventPattern <RoutedEventArgs> > UnloadedObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.Unloaded += h, h => This.Unloaded -= h));
 }
 public static IObservable <EventPattern <ManipulationCompletedEventArgs> > ManipulationCompletedObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <EventHandler <ManipulationCompletedEventArgs>, ManipulationCompletedEventArgs>(h => This.ManipulationCompleted += h, h => This.ManipulationCompleted -= h));
 }
 public static IObservable <EventPattern <ManipulationBoundaryFeedbackEventArgs> > ManipulationBoundaryFeedbackObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <EventHandler <ManipulationBoundaryFeedbackEventArgs>, ManipulationBoundaryFeedbackEventArgs>(h => This.ManipulationBoundaryFeedback += h, h => This.ManipulationBoundaryFeedback -= h));
 }
 public static IObservable <EventPattern <ManipulationInertiaStartingEventArgs> > ManipulationInertiaStartingObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <EventHandler <ManipulationInertiaStartingEventArgs>, ManipulationInertiaStartingEventArgs>(h => This.ManipulationInertiaStarting += h, h => This.ManipulationInertiaStarting -= h));
 }
 public static IObservable <EventPattern <GiveFeedbackEventArgs> > GiveFeedbackObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <GiveFeedbackEventHandler, GiveFeedbackEventArgs>(h => This.GiveFeedback += h, h => This.GiveFeedback -= h));
 }
 public static IObservable <EventPattern <MouseButtonEventArgs> > PreviewMouseDownObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.PreviewMouseDown += h, h => This.PreviewMouseDown -= h));
 }
 public static IObservable <EventPattern <TouchEventArgs> > TouchLeaveObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.TouchLeave += h, h => This.TouchLeave -= h));
 }
 public static IObservable <EventPattern <SizeChangedEventArgs> > SizeChangedObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <SizeChangedEventHandler, SizeChangedEventArgs>(h => This.SizeChanged += h, h => This.SizeChanged -= h));
 }
 public static IObservable <EventPattern <TouchEventArgs> > PreviewTouchUpObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.PreviewTouchUp += h, h => This.PreviewTouchUp -= h));
 }
 public static IObservable <EventPattern <DragEventArgs> > DropObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.Drop += h, h => This.Drop -= h));
 }
 public static IObservable <EventPattern <DragEventArgs> > PreviewDragLeaveObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.PreviewDragLeave += h, h => This.PreviewDragLeave -= h));
 }
 public static IObservable <EventPattern <RequestBringIntoViewEventArgs> > RequestBringIntoViewObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <RequestBringIntoViewEventHandler, RequestBringIntoViewEventArgs>(h => This.RequestBringIntoView += h, h => This.RequestBringIntoView -= h));
 }
 public static IObservable <EventPattern <ToolTipEventArgs> > ToolTipClosingObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <ToolTipEventHandler, ToolTipEventArgs>(h => This.ToolTipClosing += h, h => This.ToolTipClosing -= h));
 }
 public static IObservable <EventPattern <ContextMenuEventArgs> > ContextMenuClosingObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <ContextMenuEventHandler, ContextMenuEventArgs>(h => This.ContextMenuClosing += h, h => This.ContextMenuClosing -= h));
 }
 public static IObservable <EventPattern <TextCompositionEventArgs> > TextInputObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <TextCompositionEventHandler, TextCompositionEventArgs>(h => This.TextInput += h, h => This.TextInput -= h));
 }
 public static IObservable <EventPattern <MouseButtonEventArgs> > MouseUpObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.MouseUp += h, h => This.MouseUp -= h));
 }
 public static IObservable <EventPattern <QueryContinueDragEventArgs> > QueryContinueDragObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <QueryContinueDragEventHandler, QueryContinueDragEventArgs>(h => This.QueryContinueDrag += h, h => This.QueryContinueDrag -= h));
 }
Пример #27
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            handle = new WindowInteropHelper(this).Handle;

            //设置无标题窗口工作区,不遮挡任务栏
            Rect rect = SystemParameters.WorkArea;

            MaxWidth  = rect.Width;
            MaxHeight = rect.Height;

            icon            = GetTemplateChild(PART_Icon) as Image;
            icon.MouseDown += Icon_MouseDown;

            titleBar                      = GetTemplateChild(PART_TitleBar) as Grid;
            TitleBarHeight                = titleBar.Height;
            titleBar.MouseDown           += TitleBar_MouseDown;
            titleBar.MouseRightButtonUp  += TitleBar_MouseRightButtonUp;
            titleBar.MouseLeftButtonDown += TitleBar_MouseLeftButtonDown;

            btnMinimize        = GetTemplateChild(PART_TitleMinimizeButton) as Button;
            btnMinimize.Click += BtnMinimize_Click;

            btnMaximize        = GetTemplateChild(PART_TitleMaximizeButton) as Button;
            btnMaximize.Click += BtnMaximize_Click;

            btnRestore        = GetTemplateChild(PART_TitleRestoreButton) as Button;
            btnRestore.Click += BtnRestore_Click;

            btnClose        = GetTemplateChild(PART_TitleCloseButton) as Button;
            btnClose.Click += BtnClose_Click;

            topResizer            = GetTemplateChild <Thumb>(TopResizerName);
            topResizer.DragDelta += new DragDeltaEventHandler(ResizeTop);

            leftResizer            = GetTemplateChild <Thumb>(LeftResizerName);
            leftResizer.DragDelta += new DragDeltaEventHandler(ResizeLeft);

            rightResizer            = GetTemplateChild <Thumb>(RightResizerName);
            rightResizer.DragDelta += new DragDeltaEventHandler(ResizeRight);

            bottomResizer            = GetTemplateChild <Thumb>(BottomResizerName);
            bottomResizer.DragDelta += new DragDeltaEventHandler(ResizeBottom);

            resizeGrip = GetTemplateChild <ResizeGrip>(PART_ResizeGrip);

            bottomRightResizer            = GetTemplateChild <Thumb>(BottomRightResizerName);
            bottomRightResizer.DragDelta += new DragDeltaEventHandler(ResizeBottomRight);

            topRightResizer            = GetTemplateChild <Thumb>(TopRightResizerName);
            topRightResizer.DragDelta += new DragDeltaEventHandler(ResizeTopRight);

            topLeftResizer            = GetTemplateChild <Thumb>(TopLeftResizerName);
            topLeftResizer.DragDelta += new DragDeltaEventHandler(ResizeTopLeft);

            bottomLeftResizer            = GetTemplateChild <Thumb>(BottomLeftResizerName);
            bottomLeftResizer.DragDelta += new DragDeltaEventHandler(ResizeBottomLeft);

            maskGrid = GetTemplateChild <Grid>(PART_MaskGrid);

            SetModelWindowProperty();
        }
 public static IObservable <EventPattern <RoutedEventArgs> > LostFocusObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.LostFocus += h, h => This.LostFocus -= h));
 }
 public static IObservable <EventPattern <EventArgs> > LayoutUpdatedObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <EventHandler, EventArgs>(h => This.LayoutUpdated += h, h => This.LayoutUpdated -= h));
 }
 public static IObservable <EventPattern <DependencyPropertyChangedEventArgs> > FocusableChangedObserver(this ResizeGrip This)
 {
     return(Observable.FromEventPattern <DependencyPropertyChangedEventHandler, DependencyPropertyChangedEventArgs>(h => This.FocusableChanged += h, h => This.FocusableChanged -= h));
 }