Ejemplo n.º 1
0
        public Label(ControlPosition position, string text = "")
            : base()
        {
            Position  = position;
            this.text = text;

            BaseInitialize();
        }
Ejemplo n.º 2
0
        public Button(ControlPosition position, Index focusIndex, ControlSize size, string text = "")
            : base()
        {
            BaseInitialize();

            Position        = position;
            this.FocusIndex = focusIndex;
            Size            = size;
            label.Text      = text;
        }
Ejemplo n.º 3
0
        public Button(ControlPosition position, string text)
            : base()
        {
            BaseInitialize();

            Position   = position;
            label.Text = text;

            Size = new ControlSize(125, 65, SizeType.Fixed);
        }
Ejemplo n.º 4
0
        protected override void LoadControlState(object savedState)
        {
            Pair p = (Pair)savedState;

            base.LoadControlState(p.First);
            object[] values = (object[])p.Second;

            this.summaryFormetString = (string)values[0];
            LayoutWidth          = (Unit)values[1];
            this.summaryPosition = (ControlPosition)values[2];
        }
Ejemplo n.º 5
0
        public Button(ControlPosition position, Index focusIndex, string text = "")
            : base()
        {
            BaseInitialize();

            Position        = position;
            this.FocusIndex = focusIndex;
            label.Text      = text;

            Size = new ControlSize(125, 65, SizeType.Fixed);
        }
Ejemplo n.º 6
0
        private void CreateControlNumber(CourseView.ControlView controlView, ControlPosition controlPosition)
        {
            Id <ControlPoint>  controlId       = controlView.controlId;
            Id <CourseControl> courseControlId = controlView.courseControlIds[0];
            ControlPoint       control         = eventDB.GetControl(controlId);
            PointF             location        = LocationFromAbstractPosition(controlPosition.x, controlPosition.y);

            CourseLayer layer;

            if (ControlViewInSpecificVariation(controlView))
            {
                layer = courseLayerSpecificVariation;
            }
            else
            {
                layer = courseLayerAllVariationsAndParts;
            }

            CourseObj courseObj;

            switch (control.kind)
            {
            case ControlPointKind.Start:
            case ControlPointKind.MapExchange:
                // Triangle looks best if we displace it down a bit (0.8 looks right).
                courseObj = new StartCourseObj(controlId, courseControlId, courseObjRatio * 0.75F, appearance, 0, new PointF(location.X, location.Y - 0.8F), CrossHairOptions.NoCrossHair);
                break;

            case ControlPointKind.Finish:
                courseObj = new FinishCourseObj(controlId, courseControlId, courseObjRatio * 0.75F, appearance, null, location, CrossHairOptions.NoCrossHair);
                break;

            case ControlPointKind.Normal:
                courseObj = new ControlNumberCourseObj(controlId, courseControlId, courseObjRatio, appearance, control.code, location);
                break;

            case ControlPointKind.CrossingPoint:
                courseObj = new CrossingCourseObj(controlId, courseControlId, Id <Special> .None, courseObjRatio * 1.5F, appearance, 0, location);
                break;

            case ControlPointKind.MapIssue:
                courseObj = new MapIssueCourseObj(controlId, courseControlId, courseObjRatio * 1.5F, appearance, -90, new PointF(location.X - 0.8F, location.Y), MapIssueCourseObj.RenderStyle.WithTail);
                break;

            default:
                Debug.Fail("bad control kind");
                return;
            }

            courseObj.layer = layer;
            courseLayout.AddCourseObject(courseObj);
        }
Ejemplo n.º 7
0
        public Control ShowControl(Control userCtrl, bool modal = false, ControlPosition position = ControlPosition.Center, System.Windows.Forms.Control owner = null, Point?location = null)
        {
            System.Diagnostics.Debug.Assert(!_listControl.ContainsKey(userCtrl.Name), "Control Duplicated");

            if (modal && !(userCtrl is Form))
            {
                LockAllControl();
            }

            userCtrl.Location = CalculateLocation(userCtrl, position, location, owner);
            Show(userCtrl, modal);

            return(userCtrl);
        }
Ejemplo n.º 8
0
        private void CreateLegBetweenControls(CourseView.ControlView controlView1, ControlPosition controlPosition1, CourseView.ControlView controlView2, ControlPosition controlPosition2, int splitLegIndex, ForkPosition forkStart)
        {
            List <DropTarget> dropTargets;
            SymPath           path      = PathBetweenControls(controlPosition1, controlPosition2, forkStart, out dropTargets);
            CourseObj         courseObj = new TopologyLegCourseObj(controlView1.controlId, controlView1.courseControlIds[splitLegIndex], controlView2.courseControlIds[0], courseObjRatio, appearance, path);
            CourseLayer       layer;

            if (LegInSpecificVariation(controlView1.courseControlIds[splitLegIndex], controlView2.courseControlIds[0]))
            {
                layer = courseLayerSpecificVariation;
            }
            else
            {
                layer = courseLayerAllVariationsAndParts;
            }

            courseObj.layer = layer;
            courseLayout.AddCourseObject(courseObj);

            // No drop targets between map issue and start.
            if (!(eventDB.GetControl(controlView1.controlId).kind == ControlPointKind.MapIssue &&
                  eventDB.GetControl(controlView2.controlId).kind == ControlPointKind.Start))
            {
                // Add the drop targets
                foreach (DropTarget dropTarget in dropTargets)
                {
                    courseObj = new TopologyDropTargetCourseObj(controlView1.controlId, controlView1.courseControlIds[splitLegIndex], controlView2.courseControlIds[0], courseObjRatio, appearance,
                                                                LocationFromAbstractPosition(dropTarget.abstractX, dropTarget.abstractY), dropTarget.insertionLoc);

                    // Along the selected leg, show the drop targets in light gray. Along other legs, drop targets are invisible.
                    if (controlView1.courseControlIds[splitLegIndex] == courseControlIdSelection1 && controlView2.courseControlIds.Contains(courseControlIdSelection2))
                    {
                        courseObj.layer = CourseLayer.AllVariations;
                    }
                    else
                    {
                        courseObj.layer = CourseLayer.InvisibleObjects;
                    }
                    courseLayout.AddCourseObject(courseObj);
                }
            }

            if (forkStart != null && forkStart.variationCode != '\0')
            {
                // There is a variation fork.
                courseObj = CreateVariationCode(controlView1, controlPosition1, splitLegIndex, forkStart);
                courseLayout.AddCourseObject(courseObj);
            }
        }
Ejemplo n.º 9
0
        private CourseObj CreateVariationCode(CourseView.ControlView controlView1, ControlPosition controlPosition1, int splitLegIndex, ForkPosition forkStart)
        {
            // Delta between position of fork start and position of code.
            float deltaX = (forkStart.x < controlPosition1.x) ? -0.4F : 0.4F;
            float deltaY = -0.4F;

            float x = forkStart.x + deltaX;
            float y = forkStart.y + deltaY;

            string    text      = "(" + forkStart.variationCode + ")";
            CourseObj courseObj = new VariationCodeCourseObj(controlView1.controlId, controlView1.courseControlIds[splitLegIndex], courseObjRatio, appearance, text, LocationFromAbstractPosition(x, y));

            courseObj.layer = CourseLayer.AllVariations;
            return(courseObj);
        }
Ejemplo n.º 10
0
        private Point CalculateLocation(Control userCtrl, ControlPosition position, Point?location, Control owner)
        {
            var pt       = Point.Empty;
            var ownerPos = Point.Empty;

            switch (position)
            {
            case ControlPosition.Owner:
                System.Diagnostics.Debug.Assert(owner != null, "Missing Owner");
                if (userCtrl is Form)
                {
                    pt = owner.PointToScreen(Point.Empty);
                }
                else
                {
                    pt = owner.Location;
                }

                pt.Y    += owner.Height;
                ownerPos = _owner.PointToScreen(Point.Empty);
                if (pt.X + userCtrl.Width > ownerPos.X + _owner.Width)
                {
                    pt.X = ownerPos.X + _owner.Width - userCtrl.Width;
                }
                return(pt);

            case ControlPosition.Center:
                ownerPos    = _owner.PointToScreen(Point.Empty);
                ownerPos.X += (owner.Width - userCtrl.Width) / 2;
                ownerPos.Y += (owner.Height - userCtrl.Height) / 2;
                if (ownerPos.X < 0)
                {
                    ownerPos.X = 0;
                }
                if (ownerPos.Y < 0)
                {
                    ownerPos.Y = 0;
                }
                return(ownerPos);

            case ControlPosition.Manual:
                System.Diagnostics.Debug.Assert(location != null, "Location is null");
                return((Point)location);

            default:
                return((Point)location);
            }
        }
        private NumericUpDown GetNextControl(ControlPosition position)
        {
            if (position.Type == ControlType.Integer)
            {
                if (position.Index == _controlsInteger.Count - 1)
                {
                    return _controlsDivisional.First();
                }

                return _controlsInteger[position.Index + 1];
            }

            if (position.Index < _controlsDivisional.Count - 1)
            {
                return _controlsDivisional[position.Index + 1];
            }

            return null;
        }
Ejemplo n.º 12
0
        public static Vector2 CalculateVerticalPoint(ControlPosition currentPoint, ControlSize targetSize, ControlSize parentSize, ControlPosition parentPosition, VerticalAlingment alingment)
        {
            Vector2 results = Vector2.Zero;

            switch (alingment)
            {
            case VerticalAlingment.Center:
                results = new Vector2(currentPoint.Relative.X, parentSize.Height / 2 - targetSize.Height / 2);
                break;

            case VerticalAlingment.Top:
                results = new Vector2(currentPoint.Relative.X, 0);
                break;

            case VerticalAlingment.Bottom:
                results = new Vector2(currentPoint.Relative.X, parentSize.Height - targetSize.Height);
                break;
            }
            return(results);
        }
Ejemplo n.º 13
0
        public static Vector2 CalulateHorizontalPoint(ControlPosition currentPoint, ControlSize targetSize, ControlSize parentSize, ControlPosition parentPosition, HorizontalAlingment alingment)
        {
            Vector2 results = Vector2.Zero;

            switch (alingment)
            {
            case HorizontalAlingment.Right:
                results = new Vector2((parentPosition.Relative.X + parentSize.Width) - targetSize.Width, currentPoint.Relative.Y);
                break;

            case HorizontalAlingment.Left:
                results = new Vector2(parentPosition.Relative.X, currentPoint.Relative.Y);
                break;

            case HorizontalAlingment.Center:
                results = new Vector2(parentSize.Width / 2 - targetSize.Width / 2, currentPoint.Relative.Y);
                break;
            }

            return(results);
        }
        private NumericUpDown CreateNumericUpDown(string name, int left, ControlPosition position)
        {
            var ctl = new NumericUpDown
            {
                Name = name,
                Top = 0,
                Left = left,
                Font = _controlFont,
                Minimum = -1,
                Maximum = 10,
                Increment = 1,
                Value = 0,
                Tag = position
            };
            ctl.Width = ctl.Height;
            ctl.ValueChanged += Ctl_ValueChanged;
            ctl.GotFocus += Ctl_GotFocus;
            ctl.Click += Ctl_Click;
            ctl.KeyUp += Ctl_KeyUp;

            return ctl;
        }
Ejemplo n.º 15
0
        private void CreateObjectsForControlView(CourseView.ControlView controlView, ControlPosition controlPosition)
        {
            CreateControlNumber(controlView, controlPosition);

            if (controlView.legTo != null)
            {
                for (int i = 0; i < controlView.legTo.Length; ++i)
                {
                    ForkPosition forkStart;
                    if (controlPosition.forkStart != null)
                    {
                        forkStart = controlPosition.forkStart[i];
                    }
                    else
                    {
                        forkStart = null;
                    }

                    CreateLegBetweenControls(controlView, controlPosition, controlViewsAllVariationsAndParts[controlView.legTo[i]], controlPositions[controlView.legTo[i]], i, forkStart);
                }
            }
        }
Ejemplo n.º 16
0
        /// <inheritdoc />
        protected override void OnLayoutEvent(Rect position)
        {
            base.OnLayoutEvent(position);

            if (Mouseovered)
            {
                var mouseOverPartWas = MouseOverPart;

                var cursorPos = Cursor.LocalPosition;

                if (PrefixLabelPosition.Contains(cursorPos) || DragBarPosition.Contains(cursorPos))
                {
                    if (mouseOverPartWas != PrefixedControlPart.Prefix)
                    {
                        MouseOverPart = PrefixedControlPart.Prefix;
                        UpdatePrefixDrawer();
                    }
                }
                else if (ControlPosition.Contains(cursorPos))
                {
                    if (mouseOverPartWas != PrefixedControlPart.Control)
                    {
                        MouseOverPart = PrefixedControlPart.Control;
                        UpdatePrefixDrawer();
                    }
                }
                else
                {
                    if (mouseOverPartWas != PrefixedControlPart.None)
                    {
                        MouseOverPart = PrefixedControlPart.None;
                        UpdatePrefixDrawer();
                    }
                }
            }
        }
 internal Control(T options, ControlPosition position) : base(position) => Options = options;
Ejemplo n.º 18
0
 /// <summary>
 /// Sets the position of the drawing controls on the map.
 /// </summary>
 /// <param name="controlPosition"></param>
 /// <returns></returns>
 public Task SetControlPosition(ControlPosition controlPosition)
 {
     return(_jsObjectRef.InvokeAsync(
                "setControlPosition",
                controlPosition));
 }
Ejemplo n.º 19
0
        private CourseObj CreateVariationCode(CourseView.ControlView controlView1, ControlPosition controlPosition1, int splitLegIndex, ForkPosition forkStart)
        {
            // Delta between position of fork start and position of code.
            float deltaX = (forkStart.x < controlPosition1.x) ? -0.4F : 0.4F;
            float deltaY = -0.4F;

            float x = forkStart.x + deltaX;
            float y = forkStart.y + deltaY;

            string text = "(" + forkStart.variationCode + ")";
            CourseObj courseObj = new VariationCodeCourseObj(controlView1.controlId, controlView1.courseControlIds[splitLegIndex], scaleRatio, appearance, text, LocationFromAbstractPosition(x, y));
            courseObj.layer = CourseLayer.AllVariations;
            return courseObj;
        }
Ejemplo n.º 20
0
        SymPath PathBetweenControls(ControlPosition controlPosition1, ControlPosition controlPosition2, ForkPosition forkStart, out PointF dropTargetPosition)
        {
            float xStart = controlPosition1.x;
            float yStart = controlPosition1.y;
            float xEnd = controlPosition2.x;
            float yEnd = controlPosition2.y;

            if (forkStart != null) {
                if (forkStart.loopFallThru) {
                    dropTargetPosition = LocationFromAbstractPosition(xEnd, yEnd - 0.5F);
                }
                else {
                    // above end of fork start.
                    dropTargetPosition = LocationFromAbstractPosition(forkStart.x, forkStart.y - 0.5F);
                }
            }
            else if (xEnd != xStart) {
                // Below start control (use when a join is going)
                dropTargetPosition = LocationFromAbstractPosition(xStart, yStart + 0.5F);
            }
            else {
                // Above end control (other cases).
                dropTargetPosition = LocationFromAbstractPosition(xEnd, yEnd - 0.5F);
            }

            bool startHorizontal = false;
            if (forkStart != null)
                startHorizontal = forkStart.loopStart;

            if (forkStart != null && forkStart.x != controlPosition2.x) {
                // The fork start in a different horizontal position than it ends. This is probably due to a fork with no controls on it.
                // Create the path in two pieces.
                float xMiddle = forkStart.x;
                float yMiddle = forkStart.y;
                SymPath path1 = PathFromStartToEnd(xStart, yStart, xMiddle, yMiddle, startHorizontal, 0);
                SymPath path3 = PathFromStartToEnd(xMiddle, yMiddle, xEnd, yEnd, false, controlPosition2.loopBottom);
                SymPath path2 = new SymPath(new[] { path1.LastPoint, path3.FirstPoint });
                return SymPath.Join(SymPath.Join(path1, path2, PointKind.Normal), path3, PointKind.Normal);
            }
            else {
                return PathFromStartToEnd(xStart, yStart, xEnd, yEnd, startHorizontal, controlPosition2.loopBottom);
            }
        }
Ejemplo n.º 21
0
        private void CreateLegBetweenControls(CourseView.ControlView controlView1, ControlPosition controlPosition1, CourseView.ControlView controlView2, ControlPosition controlPosition2, int splitLegIndex, ForkPosition forkStart)
        {
            PointF dropTargetPosition;
            SymPath path = PathBetweenControls(controlPosition1, controlPosition2, forkStart, out dropTargetPosition);
            CourseObj courseObj = new TopologyLegCourseObj(controlView1.controlId, controlView1.courseControlIds[splitLegIndex], controlView2.courseControlIds[0], scaleRatio, appearance, path);
            CourseLayer layer;

            if (LegInSpecificVariation(controlView1.courseControlIds[splitLegIndex], controlView2.courseControlIds[0]))
                layer = courseLayerSpecificVariation;
            else
                layer = courseLayerAllVariationsAndParts;

            courseObj.layer = layer;
            courseLayout.AddCourseObject(courseObj);

            // Add the drop target.
            courseObj = new TopologyDropTargetCourseObj(controlView1.controlId, controlView1.courseControlIds[splitLegIndex], controlView2.courseControlIds[0], scaleRatio, appearance, dropTargetPosition);
            courseObj.layer = layer;
            courseLayout.AddCourseObject(courseObj);

            if (forkStart != null && forkStart.variationCode != '\0') {
                // There is a variation fork.
                courseObj = CreateVariationCode(controlView1, controlPosition1, splitLegIndex, forkStart);
                courseLayout.AddCourseObject(courseObj);
            }
        }
Ejemplo n.º 22
0
        private void CreateObjectsForControlView(CourseView.ControlView controlView, ControlPosition controlPosition)
        {
            CreateControlNumber(controlView, controlPosition);

            if (controlView.legTo != null) {
                for (int i = 0; i < controlView.legTo.Length; ++i) {
                    ForkPosition forkStart;
                    if (controlPosition.forkStart != null)
                        forkStart = controlPosition.forkStart[i];
                    else
                        forkStart = null;

                    CreateLegBetweenControls(controlView, controlPosition, controlViewsAllVariationsAndParts[controlView.legTo[i]], controlPositions[controlView.legTo[i]], i, forkStart);
                }
            }
        }
Ejemplo n.º 23
0
 public GoogleMapBuilder ZoomControlPosition(ControlPosition controlPosition)
 {
     Component.ZoomControlPosition = controlPosition;
     return(this);
 }
Ejemplo n.º 24
0
 public static void SetPosition(DependencyObject d, ControlPosition value)
 {
     d.SetValue(PositionProperty, value);
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Sets the ControlPosition at which to display the AdUnit on the map.  If the position is set to null, the AdUnit is removed from the map.
 /// </summary>
 public void SetPosition(ControlPosition position)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 26
0
 public GoogleMapBuilder MapTypeControlPosition(ControlPosition controlPosition)
 {
     Component.MapTypeControlPosition = controlPosition;
     return(this);
 }
Ejemplo n.º 27
0
 public MapBuilder MapTypeControlPosition(ControlPosition value)
 {
     this.Component.MapTypeControlPosition = value;
     return(this);
 }
Ejemplo n.º 28
0
        // Assign positions/sizes from startIndex upto (not including) endIndex, starting at given position.
        // Return total size used.
        private SizeF AssignControlPositions(int startIndex, int endIndex, float startX, float startY)
        {
            int   index = startIndex;
            float x = startX, y = startY;
            float totalWidth = 1, totalHeight = 0;   // Always at least a width of 1.

            while (index != endIndex)
            {
                int numForks = (controlViewsAllVariationsAndParts[index].legTo == null) ? 0 : controlViewsAllVariationsAndParts[index].legTo.Length;

                // Simple case, no splitting.
                controlPositions[index] = new ControlPosition()
                {
                    x = x,
                    y = y,
                };
                totalWidth   = Math.Max(totalWidth, 1);
                totalHeight += 1;
                y           += 1;

                if (numForks > 1)
                {
                    bool loop = (controlViewsAllVariationsAndParts[index].joinIndex == index);

                    // fork or loop subsequent. Two passes -- first determine totalWidth and maxHeight;
                    float          totalForkWidth = 0, maxForkHeight = 1;
                    SizeF[]        forkSize  = new SizeF[numForks];
                    ForkPosition[] forkStart = new ForkPosition[numForks];

                    int startFork = 0;
                    if (loop)
                    {
                        startFork      = 1;
                        totalForkWidth = 1;
                    }

                    // Get size of each fork.
                    for (int i = startFork; i < numForks; ++i)
                    {
                        forkSize[i]     = AssignControlPositions(controlViewsAllVariationsAndParts[index].legTo[i], controlViewsAllVariationsAndParts[index].joinIndex, 0, 0);
                        totalForkWidth += forkSize[i].Width;
                        maxForkHeight   = Math.Max(maxForkHeight, forkSize[i].Height);
                    }

                    // Get position of each fork.
                    if (loop)
                    {
                        float forkY = y;
                        float forkX = x;
                        forkStart[0] = new ForkPosition(forkX, forkY, false, true, '\0');
                        int halfForks = (numForks + 1) / 2;

                        totalForkWidth = 0;

                        forkX = x - 0.5F;
                        for (int i = startFork; i < halfForks; ++i)
                        {
                            forkX -= forkSize[i].Width;
                        }

                        totalForkWidth = Math.Max(totalForkWidth, (x - forkX) * 2);

                        for (int i = startFork; i < halfForks; ++i)
                        {
                            forkX       += forkSize[i].Width / 2;
                            forkStart[i] = new ForkPosition(forkX, forkY, loop, false, variationMap[controlViewsAllVariationsAndParts[index].courseControlIds[i]]);
                            forkX       += forkSize[i].Width / 2;
                        }

                        forkX = x + 0.5F;

                        for (int i = halfForks; i < numForks; ++i)
                        {
                            forkX       += forkSize[i].Width / 2;
                            forkStart[i] = new ForkPosition(forkX, forkY, loop, false, variationMap[controlViewsAllVariationsAndParts[index].courseControlIds[i]]);
                            forkX       += forkSize[i].Width / 2;
                        }

                        totalForkWidth = Math.Max(totalForkWidth, (forkX - x) * 2);

                        controlPositions[index].loopBottom = y + maxForkHeight - 0.5F;
                    }
                    else
                    {
                        float forkY = y + 0.5F;
                        float forkX = x - totalForkWidth / 2;
                        for (int i = startFork; i < numForks; ++i)
                        {
                            forkX       += forkSize[i].Width / 2;
                            forkStart[i] = new ForkPosition(forkX, forkY, loop, false, variationMap[controlViewsAllVariationsAndParts[index].courseControlIds[i]]);
                            forkX       += forkSize[i].Width / 2;
                        }
                    }

                    controlPositions[index].forkStart = forkStart;

                    // Assign control positions for each fork again, now that we know the start position.
                    for (int i = startFork; i < numForks; ++i)
                    {
                        AssignControlPositions(controlViewsAllVariationsAndParts[index].legTo[i], controlViewsAllVariationsAndParts[index].joinIndex, forkStart[i].x, forkStart[i].y);
                    }

                    float height = maxForkHeight + 1;
                    totalHeight += height;
                    y           += height;
                    totalWidth   = Math.Max(totalWidth, totalForkWidth);

                    if (index == controlViewsAllVariationsAndParts[index].joinIndex)
                    {
                        index = controlViewsAllVariationsAndParts[index].legTo[0];
                    }
                    else
                    {
                        index = controlViewsAllVariationsAndParts[index].joinIndex;
                    }
                }
                else
                {
                    if (controlViewsAllVariationsAndParts[index].legTo != null && controlViewsAllVariationsAndParts[index].legTo.Length > 0)
                    {
                        index = controlViewsAllVariationsAndParts[index].legTo[0];
                    }
                    else
                    {
                        break; // no more controls.
                    }
                }
            }

            return(new SizeF(totalWidth, totalHeight));
        }
Ejemplo n.º 29
0
        private System.Web.UI.HtmlControls.HtmlGenericControl GetContainer(ControlPosition position,bool isFullWidth)
        {
            System.Web.UI.HtmlControls.HtmlGenericControl control = null;
            if (position == ControlPosition.None)
            {
                CurrentPosition = position;
                control = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                control.Attributes.Add("class", "block-2");
                CurrentContainer = control;
            }
            if (CurrentContainer != null && CurrentPosition == position)
            {
                control = CurrentContainer;
            }
            else if (CurrentContainer == null && !isFullWidth)
            {
                switch (position)
                {
                    case ControlPosition.Left:
                        control = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                        control.Attributes.Add("class", "aside");
                        break;
                    case ControlPosition.Right:
                        control = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                        control.Attributes.Add("class", "wrapper");
                        break;
                    case ControlPosition.Top:
                        break;
                    case ControlPosition.Middle:
                        //control = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                        //control.Attributes.Add("class", "block-1");
                        break;
                }
                CurrentContainer = control;
            }
            else if (isFullWidth)
                CurrentContainer = null;
            else if (CurrentContainer != null)
                control = CurrentContainer;

            CurrentPosition = position;
            return control;
        }
Ejemplo n.º 30
0
 private System.Web.UI.HtmlControls.HtmlGenericControl GetContainer(ControlPosition position)
 {
     System.Web.UI.HtmlControls.HtmlGenericControl control = null;
     switch (position)
     {
         case ControlPosition.None:
                 control = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                 control.Attributes.Add("class", "block-2");
                 break;
         case ControlPosition.Left:
                 control = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                 control.Attributes.Add("class", "aside");
                 break;
         case ControlPosition.Right:
                 control = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                 control.Attributes.Add("class", "wrapper");
             break;
         case ControlPosition.Top:
             break;
         case ControlPosition.Middle:
             //control = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
             //control.Attributes.Add("class", "block-1");
             break;
     }
     return control;
 }
        private void Ctl_ValueChanged(object sender, EventArgs e)
        {
            if (_skipEvent) return;

            var ctl = (NumericUpDown) sender;
            var position = (ControlPosition) ctl.Tag;

            // ignore duplicate change value events of same control
            if (position.Equals(_eventPosition)) return;

            if (_eventPosition == null)
            {
                _eventPosition = position;
            }

            if (ctl.Value == -1)
            {
                if (position.Type == ControlType.Integer)
                {
                    if (position.Index > 0 &&
                        _controlsInteger.Take(position.Index)
                                        .Any(x => x.Value != 0))
                    {
                        ctl.Value = 9;
                        _controlsInteger[position.Index - 1].Value--;
                    }
                    else
                    {
                        ctl.Value = 0;
                    }
                }
                else
                {
                    if (position.Index == 0)
                    {
                        if (_controlsInteger.Any(x => x.Value != 0))
                        {
                            ctl.Value = 9;
                            _controlsInteger.Last().Value--;
                        }
                        else
                        {
                            ctl.Value = 0;
                        }
                    }
                    else
                    {
                        if (_controlsDivisional.Take(position.Index)
                                               .Any(x => x.Value != 0) ||
                            _controlsInteger.Any(x => x.Value != 0))
                        {
                            ctl.Value = 9;
                            _controlsDivisional[position.Index - 1].Value--;
                        }
                        else
                        {
                            ctl.Value = 0;
                        }
                    }
                }
            }
            else if (ctl.Value == 10)
            {
                ctl.Value = 0;

                if (position.Type == ControlType.Integer)
                {
                    if (position.Index > 0)
                    {
                        _controlsInteger[position.Index - 1].Value++;
                    }
                }
                else
                {
                    if (position.Index == 0)
                    {
                        _controlsInteger.Last().Value++;
                    }
                    else
                    {
                        _controlsDivisional[position.Index - 1].Value++;
                    }
                }
            }

            if (position.Equals(_eventPosition))
            {
                _eventPosition = null;

                if (CheckAndRevertValue()) return;

                var value = Value;
                _prevValue.SetValue(value);

                ValueChanged?.Invoke(this, value);
            }
        }
Ejemplo n.º 32
0
 public MapBuilder ZoomControlPosition(ControlPosition controlPosition)
 {
     this.Component.ZoomControlPosition = controlPosition;
     return(this);
 }
Ejemplo n.º 33
0
        // Determine the path between controls, and the drop targets.
        SymPath PathBetweenControls(ControlPosition controlPosition1, ControlPosition controlPosition2, ForkPosition forkStart, out List <DropTarget> dropTargets)
        {
            float xStart = controlPosition1.x;
            float yStart = controlPosition1.y;
            float xEnd   = controlPosition2.x;
            float yEnd   = controlPosition2.y;

            dropTargets = new List <DropTarget>();

            if (forkStart != null)
            {
                if (forkStart.loopFallThru)
                {
                    dropTargets.Add(new DropTarget(xEnd, yEnd - 0.5F, LegInsertionLoc.Normal));
                }
                else if (forkStart.loopStart)
                {
                    dropTargets.Add(new DropTarget(forkStart.x, forkStart.y - 0.5F, LegInsertionLoc.Normal));
                }
                else
                {
                    dropTargets.Add(new DropTarget(xStart, yStart + 0.5F, LegInsertionLoc.PreSplit));
                    dropTargets.Add(new DropTarget(forkStart.x, forkStart.y - 0.5F, LegInsertionLoc.Normal));
                    if (forkStart.x != xEnd)
                    {
                        // Empty fork.
                        dropTargets.Add(new DropTarget(xEnd, yEnd - 0.5F, LegInsertionLoc.PostJoin));
                    }
                }
            }
            else if (xEnd != xStart)
            {
                // Below start control (use when a join is going)
                dropTargets.Add(new DropTarget(xStart, yStart + 0.5F, LegInsertionLoc.Normal));
                if (yEnd > yStart)
                {
                    // Right before join point.
                    dropTargets.Add(new DropTarget(xEnd, yEnd - 0.5F, LegInsertionLoc.PostJoin));
                }
            }
            else if (yEnd > yStart + 1.25)
            {
                // Straight down, but must have join at end.
                dropTargets.Add(new DropTarget(xStart, yStart + 0.5F, LegInsertionLoc.Normal));
                dropTargets.Add(new DropTarget(xEnd, yEnd - 0.5F, LegInsertionLoc.PostJoin));
            }
            else
            {
                // Above end control (other cases).
                dropTargets.Add(new DropTarget(xEnd, yEnd - 0.5F, LegInsertionLoc.Normal));
            }

            bool startHorizontal = false;

            if (forkStart != null)
            {
                startHorizontal = forkStart.loopStart;
            }

            if (forkStart != null && forkStart.x != controlPosition2.x)
            {
                // The fork start in a different horizontal position than it ends. This is probably due to a fork with no controls on it.
                // Create the path in two pieces.
                float   xMiddle = forkStart.x;
                float   yMiddle = forkStart.y;
                SymPath path1   = PathFromStartToEnd(xStart, yStart, xMiddle, yMiddle, startHorizontal, 0);
                SymPath path3   = PathFromStartToEnd(xMiddle, yMiddle, xEnd, yEnd, false, controlPosition2.loopBottom);
                SymPath path2   = new SymPath(new[] { path1.LastPoint, path3.FirstPoint });
                return(SymPath.Join(SymPath.Join(path1, path2, PointKind.Normal), path3, PointKind.Normal));
            }
            else
            {
                return(PathFromStartToEnd(xStart, yStart, xEnd, yEnd, startHorizontal, controlPosition2.loopBottom));
            }
        }
Ejemplo n.º 34
0
 public async Task AddControl(ControlPosition position, ElementReference reference)
 {
     await _jsObjectRef.JSRuntime.MyInvokeAsync <object>("googleMapsObjectManager.addControls", this.Guid.ToString(), position, reference);
 }
Ejemplo n.º 35
0
 public LinkLabel(ControlPosition position, Index focusIndex, string text = "")
     : base(position, text)
 {
     FocusIndex = focusIndex;
 }
Ejemplo n.º 36
0
 public GoogleMapBuilder StreetViewControlPosition(ControlPosition controlPosition)
 {
     Component.StreetViewControlPosition = controlPosition;
     return(this);
 }
Ejemplo n.º 37
0
        // Assign positions/sizes from startIndex upto (not including) endIndex, starting at given position.
        // Return total size used.
        private SizeF AssignControlPositions(int startIndex, int endIndex, float startX, float startY)
        {
            int index = startIndex;
            float x = startX, y = startY;
            float totalWidth = 1, totalHeight = 0;   // Always at least a width of 1.
            while (index != endIndex) {
                int numForks = (controlViewsAllVariationsAndParts[index].legTo == null) ? 0 : controlViewsAllVariationsAndParts[index].legTo.Length;

                // Simple case, no splitting.
                controlPositions[index] = new ControlPosition() {
                    x = x,
                    y = y,
                };
                totalWidth = Math.Max(totalWidth, 1);
                totalHeight += 1;
                y += 1;

                if (numForks > 1) {
                    bool loop = (controlViewsAllVariationsAndParts[index].joinIndex == index);

                    // fork or loop subsequent. Two passes -- first determine totalWidth and maxHeight;
                    float totalForkWidth = 0, maxForkHeight = 1;
                    SizeF[] forkSize = new SizeF[numForks];
                    ForkPosition[] forkStart = new ForkPosition[numForks];

                    int startFork = 0;
                    if (loop) {
                        startFork = 1;
                        totalForkWidth = 1;
                    }

                    // Get size of each fork.
                    for (int i = startFork; i < numForks; ++i) {
                        forkSize[i] = AssignControlPositions(controlViewsAllVariationsAndParts[index].legTo[i], controlViewsAllVariationsAndParts[index].joinIndex, 0, 0);
                        totalForkWidth += forkSize[i].Width;
                        maxForkHeight = Math.Max(maxForkHeight, forkSize[i].Height);
                    }

                    // Get position of each fork.
                    if (loop) {
                        float forkY = y;
                        float forkX = x;
                        forkStart[0] = new ForkPosition(forkX, forkY, false, true, '\0');
                        int halfForks = (numForks + 1) / 2;

                        totalForkWidth = 0;

                        forkX = x - 0.5F;
                        for (int i = startFork; i < halfForks; ++i) {
                            forkX -= forkSize[i].Width;
                        }

                        totalForkWidth = Math.Max(totalForkWidth, (x-forkX) * 2);

                        for (int i = startFork; i < halfForks; ++i) {
                            forkX += forkSize[i].Width / 2;
                            forkStart[i] = new ForkPosition(forkX, forkY, loop, false, variationMap[controlViewsAllVariationsAndParts[index].courseControlIds[i]]);
                            forkX += forkSize[i].Width / 2;
                        }

                        forkX = x + 0.5F;

                        for (int i = halfForks; i < numForks; ++i) {
                            forkX += forkSize[i].Width / 2;
                            forkStart[i] = new ForkPosition(forkX, forkY, loop, false, variationMap[controlViewsAllVariationsAndParts[index].courseControlIds[i]]);
                            forkX += forkSize[i].Width / 2;
                        }

                        totalForkWidth = Math.Max(totalForkWidth, (forkX-x) * 2);

                        controlPositions[index].loopBottom = y + maxForkHeight - 0.5F;
                    }
                    else {
                        float forkY = y + 0.5F;
                        float forkX = x - totalForkWidth / 2;
                        for (int i = startFork; i < numForks; ++i) {
                            forkX += forkSize[i].Width / 2;
                            forkStart[i] = new ForkPosition(forkX, forkY, loop, false, variationMap[controlViewsAllVariationsAndParts[index].courseControlIds[i]]);
                            forkX += forkSize[i].Width / 2;
                        }
                    }

                    controlPositions[index].forkStart = forkStart;

                    // Assign control positions for each fork again, now that we know the start position.
                    for (int i = startFork; i < numForks; ++i) {
                        AssignControlPositions(controlViewsAllVariationsAndParts[index].legTo[i], controlViewsAllVariationsAndParts[index].joinIndex, forkStart[i].x, forkStart[i].y);
                    }

                    float height = maxForkHeight + 1;
                    totalHeight += height;
                    y += height;
                    totalWidth = Math.Max(totalWidth, totalForkWidth);

                    if (index == controlViewsAllVariationsAndParts[index].joinIndex)
                        index = controlViewsAllVariationsAndParts[index].legTo[0];
                    else
                        index = controlViewsAllVariationsAndParts[index].joinIndex;
                }
                else {
                    if (controlViewsAllVariationsAndParts[index].legTo != null && controlViewsAllVariationsAndParts[index].legTo.Length > 0)
                        index = controlViewsAllVariationsAndParts[index].legTo[0];
                    else
                        break; // no more controls.
                }
            }

            return new SizeF(totalWidth, totalHeight);
        }
Ejemplo n.º 38
0
 public LinkLabel(ControlPosition position, string text = "")
     : base(position, text)
 {
 }
Ejemplo n.º 39
0
        private void CreateControlNumber(CourseView.ControlView controlView, ControlPosition controlPosition)
        {
            Id<ControlPoint> controlId = controlView.controlId;
            Id<CourseControl> courseControlId = controlView.courseControlIds[0];
            ControlPoint control = eventDB.GetControl(controlId);
            PointF location = LocationFromAbstractPosition(controlPosition.x, controlPosition.y);

            CourseLayer layer;

            if (ControlViewInSpecificVariation(controlView))
                layer = courseLayerSpecificVariation;
            else
                layer = courseLayerAllVariationsAndParts;

            CourseObj courseObj;

            switch (control.kind) {
                case ControlPointKind.Start:
                case ControlPointKind.MapExchange:
                    // Triangle looks best if we displace it down a bit (0.8 looks right).
                    courseObj = new StartCourseObj(controlId, courseControlId, scaleRatio * 0.75F, appearance, 0, new PointF(location.X, location.Y - 0.8F), CrossHairOptions.NoCrossHair);
                    break;

                case ControlPointKind.Finish:
                    courseObj = new FinishCourseObj(controlId, courseControlId, scaleRatio * 0.75F, appearance, null, location, CrossHairOptions.NoCrossHair);
                    break;

                case ControlPointKind.Normal:
                    courseObj = new ControlNumberCourseObj(controlId, courseControlId, scaleRatio, appearance, control.code, location);
                    break;

                case ControlPointKind.CrossingPoint:
                    courseObj = new CrossingCourseObj(controlId, courseControlId, Id<Special>.None, scaleRatio * 1.5F, appearance, 0, location);
                    break;

                default:
                    Debug.Fail("bad control kind");
                    return;
            }

            courseObj.layer = layer;
            courseLayout.AddCourseObject(courseObj);
        }