_3PA.MainFeatures.AutoCompletion.CompletionItem.DoForEachFlag C# (CSharp) Méthode

DoForEachFlag() public méthode

Use this method to do an action for each flag of the item...
public DoForEachFlag ( ParseFlag>.Action toApplyOnFlag ) : void
toApplyOnFlag ParseFlag>.Action
Résultat void
        public void DoForEachFlag(Action<string, ParseFlag> toApplyOnFlag)
        {
            foreach (var name in Enum.GetNames(typeof(ParseFlag))) {
                ParseFlag flag = (ParseFlag)Enum.Parse(typeof(ParseFlag), name);
                if (flag == 0 || !Flag.HasFlag(flag)) continue;
                toApplyOnFlag(name, flag);
            }
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Event on format cell
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void FastOlvOnFormatCell(object sender, FormatCellEventArgs args)
        {
            CompletionItem item = (CompletionItem)args.Model;

            if (item == null)
            {
                return;
            }

            // display the flags
            int offset = -5;

            item.DoForEachFlag((name, flag) => {
                Image tryImg = (Image)ImageResources.ResourceManager.GetObject(name);
                if (tryImg != null)
                {
                    ImageDecoration decoration = new ImageDecoration(tryImg, 100, ContentAlignment.MiddleRight)
                    {
                        Offset = new Size(offset, 0)
                    };
                    if (args.SubItem.Decoration == null)
                    {
                        args.SubItem.Decoration = decoration;
                    }
                    else
                    {
                        args.SubItem.Decorations.Add(decoration);
                    }
                    offset -= 20;
                }
            });

            // display the sub string
            if (offset < -5)
            {
                offset -= 5;
            }
            if (!String.IsNullOrEmpty(item.SubString))
            {
                TextDecoration decoration = new TextDecoration(item.SubString, 100)
                {
                    Alignment      = ContentAlignment.MiddleRight,
                    Offset         = new Size(offset, 0),
                    Font           = FontManager.GetFont(FontStyle.Bold, 10),
                    TextColor      = ThemeManager.Current.SubTextFore,
                    CornerRounding = 1f,
                    Rotation       = 0,
                    BorderWidth    = 1,
                    BorderColor    = ThemeManager.Current.SubTextFore
                };
                args.SubItem.Decorations.Add(decoration);
            }
        }
CompletionItem