private static bool IsThreeByThreeGrid(this WindowLocation windowLocation)
 {
     return(windowLocation != WindowLocation.TopLeft &&
            windowLocation != WindowLocation.TopRight &&
            windowLocation != WindowLocation.BottomLeft &&
            windowLocation != WindowLocation.BottomRight);
 }
 public void ShowIcons(WindowLocation windowLocations)
 {
     _buttonLeft.Visibility   = windowLocations.HasFlag(WindowLocation.Left) ? Visibility.Visible : Visibility.Hidden;
     _buttonTop.Visibility    = windowLocations.HasFlag(WindowLocation.Top) ? Visibility.Visible : Visibility.Hidden;
     _buttonRight.Visibility  = windowLocations.HasFlag(WindowLocation.Right) ? Visibility.Visible : Visibility.Hidden;
     _buttonBottom.Visibility = windowLocations.HasFlag(WindowLocation.Bottom) ? Visibility.Visible : Visibility.Hidden;
     _buttonMiddle.Visibility = windowLocations.HasFlag(WindowLocation.Middle) ? Visibility.Visible : Visibility.Hidden;
 }
示例#3
0
        private Rectangle GetLocation(IntPtr handle)
        {
            var location = new WindowLocation();

            location.length = Marshal.SizeOf(location);
            GetWindowPlacement(handle, ref location);
            return(location.rcNormalPosition);
        }
 public MessageWindow(WindowLocation NewLocation, GameObject Player)
 {
     //
     ThisWindow      = new WindowBase();
     MessageString   = new List <GameObject>();
     CurrentLocation = Vector3.zero;
     WindowLocation  = NewLocation;
     //
     CreateWindow(Player);
     SetMaxLineSize();
     ClearContent();
 }
 public void HideInsertionIndicator()
 {
     if (_insertionIndicator != null)
     {
         if (ParentGrid.Children.Contains(_insertionIndicator))
         {
             ParentGrid.Children.Remove(_insertionIndicator);
         }
         _insertionIndicator = null;
         WindowLocation      = WindowLocation.None;
     }
 }
        //
        public MessageWindow()
        {
            //
            ThisWindow      = new WindowBase();
            MessageString   = new List <GameObject>();
            CurrentLocation = Vector3.zero;
            WindowLocation  = WindowLocation.BOTTOM;

            //
            CreateWindow();
            SetMaxLineSize();
            ClearContent();
        }
示例#7
0
        private void MoveWindow(WindowLocation location)
        {
            switch (location)
            {
            case WindowLocation.TOPLEFT:
                this.Left = 0;
                this.Top  = 0;
                break;

            case WindowLocation.TOPRIGHT:
                this.Left = Helper.GetScreenWidth() - this.Width;
                this.Top  = 0;
                break;
            }
        }
示例#8
0
        /// <summary>
        /// Saves the current position of a form in the registry, given the position values.
        /// </summary>
        /// <param name="name">
        /// A unique name for the form.
        /// </param>
        /// <param name="location">
        /// The location of the form.
        /// </param>
        /// <param name="size">
        /// The size of the form.
        /// </param>
        /// <param name="state">
        /// The window state of the form.
        /// </param>
        /// <returns>
        /// Return false if the position could not be saved.
        /// </returns>
        public bool SaveWindowPosition(string name, Point location, Size size, FormWindowState state)
        {
            Param.RequireValidString(name, "name");
            Param.Ignore(location);
            Param.Ignore(size);
            Param.Ignore(state);

            WindowLocation windowLocation = new WindowLocation();

            windowLocation.Location = location;
            windowLocation.Size     = size;
            windowLocation.State    = state;

            return(this.CUSetValue("WindowLocation\\" + name, windowLocation));
        }
示例#9
0
        public static void Move(Form form, WindowLocation location)
        {
            int screenWidth = Screen.PrimaryScreen.Bounds.Width;
            int screenHight = Screen.PrimaryScreen.Bounds.Height;

            switch (location)
            {
            case WindowLocation.TopLeft:
                form.Location = new Point(0, 0);
                break;

            case WindowLocation.TopRight:
                form.Location = new Point(screenWidth - form.Width, 0);
                break;

            case WindowLocation.BottomRight:
                form.Location = new Point(screenWidth - form.Width, screenHight - form.Height - (Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom));
                break;

            case WindowLocation.BottomLeft:
                form.Location = new Point(0, screenHight - form.Height - (Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom));
                break;

            case WindowLocation.Center:
                form.Location = new Point((screenWidth - form.Width) / 2, (screenHight - form.Height - (Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom)) / 2);
                break;

            case WindowLocation.None:
                form.Location = new Point(-1000, -1000);
                break;

            case WindowLocation.TopCenter:
                form.Location = new Point((screenWidth - form.Width) / 2, 0);
                break;

            case WindowLocation.RightCenter:
                form.Location = new Point(screenWidth - form.Width, (screenHight - form.Height - (Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom)) / 2);
                break;

            case WindowLocation.BottomCenter:
                form.Location = new Point((screenWidth - form.Width) / 2, screenHight - form.Height - (Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom));
                break;

            case WindowLocation.LeftCenter:
                form.Location = new Point(0, (screenHight - form.Height - (Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom)) / 2);
                break;
            }
        }
        private void FloatingPane_EndDrag(object sender, EventArgs e)
        {
            System.Diagnostics.Trace.Assert(sender is FloatingPane, System.Reflection.MethodBase.GetCurrentMethod().Name + ": sender not a FloatingPane");
            Application.Current.Dispatcher.Invoke(delegate
            {
                FloatingPane floatingPane = sender as FloatingPane;

                if (
                    (floatingPane == null) ||
                    ((SelectedPane != null) && !(SelectedPane is FloatingPane) && !(SelectedPane.Parent is SplitterPane) && !(SelectedPane.Parent is DocumentPanel) && (SelectedPane.Parent != IFloatingPaneHost.RootGrid)) ||
                    (_insertionIndicatorManager == null) ||
                    (_insertionIndicatorManager.WindowLocation == WindowLocation.None)
                    )
                {
                    if (floatingPane != null)
                    {
                        floatingPane.Close();
                    }
                    CancelSelection();
                    return;
                }

                ISelectablePane selectedPane  = SelectedPane;
                WindowLocation windowLocation = _insertionIndicatorManager.WindowLocation;
                CancelSelection();

                if (selectedPane is FloatingPane)
                {
                    IFloatingPane selectedFloatingPane = selectedPane as IFloatingPane;
                    selectedFloatingPane.IViewContainer.ExtractDocuments(floatingPane.IViewContainer);
                    if (floatingPane is FloatingToolPaneGroup)
                    {
                        FloatingToolPaneGroups.Remove(floatingPane);
                    }
                    else
                    {
                        FloatingDocumentPaneGroups.Remove(floatingPane);
                    }
                    floatingPane.Close();
                }
                else
                {
                    IFloatingPaneHost.Unfloat(floatingPane, selectedPane as SelectablePane, windowLocation);
                }

                Application.Current.MainWindow.Activate();
            });
        }
示例#11
0
        public void MakeUnpinnedToolPaneGroup(WindowLocation windowLocation, ToolPaneGroup toolPaneGroup, string siblingGuid, bool isHorizontal, bool isFirst)
        {
            Controls.IToolListBox iToolListBox = IUnpinnedToolHost.GetToolListBox(windowLocation);

            System.Diagnostics.Trace.Assert(iToolListBox != null);
            System.Diagnostics.Trace.Assert(toolPaneGroup != null);

            UnpinnedToolData unpinnedToolData = new UnpinnedToolData();

            unpinnedToolData.ToolPaneGroup = toolPaneGroup;
            unpinnedToolData.SiblingGuid   = new Guid(siblingGuid);
            unpinnedToolData.IsFirst       = isFirst;
            unpinnedToolData.IsHorizontal  = isHorizontal;

            AddUnpinnedToolData(unpinnedToolData, windowLocation, iToolListBox);
        }
示例#12
0
        private void AddUnpinnedToolData(UnpinnedToolData unpinnedToolData, WindowLocation windowLocation, Controls.IToolListBox toolListBox)
        {
            _dictUnpinnedToolData[windowLocation].Add(unpinnedToolData);

            int count = unpinnedToolData.ToolPaneGroup.IViewContainer.GetUserControlCount();

            for (int i = 0; i < count; ++i)
            {
                ToolListBoxItem toolListBoxItem = new ToolListBoxItem()
                {
                    IViewContainer = unpinnedToolData.ToolPaneGroup.IViewContainer,
                    Index          = i,
                };
                (toolListBox.ItemsSource as System.Collections.ObjectModel.ObservableCollection <Controls.IToolListBoxItem>).Add(toolListBoxItem);
                unpinnedToolData.Items.Add(toolListBoxItem);
            }
        }
示例#13
0
        private void CreateToolListBox(int row, int column, bool isHorizontal, WindowLocation windowLocation)
        {
            ObservableCollection <Controls.IToolListBoxItem> items = new ObservableCollection <Controls.IToolListBoxItem>();

            Controls.ToolListBox toolListBox = new Controls.ToolListBox();
            toolListBox.TextAngle          = ((windowLocation == WindowLocation.TopSide) || (windowLocation == WindowLocation.RightSide)) ? 180.0 : 0.0;
            toolListBox.WindowLocation     = windowLocation;
            toolListBox.ItemsSource        = items;
            toolListBox.IsHorizontal       = isHorizontal;
            toolListBox.DisplayMemberPath  = "Title";
            toolListBox.ItemContainerStyle = FindResource("SideToolItemStyle") as Style;
            toolListBox.ItemClick         += ToolListBox_ItemClick;
            Children.Add(toolListBox);
            Grid.SetRow(toolListBox, row);
            Grid.SetColumn(toolListBox, column);

            _dictToolListBoxes.Add(windowLocation, toolListBox);
        }
        public void CreateWindow(GameObject Player)
        {
            switch (WindowLocation)
            {
            case WindowLocation.BOTTOM:
            {
                CurrentLocation = new Vector3(0, -3);
                break;
            }

            case WindowLocation.TOP:
            {
                CurrentLocation = new Vector3(0, 3);
                break;
            }

            case WindowLocation.CENTER:
            {
                CurrentLocation = Vector3.zero;
                break;
            }

            default:
            {
                CurrentLocation = new Vector3(0, 3);
                WindowLocation  = WindowLocation.BOTTOM;
                break;
            }
            }

            //
            ThisWindow.CreateWindow("Message", new Vector2(5, 1), CurrentLocation, false, Player);

            //
            NextPrompt      = Object.Instantiate(Resources.Load("Prefabs/MessageWindow/NextCursor")) as GameObject;
            NextPrompt.name = "NextCursor";
            NextPrompt.transform.position  = ThisWindow.WindowContainer.transform.position;
            NextPrompt.transform.position += new Vector3(0, ThisWindow.WindowSize.y - 2.5f, 0);
            NextPrompt.transform.parent    = ThisWindow.WindowContainer.transform;
        }
        public bool ShowInsertionIndicator(WindowLocation windowLocation)
        {
            if (windowLocation == WindowLocation.None)
            {
                HideInsertionIndicator();
                return(true);
            }

            if (windowLocation == WindowLocation)
            {
                return(true);
            }

            WindowLocation = windowLocation;

            if (_insertionIndicator != null)
            {
                ParentGrid.Children.Remove(_insertionIndicator);
                _insertionIndicator = null;
            }

            _insertionIndicator = CreateInsertionIndicator(windowLocation);

            if (_insertionIndicator != null)
            {
                Grid.SetRow(_insertionIndicator, 0);
                if (ParentGrid.RowDefinitions.Count() > 0)
                {
                    Grid.SetRowSpan(_insertionIndicator, ParentGrid.RowDefinitions.Count());
                }
                Grid.SetColumn(_insertionIndicator, 0);
                if (ParentGrid.ColumnDefinitions.Count() > 0)
                {
                    Grid.SetColumnSpan(_insertionIndicator, ParentGrid.ColumnDefinitions.Count());
                }
                ParentGrid.Children.Add(_insertionIndicator);
            }

            return(false);
        }
示例#16
0
 public LiveLog()
 {
     InitializeComponent();
     ListBoxLog ??= new ListBoxLog(rtbLiveLog);
     WindowLocation.GeometryFromString(Properties.Settings.Default.LogWindowLocation, this);
 }
示例#17
0
 void IUnpinnedToolHost.UnpinToolPane(ToolPaneGroup toolPaneGroup, out UnpinnedToolData unpinnedToolData, out WindowLocation toolListBoxLocation)
 {
     IDockPaneManager.UnpinToolPane(toolPaneGroup, out unpinnedToolData, out toolListBoxLocation);
 }
示例#18
0
 void IUnpinnedToolHost.PinToolPane(UnpinnedToolData unpinnedToolData, WindowLocation defaultWindowLocation)
 {
     IDockPaneManager.PinToolPane(unpinnedToolData, defaultWindowLocation);
 }
示例#19
0
        IToolListBox IUnpinnedToolHost.GetToolListBox(WindowLocation windowLocation)
        {
            System.Diagnostics.Trace.Assert(_dictToolListBoxes.ContainsKey(windowLocation));

            return(_dictToolListBoxes[windowLocation]);
        }
示例#20
0
 void ILayoutFactory.MakeUnpinnedToolPaneGroup(WindowLocation windowLocation, ToolPaneGroup toolPaneGroup, string siblingGuid, bool isHorizontal, bool isFirst)
 {
     IUnpinnedToolManager.MakeUnpinnedToolPaneGroup(windowLocation, toolPaneGroup, siblingGuid, isHorizontal, isFirst);
 }
        public void ShowDialog(string key, object viewModel, string title,
                               Dictionary <string, object> ctrlPropertiesToSet,
                               Dictionary <string, object> windowPropertiesToSet, bool isModal = true,
                               Action <CancelEventArgs> winClosing = null, SolidColorBrush background = null, System.Windows.Style customStyle = null, WindowStartupLocation location = WindowStartupLocation.CenterOwner, WindowLocation customLocation = WindowLocation.Ignore)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            Type controlType;

            if (!registeredPopups.TryGetValue(key, out controlType))
            {
                return;
            }

            Window win = null;

            if (typeof(Window).IsAssignableFrom(controlType))
            {
                // Create instance of the window to be poppped up
                foreach (ConstructorInfo cnstrInfo in controlType.GetConstructors())
                {
                    ParameterInfo[] paramInfos = cnstrInfo.GetParameters();

                    if (paramInfos.Length == 1 && paramInfos[0].ParameterType.IsAssignableFrom(viewModel.GetType()))
                    {
                        win = (Window)cnstrInfo.Invoke(new object[] { viewModel });
                        break;
                    }
                    else if (paramInfos.Length == 0)
                    {
                        win = (Window)cnstrInfo.Invoke(null);
                        break;
                    }
                }

                if (win == null)
                {
                    throw new Exception("Unable to find proper constructor of the popup.");
                }
                //win = (Window)Activator.CreateInstance(controlType);
            }
            else
            {
                // Create instance of the user control to be poppped up
                Control ctrl = null;
                foreach (ConstructorInfo cnstrInfo in controlType.GetConstructors())
                {
                    ParameterInfo[] paramInfos = cnstrInfo.GetParameters();

                    if (paramInfos.Length == 1 && paramInfos[0].ParameterType.IsAssignableFrom(viewModel.GetType()))
                    {
                        ctrl = (Control)cnstrInfo.Invoke(new object[] { viewModel });
                        break;
                    }
                    else if (paramInfos.Length == 0)
                    {
                        ctrl = (Control)cnstrInfo.Invoke(null);
                        break;
                    }
                }

                if (ctrl == null)
                {
                    throw new Exception("Unable to find proper constructor of the popup user control.");
                }
                //Control ctrl = //(Control)this.container.Resolve(controlType); // (Control)Activator.CreateInstance(controlType);
                //    (Control)Activator.CreateInstance(controlType, viewModel);

                // Create window and add the user control to it
                win      = new Window();
                win.Name = key;
                //if(this.icon != null)
                //    win.Icon = this.icon;

                System.Windows.Media.SolidColorBrush backgroundBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White);
                if (background != null)
                {
                    backgroundBrush = background;
                }
                var  adornerDecorator = new System.Windows.Documents.AdornerDecorator();
                Grid layoutGrid       = new Grid();
                layoutGrid.Name       = "popupGrid";
                layoutGrid.Background = backgroundBrush;
                ctrl.Margin           = new Thickness(5);
                layoutGrid.Children.Add(ctrl);
                adornerDecorator.Child = layoutGrid;
                win.Content            = adornerDecorator;

                win.WindowStartupLocation = location;
                if (location == WindowStartupLocation.Manual)
                {
                    win.Loaded += (sender, e) =>
                    {
                        var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
                        switch (customLocation)
                        {
                        case WindowLocation.CenterLeft:
                            win.Left = 0;
                            win.Top  = (desktopWorkingArea.Height - win.Height) / 2;
                            break;

                        case WindowLocation.BottomRight:
                            win.Left = desktopWorkingArea.Right - win.Width;
                            win.Top  = desktopWorkingArea.Bottom - win.Height;
                            break;

                        case WindowLocation.Ignore:
                            break;

                        case WindowLocation.MouseCursor:
                            win.Left = System.Windows.Forms.Control.MousePosition.X;
                            win.Top  = System.Windows.Forms.Control.MousePosition.Y;
                            break;
                        }
                    };
                }

                // Adjust popup window's sizing properties with the user control
                //if (double.IsNaN(ctrl.Width) || double.IsNaN(ctrl.Height))
                //{
                //    win.Width = 800; win.Height = 500; // use some predefined Constant relative to main window size
                //}
                //else
                {
                    win.SizeToContent = SizeToContent.WidthAndHeight;
                    //win.ResizeMode = ResizeMode.CanResizeWithGrip; // To be able to resize even with windowstyle none and allowtransparency true
                }

                // Set any property of the control user wants to set by force
                if (ctrlPropertiesToSet != null)
                {
                    foreach (PropertyInfo pInfo in controlType.GetProperties())
                    {
                        if (ctrlPropertiesToSet.ContainsKey(pInfo.Name))
                        {
                            object objPropertyValue = ctrlPropertiesToSet[pInfo.Name];
                            if (objPropertyValue != null)
                            {
                                pInfo.SetValue(ctrl, objPropertyValue, null);
                            }
                        }
                    }
                }
            }

            win.DataContext = viewModel;

            // set popup window title
            if (!string.IsNullOrEmpty(title))
            {
                win.Title = title;
            }


            win.ShowInTaskbar = false;

            if (!openedPopups.ContainsKey(key))
            {
                openedPopups.Add(key, win);
            }
            win.Tag = key;

            if (winClosing != null)
            {
                win.Closing += new CancelEventHandler
                               (
                    (sender, e) =>
                {
                    winClosing(e);
                }
                               );
            }

            win.Closed += new EventHandler(win_Closed);



            // Set any property of the window user wants to set by force
            if (windowPropertiesToSet != null)
            {
                foreach (PropertyInfo pInfo in win.GetType().GetProperties())
                {
                    if (windowPropertiesToSet.ContainsKey(pInfo.Name))
                    {
                        object objPropertyValue = windowPropertiesToSet[pInfo.Name];
                        if (objPropertyValue != null)
                        {
                            pInfo.SetValue(win, objPropertyValue, null);
                        }
                    }
                }
            }

            win.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(win_PreviewKeyDown); // prevent "KeyDown" event from being fired when "busy" is being shown
            this.eventAggregator.PublishOnUIThread(new PopupOpenedEvent {
                PopupWindow = win
            });


            if (customStyle != null)
            {
                win.Style = customStyle;
            }

            if (isModal)
            {
                win.Owner = Application.Current.MainWindow;
                win.ShowDialog();
            }
            else
            {
                win.WindowStyle = WindowStyle.None; // Modeless window, assuming user will implement necessary window actions e.g. close, minimize, maximize etc. Need to fix this in future.
                win.Show();
            }
        }
示例#22
0
 public bool RestoreWindowPosition(string name, Form form, object location, object size)
 {
     Param.RequireValidString(name, "name");
     Param.RequireNotNull(form, "form");
     bool flag = false;
     object obj2 = this.CUGetValue(@"WindowLocation\" + name);
     if (obj2 == null)
     {
         if (location != null)
         {
             form.Location = (Point) location;
         }
         if (size != null)
         {
             form.Size = (Size) size;
         }
     }
     else
     {
         WindowLocation location2 = new WindowLocation((string) obj2);
         form.Location = location2.Location;
         form.Size = location2.Size;
         form.WindowState = location2.State;
         form.StartPosition = FormStartPosition.Manual;
         flag = true;
     }
     if (form.WindowState == FormWindowState.Normal)
     {
         Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;
         if (form.Width > workingArea.Width)
         {
             form.Width = workingArea.Width;
         }
         if (form.Height > workingArea.Height)
         {
             form.Height = workingArea.Height;
         }
         int x = form.Location.X;
         if (x < 0)
         {
             x = 0;
         }
         if ((x + form.Width) > workingArea.Right)
         {
             x = workingArea.Right - form.Width;
         }
         int y = form.Location.Y;
         if (y < 0)
         {
             y = 0;
         }
         if ((y + form.Height) > workingArea.Bottom)
         {
             y = workingArea.Bottom - form.Height;
         }
         form.Location = new Point(x, y);
     }
     return flag;
 }
示例#23
0
 public bool SaveWindowPosition(string name, Point location, Size size, FormWindowState state)
 {
     Param.RequireValidString(name, "name");
     WindowLocation location2 = new WindowLocation();
     location2.Location = location;
     location2.Size = size;
     location2.State = state;
     return this.CUSetValue(@"WindowLocation\" + name, location2);
 }
        private void FloatingWindow_LocationChanged(object sender, EventArgs e)
        {
            System.Diagnostics.Trace.Assert(sender is FloatingPane);

            Window          floatingWindow         = sender as Window;
            Point           cursorPositionOnScreen = OpenControls.Wpf.Utilities.Windows.GetCursorPosition();
            ISelectablePane previousPane           = SelectedPane;
            bool            foundSelectedPane      = false;

            int           windowCount = 0;
            List <IntPtr> hWnds       = new List <IntPtr>();
            Dictionary <IntPtr, IFloatingPane> dict = new Dictionary <IntPtr, IFloatingPane>();

            List <IFloatingPane> floatingPanes = (sender is FloatingToolPaneGroup) ? FloatingToolPaneGroups : FloatingDocumentPaneGroups;

            foreach (IFloatingPane iFloatingPane in floatingPanes)
            {
                if (iFloatingPane != sender)
                {
                    Point         cursorPositionInFloatingPane = (iFloatingPane as FloatingPane).PointFromScreen(cursorPositionOnScreen);
                    ViewContainer viewContainer = (iFloatingPane.IViewContainer as ViewContainer);
                    if (
                        (cursorPositionInFloatingPane.X >= 0) &&
                        (cursorPositionInFloatingPane.X <= iFloatingPane.ActualWidth) &&
                        (cursorPositionInFloatingPane.Y >= 0) &&
                        (cursorPositionInFloatingPane.Y <= iFloatingPane.ActualHeight)
                        )
                    {
                        var wih = new System.Windows.Interop.WindowInteropHelper((iFloatingPane as FloatingPane));
                        hWnds.Add(wih.Handle);
                        dict.Add(wih.Handle, iFloatingPane);
                        windowCount++;
                    }
                }
            }

            if (windowCount > 0)
            {
                IntPtr intPtr = GetTopmostWindow(hWnds);
                if (dict.ContainsKey(intPtr))
                {
                    foundSelectedPane = true;
                    IFloatingPane iFloatingPane = dict[intPtr];

                    if (SelectedPane != null)
                    {
                        SelectedPane.IsHighlighted = false;
                    }

                    if (SelectedPane != iFloatingPane)
                    {
                        _windowLocationPane?.Close();
                        _windowLocationPane         = null;
                        SelectedPane                = iFloatingPane;
                        iFloatingPane.IsHighlighted = true;

                        _windowLocationPane = new WindowLocationPane();
                        _windowLocationPane.AllowsTransparency = true;
                        _windowLocationPane.ShowIcons(WindowLocation.Middle);
                        ViewContainer viewContainer    = (iFloatingPane.IViewContainer as ViewContainer);
                        Point         topLeftPanePoint = viewContainer.PointToScreen(new Point(0, 0));

                        PresentationSource source = PresentationSource.FromVisual(viewContainer);
                        double             dpix   = source.CompositionTarget.TransformToDevice.M11;
                        double             dpiy   = source.CompositionTarget.TransformToDevice.M22;

                        _windowLocationPane.Left   = topLeftPanePoint.X / dpix;
                        _windowLocationPane.Top    = topLeftPanePoint.Y / dpiy;
                        _windowLocationPane.Width  = viewContainer.ActualWidth;
                        _windowLocationPane.Height = viewContainer.ActualHeight;
                        _windowLocationPane.Show();
                    }
                    _sideLocationPane?.Close();
                    _sideLocationPane = null;
                }
            }

            if (!foundSelectedPane)
            {
                Point cursorPositionInMainWindow = IFloatingPaneHost.RootGrid.PointFromScreen(cursorPositionOnScreen);
                if (
                    (cursorPositionInMainWindow.X >= 0) &&
                    (cursorPositionInMainWindow.X <= IFloatingPaneHost.RootGrid.ActualWidth) &&
                    (cursorPositionInMainWindow.Y >= 0) &&
                    (cursorPositionInMainWindow.Y <= IFloatingPaneHost.RootGrid.ActualHeight)
                    )
                {
                    Type paneType = (sender is FloatingDocumentPaneGroup) ? typeof(DocumentPaneGroup) : typeof(ToolPaneGroup);
                    var  pane     = IFloatingPaneHost.FindSelectablePane(cursorPositionOnScreen);
                    foundSelectedPane = pane != null;
                    if ((pane != null) && (SelectedPane != pane))
                    {
                        if (SelectedPane != null)
                        {
                            SelectedPane.IsHighlighted = false;
                        }

                        pane.IsHighlighted = true;
                        SelectedPane       = pane;
                        _windowLocationPane?.Close();
                        _windowLocationPane = null;

                        if ((paneType == pane.GetType()) || ((pane is DocumentPanel) && (sender is FloatingDocumentPaneGroup)))
                        {
                            _windowLocationPane = new WindowLocationPane();
                            _windowLocationPane.AllowsTransparency = true;
                            if (SelectedPane is DocumentPanel)
                            {
                                _windowLocationPane.ShowIcons(WindowLocation.Middle);
                            }
                            Point topLeftPanePoint = pane.PointToScreen(new Point(0, 0));

                            PresentationSource source = PresentationSource.FromVisual((UIElement)pane);
                            double             dpix   = source.CompositionTarget.TransformToDevice.M11;
                            double             dpiy   = source.CompositionTarget.TransformToDevice.M22;

                            _windowLocationPane.Left   = topLeftPanePoint.X / dpix;
                            _windowLocationPane.Top    = topLeftPanePoint.Y / dpiy;
                            _windowLocationPane.Width  = SelectedPane.ActualWidth;
                            _windowLocationPane.Height = SelectedPane.ActualHeight;
                            _windowLocationPane.Show();
                        }
                    }

                    if (sender is FloatingToolPaneGroup)
                    {
                        if (_sideLocationPane == null)
                        {
                            _sideLocationPane = new SideLocationPane();
                            _sideLocationPane.AllowsTransparency = true;
                        }

                        Point topLeftRootPoint = IFloatingPaneHost.RootPane.PointToScreen(new Point(0, 0));

                        PresentationSource source = PresentationSource.FromVisual(IFloatingPaneHost.RootPane);
                        double             dpix   = source.CompositionTarget.TransformToDevice.M11;
                        double             dpiy   = source.CompositionTarget.TransformToDevice.M22;

                        _sideLocationPane.Left   = topLeftRootPoint.X / dpix;
                        _sideLocationPane.Top    = topLeftRootPoint.Y / dpiy;
                        _sideLocationPane.Width  = IFloatingPaneHost.RootPane.ActualWidth;
                        _sideLocationPane.Height = IFloatingPaneHost.RootPane.ActualHeight;
                        _sideLocationPane.Show();
                    }
                }
            }

            if (!foundSelectedPane)
            {
                SelectedPane = null;
                _windowLocationPane?.Close();
                _windowLocationPane = null;
            }

            if ((previousPane != null) && (SelectedPane != previousPane))
            {
                previousPane.IsHighlighted = false;
            }

            WindowLocation windowLocation = WindowLocation.None;

            if (sender is FloatingDocumentPaneGroup)
            {
                _sideLocationPane?.Close();
                _sideLocationPane = null;
            }

            if (_sideLocationPane != null)
            {
                windowLocation = _sideLocationPane.TrySelectIndicator(cursorPositionOnScreen);
                switch (windowLocation)
                {
                case WindowLocation.LeftSide:
                case WindowLocation.RightSide:
                case WindowLocation.TopSide:
                case WindowLocation.BottomSide:
                    if ((_insertionIndicatorManager != null) && (_insertionIndicatorManager.ParentGrid != IFloatingPaneHost))
                    {
                        _insertionIndicatorManager.HideInsertionIndicator();
                        _insertionIndicatorManager = null;
                    }
                    if (_insertionIndicatorManager == null)
                    {
                        _insertionIndicatorManager = new InsertionIndicatorManager(IFloatingPaneHost.RootGrid);
                    }
                    _insertionIndicatorManager.ShowInsertionIndicator(windowLocation);
                    return;
                }
            }

            if ((_windowLocationPane != null) && (SelectedPane != null))
            {
                windowLocation = _windowLocationPane.TrySelectIndicator(cursorPositionOnScreen);
                if ((_insertionIndicatorManager != null) && (_insertionIndicatorManager.ParentGrid != SelectedPane))
                {
                    _insertionIndicatorManager.HideInsertionIndicator();
                    _insertionIndicatorManager = null;
                }
                if (_insertionIndicatorManager == null)
                {
                    if (SelectedPane is IFloatingPane)
                    {
                        _insertionIndicatorManager = new InsertionIndicatorManager(((SelectedPane as IFloatingPane).IViewContainer as ViewContainer));
                    }
                    else
                    {
                        _insertionIndicatorManager = new InsertionIndicatorManager(SelectedPane as Grid);
                    }
                }

                _insertionIndicatorManager.ShowInsertionIndicator(windowLocation);
            }
            else
            {
                _insertionIndicatorManager?.HideInsertionIndicator();
                _insertionIndicatorManager = null;
            }
        }
示例#25
0
        /// <summary>
        /// Saves the current position of a form in the registry, given the position values.
        /// </summary>
        /// <param name="name">A unique name for the form.</param>
        /// <param name="location">The location of the form.</param>
        /// <param name="size">The size of the form.</param>
        /// <param name="state">The window state of the form.</param>
        /// <returns>Return false if the position could not be saved.</returns>
        public bool SaveWindowPosition(string name, Point location, Size size, FormWindowState state)
        {
            Param.RequireValidString(name, "name");
            Param.Ignore(location);
            Param.Ignore(size);
            Param.Ignore(state);

            WindowLocation windowLocation = new WindowLocation();
            windowLocation.Location = location;
            windowLocation.Size = size;
            windowLocation.State = state;

            return this.CUSetValue("WindowLocation\\" + name, windowLocation);
        }
示例#26
0
        /// <summary>
        /// Restores the position of a form.
        /// </summary>
        /// <param name="name">The unique name of the form.</param>
        /// <param name="form">The form to restore.</param>
        /// <param name="location">Form's default location (optional).</param>
        /// <param name="size">Form's default size (optional).</param>
        /// <returns>Returns false if there is no registry informtion for this form, or if 
        /// the position of the form could not be restored.</returns>
        public bool RestoreWindowPosition(string name, Form form, object location, object size)
        {
            Param.RequireValidString(name, "name");
            Param.RequireNotNull(form, "form");
            Param.Ignore(location);
            Param.Ignore(size);

            bool ret = false;

            object loc = this.CUGetValue("WindowLocation\\" + name);
            if (loc == null)
            {
                // Apply passed defaults.
                if (location != null)
                {
                    form.Location = (Point)location;
                }

                if (size != null)
                {
                    form.Size = (Size)size;
                }
            }
            else
            {
                WindowLocation winLoc = new WindowLocation((string)loc);
                form.Location = winLoc.Location;
                form.Size = winLoc.Size;
                form.WindowState = winLoc.State;
                form.StartPosition = FormStartPosition.Manual;

                ret = true;
            }

            // Determine if the Location and Size is within the Screen's boundaries.
            if (form.WindowState == FormWindowState.Normal)
            {
                System.Drawing.Rectangle workArea = Screen.PrimaryScreen.WorkingArea;

                if (form.Width > workArea.Width)
                {
                    form.Width = workArea.Width;
                }

                if (form.Height > workArea.Height)
                {
                    form.Height = workArea.Height;
                }

                int posX = form.Location.X;
                if (posX < 0)
                {
                    posX = 0;
                }

                if (posX + form.Width > workArea.Right)
                {
                    posX = workArea.Right - form.Width;
                }

                int posY = form.Location.Y;
                if (posY < 0)
                {
                    posY = 0;
                }

                if (posY + form.Height > workArea.Bottom)
                {
                    posY = workArea.Bottom - form.Height;
                }

                form.Location = new Point(posX, posY);
            }

            return ret;
        }
示例#27
0
        /// <summary>
        /// Restores the position of a form.
        /// </summary>
        /// <param name="name">
        /// The unique name of the form.
        /// </param>
        /// <param name="form">
        /// The form to restore.
        /// </param>
        /// <param name="location">
        /// Form's default location (optional).
        /// </param>
        /// <param name="size">
        /// Form's default size (optional).
        /// </param>
        /// <returns>
        /// Returns false if there is no registry information for this form, or if
        /// the position of the form could not be restored.
        /// </returns>
        public bool RestoreWindowPosition(string name, Form form, object location, object size)
        {
            Param.RequireValidString(name, "name");
            Param.RequireNotNull(form, "form");
            Param.Ignore(location);
            Param.Ignore(size);

            bool ret = false;

            object loc = this.CUGetValue("WindowLocation\\" + name);

            if (loc == null)
            {
                // Apply passed defaults.
                if (location != null)
                {
                    form.Location = (Point)location;
                }

                if (size != null)
                {
                    form.Size = (Size)size;
                }
            }
            else
            {
                WindowLocation winLoc = new WindowLocation((string)loc);
                form.Location      = winLoc.Location;
                form.Size          = winLoc.Size;
                form.WindowState   = winLoc.State;
                form.StartPosition = FormStartPosition.Manual;

                ret = true;
            }

            // Determine if the Location and Size is within the Screen's boundaries.
            if (form.WindowState == FormWindowState.Normal)
            {
                Rectangle workArea = Screen.PrimaryScreen.WorkingArea;

                if (form.Width > workArea.Width)
                {
                    form.Width = workArea.Width;
                }

                if (form.Height > workArea.Height)
                {
                    form.Height = workArea.Height;
                }

                int posX = form.Location.X;
                if (posX < 0)
                {
                    posX = 0;
                }

                if (posX + form.Width > workArea.Right)
                {
                    posX = workArea.Right - form.Width;
                }

                int posY = form.Location.Y;
                if (posY < 0)
                {
                    posY = 0;
                }

                if (posY + form.Height > workArea.Bottom)
                {
                    posY = workArea.Bottom - form.Height;
                }

                form.Location = new Point(posX, posY);
            }

            return(ret);
        }
 public void ShowDialog(string key, object viewModel, string title, bool isModal = true, Action <CancelEventArgs> winClosing = null, SolidColorBrush background = null, System.Windows.Style customStyle = null, WindowStartupLocation location = WindowStartupLocation.CenterOwner, WindowLocation customLocation = WindowLocation.Ignore)
 {
     this.ShowDialog(key, viewModel, title, null, null, isModal, winClosing, background, customStyle, location, customLocation);
 }
    public static void GetWindowTopAndLeft(this WindowLocation windowLocation, double screenTop, double screenLeft, double windowWidth, double windowHeight, out double top, out double left)
    {
        top  = default;
        left = default;

        switch (windowLocation)
        {
        case WindowLocation.TopLeft:
            top  = screenTop;
            left = screenLeft;
            break;

        case WindowLocation.TopRight:
            top  = screenTop;
            left = screenLeft + windowWidth;
            break;

        case WindowLocation.BottomLeft:
            top  = screenTop + windowHeight;
            left = screenLeft;
            break;

        case WindowLocation.BottomRight:
            top  = screenTop + windowHeight;
            left = screenLeft + windowWidth;
            break;

        case WindowLocation.TopLeftSmall:
            top  = screenTop;
            left = screenLeft;
            break;

        case WindowLocation.TopSmall:
            top  = screenTop;
            left = screenLeft + windowWidth;
            break;

        case WindowLocation.TopRightSmall:
            top  = screenTop;
            left = screenLeft + windowWidth + windowWidth;
            break;

        case WindowLocation.LeftSmall:
            top  = screenTop + windowHeight;
            left = screenLeft;
            break;

        case WindowLocation.CenterSmall:
            top  = screenTop + windowHeight;
            left = screenLeft + windowWidth;
            break;

        case WindowLocation.RightSmall:
            top  = screenTop + windowHeight;
            left = screenLeft + windowWidth + windowWidth;
            break;

        case WindowLocation.BottomLeftSmall:
            top  = screenTop + windowHeight + windowHeight;
            left = screenLeft;
            break;

        case WindowLocation.BottomSmall:
            top  = screenTop + windowHeight + windowHeight;
            left = screenLeft + windowWidth;
            break;

        case WindowLocation.BottomRightSmall:
            top  = screenTop + windowHeight + windowHeight;
            left = screenLeft + windowWidth + windowWidth;
            break;
        }
    }
示例#30
0
        public void UnpinToolPane(ToolPaneGroup toolPaneGroup, out UnpinnedToolData unpinnedToolData, out WindowLocation toolListBoxLocation)
        {
            System.Diagnostics.Trace.Assert(toolPaneGroup != null);

            DocumentPanel documentPanel = FindElementOfType(typeof(DocumentPanel), IDockPaneHost.RootPane) as DocumentPanel;

            System.Diagnostics.Trace.Assert(documentPanel != null);

            List <Grid> documentPanelAncestors = new List <Grid>();
            Grid        grid = documentPanel;

            while (grid.Parent != IDockPaneHost)
            {
                grid = grid.Parent as SplitterPane;
                documentPanelAncestors.Add(grid);
            }

            /*
             * Find the first common ancestor for the document panel and the tool pane group
             */

            FrameworkElement frameworkElement = toolPaneGroup;

            while (true)
            {
                if (documentPanelAncestors.Contains(frameworkElement.Parent as Grid))
                {
                    break;
                }

                frameworkElement = frameworkElement.Parent as FrameworkElement;
            }

            toolListBoxLocation = WindowLocation.None;
            bool isFirst      = (Grid.GetRow(frameworkElement) == 0) && (Grid.GetColumn(frameworkElement) == 0);
            bool isHorizontal = (frameworkElement.Parent as SplitterPane).IsHorizontal;

            if (isHorizontal)
            {
                if (isFirst)
                {
                    toolListBoxLocation = WindowLocation.TopSide;
                }
                else
                {
                    toolListBoxLocation = WindowLocation.BottomSide;
                }
            }
            else
            {
                if (isFirst)
                {
                    toolListBoxLocation = WindowLocation.LeftSide;
                }
                else
                {
                    toolListBoxLocation = WindowLocation.RightSide;
                }
            }

            unpinnedToolData = new UnpinnedToolData();
            unpinnedToolData.ToolPaneGroup = toolPaneGroup;
            Grid parentGrid = toolPaneGroup.Parent as Grid;

            unpinnedToolData.IsFirst      = (Grid.GetRow(toolPaneGroup) == 0) && (Grid.GetColumn(toolPaneGroup) == 0);
            unpinnedToolData.IsHorizontal = (parentGrid as SplitterPane).IsHorizontal;

            ExtractDockPane(toolPaneGroup, out frameworkElement);
            System.Diagnostics.Trace.Assert(frameworkElement != null);

            unpinnedToolData.SiblingGuid = (Guid)((frameworkElement as Grid).Tag);
        }
    public static double GetWindowWidthOrHeight(this WindowLocation windowLocation, int screenWidthOrHeight, double screenScale)
    {
        var scaleFactor = windowLocation.IsThreeByThreeGrid() ? 3D : 2D;

        return(screenWidthOrHeight / scaleFactor / screenScale);
    }
示例#32
0
 void IFloatingPaneHost.Unfloat(FloatingPane floatingPane, SelectablePane selectedPane, WindowLocation windowLocation)
 {
     IDockPaneManager.Unfloat(floatingPane, selectedPane, windowLocation);
 }
示例#33
0
 private Rectangle GetLocation( IntPtr handle )
 {
     var location = new WindowLocation();
     location.length = Marshal.SizeOf( location );
     GetWindowPlacement( handle, ref location );
     return location.rcNormalPosition;
 }
示例#34
0
 public void ShowIcons(WindowLocation windowLocations)
 {
 }
示例#35
0
        private UnpinnedToolPane CreateUnpinnedToolPane(ToolListBoxItem toolListBoxItem, WindowLocation windowLocation)
        {
            UnpinnedToolPane unpinnedToolPane = new UnpinnedToolPane();

            FrameworkElement userControl = toolListBoxItem.IViewContainer.ExtractUserControl(toolListBoxItem.Index);

            unpinnedToolPane.ToolPane.IViewContainer.AddUserControl(userControl);
            Point topLeftPoint = Windows.ScaleByDpi(IUnpinnedToolHost.RootPane.PointToScreen(new Point(0, 0)));

            unpinnedToolPane.Left = topLeftPoint.X;
            unpinnedToolPane.Top  = topLeftPoint.Y;
            if ((windowLocation == WindowLocation.TopSide) || (windowLocation == WindowLocation.BottomSide))
            {
                unpinnedToolPane.Width = IUnpinnedToolHost.RootPane.ActualWidth;
                double height = toolListBoxItem.Height;
                if (height == 0.0)
                {
                    height = IUnpinnedToolHost.RootPane.ActualHeight / 3;
                }
                unpinnedToolPane.Height = height;
                if (windowLocation == WindowLocation.BottomSide)
                {
                    unpinnedToolPane.Top += IUnpinnedToolHost.RootPane.ActualHeight - height;
                }
            }
            else
            {
                unpinnedToolPane.Height = IUnpinnedToolHost.RootPane.ActualHeight;
                double width = toolListBoxItem.Width;
                if (width == 0.0)
                {
                    width = IUnpinnedToolHost.RootPane.ActualWidth / 3;
                }
                unpinnedToolPane.Width = width;
                if (windowLocation == WindowLocation.RightSide)
                {
                    unpinnedToolPane.Left += IUnpinnedToolHost.RootPane.ActualWidth - width;
                }
            }
            unpinnedToolPane.CloseRequest  += UnpinnedToolPane_CloseRequest;
            unpinnedToolPane.Closed        += UnpinnedToolPane_Closed;
            unpinnedToolPane.PinClick      += UnpinnedToolPane_PinClick;
            unpinnedToolPane.WindowLocation = windowLocation;
            unpinnedToolPane.Owner          = Application.Current.MainWindow;

            unpinnedToolPane.Show();

            return(unpinnedToolPane);
        }
示例#36
0
 private static extern bool GetWindowPlacement( IntPtr handle, ref WindowLocation location );