Beispiel #1
0
        private List <BadgeInfo> GetBadges(ListViewItem Item, ListViewItem.ListViewSubItem SubItem)
        {
            string UniqueIdPrefix = String.Format("{0}_", Item.Index);

            List <BadgeInfo> Badges = new List <BadgeInfo>();

            SdkItem Sdk = (SdkItem)SubItem.Tag;

            Action InstallAction = null;

            if (!String.IsNullOrEmpty(Sdk.Install))
            {
                InstallAction = () => { Install(Sdk.Install); };
            }
            Badges.Add(new BadgeInfo()
            {
                UniqueId = UniqueIdPrefix + "_Install", Label = "Install", OnClick = InstallAction
            });

            Action BrowseAction = null;

            if (!String.IsNullOrEmpty(Sdk.Browse))
            {
                BrowseAction = () => { Browse(Sdk.Browse); };
            }
            Badges.Add(new BadgeInfo()
            {
                UniqueId = UniqueIdPrefix + "_Browse", Label = "Browse", OnClick = BrowseAction
            });

            int Right = SubItem.Bounds.Right - 10;

            for (int Idx = Badges.Count - 1; Idx >= 0; Idx--)
            {
                Size BadgeSize = GetBadgeSize(Badges[Idx].Label);
                Right -= BadgeSize.Width;
                Badges[Idx].Rectangle = new Rectangle(Right, SubItem.Bounds.Y + (SubItem.Bounds.Height - BadgeSize.Height) / 2, BadgeSize.Width, BadgeSize.Height);
            }

            return(Badges);
        }
Beispiel #2
0
        public SdkInfoWindow(string[] SdkInfoEntries, Dictionary <string, string> Variables, Font BadgeFont)
        {
            InitializeComponent();

            this.BadgeFont = BadgeFont;

            Dictionary <string, ConfigObject> UniqueIdToObject = new Dictionary <string, ConfigObject>(StringComparer.InvariantCultureIgnoreCase);

            foreach (string SdkInfoEntry in SdkInfoEntries)
            {
                ConfigObject Object = new ConfigObject(SdkInfoEntry);

                string UniqueId = Object.GetValue("UniqueId", Guid.NewGuid().ToString());

                ConfigObject ExistingObject;
                if (UniqueIdToObject.TryGetValue(UniqueId, out ExistingObject))
                {
                    ExistingObject.AddOverrides(Object, null);
                }
                else
                {
                    UniqueIdToObject.Add(UniqueId, Object);
                }
            }

            List <SdkItem> Items = new List <SdkItem>();

            foreach (ConfigObject Object in UniqueIdToObject.Values)
            {
                SdkItem Item = new SdkItem();
                Item.Category    = Object.GetValue("Category", "Other");
                Item.Description = Object.GetValue("Description", "");

                Item.Install = Utility.ExpandVariables(Object.GetValue("Install", ""), Variables);
                if (Item.Install.Contains("$("))
                {
                    Item.Install = null;
                }

                Item.Browse = Utility.ExpandVariables(Object.GetValue("Browse", ""), Variables);
                if (Item.Browse.Contains("$("))
                {
                    Item.Browse = null;
                }

                if (!String.IsNullOrEmpty(Item.Install) && String.IsNullOrEmpty(Item.Browse))
                {
                    try
                    {
                        Item.Browse = Path.GetDirectoryName(Item.Install);
                    }
                    catch
                    {
                        Item.Browse = null;
                    }
                }

                Items.Add(Item);
            }

            foreach (IGrouping <string, SdkItem> ItemGroup in Items.GroupBy(x => x.Category).OrderBy(x => x.Key))
            {
                ListViewGroup Group = new ListViewGroup(ItemGroup.Key);
                SdkListView.Groups.Add(Group);

                foreach (SdkItem Item in ItemGroup)
                {
                    ListViewItem NewItem = new ListViewItem(Group);
                    NewItem.SubItems.Add(Item.Description);
                    NewItem.SubItems.Add(new ListViewItem.ListViewSubItem()
                    {
                        Tag = Item
                    });
                    SdkListView.Items.Add(NewItem);
                }
            }

            System.Reflection.PropertyInfo DoubleBufferedProperty = typeof(Control).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            DoubleBufferedProperty.SetValue(SdkListView, true, null);

            if (SdkListView.Items.Count > 0)
            {
                int ItemsHeight = SdkListView.Items[SdkListView.Items.Count - 1].Bounds.Bottom + 20;
                Height = SdkListView.Top + ItemsHeight + (Height - SdkListView.Bottom);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Standard data container for a tool tiem.
 /// </summary>
 /// <param name="package"></param>
 public SdkToolItemViewModel(SdkItem package, bool canExpand) : base(package, canExpand)
 {
 }
Beispiel #4
0
 /// <summary>
 /// Standard view model for a platform item.
 /// </summary>
 /// <param name="package"></param>
 public SdkPlaformItemViewModels(SdkItem package, bool canExpand) : base(package, canExpand)
 {
 }