Exemple #1
0
        private void DrawNumber(NumberWidget widget, int num)
        {
            var digits = widget.Width;

            var w = widget.Patches[0].Width;
            var h = widget.Patches[0].Height;
            var x = widget.X;

            var neg = num < 0;

            if (neg)
            {
                if (digits == 2 && num < -9)
                {
                    num = -9;
                }
                else if (digits == 3 && num < -99)
                {
                    num = -99;
                }

                num = -num;
            }

            x = widget.X - digits * w;

            if (num == 1994)
            {
                return;
            }

            x = widget.X;

            // In the special case of 0, you draw 0.
            if (num == 0)
            {
                this.screen.DrawPatch(widget.Patches[0], this.scale * (x - w), this.scale * widget.Y, this.scale);
            }

            // Draw the new number.
            while (num != 0 && digits-- != 0)
            {
                x -= w;

                this.screen.DrawPatch(widget.Patches[num % 10], this.scale * x, this.scale * widget.Y, this.scale);

                num /= 10;
            }

            // Draw a minus sign if necessary.
            if (neg)
            {
                this.screen.DrawPatch(this.patches.TallMinus, this.scale * (x - 8), this.scale * widget.Y, this.scale);
            }
        }
Exemple #2
0
        public ActionResult NumberOfAssignedTickets()
        {
            string userId = User.Identity.GetUserId();
            int    number = DbContext.Tickets.Where(t => t.AssignedToUserID == userId &&
                                                    t.Project.Archived == false).Count();

            var model = new NumberWidget {
                Number = number
            };

            return(PartialView(model));
        }
Exemple #3
0
        public ActionResult NumberOfAssignedProjects()
        {
            string userId = User.Identity.GetUserId();
            var    user   = DbContext.Users.FirstOrDefault(u => u.Id == userId);
            var    number = user.Projects.Where(p => p.Archived == false).Count();

            var model = new NumberWidget {
                Number = number
            };

            return(PartialView(model));
        }
Exemple #4
0
        public StatusBarRenderer(DrawScreen screen)
        {
            this.screen = screen;

            this.patches = new Patches();

            this.scale = screen.Width / 320;

            this.ready         = new NumberWidget();
            this.ready.Patches = this.patches.TallNumbers;
            this.ready.Width   = StatusBarRenderer.ammoWidth;
            this.ready.X       = StatusBarRenderer.ammoX;
            this.ready.Y       = StatusBarRenderer.ammoY;

            this.health = new PercentWidget();
            this.health.NumberWidget.Patches = this.patches.TallNumbers;
            this.health.NumberWidget.Width   = 3;
            this.health.NumberWidget.X       = StatusBarRenderer.healthX;
            this.health.NumberWidget.Y       = StatusBarRenderer.healthY;
            this.health.Patch = this.patches.TallPercent;

            this.armor = new PercentWidget();
            this.armor.NumberWidget.Patches = this.patches.TallNumbers;
            this.armor.NumberWidget.Width   = 3;
            this.armor.NumberWidget.X       = StatusBarRenderer.armorX;
            this.armor.NumberWidget.Y       = StatusBarRenderer.armorY;
            this.armor.Patch = this.patches.TallPercent;

            this.ammo            = new NumberWidget[4];
            this.ammo[0]         = new NumberWidget();
            this.ammo[0].Patches = this.patches.ShortNumbers;
            this.ammo[0].Width   = StatusBarRenderer.ammo0Width;
            this.ammo[0].X       = StatusBarRenderer.ammo0X;
            this.ammo[0].Y       = StatusBarRenderer.ammo0Y;
            this.ammo[1]         = new NumberWidget();
            this.ammo[1].Patches = this.patches.ShortNumbers;
            this.ammo[1].Width   = StatusBarRenderer.ammo1Width;
            this.ammo[1].X       = StatusBarRenderer.ammo1X;
            this.ammo[1].Y       = StatusBarRenderer.ammo1Y;
            this.ammo[2]         = new NumberWidget();
            this.ammo[2].Patches = this.patches.ShortNumbers;
            this.ammo[2].Width   = StatusBarRenderer.ammo2Width;
            this.ammo[2].X       = StatusBarRenderer.ammo2X;
            this.ammo[2].Y       = StatusBarRenderer.ammo2Y;
            this.ammo[3]         = new NumberWidget();
            this.ammo[3].Patches = this.patches.ShortNumbers;
            this.ammo[3].Width   = StatusBarRenderer.ammo3Wdth;
            this.ammo[3].X       = StatusBarRenderer.ammo3X;
            this.ammo[3].Y       = StatusBarRenderer.ammo3Y;

            this.maxAmmo            = new NumberWidget[4];
            this.maxAmmo[0]         = new NumberWidget();
            this.maxAmmo[0].Patches = this.patches.ShortNumbers;
            this.maxAmmo[0].Width   = StatusBarRenderer.maxAmmo0Width;
            this.maxAmmo[0].X       = StatusBarRenderer.maxAmmo0X;
            this.maxAmmo[0].Y       = StatusBarRenderer.maxAmmo0Y;
            this.maxAmmo[1]         = new NumberWidget();
            this.maxAmmo[1].Patches = this.patches.ShortNumbers;
            this.maxAmmo[1].Width   = StatusBarRenderer.maxAmmo1Width;
            this.maxAmmo[1].X       = StatusBarRenderer.maxAmmo1X;
            this.maxAmmo[1].Y       = StatusBarRenderer.maxAmmo1Y;
            this.maxAmmo[2]         = new NumberWidget();
            this.maxAmmo[2].Patches = this.patches.ShortNumbers;
            this.maxAmmo[2].Width   = StatusBarRenderer.maxAmmo2Width;
            this.maxAmmo[2].X       = StatusBarRenderer.maxAmmo2X;
            this.maxAmmo[2].Y       = StatusBarRenderer.maxAmmo2Y;
            this.maxAmmo[3]         = new NumberWidget();
            this.maxAmmo[3].Patches = this.patches.ShortNumbers;
            this.maxAmmo[3].Width   = StatusBarRenderer.maxAmmo3Width;
            this.maxAmmo[3].X       = StatusBarRenderer.maxAmmo3X;
            this.maxAmmo[3].Y       = StatusBarRenderer.maxAmmo3Y;

            this.weapons = new MultIconWidget[6];

            for (var i = 0; i < this.weapons.Length; i++)
            {
                this.weapons[i]         = new MultIconWidget();
                this.weapons[i].X       = StatusBarRenderer.armsX + (i % 3) * StatusBarRenderer.armsSpaceX;
                this.weapons[i].Y       = StatusBarRenderer.armsY + (i / 3) * StatusBarRenderer.armsSpaceY;
                this.weapons[i].Patches = this.patches.Arms[i];
            }

            this.frags         = new NumberWidget();
            this.frags.Patches = this.patches.TallNumbers;
            this.frags.Width   = StatusBarRenderer.fragsWidth;
            this.frags.X       = StatusBarRenderer.fragsX;
            this.frags.Y       = StatusBarRenderer.fragsY;

            this.keys            = new MultIconWidget[3];
            this.keys[0]         = new MultIconWidget();
            this.keys[0].X       = StatusBarRenderer.key0X;
            this.keys[0].Y       = StatusBarRenderer.key0Y;
            this.keys[0].Patches = this.patches.Keys;
            this.keys[1]         = new MultIconWidget();
            this.keys[1].X       = StatusBarRenderer.key1X;
            this.keys[1].Y       = StatusBarRenderer.key1Y;
            this.keys[1].Patches = this.patches.Keys;
            this.keys[2]         = new MultIconWidget();
            this.keys[2].X       = StatusBarRenderer.key2X;
            this.keys[2].Y       = StatusBarRenderer.key2Y;
            this.keys[2].Patches = this.patches.Keys;
        }
Exemple #5
0
        public StatusBarRenderer(Wad wad, DrawScreen screen)
        {
            this.screen = screen;

            patches = new Patches(wad);

            scale = screen.Width / 320;

            ready         = new NumberWidget();
            ready.Patches = patches.TallNumbers;
            ready.Width   = ammoWidth;
            ready.X       = ammoX;
            ready.Y       = ammoY;

            health = new PercentWidget();
            health.NumberWidget.Patches = patches.TallNumbers;
            health.NumberWidget.Width   = 3;
            health.NumberWidget.X       = healthX;
            health.NumberWidget.Y       = healthY;
            health.Patch = patches.TallPercent;

            armor = new PercentWidget();
            armor.NumberWidget.Patches = patches.TallNumbers;
            armor.NumberWidget.Width   = 3;
            armor.NumberWidget.X       = armorX;
            armor.NumberWidget.Y       = armorY;
            armor.Patch = patches.TallPercent;

            ammo            = new NumberWidget[(int)AmmoType.Count];
            ammo[0]         = new NumberWidget();
            ammo[0].Patches = patches.ShortNumbers;
            ammo[0].Width   = ammo0Width;
            ammo[0].X       = ammo0X;
            ammo[0].Y       = ammo0Y;
            ammo[1]         = new NumberWidget();
            ammo[1].Patches = patches.ShortNumbers;
            ammo[1].Width   = ammo1Width;
            ammo[1].X       = ammo1X;
            ammo[1].Y       = ammo1Y;
            ammo[2]         = new NumberWidget();
            ammo[2].Patches = patches.ShortNumbers;
            ammo[2].Width   = ammo2Width;
            ammo[2].X       = ammo2X;
            ammo[2].Y       = ammo2Y;
            ammo[3]         = new NumberWidget();
            ammo[3].Patches = patches.ShortNumbers;
            ammo[3].Width   = ammo3Wdth;
            ammo[3].X       = ammo3X;
            ammo[3].Y       = ammo3Y;

            maxAmmo            = new NumberWidget[(int)AmmoType.Count];
            maxAmmo[0]         = new NumberWidget();
            maxAmmo[0].Patches = patches.ShortNumbers;
            maxAmmo[0].Width   = maxAmmo0Width;
            maxAmmo[0].X       = maxAmmo0X;
            maxAmmo[0].Y       = maxAmmo0Y;
            maxAmmo[1]         = new NumberWidget();
            maxAmmo[1].Patches = patches.ShortNumbers;
            maxAmmo[1].Width   = maxAmmo1Width;
            maxAmmo[1].X       = maxAmmo1X;
            maxAmmo[1].Y       = maxAmmo1Y;
            maxAmmo[2]         = new NumberWidget();
            maxAmmo[2].Patches = patches.ShortNumbers;
            maxAmmo[2].Width   = maxAmmo2Width;
            maxAmmo[2].X       = maxAmmo2X;
            maxAmmo[2].Y       = maxAmmo2Y;
            maxAmmo[3]         = new NumberWidget();
            maxAmmo[3].Patches = patches.ShortNumbers;
            maxAmmo[3].Width   = maxAmmo3Width;
            maxAmmo[3].X       = maxAmmo3X;
            maxAmmo[3].Y       = maxAmmo3Y;

            weapons = new MultIconWidget[6];
            for (var i = 0; i < weapons.Length; i++)
            {
                weapons[i]         = new MultIconWidget();
                weapons[i].X       = armsX + (i % 3) * armsSpaceX;
                weapons[i].Y       = armsY + (i / 3) * armsSpaceY;
                weapons[i].Patches = patches.Arms[i];
            }

            frags         = new NumberWidget();
            frags.Patches = patches.TallNumbers;
            frags.Width   = fragsWidth;
            frags.X       = fragsX;
            frags.Y       = fragsY;

            keys            = new MultIconWidget[3];
            keys[0]         = new MultIconWidget();
            keys[0].X       = key0X;
            keys[0].Y       = key0Y;
            keys[0].Patches = patches.Keys;
            keys[1]         = new MultIconWidget();
            keys[1].X       = key1X;
            keys[1].Y       = key1Y;
            keys[1].Patches = patches.Keys;
            keys[2]         = new MultIconWidget();
            keys[2].X       = key2X;
            keys[2].Y       = key2Y;
            keys[2].Patches = patches.Keys;
        }
Exemple #6
0
        private void InitializeData()
        {
            ContentPanel.Controls.Clear();

            var entity = Action.Entity;

            var rowCount = 1;
            var colCount = 0;

            var fields = Action.EntityAction?.Fields ?? Enumerable.Empty <Field>();

            foreach (var field in fields)
            {
                IInputWidget widget;

                int colExtent;

                if (field.Rel.Has(RelNames.Self) && Action.Selection != null)
                {
                    colExtent      = 0;
                    widget         = new HiddenWidget();
                    widget.Content = Action.Selection;
                }
                else if (field.Type == FieldTypeNames.Hidden)
                {
                    colExtent = 0;
                    widget    = new HiddenWidget();
                }
                else
                {
                    switch (field.DataType)
                    {
                    //case DataTypeNames.Bit:
                    //case DataTypeNames.Decimal:
                    //case DataTypeNames.Date:
                    //case DataTypeNames.Time:
                    //case DataTypeNames.Datetime:

                    case DataTypeNames.Number:
                    {
                        colExtent = 1;
                        widget    = new NumberWidget();
                        break;
                    }

                    case DataTypeNames.Label:
                    case DataTypeNames.Text:
                    default:
                    {
                        colExtent = 3;
                        widget    = new TextWidget();
                        break;
                    }
                    }
                }

                widget.Field      = field;
                widget.Text       = field.Title;
                widget.Content    = field.Value;
                widget.Required   = (field.Required == true);
                widget.Host.Width = (88 * colExtent) - 6;

                ContentPanel.Controls.Add(widget.Host);

                if (colCount + colExtent <= 3)
                {
                    colCount += colExtent;
                }
                else
                {
                    rowCount++;
                    colCount = colExtent;
                }
            }

            // c = ⌈x / 10⌉
            // r = ⌈x / c⌉
            var margin = this.Padding.All;
            var cols   = Math.Ceiling(rowCount / 10M);
            var rows   = Math.Ceiling(rowCount / cols);
            var w      = ((3 * 88) * cols) + (margin * 2);
            var h      = (42 * rows) + (margin * 2) + pnActions.Height;

            //this.MinimumSize = new Size((int)w, (int)h);
            this.ClientSize = new Size((int)w, (int)h);
        }
        private void DrawNumber(NumberWidget widget, int num)
        {
            var numdigits = widget.Width;

            var w = widget.Patches[0].Width;
            var h = widget.Patches[0].Height;
            var x = widget.X;

            var neg = num < 0;

            if (neg)
            {
                if (numdigits == 2 && num < -9)
                {
                    num = -9;
                }
                else if (numdigits == 3 && num < -99)
                {
                    num = -99;
                }

                num = -num;
            }

            // clear the area
            x = widget.X - numdigits * w;

            /*
             * if (n.Y - ST_Y < 0)
             * {
             *  throw new Exception("drawNum: n->y - ST_Y < 0");
             * }
             */

            //V_CopyRect(x, n->y - ST_Y, BG, w * numdigits, h, x, n->y, FG);

            // if non-number, do not draw it
            if (num == 1994)
            {
                return;
            }

            x = widget.X;

            // in the special case of 0, you draw 0
            if (num == 0)
            {
                screen.DrawPatch(widget.Patches[0], scale * (x - w), scale * widget.Y, scale);
            }

            // draw the new number
            while (num != 0 && numdigits-- != 0)
            {
                x -= w;
                screen.DrawPatch(widget.Patches[num % 10], scale * x, scale * widget.Y, scale);
                num /= 10;
            }

            // draw a minus sign if necessary
            if (neg)
            {
                screen.DrawPatch(patches.TallMinus, scale * (x - 8), scale * widget.Y, scale);
            }
        }
        public StatusBarRenderer(Wad wad, DrawScreen screen)
        {
            this.screen = screen;

            patches = new Patches(wad);

            scale = screen.Width / 320;

            wReady         = new NumberWidget();
            wReady.Patches = patches.TallNumbers;
            wReady.Width   = ST_AMMOWIDTH;
            wReady.X       = ST_AMMOX;
            wReady.Y       = ST_AMMOY;

            wHealth = new PercentWidget();
            wHealth.NumberWidget.Patches = patches.TallNumbers;
            wHealth.NumberWidget.Width   = 3;
            wHealth.NumberWidget.X       = ST_HEALTHX;
            wHealth.NumberWidget.Y       = ST_HEALTHY;
            wHealth.Patch = patches.TallPercent;

            wArmor = new PercentWidget();
            wArmor.NumberWidget.Patches = patches.TallNumbers;
            wArmor.NumberWidget.Width   = 3;
            wArmor.NumberWidget.X       = ST_ARMORX;
            wArmor.NumberWidget.Y       = ST_ARMORY;
            wArmor.Patch = patches.TallPercent;

            wAmmo    = new NumberWidget[(int)AmmoType.Count];
            wMaxAmmo = new NumberWidget[(int)AmmoType.Count];

            wAmmo[0]         = new NumberWidget();
            wAmmo[0].Patches = patches.ShortNumbers;
            wAmmo[0].Width   = ST_AMMO0WIDTH;
            wAmmo[0].X       = ST_AMMO0X;
            wAmmo[0].Y       = ST_AMMO0Y;

            wAmmo[1]         = new NumberWidget();
            wAmmo[1].Patches = patches.ShortNumbers;
            wAmmo[1].Width   = ST_AMMO1WIDTH;
            wAmmo[1].X       = ST_AMMO1X;
            wAmmo[1].Y       = ST_AMMO1Y;

            wAmmo[2]         = new NumberWidget();
            wAmmo[2].Patches = patches.ShortNumbers;
            wAmmo[2].Width   = ST_AMMO2WIDTH;
            wAmmo[2].X       = ST_AMMO2X;
            wAmmo[2].Y       = ST_AMMO2Y;

            wAmmo[3]         = new NumberWidget();
            wAmmo[3].Patches = patches.ShortNumbers;
            wAmmo[3].Width   = ST_AMMO3WIDTH;
            wAmmo[3].X       = ST_AMMO3X;
            wAmmo[3].Y       = ST_AMMO3Y;

            wMaxAmmo[0]         = new NumberWidget();
            wMaxAmmo[0].Patches = patches.ShortNumbers;
            wMaxAmmo[0].Width   = ST_MAXAMMO0WIDTH;
            wMaxAmmo[0].X       = ST_MAXAMMO0X;
            wMaxAmmo[0].Y       = ST_MAXAMMO0Y;

            wMaxAmmo[1]         = new NumberWidget();
            wMaxAmmo[1].Patches = patches.ShortNumbers;
            wMaxAmmo[1].Width   = ST_MAXAMMO1WIDTH;
            wMaxAmmo[1].X       = ST_MAXAMMO1X;
            wMaxAmmo[1].Y       = ST_MAXAMMO1Y;

            wMaxAmmo[2]         = new NumberWidget();
            wMaxAmmo[2].Patches = patches.ShortNumbers;
            wMaxAmmo[2].Width   = ST_MAXAMMO2WIDTH;
            wMaxAmmo[2].X       = ST_MAXAMMO2X;
            wMaxAmmo[2].Y       = ST_MAXAMMO2Y;

            wMaxAmmo[3]         = new NumberWidget();
            wMaxAmmo[3].Patches = patches.ShortNumbers;
            wMaxAmmo[3].Width   = ST_MAXAMMO3WIDTH;
            wMaxAmmo[3].X       = ST_MAXAMMO3X;
            wMaxAmmo[3].Y       = ST_MAXAMMO3Y;

            // weapons owned
            wArms = new MultIconWidget[6];
            for (var i = 0; i < wArms.Length; i++)
            {
                wArms[i]         = new MultIconWidget();
                wArms[i].X       = ST_ARMSX + (i % 3) * ST_ARMSXSPACE;
                wArms[i].Y       = ST_ARMSY + (i / 3) * ST_ARMSYSPACE;
                wArms[i].Patches = patches.Arms[i];
            }

            wFrags         = new NumberWidget();
            wFrags.Patches = patches.TallNumbers;
            wFrags.Width   = ST_FRAGSWIDTH;
            wFrags.X       = ST_FRAGSX;
            wFrags.Y       = ST_FRAGSY;
        }