Exemplo n.º 1
0
        /// <override></override>
        public override RelativePosition CalculateRelativePosition(int x, int y)
        {
            if (!Geometry.IsValid(x, y))
            {
                throw new ArgumentOutOfRangeException("x / y");
            }
            // The RelativePosition of a RectangleBased shape is:
            // A = Tenths of percent of Width
            // B = Tenths of percent of Height
            RelativePosition result = RelativePosition.Empty;

            if (Angle != 0)
            {
                float ptX = x;
                float ptY = y;
                Geometry.RotatePoint(X, Y, Geometry.TenthsOfDegreeToDegrees(-Angle), ref x, ref y);
            }
            if (DiameterInternal != 0)
            {
                result.A = (int)Math.Round((x - (X - DiameterInternal / 2f)) / (this.DiameterInternal / 1000f));
                result.B = (int)Math.Round((y - (Y - DiameterInternal / 2f)) / (this.DiameterInternal / 1000f));
            }
            else
            {
                result.A = x - X;
                result.B = y - Y;
            }
            return(result);
        }
Exemplo n.º 2
0
        public void PlaceRelative(Transform relativeTransform, RelativePosition position, float spacing)
        {
            Vector3 screenPosition = Camera.main.WorldToScreenPoint(relativeTransform.position);

            switch (position)
            {
            case RelativePosition.Top:
                transform.position         = screenPosition + new Vector3(0, spacing);
                transform.localEulerAngles = new Vector3(0, 0, 180);
                break;

            case RelativePosition.Bottom:
                transform.position = screenPosition + new Vector3(0, -spacing);
                break;

            case RelativePosition.Left:
                transform.position         = screenPosition + new Vector3(-spacing, 0);
                transform.localEulerAngles = new Vector3(0, 0, -90);
                break;

            case RelativePosition.Right:
                transform.position         = screenPosition + new Vector3(spacing, 0);
                transform.localEulerAngles = new Vector3(0, 0, 90);
                break;
            }

            floatable.ReStart();
        }
Exemplo n.º 3
0
            public PointPositions(Shape shape, Shape owner)
                : this()
            {
                if (shape == null)
                {
                    throw new ArgumentNullException("shape");
                }
                if (owner == null)
                {
                    throw new ArgumentNullException("owner");
                }
                // First, store position of reference point
                RelativePosition relativePos = RelativePosition.Empty;

                relativePos = owner.CalculateRelativePosition(shape.X, shape.Y);
                Debug.Assert(relativePos != RelativePosition.Empty);
                items.Add(ControlPointId.Reference, relativePos);
                // Then, store all resize control point positions as relative position
                foreach (ControlPointId ptId in shape.GetControlPointIds(ControlPointCapabilities.Resize))
                {
                    Point p = shape.GetControlPointPosition(ptId);
                    relativePos = owner.CalculateRelativePosition(p.X, p.Y);
                    Debug.Assert(relativePos != RelativePosition.Empty);
                    items.Add(ptId, relativePos);
                }
            }
Exemplo n.º 4
0
        /// <summary>
        ///     Создает новый экземпляр файлового менеджера.
        /// </summary>
        /// <param name="maxWidth">Максимальная используемая ширина.</param>
        /// <param name="maxHeight">Максимальная используемая высота.</param>
        public FileManager(int maxWidth, int maxHeight)
        {
            CurrentDirectory = null;
            panelWidth       = maxWidth / 2 - 2;
            list             = new StackContainer(Orientation.Vertical, maxVisibleCount: maxHeight - 3);
            header           = new Label("", maxWidth);
            selectedWidget   = new StackContainer(Orientation.Vertical, maxVisibleCount: maxHeight - 3);
            selectedSet      = new OrderedSet <string>();

            var wrappedList = new RelativePosition(0, 1)
                              .Add(new Frame(Style.DarkGrayOnDefault)
                                   .Add(list));
            var wrappedSelected = new RelativePosition(40, 1, 1)
                                  .Add(new Frame(Style.DarkGrayOnDefault)
                                       .Add(selectedWidget));

            RootContainer = new BaseContainer()
                            .Add(new RelativePosition(0, 0, 1)
                                 .Add(header))
                            .AddFocused(wrappedList)
                            .Add(wrappedSelected);
            RootContainer.AsIKeyHandler()
            .Add(new[] { new KeySelector(ConsoleKey.F10), new KeySelector(ConsoleKey.Q) },
                 () => RootContainer.Loop.OnStop = () => Console.WriteLine("До новых встреч!"));
            list.AsIKeyHandler()
            .Add(new[] { new KeySelector('/'), new KeySelector('\\') }, () => ChangeDir(null))
            .Add(new KeySelector(ConsoleKey.Tab), () => RootContainer.Focused = wrappedSelected);
            selectedWidget.AsIKeyHandler()
            .Add(new KeySelector(ConsoleKey.Tab), () => RootContainer.Focused = wrappedList);
        }
Exemplo n.º 5
0
 public TreeCursor(RelativePosition Rltv, T Node, T Top)
     : this()
 {
     this.Position = Rltv;
     this.Node     = Node;
     this.Top      = Top;
 }
Exemplo n.º 6
0
    private void GenerateCorridor()
    {
        var relativePositionOfStructure2 = CheckPositionStructure2AgainstStructure1();

        orientation = relativePositionOfStructure2;
        switch (relativePositionOfStructure2)
        {
        case RelativePosition.Up:
            ProcessRoomInRelationUpOrDown(this.structure1, this.structure2);
            break;

        case RelativePosition.Down:
            ProcessRoomInRelationUpOrDown(this.structure2, this.structure1);
            break;

        case RelativePosition.Right:
            ProcessRoomInRelationRightOrLeft(this.structure1, this.structure2);
            break;

        case RelativePosition.Left:
            ProcessRoomInRelationRightOrLeft(this.structure2, this.structure1);
            break;

        default:
            break;
        }
    }
Exemplo n.º 7
0
 internal void Read(Stream reader)
 {
     Id                  = reader.ReadString();
     SiblingId           = reader.ReadString();
     RelativePosition    = (RelativePosition)reader.ReadSByte();
     ExtensionBuilderUid = reader.ReadInt32();
 }
 Annotation GetHoveredAnnotation(Point mouseLocation)
 {
     foreach (Annotation annotation in Chart.AnnotationRepository)
     {
         PaneAnchorPoint anchorPoint = (PaneAnchorPoint)annotation.AnchorPoint;
         XYDiagram       diagram     = ((XYDiagram)Chart.Diagram);
         DateTime        argument    = (DateTime)anchorPoint.AxisXCoordinate.AxisValue;
         if ((DateTime)diagram.AxisX.VisualRange.MaxValue < argument || (DateTime)diagram.AxisX.VisualRange.MinValue > argument)
         {
             continue;
         }
         ControlCoordinates coords = diagram.DiagramToPoint((DateTime)anchorPoint.AxisXCoordinate.AxisValue,
                                                            (double)anchorPoint.AxisYCoordinate.AxisValue,
                                                            anchorPoint.AxisXCoordinate.Axis, anchorPoint.AxisYCoordinate.Axis, anchorPoint.Pane);
         if (coords.Visibility == ControlCoordinatesVisibility.Visible)
         {
             RelativePosition position = (RelativePosition)annotation.ShapePosition;
             Point            center   = new Point((int)(coords.Point.X + Math.Cos(position.Angle / 180 * Math.PI) * position.ConnectorLength),
                                                   (int)(coords.Point.Y - Math.Sin(position.Angle / 180 * Math.PI) * position.ConnectorLength));
             int diffX = Math.Abs(center.X - mouseLocation.X);
             int diffY = Math.Abs(center.Y - mouseLocation.Y);
             if (diffX <= annotation.Width / 2 && diffY <= annotation.Height / 2)
             {
                 return(annotation);
             }
         }
     }
     return(null);
 }
Exemplo n.º 9
0
        private static double GetPositionOnShape(Shapes.XFormCells xform, RelativePosition pos)
        {
            switch (pos)
            {
            case RelativePosition.PinY:
                return(xform.PinY.Result);

            case RelativePosition.PinX:
                return(xform.PinX.Result);
            }

            var r = ArrangeHelper.GetRectangle(xform);

            switch (pos)
            {
            case RelativePosition.Left:
                return(r.Left);

            case RelativePosition.Right:
                return(r.Right);

            case RelativePosition.Top:
                return(r.Top);

            case RelativePosition.Bottom:
                return(r.Bottom);
            }

            throw new System.ArgumentOutOfRangeException(nameof(pos));
        }
Exemplo n.º 10
0
        public void PlaceRelative(RectTransform relativeTransform, RelativePosition position, float spacing)
        {
            RectTransform rectTransform = (RectTransform)transform;
            Vector2       size          = relativeTransform.sizeDelta;

            switch (position)
            {
            case RelativePosition.Top:
                rectTransform.anchoredPosition = new Vector2(0, size.y * 0.5f + spacing);
                transform.localEulerAngles     = new Vector3(0, 0, 180);
                break;

            case RelativePosition.Bottom:
                rectTransform.anchoredPosition = new Vector2(0, -(size.y * 0.5f + spacing));
                break;

            case RelativePosition.Left:
                rectTransform.anchoredPosition = new Vector2(-(size.x * 0.5f + spacing), 0);
                transform.localEulerAngles     = new Vector3(0, 0, -90);
                break;

            case RelativePosition.Right:
                rectTransform.anchoredPosition = new Vector2(size.x * 0.5f + spacing, 0);
                transform.localEulerAngles     = new Vector3(0, 0, 90);
                break;
            }

            floatable.ReStart();
        }
Exemplo n.º 11
0
 public override void OnClick(Microsoft.Xna.Framework.Input.MouseState state)
 {
     base.OnClick(state);
     layout.Arrange(this, container , (int)tmp);
     tmp++;
     if ((int)tmp > 40) tmp = 0;
 }
Exemplo n.º 12
0
 public NodeSpecification(string nodeName, string algorithmName, RelativePosition relPos, params string[] arguments)
 {
     this.nodeName = nodeName;
     this.algorithmName = algorithmName;
     this.relPos = relPos;
     this.args = arguments;
 }
Exemplo n.º 13
0
        void SetMouseCursor(RelativePosition d)
        {
            switch (d)
            {
            case RelativePosition.E:
            case RelativePosition.W:
                Mouse.OverrideCursor = Cursors.SizeWE;
                break;

            case RelativePosition.N:
            case RelativePosition.S:
                Mouse.OverrideCursor = Cursors.SizeNS;
                break;

            case RelativePosition.SE:
            case RelativePosition.NW:
                Mouse.OverrideCursor = Cursors.SizeNWSE;
                break;

            case RelativePosition.NE:
            case RelativePosition.SW:
                Mouse.OverrideCursor = Cursors.SizeNESW;
                break;

            default:
                Mouse.OverrideCursor = Cursors.SizeAll;
                break;
            }
        }
Exemplo n.º 14
0
        public Tuple <LinkedListNode <IVisualItem>, RelativePosition> FindInsertLoc(
            IVisualItem AddItem)
        {
            LinkedListNode <IVisualItem> baseNode = null;
            RelativePosition             rltv     = RelativePosition.End;

            // find the item to insert before.
            var node = ItemList.First;

            while (node != null)
            {
                if (AddItem.ShowEndRowCol( ).ColNum < node.Value.ShowRowCol( ).ColNum)
                {
                    baseNode = node;
                    rltv     = RelativePosition.Before;
                    break;
                }
                else if (AddItem.ShowRowCol( ).ColNum <= node.Value.ShowEndRowCol( ).ColNum)
                {
                    baseNode = node;
                    rltv     = RelativePosition.At;
                    break;
                }
                node = node.Next;
            }

            return(new Tuple <LinkedListNode <IVisualItem>, RelativePosition>(baseNode, rltv));
        }
Exemplo n.º 15
0
 public GeneratePlanarMenuMeshTask(float width, float height,
                                   RelativePosition alignment = RelativePosition.TopLeft)
 {
     _width     = width;
     _height    = height;
     _alignment = alignment;
 }
Exemplo n.º 16
0
    public Item(
        Game game,
        string id,
        ActionHandlers actionHandlers,
        ItemDependency?dependency,
        string displayName,
        RelativePosition interactPosition,
        string interactStatus,
        bool isTouchable,
        int scrollFactor,
        int depthOffset,
        string status,
        bool canBeUsedWithOtherObject)
        : base(
            game,
            id,
            actionHandlers,
            displayName,
            interactPosition,
            interactStatus,
            isTouchable,
            scrollFactor,
            depthOffset,
            status)
    {
        _dependency = dependency;

        CanBeUsedWithOtherObject = canBeUsedWithOtherObject;
    }
Exemplo n.º 17
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            e.Handled = false;
            var p = PlacementHelper.RoundToGrid(e.GetPosition(this));

            if (_currentOperationHandler == null)
            {
                e.Handled = true;
                //if (LabelArea.Contains(p) && Model.AllowEdit)
                //{
                //    Mouse.OverrideCursor = Cursors.Hand;
                //}
                //else
                if (e.LeftButton == MouseButtonState.Released &&
                    e.RightButton == MouseButtonState.Released)
                {
                    _mouseMoveHitResult = RelativePosition.Undefined;
                    if (IsSelected)
                    {
                        _mouseMoveHitResult = _adorner.HitShadowBorder(p);
                    }
                    SetMouseCursor(_mouseMoveHitResult);
                    PositionTools();
                }
            }
        }
Exemplo n.º 18
0
    private void GenerateCorridor()
    {
        RelativePosition relativePositionOfStructure2 = CheckPositionBetweenTwoStructures();

        switch (relativePositionOfStructure2)
        {
        case RelativePosition.UP:

            ProcessRoomRelationUpOrDown(this.structure1, this.structure2);

            break;

        case RelativePosition.DOWN:

            ProcessRoomRelationUpOrDown(this.structure2, this.structure1);

            break;

        case RelativePosition.RIGHT:

            ProcessRoomRelationRightOrLeft(this.structure1, this.structure2);

            break;

        case RelativePosition.LEFT:

            ProcessRoomRelationRightOrLeft(this.structure2, this.structure1);

            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
        private static double GetPositionOnShape(Shapes.XFormCells xform, RelativePosition pos)
        {
            if (pos == RelativePosition.PinY)
            {
                return xform.PinY.Result;
            }
            if (pos == RelativePosition.PinX)
            {
                return xform.PinX.Result;
            }

            var r = ArrangeHelper.GetRectangle(xform);
            if (pos == RelativePosition.Left)
            {
                return r.Left;
            }
            if (pos == RelativePosition.Right)
            {
                return r.Right;
            }
            if (pos == RelativePosition.Top)
            {
                return r.Top;
            }
            if (pos == RelativePosition.Right)
            {
                return r.Bottom;
            }
            throw new System.ArgumentOutOfRangeException(nameof(pos));
        }
Exemplo n.º 20
0
        public void AddTextAnnotation(string txt, DateTime x, Double y, float fontsize, int angle, Color textcolor)
        {
            string         annotationname   = String.Format("a{0}", this.chart.Annotations.Count);
            TextAnnotation myTextAnnotation = this.chart.Annotations.AddTextAnnotation(annotationname, txt);

            Font font = new Font("Arial", fontsize);

            RelativePosition position = new RelativePosition();

            myTextAnnotation.ShapePosition = position;

            PaneAnchorPoint anchorPoint = new PaneAnchorPoint();

            myTextAnnotation.AnchorPoint = anchorPoint;

            position.ConnectorLength = 0;
            anchorPoint.AxisXCoordinate.AxisValue = x;
            anchorPoint.AxisYCoordinate.AxisValue = y;

            myTextAnnotation.TextAlignment  = StringAlignment.Near;
            myTextAnnotation.Angle          = angle;
            myTextAnnotation.Font           = font;
            myTextAnnotation.TextColor      = textcolor;
            myTextAnnotation.BackColor      = Color.Transparent;
            myTextAnnotation.ShapeKind      = ShapeKind.RoundedRectangle;
            myTextAnnotation.Border.Color   = Color.Transparent;
            myTextAnnotation.ConnectorStyle = AnnotationConnectorStyle.None;
        }
Exemplo n.º 21
0
                public override int GetHashCode()
                {
                    int hash = 1;

                    if (X != 0)
                    {
                        hash ^= X.GetHashCode();
                    }
                    if (Y != 0)
                    {
                        hash ^= Y.GetHashCode();
                    }
                    if (ActionType != 0)
                    {
                        hash ^= ActionType.GetHashCode();
                    }
                    if (WheelRotation != 0)
                    {
                        hash ^= WheelRotation.GetHashCode();
                    }
                    if (RelativePosition != false)
                    {
                        hash ^= RelativePosition.GetHashCode();
                    }
                    if (MappedToVirtualDesktop != false)
                    {
                        hash ^= MappedToVirtualDesktop.GetHashCode();
                    }
                    if (_unknownFields != null)
                    {
                        hash ^= _unknownFields.GetHashCode();
                    }
                    return(hash);
                }
Exemplo n.º 22
0
        public void LineAdvance(TextLines InLines)
        {
            switch (mRltv)
            {
            case RelativePosition.Begin:
                mLinesNode = InLines.FirstLine;
                break;

            case RelativePosition.Before:
                break;

            case RelativePosition.At:
                mLinesNode = mLinesNode.Next;
                break;

            case RelativePosition.After:
                mLinesNode = mLinesNode.Next;
                break;

            default:
                mLinesNode = null;
                break;
            }

            if (mLinesNode == null)
            {
                mRltv = RelativePosition.None;
            }
            else
            {
                mRltv   = RelativePosition.At;
                mLineOx = 0;
            }
        }
Exemplo n.º 23
0
 public TextLinesCursor()
 {
     mLines     = null;
     mLinesNode = null;
     mLineOx    = -1;
     mRltv      = RelativePosition.None;
 }
Exemplo n.º 24
0
 public TextLinesCursor(TextLinesCursor InCsr)
 {
     mLines     = InCsr.mLines;
     mLinesNode = InCsr.mLinesNode;
     mLineOx    = InCsr.mLineOx;
     mRltv      = InCsr.mRltv;
 }
Exemplo n.º 25
0
 public override void RecieveEnergy(IElement element, RelativePosition elementPosition)
 {
     if (elementPosition == RelativePosition.Left)
     {
         isOn = true;
     }
 }
Exemplo n.º 26
0
    internal Actor(
        Game game,
        string id,
        ActionHandlers actionHandlers,
        string displayName,
        RelativePosition interactPosition,
        string interactStatus,
        bool isTouchable,
        int scrollFactor,
        int depthOffset,
        string status,
        string textColor)
        : base(
            game,
            id,
            actionHandlers,
            displayName,
            interactPosition,
            interactStatus,
            isTouchable,
            scrollFactor,
            depthOffset,
            status)
    {
        _inventory = new();

        TextColor = textColor;
    }
Exemplo n.º 27
0
        public bool CheckDirection(RelativePosition checkType,
                                   int[] source, int targetX, int targetY)
        {
            position = new int[] { targetX, targetY };

            return(CheckDirection(checkType, source, position));
        }
Exemplo n.º 28
0
        public void Pos(View view,
                        double x, RelativePosition xRel,
                        double y, RelativePosition yRel,
                        double width, RelativePosition widthRel,
                        double height, RelativePosition heightRel)
        {
            Position  p = new Position(x, xRel, y, yRel, width, widthRel, height, heightRel);
            Rectangle r = p.GetRectangle();

            //AbsoluteLayout.SetLayoutBounds((View)view, r);

            if (view is INukeView)
            {
                INukeView nuke = (INukeView)view;
                nuke.Position = p;
            }
            else
            {
                if (positions.ContainsKey(view))
                {
                    positions[view] = p;
                }
                else
                {
                    positions.Add(view, p);
                }

                if (view is Layout <View> )
                {
                    view.SizeChanged += view_SizeChanged;
                }
            }
        }
Exemplo n.º 29
0
 public TextLinesCursor(
     LinkedListNode <TextLine> InLinesNode, int InLineOx, RelativePosition InRltv)
 {
     mLines     = null;
     mLinesNode = InLinesNode;
     mLineOx    = InLineOx;
     mRltv      = InRltv;
 }
Exemplo n.º 30
0
 public virtual void Connect(IElement element, RelativePosition elementPosition)
 {
     connections[elementPosition] = element;
     if (element != null)
     {
         element.connections[~elementPosition] = this;
     }
 }
 /// <summary>
 /// construct this cursor as a copy of the input cursor.
 /// </summary>
 /// <param name="Cursor"></param>
 public StmtWordListCursor(StmtWordListCursor Cursor)
 {
     this.mRltv       = Cursor.mRltv;
     this.mNode       = Cursor.mNode;
     this.mList       = Cursor.mList;
     this.mStayAtFlag = Cursor.mStayAtFlag;
     this.mEdge       = Cursor.mEdge;
 }
 public GenerateCylindricalMenuMeshTask(float angleSweep, float height, float radius,
                                        RelativePosition alignment = RelativePosition.Bottom)
 {
     _angleSweep = angleSweep * Mathf.Deg2Rad;
     _height     = height;
     _radius     = radius;
     _alignment  = alignment;
 }
Exemplo n.º 33
0
 private static RelativePosition GetPosition(ref RelativePosition pos, string name, params RelativePosition[] values)
 {
     if (object.ReferenceEquals((object)pos, (object)null))
     {
         pos = new RelativePosition(name, values);
     }
     return(pos);
 }
Exemplo n.º 34
0
        public static FaceType FaceAtRelativePositionTo(FaceType face, RelativePosition position)
        {
            if (position == RelativePosition.Same) return face;

            switch (face)
            {
                case FaceType.Front:
                    switch (position)
                    {
                        case RelativePosition.Right:
                            return FaceType.Right;
                        case RelativePosition.Left:
                            return FaceType.Left;
                        case RelativePosition.Opposite:
                            return FaceType.Back;
                    }
                    break;
                case FaceType.Right:
                    switch (position)
                    {
                        case RelativePosition.Right:
                            return FaceType.Back;
                        case RelativePosition.Left:
                            return FaceType.Front;
                        case RelativePosition.Opposite:
                            return FaceType.Left;
                    }
                    break;
                case FaceType.Back:
                    switch (position)
                    {
                        case RelativePosition.Right:
                            return FaceType.Left;
                        case RelativePosition.Left:
                            return FaceType.Right;
                        case RelativePosition.Opposite:
                            return FaceType.Front;
                    }
                    break;
                case FaceType.Left:
                    switch (position)
                    {
                        case RelativePosition.Right:
                            return FaceType.Front;
                        case RelativePosition.Left:
                            return FaceType.Back;
                        case RelativePosition.Opposite:
                            return FaceType.Right;
                    }
                    break;
            }

            throw new Exception("Invalid face type");
        }
Exemplo n.º 35
0
		/// <override></override>
		public override Point CalculateAbsolutePosition(RelativePosition relativePosition) {
			if (relativePosition == RelativePosition.Empty) throw new ArgumentOutOfRangeException("relativePosition");
			// The relative Position of an arc is defined by...
			// A: Tenths of percentage of the distance between StartPoint and EndPoint
			// B: Radius offset (tenths)
			// C: Not used
			Point result = Geometry.InvalidPoint;
			if (IsLine)
				result = Geometry.VectorLinearInterpolation(StartPoint, EndPoint, relativePosition.A / 1000f);
			else result = CalcPointFromRelativeAngle(relativePosition.A, relativePosition.B);
			if (!Geometry.IsValid(result)) System.Diagnostics.Debug.Fail("Unable to calculate glue point position!");
			return result;
		}
        internal static IList<int> SortShapesByPosition(IVisio.Page page, IList<int> shapeids, RelativePosition pos)
        {
            // First get the transforms of the shapes on the given axis
            var xforms = Shapes.XFormCells.GetCells(page, shapeids);

            // Then, sort the shapeids pased on the corresponding value in the results

            var sorted_shape_ids = Enumerable.Range(0, shapeids.Count)
                .Select(i => new { index = i, shapeid = shapeids[i], pos = ArrangeHelper.GetPositionOnShape(xforms[i], pos) })
                .OrderBy(i => i.pos)
                .Select(i => i.shapeid)
                .ToList();

            return sorted_shape_ids;
        }
Exemplo n.º 37
0
		/// <override></override>
		public override Point CalculateAbsolutePosition(RelativePosition relativePosition)
		{
			if (relativePosition == RelativePosition.Empty) throw new ArgumentOutOfRangeException("relativePosition");
			// The RelativePosition of a RectangleBased shape is:
			// A = Tenths of percent of Width
			// B = Tenths of percent of Height
			Point result = Point.Empty;
			result.X = (int) Math.Round((X - (Width/2f)) + (relativePosition.A*(Width/1000f)));
			result.Y = (int) Math.Round((Y - (Height/2f)) + (relativePosition.B*(Height/1000f)));
			if (Angle != 0) result = Geometry.RotatePoint(Center, Geometry.TenthsOfDegreeToDegrees(Angle), result);
			return result;
		}
Exemplo n.º 38
0
        internal Toolbar(Mode mode = Mode.TOOLBAR, Toolbar parentToolbar = null, RelativePosition preferredRelativePosition = RelativePosition.DEFAULT)
        {
            this.mode = mode;
            this.parentToolbar = parentToolbar;
            this.relativePosition = preferredRelativePosition;

            visibleButtons = new VisibleButtons(buttons, isEffectivelyUserVisible);

            autoHideUnimportantButtonAlpha.a = 0.4f;

            rect = new Rectangle(new Rect(DEFAULT_X, DEFAULT_Y, DEFAULT_WIDTH, float.MinValue));

            if (mode == Mode.TOOLBAR) {
                dropdownMenuButton = Button.createToolbarDropdown();
                dropdownMenuButton.OnClick += (e) => toggleDropdownMenu();
                buttons.Add(dropdownMenuButton);

                draggable = new Draggable(rect, PADDING, (pos) => !dropdownMenuButtonContains(pos) && !resizable.HandleRect.Contains(pos));
                resizable = new Resizable(rect, PADDING, (pos) => !dropdownMenuButtonContains(pos));
                draggable.OnDrag += (e) => {
                    resizable.Enabled = !draggable.Dragging;
                    toolbarDrag();
                };
                resizable.OnDrag += (e) => {
                    draggable.Enabled = !resizable.Dragging;
                    toolbarResize();
                };
                CursorGrabbing.Instance.add(draggable);
                CursorGrabbing.Instance.add(resizable);

                CursorGrabbing.Instance.add(this);

                ToolbarManager.InternalInstance.OnCommandAdded += updateVisibleButtons;
            } else {
                showBorder = parentToolbar.showBorder;
                useKSPSkin_ = parentToolbar.UseKSPSkin;
            }
        }
Exemplo n.º 39
0
 private RelativePosition autoPositionFolder(RelativePosition preferredPosition)
 {
     // at this point, we should already have a good width/height
     AutoPositionResult result = autoPositionAgainstParent(new Vector2(rect.width, rect.height), parentToolbar.rect.Rect, parentToolbar.SingleColumn, preferredPosition);
     rect.x = result.position.x;
     rect.y = result.position.y;
     return result.relativePosition;
 }
Exemplo n.º 40
0
        private AutoPositionResult autoPositionAgainstParent(Vector2 size, Rect parentRect, bool parentIsSingleColumn, RelativePosition preferredPosition)
        {
            Vector2 posLeft = new Vector2(parentRect.x - size.x - BUTTON_SPACING, parentRect.y + (parentRect.height - size.y) / 2);
            Vector2 posRight = new Vector2(parentRect.x + parentRect.width + BUTTON_SPACING, posLeft.y);
            Vector2 posAbove = new Vector2(parentRect.x + (parentRect.width - size.x) / 2, parentRect.y - size.y - BUTTON_SPACING);
            Vector2 posBelow = new Vector2(posAbove.x, parentRect.y + parentRect.height + BUTTON_SPACING);

            // figure out potential positions based on blocking important GUI
            bool canUseLeft = !isBlockingImportantGUI(posLeft, size);
            bool canUseRight = !isBlockingImportantGUI(posRight, size);
            bool canUseAbove = !isBlockingImportantGUI(posAbove, size);
            bool canUseBelow = !isBlockingImportantGUI(posBelow, size);

            // all blocked, let's ignore blocking things
            if (!canUseLeft && !canUseRight && !canUseAbove && !canUseBelow) {
                canUseLeft = true;
                canUseRight = true;
                canUseAbove = true;
                canUseBelow = true;
            }

            // figure out potential positions based on being off-screen
            canUseLeft = canUseLeft && !isOffScreenX(posLeft, size);
            canUseRight = canUseRight && !isOffScreenX(posRight, size);
            canUseAbove = canUseAbove && !isOffScreenY(posAbove, size);
            canUseBelow = canUseBelow && !isOffScreenY(posBelow, size);

            // all off-screen, let's position it anywhere
            if (!canUseLeft && !canUseRight && !canUseAbove && !canUseBelow) {
                canUseLeft = true;
                canUseRight = true;
                canUseAbove = true;
                canUseBelow = true;
            }

            // switch preferred position to the opposite side if blocked
            if ((preferredPosition == RelativePosition.LEFT) && !canUseLeft && canUseRight) {
                preferredPosition = RelativePosition.RIGHT;
            } else if ((preferredPosition == RelativePosition.RIGHT) && !canUseRight && canUseLeft) {
                preferredPosition = RelativePosition.LEFT;
            } else if ((preferredPosition == RelativePosition.ABOVE) && !canUseAbove && canUseBelow) {
                preferredPosition = RelativePosition.BELOW;
            } else if ((preferredPosition == RelativePosition.BELOW) && !canUseBelow && canUseAbove) {
                preferredPosition = RelativePosition.ABOVE;
            }

            RelativePosition finalPosition;

            if (((preferredPosition == RelativePosition.ABOVE) && canUseAbove) ||
                ((preferredPosition == RelativePosition.BELOW) && canUseBelow) ||
                ((preferredPosition == RelativePosition.LEFT) && canUseLeft) ||
                ((preferredPosition == RelativePosition.RIGHT) && canUseRight)) {

                // preferred position is good to go
                finalPosition = preferredPosition;
            } else if (parentIsSingleColumn) {
                // default positioning for single column: right > left > above > below
                if (canUseRight) {
                    finalPosition = RelativePosition.RIGHT;
                } else if (canUseLeft) {
                    finalPosition = RelativePosition.LEFT;
                } else if (canUseAbove) {
                    finalPosition = RelativePosition.ABOVE;
                } else {
                    finalPosition = RelativePosition.BELOW;
                }
            } else {
                // default positioning: above > below > right > left
                if (canUseAbove) {
                    finalPosition = RelativePosition.ABOVE;
                } else if (canUseBelow) {
                    finalPosition = RelativePosition.BELOW;
                } else if (canUseRight) {
                    finalPosition = RelativePosition.RIGHT;
                } else {
                    finalPosition = RelativePosition.LEFT;
                }
            }

            Vector2 pos;
            switch (finalPosition) {
                case RelativePosition.ABOVE:
                    pos = posAbove;
                    break;
                case RelativePosition.BELOW:
                    pos = posBelow;
                    break;
                case RelativePosition.LEFT:
                    pos = posLeft;
                    break;
                case RelativePosition.RIGHT:
                    pos = posRight;
                    break;
                default:
                    throw new Exception("unknown final position: " + finalPosition);
            }

            Rect r = new Rect(pos.x, pos.y, size.x, size.y);
            r = r.clampToScreen();
            pos = new Vector2(r.x, r.y);

            return new AutoPositionResult(finalPosition, pos);
        }
Exemplo n.º 41
0
 public RelativePositionEventArgs(RelativePosition rp)
 {
     RelativePosition = rp;
 }
Exemplo n.º 42
0
        private void OnModelPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (!(sender is IChatWindowLayoutSetting)) return;

            var setting = sender as IChatWindowLayoutSetting;
            if (e.PropertyName == nameof(DefaultWidth))
            {
                DefaultWidth = setting.DefaultWidth;
            }
            else if (e.PropertyName == nameof(DefaultHeight))
            {
                DefaultHeight = setting.DefaultHeight;
            }
            else if (e.PropertyName == nameof(RelativePosition))
            {
                RelativePosition = setting.RelativePosition;
            }

        }
Exemplo n.º 43
0
		/// <override></override>
		public override Point CalculateAbsolutePosition(RelativePosition relativePosition) {
			// The RelativePosition of a PolyLine is defined as
			// A = ControlPointId of the first vertex of the nearest line segment (FirstVertex -> LastVertex)
			// B = Angle between the line segment (A / next vertex of A) and the point
			// C = Distance of the point from A in percentage of the line segment's length
			Point result = Point.Empty;
			int idx = GetControlPointIndex(relativePosition.A);
			float angle = Geometry.TenthsOfDegreeToDegrees(relativePosition.B);
			float distance = relativePosition.C / 1000f;
			if (distance != 0) {
				float segmentLength = Geometry.DistancePointPoint(vertices[idx], vertices[idx + 1]);
				Point p = Geometry.VectorLinearInterpolation(vertices[idx], vertices[idx + 1], (distance));
				result = Geometry.RotatePoint(vertices[idx], angle, p);
				Debug.Assert(Geometry.IsValid(result));
			} else result = vertices[idx];
			return result;
		}
Exemplo n.º 44
0
    /// <summary>
    ///  Fixes the property after a deserialisation
    /// </summary>
    /// <param name="property">A reference to the property to be fixed</param>
    public static void FixType(ref Property property)
    {
        switch (property.PropertyType) {
        case Property.Type.ProjectionSize:
            if (!(property is ProjectionSize))
                property = new ProjectionSize (property);
            break;

        case Property.Type.PositionOnScreen:
            if (!(property is PositionOnScreen))
                property = new PositionOnScreen (property);
            break;

        case Property.Type.VantageAngle:
            if (!(property is VantageAngle))
                property = new VantageAngle (property);
            break;

        case Property.Type.RelativePosition:
            if (!(property is RelativePosition))
                property = new RelativePosition (property);
            break;
        }
    }
Exemplo n.º 45
0
        /// <override></override>
        public override Point CalculateAbsolutePosition(RelativePosition relativePosition)
        {
            // Definition of the relative position:
            // Let posA be thwe intersection point of A|xy and B|C
            // Let posB be the intersection point of B|xy and A|C
            // The relative position is the intersection point of A|posA and B|posB
            // Storage in the relative position's fields:
            // RelativePosition.A = Tenths of percentage of BC
            // RelativePosition.B = Tenths of percentage of AC
            float angle = Geometry.TenthsOfDegreeToDegrees(relativePosition.A);
            float dist = (relativePosition.B / 1000f) * diameter;

            Point result = Point.Round(Geometry.CalcPoint(X, Y, angle, dist));
            return result;
        }
Exemplo n.º 46
0
        /// <override></override>
        public override Point CalculateAbsolutePosition(RelativePosition relativePosition)
        {
            // Definition of the relative position:
            // Let posA be thwe intersection point of A|xy and B|C
            // Let posB be the intersection point of B|xy and A|C
            // The relative position is the intersection point of A|posA and B|posB
            // Storage in the relative position's fields:
            // RelativePosition.A = Tenths of percentage of BC
            // RelativePosition.B = Tenths of percentage of AC
            int sX = X, sY = Y;
            float angleDeg = Geometry.TenthsOfDegreeToDegrees(Angle);
            Point p1 = Geometry.RotatePoint(sX, sY, angleDeg, shapePoints[0].X + sX, shapePoints[0].Y + sY);
            Point p2 = Geometry.RotatePoint(sX, sY, angleDeg, shapePoints[1].X + sX, shapePoints[1].Y + sY);
            Point p3 = Geometry.RotatePoint(sX, sY, angleDeg, shapePoints[2].X + sX, shapePoints[2].Y + sY);
            float distA = relativePosition.A / 1000f;
            float distB = relativePosition.B / 1000f;

            Point posA = Geometry.VectorLinearInterpolation(p2, p3, distA);
            Point posB = Geometry.VectorLinearInterpolation(p1, p3, distB);

            Point result = Geometry.IntersectLines(p1.X, p1.Y, posA.X, posA.Y, p2.X, p2.Y, posB.X, posB.Y);
            return result;
        }
Exemplo n.º 47
0
 /// <summary>Overriden method. Check base class for documentation.</summary>
 /// <remarks>See <see cref="CalculateRelativePosition">CalcRelativePosition</see> for definition of relative positions for rectangular lines.</remarks>
 public override Point CalculateAbsolutePosition(RelativePosition relativePosition)
 {
     if (relativePosition == RelativePosition.Empty) throw new ArgumentOutOfRangeException("relativePosition");
     Point result = Point.Empty;
     //
     // Find the relevant segment for this relative position.
     Point knee1, knee2;
     FindSegment(relativePosition.A, out knee1, out knee2);
     //
     // Calculate the perpendicular foot
     int fX = knee1.X + relativePosition.B * (knee2.X - knee1.X) / 100;
     int fY = knee1.Y + relativePosition.B * (knee2.Y - knee1.Y) / 100;
     //
     // Calculate absolute position on the perpendicular in distance relativePosition.C
     int pX, pY;
     Geometry.CalcNormalVectorOfLine(knee1.X, knee1.Y, knee2.X, knee2.Y, fX, fY, relativePosition.C, out pX, out pY);
     //
     result.Offset(pX, pY);
     return result;
 }
Exemplo n.º 48
0
 public new void SetPosition(Coordinate2 position, RelativePosition relativeTo = RelativePosition.Center)
 {
     base.SetPosition(position, relativeTo);
 }
Exemplo n.º 49
0
 protected void SetPosition(Single x, Single y, RelativePosition relativeTo = RelativePosition.Center)
 {
     SetPosition(new Coordinate2(x, y), relativeTo);
 }
Exemplo n.º 50
0
    //Converting Percentage Values to Actual Points
    public Rect GetAdjustedRect(float UIScale,Rect totalArea,Rect rect, RelativePosition relativePosition)
    {
        float sf = GetScaleFactor(UIScale,totalArea);

        rect = new Rect(rect.x*sf,rect.y*sf,rect.width*sf,rect.height*sf);

        Vector2 position = new Vector2();

        switch(relativePosition){

            case RelativePosition.TopCenter:
                position = new Vector2(totalArea.width/2-rect.width/2,0);
                break;

            case RelativePosition.TopRight:
                position = new Vector2(totalArea.width-rect.width,0);
                break;

            case RelativePosition.MiddleLeft:
                position = new Vector2(0,totalArea.height/2-rect.height/2);
                break;

            case RelativePosition.MiddleCenter:
                position = new Vector2(totalArea.width/2-rect.width/2,totalArea.height/2-rect.height/2);
                break;

            case RelativePosition.MiddleRight:
                position = new Vector2(totalArea.width-rect.width,totalArea.height/2-rect.height/2);
                break;

            case RelativePosition.BottomLeft:
                position = new Vector2(0,totalArea.height-rect.height);
                break;

            case RelativePosition.BottomCenter:
                position = new Vector2(totalArea.width/2-rect.width/2,totalArea.height-rect.height);
                break;

            case RelativePosition.BottomRight:
                position = new Vector2(totalArea.width-rect.width,totalArea.height-rect.height);
                break;
        }

        position = new Vector2(position.x+rect.x,position.y+rect.y);

        return new Rect(position.x+totalArea.x,position.y+totalArea.y,rect.width,rect.height);
    }
Exemplo n.º 51
0
        // Draw sub piece range and annotation
        private void DrawSubPiece()
        {
            // get current using unit
            NowUnit ucd = _units.Find(x => x.ComponentName == "Flaw Map CD");

            _totalScore = 0;
            DataRow[] flawRows = _dtbFlaws.Select(_dtbFlaws.DefaultView.RowFilter);

            ConfigHelper ch = new ConfigHelper();
            string gradeConfigFile = ch.GetDefaultGradeConfigName();
            DataTable gradeColumn = ch.GetDataTableOfdgvColumns(gradeConfigFile);
            DataTable gradeRow = ch.GetDataTableOfdgvRows(gradeConfigFile);
            string roiMode = ch.GetGradeNoRoiMode(gradeConfigFile);
            bool showScore = ch.IsGradePointEnable(gradeConfigFile);
            bool showGrade = ch.IsGradeMarksEnable(gradeConfigFile);

            if (roiMode == "Symmetrical")
            {
                foreach (DataRow drCol in gradeColumn.Rows)
                {
                    foreach (DataRow drRow in gradeRow.Rows)
                    {
                        // Add rangearea
                        string rangeName = String.Format("{0}{1}", drCol["Name"], drRow["Name"]);
                        Series range = new Series(rangeName, ViewType.RangeArea);
                        range.ShowInLegend = false;
                        range.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.False;
                        range.ArgumentScaleType = ScaleType.Numerical;

                        range.Points.Add(new SeriesPoint(drCol["Start"], drRow["Start"], drRow["End"]));
                        range.Points.Add(new SeriesPoint(drCol["End"], drRow["Start"], drRow["End"]));

                        RangeAreaSeriesView view = (RangeAreaSeriesView)range.View;
                        view.Color = Color.Red;
                        view.Transparency = 230;
                        view.Marker1.Visible = false;
                        view.Marker2.Visible = false;
                        view.Border1.Color = Color.Transparent;
                        view.Border2.Color = Color.Transparent;

                        chartControl.Series.Add(range);

                        int subPieceScore = 0;
                        string subPieceGrade = "F";
                        if (showScore)
                        {
                            string subPieceFilter = String.Format("(CD >= {0} AND CD <= {1}) AND (MD > {2} AND MD < {3})", Convert.ToDouble(drCol["Start"]) / ucd.Conversion, Convert.ToDouble(drCol["End"]) / ucd.Conversion, (Convert.ToDouble(drRow["Start"]) / ucd.Conversion + _topOfPart), (Convert.ToDouble(drRow["End"]) / ucd.Conversion + _topOfPart));
                            DataRow[] subFlawRows = _dtbFlaws.Select(subPieceFilter);
                            foreach (DataRow dr in subFlawRows)
                            {
                                string pointFilter = String.Format("SubpieceName = 'ROI-{0}' AND ClassName = '{1}'", rangeName, dr["FlawClass"]);
                                subPieceScore += Convert.ToInt32(_dtbPoints.Select(pointFilter).First()["Score"]);
                            }
                        }
                        if (showGrade)
                        {
                            string gradeFilter = String.Format("SubpieceName = 'ROI-{0}' AND Score >= {1}", rangeName, subPieceScore);
                            DataRow[] r = _dtbGrades.Select(gradeFilter);
                            if (_dtbGrades.Select(gradeFilter).Length > 0)
                            {
                                subPieceGrade = _dtbGrades.Select(gradeFilter).First()["GradeName"].ToString();
                            }
                        }

                        // Add annotation
                        TextAnnotation annotation = new TextAnnotation();
                        PaneAnchorPoint paPoint = new PaneAnchorPoint();
                        RelativePosition relPosition = new RelativePosition();

                        annotation.LabelMode = true;
                        annotation.BackColor = System.Drawing.Color.Transparent;
                        annotation.Border.Visible = false;
                        annotation.ConnectorStyle = AnnotationConnectorStyle.None;
                        annotation.Font = new System.Drawing.Font("Tahoma", 8F, FontStyle.Bold);
                        annotation.TextColor = Color.Blue;
                        annotation.Name = rangeName;
                        string annotationScore = "";
                        if (showScore)
                        {
                            annotationScore = String.Format(" - {0}", subPieceScore);
                        }
                        string annotationGrade = "";
                        if (showGrade)
                        {
                            annotationGrade = String.Format("({0})", subPieceGrade);
                        }
                        annotation.Text = String.Format("{0}{1}{2}", rangeName, annotationScore, annotationGrade);
                        string annotationX = Convert.ToString(Convert.ToDouble(drCol["Start"]) + (Convert.ToDouble(drCol["End"]) - Convert.ToDouble(drCol["Start"])) * 0.3);
                        string annotationY = Convert.ToString(Convert.ToDouble(drRow["End"]) - (Convert.ToDouble(drRow["End"]) - Convert.ToDouble(drRow["Start"])) * 0.1);
                        paPoint.AxisXCoordinate.AxisValueSerializable = annotationX;
                        paPoint.AxisYCoordinate.AxisValueSerializable = annotationY;
                        annotation.AnchorPoint = paPoint;
                        relPosition.Angle = 0;
                        relPosition.ConnectorLength = 0;
                        annotation.ShapePosition = relPosition;
                        chartControl.AnnotationRepository.AddRange(new Annotation[] { annotation });

                        _totalScore += subPieceScore;
                    }
                }
            }
            DrawDummyPoint();

            // Calculate flaw quantity
            Dictionary<string, int> flawLegendRefDic = new Dictionary<string, int>();
            int i = 0;
            foreach (DataGridViewRow dgvr in dgvFlawLegendDetial.Rows)
            {
                dgvr.Cells["PieceDoffNum"].Value = "0";
                flawLegendRefDic.Add(dgvr.Cells["Name"].Value.ToString(), i);
                i++;
            }
            if (flawRows.Length > 0)
            {
                foreach (DataRow dr in flawRows)
                {
                    string flawName = dr["FlawClass"].ToString();
                    int rowPosition = flawLegendRefDic[flawName];
                    int flawQuantity = Convert.ToInt32(dgvFlawLegendDetial.Rows[rowPosition].Cells["PieceDoffNum"].Value) + 1;
                    dgvFlawLegendDetial.Rows[rowPosition].Cells["PieceDoffNum"].Value = flawQuantity.ToString();
                }
            }
        }
Exemplo n.º 52
0
    //Convert Actual Points to Percentage Values
    public Rect GetActualRect(float UIScale,Rect totalArea,Rect rect, RelativePosition relativePosition)
    {
        Vector2 position = new Vector2();

        switch(relativePosition){

            case RelativePosition.TopCenter:
                position = new Vector2(totalArea.width/2-rect.width/2,0);
                break;

            case RelativePosition.TopRight:
                position = new Vector2(totalArea.width-rect.width,0);
                break;

            case RelativePosition.MiddleLeft:
                position = new Vector2(0,totalArea.height/2-rect.height/2);
                break;

            case RelativePosition.MiddleCenter:
                position = new Vector2(totalArea.width/2-rect.width/2,totalArea.height/2-rect.height/2);
                break;

            case RelativePosition.MiddleRight:
                position = new Vector2(totalArea.width-rect.width,totalArea.height/2-rect.height/2);
                break;

            case RelativePosition.BottomLeft:
                position = new Vector2(0,totalArea.height-rect.height);
                break;

            case RelativePosition.BottomCenter:
                position = new Vector2(totalArea.width/2-rect.width/2,totalArea.height-rect.height);
                break;

            case RelativePosition.BottomRight:
                position = new Vector2(totalArea.width-rect.width,totalArea.height-rect.height);
                break;
        }

        position = new Vector2(rect.x-position.x,rect.y-position.y);

        float sf = GetScaleFactor(UIScale,totalArea);

        return new Rect(position.x/sf,position.y/sf,rect.width/sf,rect.height/sf);
    }
Exemplo n.º 53
0
 internal AutoPositionResult(RelativePosition relativePosition, Vector2 position)
 {
     this.relativePosition = relativePosition;
     this.position = position;
 }
Exemplo n.º 54
0
		public double X(int x, RelativePosition position)
		{
			if (x < 0)
				throw new ArgumentException();

			if (x < Offset)
				x = Offset;

			if (x > Offset + XRange - 1)
				x = Offset + XRange - 1;

			double firstSeparator = (ActualWidth - LeftMargin - RightMargin - (XRange * (CandleWidth + CandleSpacing) - CandleSpacing)) / 2.0;
			firstSeparator = Math.Max(firstSeparator, 0);

			double retVal = LeftMargin + firstSeparator;
			retVal += (x - Offset) * (CandleWidth + CandleSpacing);

			switch (position)
			{
				case RelativePosition.Before:
					{
						if (x == Offset)
							retVal -= firstSeparator / 2.0;
						else
							retVal -= CandleSpacing / 2.0;
					} break;

				case RelativePosition.Left:
					{
						// Nothing to do
					} break;

				case RelativePosition.Middle:
					{
						retVal += CandleWidth / 2.0;
					} break;

				case RelativePosition.Right:
					{
						retVal += CandleWidth;
					} break;

				case RelativePosition.After:
					{
						if (x == Offset + XRange - 1)
							retVal += CandleWidth + firstSeparator / 2.0;
						else
							retVal += CandleWidth + CandleSpacing / 2.0;
					} break;

				default: throw new ArgumentOutOfRangeException();
			}

			return retVal;
		}
Exemplo n.º 55
0
        internal void draw()
        {
            // only show toolbar if there is at least one visible button that is not the drop-down menu button
            if (Visible &&
                ((mode == Mode.FOLDER) || buttons.Any((b) => !b.Equals(dropdownMenuButton) && isEffectivelyUserVisible(b)))) {

                forceAutoSizeIfButtonVisibilitiesChanged();
                autoSize();

                if (mode == Mode.FOLDER) {
                    relativePosition = autoPositionFolder(relativePosition);
                }

                if (autoHide && (dropdownMenu == null) && AtScreenEdge && !buttons.Any(b => b.command.Drawable != null)) {
                    handleAutoHide();
                }

                int oldDepth = GUI.depth;

                GUI.depth = -99;
                drawToolbarBorder();

                GUI.depth = -100;
                if (buttonOrderDropMarker != null) {
                    buttonOrderDropMarker.draw();
                }

                GUISkin oldSkin = GUI.skin;
                if (UseKSPSkin) {
                    GUI.skin = HighLogic.Skin;
                }
                drawButtons();
                GUI.skin = oldSkin;

                foreach (Toolbar folder in folders.Values) {
                    folder.draw();
                }

                if (Enabled && rectLocked && buttonOrderLocked && (displayMode == DisplayMode.VISIBLE)) {
                    drawDrawables();
                }

                if (Enabled && rectLocked && (buttonOrderLocked || (draggedButton == null)) && (dropdownMenu == null) && (displayMode == DisplayMode.VISIBLE)) {
                    drawButtonToolTips();
                }

                GUI.depth = oldDepth;

                Vector2 mousePos = Utils.getMousePosition();
                editorLockToolbar.draw(rect.contains(mousePos));
                editorLockDrag.draw(!rectLocked);
                editorLockReorder.draw(!buttonOrderLocked);
            } else {
                editorLockToolbar.draw(false);
                editorLockDrag.draw(false);
                editorLockReorder.draw(false);
            }
        }
Exemplo n.º 56
0
		/// <override></override>
		public override Point CalculateAbsolutePosition(RelativePosition relativePosition)
		{
			if (relativePosition == RelativePosition.Empty) throw new ArgumentOutOfRangeException("relativePosition");
			Point result = Point.Empty;
			result.X = relativePosition.A + X;
			result.Y = relativePosition.A + Y;
			return result;
		}
Exemplo n.º 57
0
        private static async Task MoveWhiteFromMiddleLayer(CubeConfiguration<FaceColour> configuration, FaceType faceType, ICollection<IRotation> solution, RelativePosition relativePosition, Edge edge, RotationDirection downDirection)
        {
            var joiningFace = FaceRules.FaceAtRelativePositionTo(faceType, relativePosition);
            var joiningColour = configuration.Faces[joiningFace].GetEdge(edge).Centre();

            var faceWithJoiningColour = FaceRules.GetFaceOfColour(joiningColour, configuration);

            var relativePostion = FaceRules.RelativePositionBetweenFaces(faceWithJoiningColour, joiningFace);
            switch (relativePostion)
            {
                case RelativePosition.Same:
                    await CommonActions.ApplyAndAddRotation(Rotations.ByFace(joiningFace, downDirection), solution, configuration).ConfigureAwait(false);

                    break;

                case RelativePosition.Left:
                case RelativePosition.Right:
                case RelativePosition.Opposite:
                    // TODO: ROTATE SO THAT WE ARE ONLY DOING RIGHT... MOVES
                    await CommonActions.ApplyAndAddRotation(Rotations.ByFace(joiningFace, RotationDirectionEx.Reverse(downDirection)), solution, configuration).ConfigureAwait(false);

                    await CommonActions.ApplyAndAddRotation(Rotations.UpperAntiClockwise, solution, configuration).ConfigureAwait(false);

                    await CommonActions.ApplyAndAddRotation(Rotations.ByFace(joiningFace, downDirection), solution, configuration).ConfigureAwait(false);

                    await CheckTopFaceForWhite(configuration, joiningFace, solution).ConfigureAwait(false);

                    break;
            }
        }
Exemplo n.º 58
0
 public new void SetPosition(Single x, Single y, RelativePosition relativeTo = RelativePosition.Center)
 {
     base.SetPosition(x, y, relativeTo);
 }
Exemplo n.º 59
0
        protected void SetPosition(Coordinate2 position, RelativePosition relativeTo = RelativePosition.Center)
        {
            //TODO: Add support for CoordinateSystemMode
            if (DrawEngine2d.CoordinateSystemMode != CoordinateSystemMode.OriginAtUpperLeft)
                throw new NotImplementedException();

            switch (relativeTo)
            {
                case RelativePosition.Center :
                    Position = new Coordinate2(position.X - HalfWidth, position.Y - HalfHeight);
                    break;

                case RelativePosition.TopLeft :
                    Position = position;
                    break;

                case RelativePosition.Top :
                    Position = new Coordinate2(position.X - HalfWidth, position.Y);
                    break;

                case RelativePosition.TopRight :
                    Position = new Coordinate2(position.X - Width, position.Y);
                    break;

                case RelativePosition.Left :
                    Position = new Coordinate2(position.X, position.Y - HalfHeight);
                    break;

                case RelativePosition.Right :
                    Position = new Coordinate2(position.X - Width, position.Y - HalfHeight);
                    break;

                case RelativePosition.BottomLeft :
                    Position = new Coordinate2(position.X, position.Y - Height);
                    break;

                case RelativePosition.Bottom :
                    Position = new Coordinate2(position.X - HalfWidth, position.Y - Height);
                    break;

                case RelativePosition.BottomRight :
                    Position = new Coordinate2(position.X - Width, position.Y - Height);
                    break;

                default :
                    throw new NotImplementedException();
            }
        }