示例#1
0
        private XElement CreateCell(int x, int y, GridState grid)
        {
            IconPosition test = new IconPosition()
            {
                XCoord = x, YCoord = y
            };
            Icon     icon = grid.Cells.Where(ip => ip.PositionEquals(test)).FirstOrDefault()?.Icon;
            XElement div;

            if (icon != null)
            {
                XAttribute styleAttribute = new XAttribute("style",
                                                           string.Format(GRID_STYLE_FORMAT, icon.Id, icon.Image,
                                                                         icon.DateChanged.ToString().Replace(" ", ""))
                                                           );
                XAttribute ondblclickAttribute = new XAttribute("ondblclick",
                                                                string.Format(ON_DBLCLICK_FORMAT, icon.Link)
                                                                );
                div = new XElement("div", CELL_CLASS_ATTRIBUTE, ON_CLICK_FORMAT,
                                   styleAttribute, ondblclickAttribute);
            }
            else
            {
                div = new XElement("div");
            }
            return(div);
        }
示例#2
0
        private IEnumerable <IconPosition> BuildIconsToBeInactive(GridState newGrid, GridState oldGrid)
        {
            List <IconPosition> toBeInactive = new List <IconPosition>();

            foreach (IconPosition oldIcon in oldGrid.Cells)
            {
                // inactive if out of bounds
                if (oldIcon.XCoord >= newGrid.Size.Width)
                {
                    toBeInactive.Add(oldIcon);
                    continue;
                }
                if (oldIcon.YCoord >= newGrid.Size.Height)
                {
                    toBeInactive.Add(oldIcon);
                    continue;
                }
                // inactive if removed
                IEnumerable <IconPosition> newPositionMatches =
                    newGrid.Cells.Where(findNewIcon => oldIcon.PositionEquals(findNewIcon));
                if (newPositionMatches.NotAny())
                {
                    toBeInactive.Add(oldIcon);
                    continue;
                }
                // inactive if changed
                IconPosition newIcon = newPositionMatches.Single();
                if (oldIcon.Icon.Id != newIcon.Icon.Id)
                {
                    toBeInactive.Add(oldIcon);
                    continue;
                }
            }
            return(toBeInactive);
        }
示例#3
0
 private void setSizeIcon(Size value)
 {
     if (icoPos != IconPosition.OnlyText && value != icoSize && value.Width >= 0 && value.Height >= 0)
     {
         if (lnLayout == LinePosition.Buttom || lnLayout == LinePosition.Top)
         {
             if (value.Height + lnSize <= this.Height && value.Width + iconAln <= this.Width)
             {
                 icoSize = value;
             }
         }
         else if (lnLayout == LinePosition.Left || lnLayout == LinePosition.Right)
         {
             if (value.Width + lnSize + iconAln <= this.Width && value.Height <= this.Height)
             {
                 icoSize = value;
             }
         }
         else
         {
             if (value.Width + iconAln <= this.Width && value.Height <= this.Height)
             {
                 icoSize = value;
             }
         }
         if (icoSize.Height == 0 || IconSize.Width == 0)
         {
             icoPos = IconPosition.OnlyText;
         }
     }
 }
 public void ValidateIconPosition(IconPosition icon, GridSize size) {
     if (icon.XCoord < 0)
         throw new PortalException(GridResult.FAIL_ICON_BOUNDS, "X coord must be at least 0.");
     if (icon.YCoord < 0)
         throw new PortalException(GridResult.FAIL_ICON_BOUNDS, "Y coord must be at least 0.");
     if (icon.XCoord > size.Width - 1)
         throw new PortalException(GridResult.FAIL_ICON_BOUNDS, string.Format("Maximum X coord is {0}.", size.Width));
     if (icon.YCoord > size.Height - 1)
         throw new PortalException(GridResult.FAIL_ICON_BOUNDS, string.Format("Maximum Y coord is {0}.", size.Height));
 }
示例#5
0
        protected override void Execute(bool isRedo)
        {
            oldIconPosition = Node.IconPosition;

            Node.ChangeIconPosition(newIconPosition);

            if (isRedo)
            {
                Node.Select();
            }
        }
示例#6
0
        public static void ChangeIconPositionTransactional(this NodeBase node, IconPosition iconPosition)
        {
            if (node.Document != null && !Equals(node.IconPosition, iconPosition))
            {
                var transactionName = LocalizationManager.GetString("TransactionName_ChangeIconPosition");

                node.Document.MakeTransaction(transactionName, commands =>
                {
                    commands.Apply(new ChangeIconPositionCommand(node, iconPosition));
                });
            }
        }
示例#7
0
        public object ToJsObject()
        {
            var jObj = this.ToDynamic();

            if (!Script.IsNaN(Classes))
            {
                jObj.classes = Classes.ToJsDynamic();
            }
            if (!Script.IsNaN(IconPosition))
            {
                jObj.iconPosition = IconPosition.ToString();
            }
            return(jObj);
        }
示例#8
0
        private void initializeIcons()
        {
            images = new RawImage[maxNumIcons];
            if (startLocation == StartLocation.LEFT)
            {
                iconPositionFormula += iconPosFromLeft;
            }
            else
            {
                iconPositionFormula += iconPosFromRight;
            }

            for (int i = 0; i < maxNumIcons; i++)
            {
                images[i] = Instantiate(movesLeftIcon, transform);
                Vector3 newPosition = new Vector3(iconPositionFormula(i), 0, 0);
                images[i].rectTransform.localPosition = newPosition;
            }
        }
示例#9
0
        public ChangeIconPositionCommand(PropertiesBag properties, Document document)
            : base(properties, document)
        {
            IconPosition value;

            int intValue;

            if (properties.TryParseEnum(PropertyIconPosition, out value))
            {
                newIconPosition = value;
            }
            else if (properties.TryParseInt32(PropertyIconPosition, out intValue) && Enum.IsDefined(typeof(NodeSide), intValue))
            {
                newIconPosition = (IconPosition)intValue;
            }
            else
            {
                newIconPosition = IconPosition.Left;
            }
        }
示例#10
0
        public void HorizontalCenterElements(ButtonBase btn, Viewbox symbolView, ContentPresenter contentPresenter, IconPosition iconPos, double iconInterval)
        {
            if (symbolView == null || contentPresenter == null)
                return;

            switch (iconPos)
            {
                case IconPosition.Left:
                    symbolView.Margin = new Thickness(CalculateMarginWidth(btn, symbolView, contentPresenter, iconInterval), 0, 0, 0);
                    break;
                case IconPosition.Right:
                    symbolView.Margin = new Thickness(0, 0, CalculateMarginWidth(btn, symbolView, contentPresenter, iconInterval), 0);
                    break;
                case IconPosition.Top:
                    symbolView.Margin = new Thickness(0, CalculateMarginHeight(btn, symbolView, contentPresenter, iconInterval), 0, 0);
                    break;
                case IconPosition.Bottom:
                    symbolView.Margin = new Thickness(0, 0, 0, CalculateMarginHeight(btn, symbolView, contentPresenter, iconInterval));
                    break;
            }
        }
示例#11
0
 public ClassicIndicator(
     int mode,
     string releaseText    = null,
     string idleText       = null,
     string refreshingText = null,
     string completeText   = null,
     string failedText     = null,
     string noDataText     = null,
     Widget releaseIcon    = null,
     Widget idleIcon       = null,
     Widget noMoreIcon     = null,
     Widget refreshingIcon = null,
     Widget completeIcon   = null,
     Widget failedIcon     = null,
     float height          = 60,
     float spacing         = 15,
     IconPosition iconPos  = IconPosition.left,
     TextStyle textStyle   = null,
     Key key = null
     ) : base(mode, key)
 {
     this.releaseText    = releaseText ?? "";
     this.idleText       = idleText ?? "";
     this.refreshingText = refreshingText ?? "";
     this.completeText   = completeText ?? "";
     this.failedText     = failedText ?? "";
     this.noDataText     = noDataText ?? "";
     this.releaseIcon    = releaseIcon ?? new CustomActivityIndicator(animating: AnimatingType.reset);
     this.idleIcon       = idleIcon ?? new Icon(new IconData(1, "23"));
     this.noMoreIcon     = noMoreIcon ?? new Icon(Icons.close, color: CColors.Grey);
     this.refreshingIcon = refreshingIcon ?? new CustomActivityIndicator();
     this.completeIcon   = completeIcon ?? new CustomActivityIndicator(animating: AnimatingType.stop);
     this.failedIcon     = failedIcon ?? new Icon(Icons.close, color: CColors.Grey);
     this.height         = height;
     this.spacing        = spacing;
     this.iconPos        = iconPos;
     this.textStyle      = textStyle;
 }
示例#12
0
 public static void SetIconPosition(RepeatButton repeatButton, IconPosition value)
 {
     repeatButton.SetValue(IconPositionProperty, value);
 }
示例#13
0
        private void Flat_Button_Paint(object sender, PaintEventArgs e)
        {
            if (ico == null)
            {
                icoPos = IconPosition.OnlyText;
            }
            switch (lnLayout)
            {
            case LinePosition.Buttom:
                //vẽ line
                e.Graphics.FillRectangle(new SolidBrush(lnClr), new Rectangle(0, this.Height - lnSize, this.Width, lnSize));
                switch (icoPos)
                {
                case IconPosition.OnlyIcon:
                    e.Graphics.DrawImage(ico, new Rectangle(iconAln, (this.Height - lnSize - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    break;

                case IconPosition.OnlyText:
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(this.ForeColor),
                                              new RectangleF(0, 0, this.Width, this.Height - lnSize), strFM);
                    }
                    break;

                case IconPosition.LeftOfText:
                    e.Graphics.DrawImage(ico, new Rectangle(iconAln, (this.Height - lnSize - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr), new RectangleF(iconAln + icoSize.Width,
                                                                                                      0, this.Width - iconAln - icoSize.Width, this.Height - lnSize), strFM);
                    }
                    break;

                case IconPosition.RightOfText:
                    e.Graphics.DrawImage(ico, new Rectangle(this.Width - iconAln - icoSize.Width, (this.Height - lnSize - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr), new RectangleF(0, 0, this.Width - iconAln - icoSize.Width,
                                                                                                      this.Height - lnSize), strFM);
                    }
                    break;
                }
                break;

            case LinePosition.Top:
                e.Graphics.FillRectangle(new SolidBrush(lnClr), new Rectangle(0, 0, this.Width, lnSize));
                switch (icoPos)
                {
                case IconPosition.OnlyIcon:
                    e.Graphics.DrawImage(ico, new Rectangle(iconAln, (this.Height - lnSize - icoSize.Height) / 2 + lnSize, icoSize.Width, icoSize.Height));
                    break;

                case IconPosition.OnlyText:
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr),
                                              new RectangleF(0, lnSize, this.Width, this.Height - lnSize), strFM);
                    }
                    break;

                case IconPosition.LeftOfText:
                    e.Graphics.DrawImage(ico, new Rectangle(iconAln, (this.Height - lnSize - icoSize.Height) / 2 + lnSize, icoSize.Width, icoSize.Height));
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr), new RectangleF(iconAln + icoSize.Width,
                                                                                                      lnSize, this.Width - iconAln - icoSize.Width, this.Height - lnSize), strFM);
                    }
                    break;

                case IconPosition.RightOfText:
                    e.Graphics.DrawImage(ico, new Rectangle(this.Width - iconAln - icoSize.Width, (this.Height - lnSize - icoSize.Height) / 2 + lnSize, icoSize.Width, icoSize.Height));
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr), new RectangleF(0, lnSize, this.Width - iconAln - icoSize.Width,
                                                                                                      this.Height - lnSize), strFM);
                    }
                    break;
                }
                break;

            case LinePosition.Left:
                e.Graphics.FillRectangle(new SolidBrush(lnClr), new Rectangle(0, 0, lnSize, this.Height));
                switch (icoPos)
                {
                case IconPosition.OnlyIcon:
                    e.Graphics.DrawImage(ico, new Rectangle(iconAln + lnSize, (this.Height - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    break;

                case IconPosition.OnlyText:
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr),
                                              new RectangleF(lnSize, 0, this.Width - lnSize, this.Height), strFM);
                    }
                    break;

                case IconPosition.LeftOfText:
                    e.Graphics.DrawImage(ico, new Rectangle(iconAln + lnSize, (this.Height - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr), new RectangleF(iconAln + icoSize.Width + lnSize,
                                                                                                      0, this.Width - iconAln - icoSize.Width - lnSize, this.Height), strFM);
                    }
                    break;

                case IconPosition.RightOfText:
                    e.Graphics.DrawImage(ico, new Rectangle(this.Width - iconAln - icoSize.Width, (this.Height - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr), new RectangleF(lnSize, 0, this.Width - iconAln - icoSize.Width - lnSize,
                                                                                                      this.Height), strFM);
                    }
                    break;
                }
                break;

            case LinePosition.Right:
                e.Graphics.FillRectangle(new SolidBrush(lnClr), new Rectangle(this.Width - lnSize, 0, lnSize, this.Height));
                switch (icoPos)
                {
                case IconPosition.OnlyIcon:
                    e.Graphics.DrawImage(ico, new Rectangle(iconAln, (this.Height - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    break;

                case IconPosition.OnlyText:
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr),
                                              new RectangleF(0, 0, this.Width - lnSize, this.Height), strFM);
                    }
                    break;

                case IconPosition.LeftOfText:
                    e.Graphics.DrawImage(ico, new Rectangle(iconAln, (this.Height - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr), new RectangleF(iconAln + icoSize.Width,
                                                                                                      0, this.Width - iconAln - icoSize.Width - lnSize, this.Height), strFM);
                    }
                    break;

                case IconPosition.RightOfText:
                    e.Graphics.DrawImage(ico, new Rectangle(this.Width - iconAln - icoSize.Width - lnSize, (this.Height - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr), new RectangleF(0, 0, this.Width - iconAln - icoSize.Width - lnSize,
                                                                                                      this.Height), strFM);
                    }
                    break;
                }
                break;

            case LinePosition.None:
                switch (icoPos)
                {
                case IconPosition.OnlyIcon:
                    e.Graphics.DrawImage(ico, new Rectangle(iconAln, (this.Height - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    break;

                case IconPosition.OnlyText:
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr),
                                              new RectangleF(0, 0, this.Width, this.Height), strFM);
                    }
                    break;

                case IconPosition.LeftOfText:
                    e.Graphics.DrawImage(ico, new Rectangle(iconAln, (this.Height - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr), new RectangleF(iconAln + icoSize.Width,
                                                                                                      0, this.Width - iconAln - icoSize.Width, this.Height), strFM);
                    }
                    break;

                case IconPosition.RightOfText:
                    e.Graphics.DrawImage(ico, new Rectangle(this.Width - iconAln - icoSize.Width, (this.Height - icoSize.Height) / 2, icoSize.Width, icoSize.Height));
                    using (StringFormat strFM = new StringFormat())
                    {
                        strFM.Alignment     = txtAlnHor;
                        strFM.LineAlignment = txtAlnVer;
                        e.Graphics.DrawString(text, this.Font, new SolidBrush(txtClr), new RectangleF(0, 0, this.Width - iconAln - icoSize.Width,
                                                                                                      this.Height), strFM);
                    }
                    break;
                }
                break;
            }
        }
示例#14
0
 public void ChangeIconPosition(IconPosition newIconPosition)
 {
     IconPosition = newIconPosition;
 }
示例#15
0
            private string Strip(SkinControl skin, int offset, string text)
            {
                string result = "";
                bool linkStarted = false;
                foreach (string word in text.Split(' '))
                {
                    if (_iconDict.ContainsKey(word))
                    {
                        Vector2 tmp = skin.Layers[0].Text.Font.Resource.MeasureString(result);

                        IconPosition pos = new IconPosition();                       
                        pos.Location = new Vector2(13 + tmp.X, offset);
                        pos.IconName = word;
                        Icons.Add(pos);

                        result += "--- "; 
                    }
                    else if (linkStarted && word != "[/link]")
                    {
                        Links.Last().Link += word + " ";
                        result += word + " ";
                    }
                    else if(word.StartsWith("[link="))
                    {
                        Vector2 tmp = skin.Layers[0].Text.Font.Resource.MeasureString(result);

                        LinkPosition link = new LinkPosition();
                        link.Link = "";
                        link.Target = word.Replace("[link=", "").Replace("]", "");                        
                        link.Location = new Vector2(13 + tmp.X, offset);
                        Links.Add(link);

                        linkStarted = true;
                    }
                    else if (word == "[/link]")
                    {
                        // do nothing
                        linkStarted = false;

                        // update link width
                    }
                    else
                        result += word + " ";
                }

                return result.Trim();
            }
示例#16
0
 public static void SetIconPosition(Button button, IconPosition value)
 {
     button.SetValue(IconPositionProperty, value);
 }
示例#17
0
        public void HorizontalCenterElements(ButtonBase btn, Viewbox symbolView, ContentPresenter contentPresenter, IconPosition iconPos, double iconInterval)
        {
            if (symbolView == null || contentPresenter == null)
            {
                return;
            }

            switch (iconPos)
            {
            case IconPosition.Left:
                symbolView.Margin = new Thickness(CalculateMarginWidth(btn, symbolView, contentPresenter, iconInterval), 0, 0, 0);
                break;

            case IconPosition.Right:
                symbolView.Margin = new Thickness(0, 0, CalculateMarginWidth(btn, symbolView, contentPresenter, iconInterval), 0);
                break;

            case IconPosition.Top:
                symbolView.Margin = new Thickness(0, CalculateMarginHeight(btn, symbolView, contentPresenter, iconInterval), 0, 0);
                break;

            case IconPosition.Bottom:
                symbolView.Margin = new Thickness(0, 0, 0, CalculateMarginHeight(btn, symbolView, contentPresenter, iconInterval));
                break;
            }
        }
示例#18
0
 /// <summary>
 /// Adds a data-icon-primary or data-icon-scondary attribute to the control (for use with wiring up jquery-ui buttons)
 /// </summary>
 /// <typeparam name="TBuilder">The type of the builder.</typeparam>
 /// <param name="instance">The instance.</param>
 /// <param name="iconName">One of the <see cref="IconName"/> constants or a custom value</param>
 /// <param name="position">The position.</param>
 public static TBuilder Icon <TBuilder>(this TBuilder instance, string iconName, IconPosition position = IconPosition.Left) where TBuilder : ICanHasJQueryIcon
 {
     if (position.HasFlag(IconPosition.Left))
     {
         instance.Data("icon-primary", iconName);
     }
     if (position.HasFlag(IconPosition.Right))
     {
         instance.Data("icon-secondary", iconName);
     }
     return(instance);
 }
 public static void SetIconPosition(ToggleButton toggleButton, IconPosition value)
 {
     toggleButton.SetValue(IconPositionProperty, value);
 }
示例#20
0
 public ChangeIconPositionCommand(NodeBase node, IconPosition newIconPosition)
     : base(node)
 {
     this.newIconPosition = newIconPosition;
 }