Beispiel #1
0
        internal override void CopyPropertiesFrom(LW_Element element)
        {
            LW_Marker marker = element as LW_Marker;

            if (marker != null)
            {
                m_Graphic            = marker.m_Graphic;
                m_Position           = marker.m_Position;
                m_EulerRotation      = marker.m_EulerRotation;
                m_Scale              = marker.m_Scale;
                m_ScaleWithStroke    = marker.m_ScaleWithStroke;
                m_Stroke             = marker.m_Stroke;
                m_VariableScales     = marker.m_VariableScales;
                m_AtStart            = marker.m_AtStart;
                m_AtMiddle           = marker.m_AtMiddle;
                m_AtEnd              = marker.m_AtEnd;
                m_FlipEnd            = marker.m_FlipEnd;
                m_FaceForward        = marker.m_FaceForward;
                m_PlacementMode      = marker.m_PlacementMode;
                m_FixedSpacingLength = marker.m_FixedSpacingLength;
                m_FixedJustification = marker.m_FixedJustification;
                m_NumberOfMarkers    = marker.m_NumberOfMarkers;
            }
            base.CopyPropertiesFrom(element);
        }
        private void ListViewOnDragLeave(object sender, DragEventArgs dragEventArgs)
        {
            var listView = sender as ListView;

            if (listView == null)
            {
                return;
            }

            if (_lastOverItemAndIndex.Item1 == null)
            {
                return;
            }

            ScrollViewer.SetVerticalScrollMode(listView, _lastScrollMode);

            _lastOverItemAndIndex.Item1.BorderBrush     = _lastBorderBrush;
            _lastOverItemAndIndex.Item1.BorderThickness = new Thickness(0);

            _lastOverItemAndIndex = new Tuple <ListViewItem, int>(null, -1);
            _lastBorderBrush      = null;
            _lastPlacementMode    = PlacementMode.Mouse;

            dragEventArgs.Handled = true;
        }
Beispiel #3
0
 public static void OpenPopup(this TimelineTimeEntryBlockPopup popup, PlacementMode mode,
                              FrameworkElement placementTarget, object dataContext, double horizontal, double vertical)
 {
     popup.DataContext = dataContext;
     popup.PlacePopup(mode, placementTarget, horizontal, vertical);
     popup.Popup.IsOpen = true;
 }
Beispiel #4
0
        // Unused and untested
        public static void ShowMessage(string message, UIElement placementTarget, PlacementMode placementMode = PlacementMode.Top)
        {
            var f = new Callisto.Controls.Flyout();

            var b = new Border()
            {
                Width  = 300,
                Height = 125
            };

            TextBlock tb = new TextBlock();

            tb.HorizontalAlignment = HorizontalAlignment.Center;
            tb.VerticalAlignment   = VerticalAlignment.Center;
            tb.TextWrapping        = TextWrapping.Wrap;
            tb.FontSize            = 12f;
            tb.Text = message;

            b.Child = tb;

            f.Content = b;

            f.Placement       = placementMode;
            f.PlacementTarget = placementTarget;

            f.IsOpen = true;
        }
Beispiel #5
0
 public static void SetPlacement(
     DependencyObject dependencyObject,
     PlacementMode value
     )
 {
     dependencyObject.SetValue(PlacementProperty, value);
 }
        public DockMapDocument(string text, Image icon, FileInfo file, Project project,
                               DockTilesetTools dockTilesetTools, DockLayers dockLayers, DockMapObjectProperties dockMapObject, DockMapAttributes dockMapAttributes)
            : this()
        {
            _regularDockText = text;
            _unsavedDockText = text + "*";

            DockText = text;
            Icon     = icon;

            _file              = file;
            _project           = project;
            _dockLayers        = dockLayers;
            _dockTilesetTools  = dockTilesetTools;
            _dockMapObject     = dockMapObject;
            _dockMapAttributes = dockMapAttributes;
            _dockMapAttributes.SetProject(project);

            _dockTilesetTools.Tileset_Loaded   += _tilesetTools_Tileset_Loaded;
            _dockTilesetTools.Tileset_Unloaded += _tilesetTools_Tileset_Unloaded;

            _dockMapAttributes.SelectingTile += DockMapAttributesOnSelectingTile;

            _dockLayers.LayersUpdated += DockLayersOnLayersUpdated;

            this.mapToolStrip.Items[1].Image = Icons.BrushSelected;
            this.mapView.Cursor = new Cursor(Icons.Brush.GetHicon());
            _placementMode      = PlacementMode.Paint;

            this.mapView.Resize += MapView_Resize;

            _tileAttributeSprites = new Dictionary <Vector3, Sprite>();
        }
Beispiel #7
0
        private static Point[] GetPointArray(IList <Point> target, PlacementMode placement, Rect plugin, double width, double height)
        {
            Point[] pointArray;
            switch (placement)
            {
            case PlacementMode.Bottom:
                pointArray = new[] { new Point(target[2].X, Math.Max(0.0, target[2].Y + 1.0)), new Point((target[3].X - width) + 1.0, Math.Max(0.0, target[2].Y + 1.0)), new Point(0.0, Math.Max(0.0, target[2].Y + 1.0)) };
                break;

            case PlacementMode.Right:
                pointArray = new[] { new Point(Math.Max(0.0, target[1].X + 1.0), target[1].Y), new Point(Math.Max(0.0, target[3].X + 1.0), (target[3].Y - height) + 1.0), new Point(Math.Max(0.0, target[1].X + 1.0), 0.0) };
                break;

            case PlacementMode.Left:
                pointArray = new[] { new Point(Math.Min(plugin.Width, target[0].X) - width, target[1].Y), new Point(Math.Min(plugin.Width, target[2].X) - width, (target[3].Y - height) + 1.0), new Point(Math.Min(plugin.Width, target[0].X) - width, 0.0) };
                break;

            case PlacementMode.Top:
                pointArray = new[] { new Point(target[0].X, Math.Min(target[0].Y, plugin.Height) - height), new Point((target[1].X - width) + 1.0, Math.Min(target[0].Y, plugin.Height) - height), new Point(0.0, Math.Min(target[0].Y, plugin.Height) - height) };
                break;

            default:
                pointArray = new[] { new Point(0.0, 0.0) };
                break;
            }
            return(pointArray);
        }
Beispiel #8
0
 public static Popup Configure(Popup popup, string text, UIElement target, PlacementMode placement)
 {
     (popup.Child as TextBlock).Text = text;
     popup.PlacementTarget           = target;
     popup.Placement = placement;
     return(popup);
 }
        private Point PlacePopup(Rect plugin, Point[] target, Point[] toolTip, PlacementMode placement)
        {
            var bounds = GetBounds(target);
            var rect2  = GetBounds(toolTip);
            var width  = rect2.Width;
            var height = rect2.Height;

            placement = ValidatePlacement(target, placement, plugin, width, height);

            var pointArray = GetPointArray(target, placement, plugin, width, height);
            var index      = GetIndex(plugin, width, height, pointArray);
            var point      = CalculatePoint(target, placement, plugin, width, height, pointArray, index, bounds);

#if TRACE_DETAILS
            Debug.WriteLine($"Placing popup");
            Debug.WriteLine($"  Target points:");

            foreach (var targetPoint in target)
            {
                Debug.WriteLine($"  '{targetPoint.X}, {targetPoint.Y}'");
            }

            Debug.WriteLine($"  ToolTip points:");

            foreach (var toolTipPoint in toolTip)
            {
                Debug.WriteLine($"  '{toolTipPoint.X}, {toolTipPoint.Y}'");
            }
#endif

            return(point);
        }
Beispiel #10
0
        private static Rect PositionRelativeOnSide(
            Rect windowToTrack,
            Rect rcWindow,
            PlacementMode nSide,
            Rect constraint)
        {
            var rcAdjusted = default(Rect);

            switch (nSide)
            {
            case PlacementMode.Left:
            case PlacementMode.Right:
            {
                rcAdjusted = VerticallyCenterRect(windowToTrack, MoveNearRect(rcWindow, windowToTrack, nSide));
            }
            break;

            case PlacementMode.Top:
            case PlacementMode.Bottom:
            {
                rcAdjusted = HorizontallyCenterRect(windowToTrack, MoveNearRect(rcWindow, windowToTrack, nSide));
            }
            break;
            }

            if (!IsContainedInRect(constraint, rcAdjusted))
            {
                rcAdjusted = ShiftRectIntoContainer(constraint, rcAdjusted);
            }
            return(rcAdjusted);
        }
        private void _tileAttributeDialog_Submitted(object sender, EventArgs e)
        {
            this.Show();

            _placementMode = _prevPlacementMode;
            _tileAttributeDialog.Submitted -= _tileAttributeDialog_Submitted;
        }
Beispiel #12
0
        private static PlacementBase GetPlacement(PlacementMode placementMode)
        {
            switch (placementMode)
            {
            case PlacementMode.Absolute: return(AbsolutePlacement.Default);

            case PlacementMode.Relative: return(RelativePlacement.Default);

            case PlacementMode.Bottom: return(BottomPlacement.Default);

            case PlacementMode.Center: return(CenterPlacement.Default);

            case PlacementMode.Right: return(RightPlacement.Default);

            case PlacementMode.AbsolutePoint: return(AbsolutePointPlacement.Default);

            case PlacementMode.RelativePoint: return(RelativePointPlacement.Default);

            case PlacementMode.Mouse: return(MousePlacement.Default);

            case PlacementMode.MousePoint: return(MousePointPlacement.Default);

            case PlacementMode.Left: return(LeftPlacement.Default);

            case PlacementMode.Top: return(TopPlacement.Default);
            }

            throw new Granular.Exception("Unexpected PlacementMode \"{0}\"", placementMode);
        }
Beispiel #13
0
 public void ConfigurePosition(IVisual target, PlacementMode placement, Point offset,
                               PopupPositioningEdge anchor = PopupPositioningEdge.None, PopupPositioningEdge gravity = PopupPositioningEdge.None)
 {
     _positionerParameters.ConfigurePosition((TopLevel)_overlayLayer.GetVisualRoot(), target, placement, offset, anchor,
                                             gravity);
     UpdatePosition();
 }
Beispiel #14
0
        private void handleInspectBlockSelection(BlockType blockType)
        {
            placementType = PlacementType.BlockPlacement;
            placementMode = PlacementMode.Manage;
            manageObjectList.Clear();

            UIElement selectedItem = null;

            foreach (var item in BlockType.lookup)
            {
                var newItem = new BlockListItem(item.Value);

                if (item.Value == blockType)
                {
                    selectedItem = newItem;
                }

                manageObjectList.AddElement(newItem);
            }

            if (SimulationGame.KeyboardState.IsKeyDown(Keys.LeftControl) || SimulationGame.KeyboardState.IsKeyDown(Keys.RightControl))
            {
                manageObjectList.SelectElement(selectedItem);

                placeView.OnClick(placeObjectAtPosition);
            }
            else
            {
                manageObjectList.ScrollToElement(selectedItem);
            }
        }
    //replace soon
    void HandleControls()
    {
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            IncreaseBrushSize();
        }
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            DecreaseBrushSize();
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            DetachCurrentSelectedBlocks();

            _placementMode = PlacementMode.Delete;

            AttachDeletionBlocks();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            //rotate blocks + 90.0f
            RotateSelectedBlocks();
        }
    }
Beispiel #16
0
        internal static Point GetPosition(Control target, PlacementMode placement, PopupRoot popupRoot, double horizontalOffset, double verticalOffset)
        {
            var zero = default(Point);
            var mode = placement;

            if (target?.GetVisualRoot() == null)
            {
                mode = PlacementMode.Pointer;
            }

            switch (mode)
            {
            case PlacementMode.Pointer:
                if (popupRoot != null)
                {
                    // Scales the Horizontal and Vertical offset to screen co-ordinates.
                    var screenOffset = new Point(horizontalOffset * (popupRoot as ILayoutRoot).LayoutScaling,
                                                 verticalOffset * (popupRoot as ILayoutRoot).LayoutScaling);
                    return((((IInputRoot)popupRoot)?.MouseDevice?.Position ?? default(Point)) + screenOffset);
                }

                return(default(Point));

            case PlacementMode.Bottom:
                return(target?.PointToScreen(new Point(0 + horizontalOffset, target.Bounds.Height + verticalOffset)) ??
                       zero);

            case PlacementMode.Right:
                return(target?.PointToScreen(new Point(target.Bounds.Width + horizontalOffset, 0 + verticalOffset)) ?? zero);

            default:
                throw new InvalidOperationException("Invalid value for Popup.PlacementMode");
            }
        }
Beispiel #17
0
        // Gets the number of InterestPoint combinations for the given placement
        private static int GetNumberOfCombinations(PlacementMode placement)
        {
            switch (placement)
            {
            case PlacementMode.Bottom:
            case PlacementMode.Top:
            case PlacementMode.Mouse:
                return(2);

            case PlacementMode.Right:
            case PlacementMode.Left:
            case PlacementMode.RelativePoint:
            case PlacementMode.MousePoint:
            case PlacementMode.AbsolutePoint:
                return(4);

            case PlacementMode.Custom:
                return(0);

            case PlacementMode.Absolute:
            case PlacementMode.Relative:
            case PlacementMode.Center:
            default:
                return(1);
            }
        }
        // Unused and untested 
        public static void ShowMessage(string message, UIElement placementTarget, PlacementMode placementMode=PlacementMode.Top)
        {
            var f = new Callisto.Controls.Flyout();

            var b = new Border()
                           {
                               Width = 300,
                               Height = 125
                           };

            TextBlock tb = new TextBlock();
            tb.HorizontalAlignment = HorizontalAlignment.Center;
            tb.VerticalAlignment = VerticalAlignment.Center;
            tb.TextWrapping = TextWrapping.Wrap;
            tb.FontSize = 12f;
            tb.Text = message;

            b.Child = tb;

            f.Content = b;

            f.Placement = placementMode;
            f.PlacementTarget = placementTarget;

            f.IsOpen = true;
        }
Beispiel #19
0
 public static void SetPlacement(UIElement element, PlacementMode value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.AttachedProperties[PlacementMember] = value;
 }
Beispiel #20
0
 public static void SetPopupPlacement(DependencyObject o, PlacementMode value)
 {
     if (o == null)
     {
         throw new ArgumentNullException("o");
     }
     o.SetValue(PopupPlacementProperty, value);
 }
Beispiel #21
0
 public static void SetPlacement(DependencyObject obj, PlacementMode mode)
 {
     NoesisGUI_PINVOKE.ContextMenuService_SetPlacement(DependencyObject.getCPtr(obj), (int)mode);
     if (NoesisGUI_PINVOKE.SWIGPendingException.Pending)
     {
         throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #22
0
 public ItemsBasedOrder(ItemsBasedOrder order)
 {
     _dateFrom     = order._dateFrom;
     _dateTo       = order._dateTo;
     PlacementMode = order.PlacementMode;
     OrderLevel    = order.OrderLevel;
     Listener      = order.Listener;
 }
Beispiel #23
0
 public static void SetPlacement(DependencyObject obj, PlacementMode placement)
 {
     NoesisGUI_PINVOKE.ToolTipService_SetPlacement(DependencyObject.getCPtr(obj), (int)placement);
     if (NoesisGUI_PINVOKE.SWIGPendingException.Pending)
     {
         throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #24
0
 public ItemsBasedOrder(DateTime dateFrom, DateTime dateTo, PlacementMode placementMode, OrderLevel orderLevel, IDataLoadEventListener listener)
 {
     _dateFrom     = dateFrom;
     _dateTo       = dateTo;
     PlacementMode = placementMode;
     OrderLevel    = orderLevel;
     Listener      = listener;
 }
Beispiel #25
0
 /// <summary>
 ///     Sets the value of the Placement property.
 /// </summary>
 /// <param name="element">The object on which to set the value.</param>
 /// <param name="value">The desired value of the property.</param>
 public static void SetPlacement(DependencyObject element, PlacementMode value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(PlacementProperty, value);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TutorialItem" /> class.
 /// </summary>
 /// <param name="title">Title of the item.</param>
 /// <param name="text">Text of the item. Use '*' and '_' for bold and italic respectively (double to escape).</param>
 /// <param name="borderColor">The color of the <see cref="System.Windows.Controls.Border"/>. If null there will be no border.</param>
 /// <param name="placementMode">The placement position of the <see cref="Dialogs.TutorialDialog"/>; default bottom.</param>
 /// <param name="beforeShow">Action to be executed before showing the item.</param>
 public TutorialItem(string title, string text, Color?borderColor, PlacementMode placementMode = PlacementMode.Bottom, Action <ITutorialItem> beforeShow = null)
 {
     Title         = title;
     Text          = text;
     BorderColor   = borderColor;
     PlacementMode = placementMode;
     BeforeShow    = beforeShow;
 }
Beispiel #27
0
 public Image(string sopInstance, PlacementMode placementMode = PlacementMode.PlaceThenFill, OrderLevel orderLevel = OrderLevel.Series)
 {
     IsFilled       = false;
     IsRequested    = false;
     SOPInstanceUID = sopInstance;
     PlacementMode  = placementMode;
     OrderLevel     = orderLevel;
 }
Beispiel #28
0
        public static void SetPlacement(DependencyObject element, PlacementMode value)
        {
            if (element == null) 
            {
                throw new ArgumentNullException("element");
            } 
 
            element.SetValue(ToolTipService.PlacementProperty, value);
        } 
        // ------------------------------------------------------------------------
        // Private Methods
        // ------------------------------------------------------------------------
        private void setPlacementMode(PlacementMode mode)
        {
            if (mode != _placementMode)
            {
                _placementMode = mode;

                PwePlacementTools.Instance.showToolPanels(mode);
            }
        }
Beispiel #30
0
 public void ConfigurePosition(IVisual target, PlacementMode placement, Point offset,
                               PopupAnchor anchor = PopupAnchor.None, PopupGravity gravity = PopupGravity.None,
                               PopupPositionerConstraintAdjustment constraintAdjustment = PopupPositionerConstraintAdjustment.All,
                               Rect?rect = null)
 {
     _positionerParameters.ConfigurePosition((TopLevel)_overlayLayer.GetVisualRoot(), target, placement, offset, anchor,
                                             gravity, constraintAdjustment, rect);
     UpdatePosition();
 }
        private void mapView_MouseClick(object sender, MouseEventArgs e)
        {
            if (_placementMode == PlacementMode.Paint)
            {
                if (e.Button == MouseButtons.Left)
                {
                    this.PlaceTile((e.X + (int)_camera.Position.X) / Constants.TILE_SIZE,
                                   (e.Y + (int)_camera.Position.Y) / Constants.TILE_SIZE);
                }
                else
                {
                    this.RemoveTile((e.X + (int)_camera.Position.X) / Constants.TILE_SIZE,
                                    (e.Y + (int)_camera.Position.Y) / Constants.TILE_SIZE);
                }
            }
            else if (_placementMode == PlacementMode.Erase)
            {
                this.RemoveTile((e.X + (int)_camera.Position.X) / Constants.TILE_SIZE, (e.Y + (int)_camera.Position.Y) / Constants.TILE_SIZE);
            }
            else if (_placementMode == PlacementMode.Fill)
            {
                for (int x = 0; x < _map.Dimensions.X; x++)
                {
                    for (int y = 0; y < _map.Dimensions.Y; y++)
                    {
                        this.PlaceTile(x, y);
                    }
                }
            }
            else if (_placementMode == PlacementMode.MapObject)
            {
                this.PlaceMapObject((e.X + (int)_camera.Position.X) / Constants.TILE_SIZE, (e.Y + (int)_camera.Position.Y) / Constants.TILE_SIZE);
            }
            else if (_placementMode == PlacementMode.Place_Attribute)
            {
                if (e.Button == MouseButtons.Left)
                {
                    this.PlaceTileAttribute((e.X + (int)_camera.Position.X) / Constants.TILE_SIZE,
                                            (e.Y + (int)_camera.Position.Y) / Constants.TILE_SIZE, _dockMapAttributes.Attribute);
                }
                else
                {
                    this.RemoveMapAttribute((e.X + (int)_camera.Position.X) / Constants.TILE_SIZE,
                                            (e.Y + (int)_camera.Position.Y) / Constants.TILE_SIZE);
                }
            }
            else if (_placementMode == PlacementMode.Picking_Tile)
            {
                _tileAttributeDialog.WarpX         = (int)(e.X + _camera.Position.X);
                _tileAttributeDialog.WarpY         = (int)(e.Y + _camera.Position.Y);
                _tileAttributeDialog.WarpMapID     = _map.Name;
                _tileAttributeDialog.WarpLayerName = _dockLayers.SelectedLayer;
                _tileAttributeDialog.Show();

                _placementMode = _prevPlacementMode;
            }
        }
Beispiel #32
0
 public Series(string seriesUid, string sopInstance, PlacementMode placementMode, OrderLevel orderLevel, IDataLoadEventListener listener)
 {
     Images            = new Dictionary <string, Image>();
     PlacementMode     = placementMode;
     OrderLevel        = orderLevel;
     Listener          = listener;
     SeriesInstanceUID = seriesUid;
     Add(sopInstance);
 }
Beispiel #33
0
 public void ShowAnimated(PlacementMode preferedPlacement, FrameworkElement targetPlacement, System.Windows.Point? mousePositionPoint = null)
 {
     this.Show();
       if (!mousePositionPoint.HasValue)
     mousePositionPoint = new System.Windows.Point?(System.Windows.Application.Current.MainWindow.PointToScreen(Mouse.GetPosition((IInputElement) System.Windows.Application.Current.MainWindow)));
       this.UpdatePosition = (Action) (() => this.SetPosition(preferedPlacement, targetPlacement, mousePositionPoint.Value, false));
       this.UpdatePosition();
       this.Owner.LocationChanged += new EventHandler(this.Owner_LocationChanged);
       this.Owner.SizeChanged += new SizeChangedEventHandler(this.Owner_SizeChanged);
       this.SizeChanged += new SizeChangedEventHandler(this.InlinePopup_SizeChanged);
 }
 /// <summary>
 /// Displays a popup containing the FileBinding menu features.
 /// </summary>
 public static EditVideoWindow InstancePopup(UIElement target, PlacementMode placement, Guid? videoId, string fileName, IMediaPlayerBusiness player, ClosingCallback callback) {
     EditVideoWindow NewForm = new EditVideoWindow();
     NewForm.isPopup = true;
     NewForm.videoId = videoId;
     if (videoId != null && videoId != Guid.Empty)
         NewForm.videoId = videoId;
     else
         NewForm.fileName = fileName;
     NewForm.player = player;
     NewForm.callback = callback;
     WindowHelper.SetScale(NewForm.FileBindingButton.ContextMenu);
     NewForm.Window_Loaded(null, null);
     NewForm.ShowFileBindingMenu(target, placement);
     return NewForm;
 }
Beispiel #35
0
        /// <summary>
        /// Shows a flyout with the current <seealso cref="Text"/> and <seealso cref="Commands"/>.
        /// </summary>
        /// <param name="target">The object near which to show the flyout.</param>
        /// <param name="placement">The direction from the <paramref name="target"/> to show the flyout.</param>
        /// <param name="maxWidth">The maximum width of the flyout. If null, automatically determines a feasible width.</param>
        public override void Show(UIElement target, PlacementMode placement, double? maxWidth)
        {
            // Create text
            TextBlock textContainer = new TextBlock()
            {
                Text = this.Text,
                Style = Application.Current.Resources["FlyoutText"] as Style
            };

            // Create action buttons
            StackPanel flyoutButtonContainer = new StackPanel()
            {
                Orientation = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Right
            };

            foreach (IUICommand cmd in _commands)
            {
                Button button = new Button()
                {
                    Content = new TextBlock() { Text = cmd.Label },
                    Tag = cmd,
                    Style = Application.Current.Resources["FlyoutActionButton"] as Style
                };

                button.Click += button_Click;

                flyoutButtonContainer.Children.Add(button);
            }

            // Create outer container
            var outerContainer = new StackPanel()
            {
                Orientation = Orientation.Vertical,
                Margin = new Thickness(10d)
            };

            outerContainer.Children.Add(textContainer);
            outerContainer.Children.Add(flyoutButtonContainer);

            lock (__showLock)
            {
                Content = outerContainer;
                base.Show(target, placement, maxWidth);
            }
        }
Beispiel #36
0
        private static PlacementBase GetPlacement(PlacementMode placementMode)
        {
            switch (placementMode)
            {
                case PlacementMode.Absolute: return AbsolutePlacement.Default;
                case PlacementMode.Relative: return RelativePlacement.Default;
                case PlacementMode.Bottom: return BottomPlacement.Default;
                case PlacementMode.Center: return CenterPlacement.Default;
                case PlacementMode.Right: return RightPlacement.Default;
                case PlacementMode.AbsolutePoint: return AbsolutePointPlacement.Default;
                case PlacementMode.RelativePoint: return RelativePointPlacement.Default;
                case PlacementMode.Mouse: return MousePlacement.Default;
                case PlacementMode.MousePoint: return MousePointPlacement.Default;
                case PlacementMode.Left: return LeftPlacement.Default;
                case PlacementMode.Top: return TopPlacement.Default;
            }

            throw new Granular.Exception("Unexpected PlacementMode \"{0}\"", placementMode);
        }
 public static void SetPlacement(DependencyObject obj, PlacementMode value)
 {
     obj.SetValue(PlacementProperty, value);
 }
Beispiel #38
0
        private Rect GetMouseRect(PlacementMode placement)
        {
            NativeMethods.POINT mousePoint = _secHelper.GetMouseCursorPos(GetTarget());

            if (placement == PlacementMode.Mouse)
            {
                // In Mouse mode, the bounding box of the mouse cursor becomes the target
                int cursorWidth, cursorHeight, hotX, hotY;
                GetMouseCursorSize(out cursorWidth, out cursorHeight, out hotX, out hotY);

                // Add a margin of 1 px above and below the mouse
                return new Rect(mousePoint.x, mousePoint.y - 1, Math.Max(0, cursorWidth - hotX), Math.Max(0, cursorHeight - hotY + 2));
            }
            else
            {
                // In MousePoint mode, the mouse position is the target
                return new Rect(mousePoint.x, mousePoint.y, 0, 0);
            }
        }
 public static void SetMenuPlacementMode(DependencyObject obj, PlacementMode value)
 {
     obj.SetValue(MenuPlacementModeProperty, value);
 }
Beispiel #40
0
        /// <summary>
        /// The get point array.
        /// </summary>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="placement">
        /// The placement.
        /// </param>
        /// <param name="plugin">
        /// The plugin.
        /// </param>
        /// <param name="width">
        /// The width.
        /// </param>
        /// <param name="height">
        /// The height.
        /// </param>
        /// <returns>
        /// The <see><cref>Point[]</cref></see>.
        /// </returns>
        private static Point[] GetPointArray(
            IList<Point> target, PlacementMode placement, Rect plugin, double width, double height)
        {
            Point[] pointArray;
            switch (placement)
            {
                case PlacementMode.Bottom:
                    pointArray = new[]
                                     {
                                         new Point(target[2].X, Math.Max(0.0, target[2].Y + 1.0)), 
                                         new Point((target[3].X - width) + 1.0, Math.Max(0.0, target[2].Y + 1.0)), 
                                         new Point(0.0, Math.Max(0.0, target[2].Y + 1.0))
                                     };
                    break;

                case PlacementMode.Right:
                    pointArray = new[]
                                     {
                                         new Point(Math.Max(0.0, target[1].X + 1.0), target[1].Y), 
                                         new Point(Math.Max(0.0, target[3].X + 1.0), (target[3].Y - height) + 1.0), 
                                         new Point(Math.Max(0.0, target[1].X + 1.0), 0.0)
                                     };
                    break;

                case PlacementMode.Left:
                    pointArray = new[]
                                     {
                                         new Point(Math.Min(plugin.Width, target[0].X) - width, target[1].Y), 
                                         new Point(
                                             Math.Min(plugin.Width, target[2].X) - width, (target[3].Y - height) + 1.0), 
                                         new Point(Math.Min(plugin.Width, target[0].X) - width, 0.0)
                                     };
                    break;

                case PlacementMode.Top:
                    pointArray = new[]
                                     {
                                         new Point(target[0].X, Math.Min(target[0].Y, plugin.Height) - height), 
                                         new Point(
                                             (target[1].X - width) + 1.0, Math.Min(target[0].Y, plugin.Height) - height), 
                                         new Point(0.0, Math.Min(target[0].Y, plugin.Height) - height)
                                     };
                    break;

                default:
                    pointArray = new[] { new Point(0.0, 0.0) };
                    break;
            }

            return pointArray;
        }
Beispiel #41
0
        /// <summary>
        /// The place popup.
        /// </summary>
        /// <param name="plugin">
        /// The plugin.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="toolTip">
        /// The tool tip.
        /// </param>
        /// <param name="placement">
        /// The placement.
        /// </param>
        /// <returns>
        /// The <see cref="Point"/>.
        /// </returns>
        private static Point PlacePopup(Rect plugin, Point[] target, Point[] toolTip, PlacementMode placement)
        {
            Rect bounds = GetBounds(target);
            Rect rect2 = GetBounds(toolTip);
            double width = rect2.Width;
            double height = rect2.Height;

            placement = ValidatePlacement(target, placement, plugin, width, height);

            Point[] pointArray = GetPointArray(target, placement, plugin, width, height);
            int index = GetIndex(plugin, width, height, pointArray);
            Point point = CalculatePoint(target, placement, plugin, width, height, pointArray, index, bounds);

            return point;
        }
Beispiel #42
0
        private static bool IsAbsolutePlacementMode(PlacementMode placement)
        {
            switch (placement)
            {
                case PlacementMode.MousePoint:
                case PlacementMode.Mouse:
                case PlacementMode.AbsolutePoint:
                case PlacementMode.Absolute:
                    return true;
            }

            return false;
        }
Beispiel #43
0
        // Gets the number of InterestPoint combinations for the given placement
        private static int GetNumberOfCombinations(PlacementMode placement)
        {
            switch (placement)
            {
                case PlacementMode.Bottom:
                case PlacementMode.Top:
                case PlacementMode.Mouse:
                    return 2;

                case PlacementMode.Right:
                case PlacementMode.Left:
                case PlacementMode.RelativePoint:
                case PlacementMode.MousePoint:
                case PlacementMode.AbsolutePoint:
                    return 4;

                case PlacementMode.Custom:
                    return 0;

                case PlacementMode.Absolute:
                case PlacementMode.Relative:
                case PlacementMode.Center:
                default:
                    return 1;
            }
        }
Beispiel #44
0
        /// <summary>
        /// The calculate point.
        /// </summary>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="placement">
        /// The placement.
        /// </param>
        /// <param name="plugin">
        /// The plugin.
        /// </param>
        /// <param name="width">
        /// The width.
        /// </param>
        /// <param name="height">
        /// The height.
        /// </param>
        /// <param name="pointArray">
        /// The point array.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <param name="bounds">
        /// The bounds.
        /// </param>
        /// <returns>
        /// The <see cref="Point"/>.
        /// </returns>
        private static Point CalculatePoint(
            IList<Point> target,
            PlacementMode placement,
            Rect plugin,
            double width,
            double height,
            IList<Point> pointArray,
            int index,
            Rect bounds)
        {
            double x = pointArray[index].X;
            double y = pointArray[index].Y;
            if (index > 1)
            {
                if ((placement == PlacementMode.Left) || (placement == PlacementMode.Right))
                {
                    if (((Math.Abs(y - target[0].Y) > Epsilon) && (Math.Abs(y - target[1].Y) > Epsilon))
                        && ((Math.Abs((y + height) - target[0].Y) > Epsilon)
                            && (Math.Abs((y + height) - target[1].Y) > Epsilon)))
                    {
                        double num18 = bounds.Top + (bounds.Height / 2.0);
                        if ((num18 > 0.0) && ((num18 - 0.0) > (plugin.Height - num18)))
                        {
                            y = plugin.Height - height;
                        }
                        else
                        {
                            y = 0.0;
                        }
                    }
                }
                else if (((placement == PlacementMode.Top) || (placement == PlacementMode.Bottom))
                         && (((Math.Abs(x - target[0].X) > 0.0001) && (Math.Abs(x - target[1].X) > 0.0001))
                             && ((Math.Abs((x + width) - target[0].X) > 0.0001) && (Math.Abs((x + width) - target[1].X) > 0.0001))))
                {
                    double num19 = bounds.Left + (bounds.Width / 2.0);
                    if ((num19 > 0.0) && ((num19 - 0.0) > (plugin.Width - num19)))
                    {
                        x = plugin.Width - width;
                    }
                    else
                    {
                        x = 0.0;
                    }
                }
            }

            return new Point(x, y);
        }
 public static void SetMode(DependencyObject container, PlacementMode value)
 {
     container.SetValue(ModeProperty, value);
 }
Beispiel #46
0
        /// <summary>
        /// Shows a flyout with the current <seealso cref="Content"/>.
        /// </summary>
        /// <param name="target">The object near which to show the flyout.</param>
        /// <param name="placement">The direction from the <paramref name="target"/> to show the flyout.</param>
        /// <param name="maxWidth">The maximum width of the flyout. If null, automatically determines a feasible width.</param>
        public virtual void Show(UIElement target, PlacementMode placement, double? maxWidth)
        {
            lock (__showLock)
            {
                if (__currentOpenFlyout != null)
                {
                    // Must close previous one before opening a new one.
                    __currentOpenFlyout.DisposeFlyout();
                }

                IsOpen = true;

                // Deconnect content
                var contentParent = Content.Parent as Panel;
                if (contentParent != null)
                {
                    contentParent.Children.Remove(Content);
                }

                // Create flyout
                _flyout = new Callisto.Controls.Flyout()
                {
                    Content = this.Content,
                    PlacementTarget = target,
                    Placement = placement
                };

                if (maxWidth.HasValue)
                {
                    _flyout.MaxWidth = maxWidth.Value;
                }

                _flyout.Closed += _flyout_Closed;
                _flyout.IsOpen = true;
            }
        }
Beispiel #47
0
        private Point GetPlacementOriginWithoutRounding(PlacementMode placementMode)
        {
            bool rightToLeft = this.IsRightToLeft;
            if (rightToLeft)
            {
                if (placementMode == PlacementMode.Left)
                {
                    placementMode = PlacementMode.Right;
                }
                else if (placementMode == PlacementMode.Right)
                {
                    placementMode = PlacementMode.Left;
                }
            }

            switch (placementMode)
            {
                case PlacementMode.Bottom:
                    if (this.CanFitBottom())
                    {
                        this.ActualPlacement = PlacementMode.Bottom;
                        return this.FitBottom();
                    }
                    if (this.CanFitTop())
                    {
                        this.ActualPlacement = PlacementMode.Top;
                        return this.FitTop();
                    }
                    this.ActualPlacement = PlacementMode.Bottom;
                    return this.AdjustForBottom();

                case PlacementMode.Top:
                    if (this.CanFitTop())
                    {
                        this.ActualPlacement = PlacementMode.Top;
                        return this.FitTop();
                    }
                    if (this.CanFitBottom())
                    {
                        this.ActualPlacement = PlacementMode.Bottom;
                        return this.FitBottom();
                    }
                    this.ActualPlacement = PlacementMode.Top;
                    return this.AdjustForTop();

                case PlacementMode.Left:
                    if (this.CanFitLeft())
                    {
                        this.ActualPlacement = PlacementMode.Left;
                        if (rightToLeft)
                        {
                            return this.FitRight();
                        }
                        else
                        {
                            return this.FitLeft();
                        }
                    }
                    if (this.CanFitRight())
                    {
                        this.ActualPlacement = PlacementMode.Right;
                        if (rightToLeft)
                        {
                            return this.FitLeft();
                        }
                        else
                        {
                            return this.FitRight();
                        }
                    }
                    if (rightToLeft)
                    {
                        return this.AdjustForRight();
                    }
                    else
                    {
                        return this.AdjustForLeft();
                    }

                case PlacementMode.Right:
                    if (this.CanFitRight())
                    {
                        this.ActualPlacement = PlacementMode.Right;
                        if (rightToLeft)
                        {
                            return this.FitLeft();
                        }
                        else
                        {
                            return this.FitRight();
                        }
                    }
                    if (this.CanFitLeft())
                    {
                        this.ActualPlacement = PlacementMode.Left;
                        if (rightToLeft)
                        {
                            return this.FitRight();
                        }
                        else
                        {
                            return this.FitLeft();
                        }
                    }
                    this.ActualPlacement = PlacementMode.Right;

                    if (rightToLeft)
                    {
                        return this.AdjustForLeft();
                    }
                    else
                    {
                        return this.AdjustForRight();
                    }

                case PlacementMode.Center:
                    this.ActualPlacement = PlacementMode.Center;
                    return this.FitCenter();

                case PlacementMode.Absolute:
                case PlacementMode.MousePoint:
                    this.ActualPlacement = PlacementMode.Absolute;
                    return this.FitAbsolute();
                case PlacementMode.Mouse:
                    this.ActualPlacement = PlacementMode.Mouse;
                    return this.FitMouse();

                default:
                    throw new NotSupportedException("placementMode");
            }
        }
Beispiel #48
0
 public Point GetPlacementOrigin(PlacementMode placementMode)
 {
     Point placement = this.GetPlacementOriginWithoutRounding(placementMode);
     return new Point(Math.Round(placement.X, 0), Math.Round(placement.Y, 0));
 }
Beispiel #49
0
        // Gets the primary axis for the specified placement mode
        private static PopupPrimaryAxis GetPrimaryAxis(PlacementMode placement)
        {
            switch (placement)
            {
                case PlacementMode.Right:
                case PlacementMode.Left:
                    return PopupPrimaryAxis.Vertical;

                case PlacementMode.Bottom:
                case PlacementMode.Top:
                case PlacementMode.RelativePoint:
                case PlacementMode.AbsolutePoint:
                    return PopupPrimaryAxis.Horizontal;

                case PlacementMode.Relative:
                case PlacementMode.Mouse:
                case PlacementMode.MousePoint:
                case PlacementMode.Center:
                case PlacementMode.Absolute:
                case PlacementMode.Custom:
                default:
                    return PopupPrimaryAxis.None;
            }
        }
        public void ShowFileBindingMenu(UIElement target, PlacementMode placement) {
            // Set context menu items visibility.
            if (player == null)
                FileBindingButton.ContextMenu.Items.Remove(menuPlay);
            else
                menuPlay.IsEnabled = (!fileNotFound && video.FileName != null);
            if (!isPopup)
                FileBindingButton.ContextMenu.Items.Remove(menuEdit);
            string DefaultFileName = GetDefaultFileName();
            menuMoveFile.IsEnabled = (video.Title.Length > 0 && video.FileName != null && video.FileName != DefaultFileName);
            if (menuMoveFile.IsEnabled)
                menuMoveFile.Header = string.Format("_Move to \"{0}\"", DefaultFileName);
            else
                menuMoveFile.Header = "_Move to Default Location";
            if (isNew)
                menuSelectFile.Header = "_Select Existing Entry...";
            else
                menuSelectFile.Header = "_Select Another File...";
            menuDownloadVideo.IsEnabled = (!downloaded && (fileNotFound || video.FileName == null) && video.DownloadUrl.Length > 0);
            menuExtractAudio.IsEnabled = (!fileNotFound && video.FileName != null);
            menuRemoveBinding.IsEnabled = (!isNew && video.FileName != null);
            menuDeleteVideo.IsEnabled = (!fileNotFound && video.FileName != null);
            if (isNew)
                menuDeleteVideo.Header = "Delete _File";
            else
                menuDeleteVideo.Header = "Delete Attached _File";
            menuDeleteEntry.IsEnabled = !isNew;

            // Show context menu.
            FileBindingButton.ContextMenu.IsEnabled = true;
            FileBindingButton.ContextMenu.PlacementTarget = target;
            FileBindingButton.ContextMenu.Placement = placement;
            FileBindingButton.ContextMenu.IsOpen = true;
        }
Beispiel #51
0
        // Retrieves a list of the interesting points of the popup target in screen space
        private Point[] GetPlacementTargetInterestPoints(PlacementMode placement)
        {
            if (_positionInfo == null)
            {
                _positionInfo = new PositionInfo();
            }

            // Calculate the placement rectangle, which is the rectangle that popup will position relative to.
            Rect placementRect = PlacementRectangle;

            Point[] interestPoints;

            UIElement target = GetTarget() as UIElement;

            Vector offset = new Vector(HorizontalOffset, VerticalOffset);

            // Popup positioning is based on the PlacementTarget or the Placement mode
            if (target == null || IsAbsolutePlacementMode(placement))
            {
                // When the Mode is Mouse, the placement rectangle is the mouse position
                if (placement == PlacementMode.Mouse || placement == PlacementMode.MousePoint)
                {
                    if (_positionInfo.MouseRect == Rect.Empty)
                    {
                        // Everytime something changes we will reposition the popup.  We generally don't
                        // want to get a new position for the mouse at every reposition (for example,
                        // if the popup's content size is animated the popup will keep repositioning,
                        // but we should not pick up a new position for the mouse).
                        _positionInfo.MouseRect = GetMouseRect(placement);
                    }

                    placementRect = _positionInfo.MouseRect;
                }
                else if (placementRect == Rect.Empty)
                {
                    placementRect = new Rect();
                }

                offset = _secHelper.GetTransformToDevice().Transform(offset);

                // Offset the rect
                placementRect.Offset(offset);

                // These points are already positioned in screen coordinates
                // no transformations are necessary
                interestPoints = InterestPointsFromRect(placementRect);
            }
            else
            {
                // If no rectangle was given, then use the render bounds of the target
                if (placementRect == Rect.Empty)
                {
                    if (placement != PlacementMode.Relative && placement != PlacementMode.RelativePoint)
                        placementRect = new Rect(0.0, 0.0, target.RenderSize.Width, target.RenderSize.Height);
                    else // For relative and relative point use upperleft corner of target
                        placementRect = new Rect();
                }

                // Offset the rect
                placementRect.Offset(offset);

                // Get the points int the target's coordinate space
                interestPoints = InterestPointsFromRect(placementRect);

                // Next transform from the target's space to the screen space
                Visual rootVisual = GetRootVisual(target);
                GeneralTransform targetToClientTransform = TransformToClient(target, rootVisual);

                // transform point to the screen coordinate space
                for (int i = 0; i < 5; i++)
                {
                    targetToClientTransform.TryTransform(interestPoints[i], out interestPoints[i]);

                    interestPoints[i] = _secHelper.ClientToScreen(rootVisual, interestPoints[i]);
                }
            }

            return interestPoints;
        }
Beispiel #52
0
        // Retrieves a list of the interesting points of the popups child in the popup window space
        private Point[] GetChildInterestPoints(PlacementMode placement)
        {
            UIElement child = Child;

            if (child == null)
            {
                return InterestPointsFromRect(new Rect());
            }

            Point[] interestPoints = InterestPointsFromRect(new Rect(new Point(), child.RenderSize));


            UIElement target = GetTarget() as UIElement;

            // Popup positioning is based on the PlacementTarget or the Placement mode
            if (target != null && !IsAbsolutePlacementMode(placement))
            {
                // In scenarios where the flow direction is different between the
                // child and target, the child rect should be treated as it is flipped
                if ((FlowDirection)target.GetValue(FlowDirectionProperty) !=
                    (FlowDirection)child.GetValue(FlowDirectionProperty))
                {
                    SwapPoints(ref interestPoints[(int)InterestPoint.TopLeft], ref interestPoints[(int)InterestPoint.TopRight]);
                    SwapPoints(ref interestPoints[(int)InterestPoint.BottomLeft], ref interestPoints[(int)InterestPoint.BottomRight]);
                }
            }

            // Use remove the render transform translation from the child
            Vector offset = _popupRoot.Value.AnimationOffset;

            // Transform InterestPoints to popup's space
            GeneralTransform childToPopupTransform = TransformToClient(child, _popupRoot.Value);

            for (int i = 0; i < 5; i++)
            {
                // subtract Animation offset and transform point to the screen coordinate space
                childToPopupTransform.TryTransform(interestPoints[i] - offset, out interestPoints[i]);
            }

            return interestPoints;
        }
Beispiel #53
0
        /// <summary>
        /// The validate placement.
        /// </summary>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <param name="placement">
        /// The placement.
        /// </param>
        /// <param name="plugin">
        /// The plugin.
        /// </param>
        /// <param name="width">
        /// The width.
        /// </param>
        /// <param name="height">
        /// The height.
        /// </param>
        /// <returns>
        /// The <see cref="PlacementMode"/>.
        /// </returns>
        private static PlacementMode ValidatePlacement(
            IList<Point> target, PlacementMode placement, Rect plugin, double width, double height)
        {
            switch (placement)
            {
                case PlacementMode.Right:
                    double num5 = Math.Max(0.0, target[0].X - 1.0);
                    double num6 = plugin.Width - Math.Min(plugin.Width, target[1].X + 1.0);
                    if ((num6 < width) && (num6 < num5))
                    {
                        placement = PlacementMode.Left;
                    }

                    break;
                case PlacementMode.Left:
                    double num7 = Math.Min(plugin.Width, target[1].X + width) - target[1].X;
                    double num8 = target[0].X - Math.Max(0.0, target[0].X - width);
                    if ((num8 < width) && (num8 < num7))
                    {
                        placement = PlacementMode.Right;
                    }

                    break;
                case PlacementMode.Top:
                    double num9 = target[0].Y - Math.Max(0.0, target[0].Y - height);
                    double num10 = Math.Min(plugin.Height, plugin.Height - height) - target[2].Y;
                    if ((num9 < height) && (num9 < num10))
                    {
                        placement = PlacementMode.Bottom;
                    }

                    break;
                case PlacementMode.Bottom:
                    double num11 = Math.Max(0.0, target[0].Y);
                    double num12 = plugin.Height - Math.Min(plugin.Height, target[2].Y);
                    if ((num12 < height) && (num12 < num11))
                    {
                        placement = PlacementMode.Top;
                    }

                    break;
            }

            return placement;
        }
 /// <summary>
 /// The set placement.
 /// </summary>
 /// <param name="element">
 /// The element.
 /// </param>
 /// <param name="value">
 /// The value.
 /// </param>
 public static void SetPlacement(DependencyObject element, PlacementMode value)
 {
     element.SetValue(PlacementProperty, value);
 }
        /// <summary>
        /// Sets the tooltip's placement mode.
        /// </summary>
        /// <param name="element">The element to update.</param>
        /// <param name="value">A <see cref="PlacementMode"/> value which specifies how the tooltip is arranged on the screen.</param>
        public static void SetPlacement(DependencyObject element, PlacementMode value)
        {
            Contract.Require(element, "element");

            element.SetValue(PlacementProperty, value);
        }
 public void Show(PlacementMode placement)
 {
     this.IsOpen = true;
     this.Placement = placement;
 }
Beispiel #57
0
        private Point PlacePopup(Rect window, Point[] target, Point[] flyout, PlacementMode placement)
        {
            Point[] pointArray;
            double y = 0.0;
            double x = 0.0;
            Rect bounds = GetBounds(target);
            Rect rect2 = GetBounds(flyout);
            double width = rect2.Width;
            double height = rect2.Height;
            if (placement == PlacementMode.Right)
            {
                double num5 = Math.Max(0.0, target[0].X);
                double num6 = window.Width - Math.Min(window.Width, target[1].X + 1.0);
                if ((num6 < width) && (num6 < num5))
                {
                    placement = PlacementMode.Left;
                }
            }
            else if (placement == PlacementMode.Left)
            {
                double num7 = window.Width - Math.Min(window.Width, target[1].X + 1.0);
                double num8 = Math.Max(0.0, target[0].X);
                if ((num8 < width) && (num8 < num7))
                {
                    placement = PlacementMode.Right;
                }
            }
            else if (placement == PlacementMode.Top)
            {
                double num9 = Math.Max(0.0, target[0].Y);
                double num10 = window.Height - Math.Min(window.Height, target[2].Y + 1.0);
                if ((num9 < height) && (num9 < num10))
                {
                    placement = PlacementMode.Bottom;
                }
            }
            else if (placement == PlacementMode.Bottom)
            {
                double num11 = Math.Max(0.0, target[0].Y);
                double num12 = window.Height - Math.Min(window.Height, target[2].Y + 1.0);
                if ((num12 < height) && (num12 < num11))
                {
                    placement = PlacementMode.Top;
                }
            }
            switch (placement)
            {
                case PlacementMode.Bottom:
                    pointArray = new Point[] { new Point(target[2].X, Math.Max((double)0.0, (double)(target[2].Y + 1.0))), new Point((target[3].X - width) + 1.0, Math.Max((double)0.0, (double)(target[2].Y + 1.0))), new Point(0.0, Math.Max((double)0.0, (double)(target[2].Y + 1.0))) };
                    break;

                case PlacementMode.Right:
                    pointArray = new Point[] { new Point(Math.Max((double)0.0, (double)(target[1].X + 1.0)), target[1].Y), new Point(Math.Max((double)0.0, (double)(target[3].X + 1.0)), (target[3].Y - height) + 1.0), new Point(Math.Max((double)0.0, (double)(target[1].X + 1.0)), 0.0) };
                    break;

                case PlacementMode.Left:
                    pointArray = new Point[] { new Point(Math.Min(window.Width, target[0].X) - width, target[1].Y), new Point(Math.Min(window.Width, target[2].X) - width, (target[3].Y - height) + 1.0), new Point(Math.Min(window.Width, target[0].X) - width, 0.0) };
                    break;

                case PlacementMode.Top:
                    pointArray = new Point[] { new Point(target[0].X, Math.Min(target[0].Y, window.Height) - height), new Point((target[1].X - width) + 1.0, Math.Min(target[0].Y, window.Height) - height), new Point(0.0, Math.Min(target[0].Y, window.Height) - height) };
                    break;

                default:
                    pointArray = new Point[] { new Point(0.0, 0.0) };
                    break;
            }
            double num13 = width * height;
            int index = 0;
            double num15 = 0.0;
            for (int i = 0; i < pointArray.Length; i++)
            {
                Rect rect3 = new Rect(pointArray[i].X, pointArray[i].Y, width, height);
                rect3.Intersect(window);
                double d = rect3.Width * rect3.Height;
                if (double.IsInfinity(d))
                {
                    index = pointArray.Length - 1;
                    break;
                }
                if (d > num15)
                {
                    index = i;
                    num15 = d;
                }
                if (d == num13)
                {
                    index = i;
                    break;
                }
            }
            // x = pointArray[index].X;
            x = pointArray[0].X; // TODO: taking this solves my horizontal nudging, but is a hack...keeping it though until a better solution
            y = pointArray[index].Y;
            if (index > 1)
            {
                if ((placement == PlacementMode.Left) || (placement == PlacementMode.Right))
                {
                    if (((y != target[0].Y) && (y != target[1].Y)) && (((y + height) != target[0].Y) && ((y + height) != target[1].Y)))
                    {
                        double num18 = bounds.Top + (bounds.Height / 2.0);
                        if ((num18 > 0.0) && ((num18 - 0.0) > (window.Height - num18)))
                        {
                            y = window.Height - height;
                        }
                        else
                        {
                            y = 0.0;
                        }
                    }
                }
                else if (((placement == PlacementMode.Top) || (placement == PlacementMode.Bottom)) && (((x != target[0].X) && (x != target[1].X)) && (((x + width) != target[0].X) && ((x + width) != target[1].X))))
                {
                    double num19 = bounds.Left + (bounds.Width / 2.0);
                    if ((num19 > 0.0) && ((num19 - 0.0) > (window.Width - num19)))
                    {
                        x = window.Width - width;
                    }
                    else
                    {
                        x = 0.0;
                    }
                }
            }

            _realizedPlacement = placement;

            return new Point(x, y);
        }
Beispiel #58
0
 /// <summary>
 /// Occurs when the value of the <see cref="Placement"/> dependency property changes.
 /// </summary>
 private static void HandlePlacementChanged(DependencyObject dobj, PlacementMode oldValue, PlacementMode newValue)
 {
     var popup = (Popup)dobj;
     popup.UpdatePopupArrange(popup.MostRecentFinalRect.Size);
 }
Beispiel #59
0
        // Returns the ith possible alignment for the given PlacementMode
        private PointCombination GetPointCombination(PlacementMode placement, int i, out PopupPrimaryAxis axis)
        {
            Debug.Assert(i >= 0 && i < GetNumberOfCombinations(placement));

            bool dropFromRight = SystemParameters.MenuDropAlignment;

            switch (placement)
            {
                case PlacementMode.Bottom:
                case PlacementMode.Mouse:
                    axis = PopupPrimaryAxis.Horizontal;
                    if (dropFromRight)
                    {
                        if (i == 0) return new PointCombination(InterestPoint.BottomRight, InterestPoint.TopRight);
                        if (i == 1) return new PointCombination(InterestPoint.TopRight, InterestPoint.BottomRight);
                    }
                    else
                    {
                        if (i == 0) return new PointCombination(InterestPoint.BottomLeft, InterestPoint.TopLeft);
                        if (i == 1) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft);
                    }
                    break;


                case PlacementMode.Top:
                    axis = PopupPrimaryAxis.Horizontal;
                    if (dropFromRight)
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopRight, InterestPoint.BottomRight);
                        if (i == 1) return new PointCombination(InterestPoint.BottomRight, InterestPoint.TopRight);

                    }
                    else
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft);
                        if (i == 1) return new PointCombination(InterestPoint.BottomLeft, InterestPoint.TopLeft);

                    }
                    break;


                case PlacementMode.Right:
                case PlacementMode.Left:
                    axis = PopupPrimaryAxis.Vertical;
                    dropFromRight |= DropOpposite;

                    if ((dropFromRight && placement == PlacementMode.Right) ||
                        (!dropFromRight && placement == PlacementMode.Left))
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight);
                        if (i == 1) return new PointCombination(InterestPoint.BottomLeft, InterestPoint.BottomRight);
                        if (i == 2) return new PointCombination(InterestPoint.TopRight, InterestPoint.TopLeft);
                        if (i == 3) return new PointCombination(InterestPoint.BottomRight, InterestPoint.BottomLeft);
                    }
                    else
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopRight, InterestPoint.TopLeft);
                        if (i == 1) return new PointCombination(InterestPoint.BottomRight, InterestPoint.BottomLeft);
                        if (i == 2) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight);
                        if (i == 3) return new PointCombination(InterestPoint.BottomLeft, InterestPoint.BottomRight);
                    }
                    break;

                case PlacementMode.Relative:
                case PlacementMode.RelativePoint:
                case PlacementMode.MousePoint:
                case PlacementMode.AbsolutePoint:
                    axis = PopupPrimaryAxis.Horizontal;
                    if (dropFromRight)
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight);
                        if (i == 1) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopLeft);
                        if (i == 2) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomRight);
                        if (i == 3) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft);
                    }
                    else
                    {
                        if (i == 0) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopLeft);
                        if (i == 1) return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight);
                        if (i == 2) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomLeft);
                        if (i == 3) return new PointCombination(InterestPoint.TopLeft, InterestPoint.BottomRight);
                    }
                    break;

                case PlacementMode.Center:
                    axis = PopupPrimaryAxis.None;
                    return new PointCombination(InterestPoint.Center, InterestPoint.Center);

                case PlacementMode.Absolute:
                case PlacementMode.Custom:
                default:
                    axis = PopupPrimaryAxis.None;
                    return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopLeft);
            }

            return new PointCombination(InterestPoint.TopLeft, InterestPoint.TopRight);
        }
        private static void SetMenuPlacement(MenuItem menuItem, PlacementMode mode)
        {
            ModuleProc PROC = new ModuleProc("MenuExtensions", "SetMenuPlacement");

            try
            {
                Popup menuItemPopup = menuItem.Template.FindName("PART_Popup", menuItem) as Popup;
                if (menuItemPopup != null)
                {
                    menuItemPopup.Placement = mode;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }