示例#1
0
        public Framework.AsyncObservableCollection <FrameworkElement> generateRightClickMenuItems()
        {
            Framework.AsyncObservableCollection <FrameworkElement> rightClickMenu = new Framework.AsyncObservableCollection <FrameworkElement>();
            try
            {
                foreach (List.contextMenu cItem in List.gameContextMenuItems.Where(x => x.IsActive))
                {
                    if (IsSteamBackup && cItem.showToSteamBackup == Enums.menuVisibility.NotVisible)
                    {
                        continue;
                    }
                    else if (installedLibrary.Backup && cItem.showToSLMBackup == Enums.menuVisibility.NotVisible)
                    {
                        continue;
                    }
                    else if (IsCompressed && cItem.showToCompressed == Enums.menuVisibility.NotVisible)
                    {
                        continue;
                    }
                    else if (cItem.showToNormal == Enums.menuVisibility.NotVisible)
                    {
                        continue;
                    }

                    if (cItem.IsSeparator)
                    {
                        rightClickMenu.Add(new Separator());
                    }
                    else
                    {
                        MenuItem slmItem = new MenuItem();

                        slmItem.Tag    = this;
                        slmItem.Header = string.Format(cItem.Header, appName, appID, Functions.fileSystem.FormatBytes(sizeOnDisk));
                        slmItem.Tag    = cItem.Action;
                        slmItem.Icon   = Functions.fAwesome.getAwesomeIcon(cItem.Icon, cItem.IconColor);

                        rightClickMenu.Add(slmItem);
                    }
                }

                return(rightClickMenu);
            }
            catch (FormatException ex)
            {
                MessageBox.Show($"An error happened while parsing context menu, most likely happened duo typo on color name.\n\n{ex}");

                return(rightClickMenu);
            }
        }
        public Framework.AsyncObservableCollection <FrameworkElement> GenerateCMenuItems()
        {
            Framework.AsyncObservableCollection <FrameworkElement> CMenu = new Framework.AsyncObservableCollection <FrameworkElement>();
            try
            {
                foreach (ContextMenuItem CMenuItem in List.LibraryCMenuItems.Where(x => x.IsActive && x.LibraryType == Enums.LibraryType.Steam))
                {
                    if (!CMenuItem.ShowToNormal)
                    {
                        continue;
                    }

                    if (CMenuItem.IsSeparator)
                    {
                        CMenu.Add(new Separator());
                    }
                    else
                    {
                        MenuItem SLMItem = new MenuItem()
                        {
                            Tag    = CMenuItem.Action,
                            Header = string.Format(CMenuItem.Header, FullPath, Library.PrettyFreeSpace),
                            Icon   = Functions.FAwesome.GetAwesomeIcon(CMenuItem.Icon, CMenuItem.IconColor),
                            HorizontalContentAlignment = HorizontalAlignment.Left,
                            VerticalContentAlignment   = VerticalAlignment.Center
                        };

                        SLMItem.Click += Main.FormAccessor.LibraryCMenuItem_Click;

                        CMenu.Add(SLMItem);
                    }
                }

                return(CMenu);
            }
            catch (FormatException ex)
            {
                MessageBox.Show($"An error happened while parsing context menu, most likely happened duo typo on color name.\n\n{ex}");
                return(CMenu);
            }
        }