コード例 #1
0
        private void SortThumbnails()
        {
            thumbnailFlowPanel.SortChildren(delegate(Panel x, Panel y)
            {
                var favMarkerX = (Blish_HUD.Controls.Image)x.Children.FirstOrDefault(m =>
                                                                                     m.BasicTooltipText != null && (m.BasicTooltipText.Equals(FavoriteMarkerTooltip) ||
                                                                                                                    m.BasicTooltipText.Equals(UnfavoriteMarkerTooltip)));
                var favMarkerY = (Blish_HUD.Controls.Image)y.Children.FirstOrDefault(m =>
                                                                                     m.BasicTooltipText != null && (m.BasicTooltipText.Equals(FavoriteMarkerTooltip) ||
                                                                                                                    m.BasicTooltipText.Equals(UnfavoriteMarkerTooltip)));
                if (favMarkerX != null && favMarkerY != null)
                {
                    var favorite = string.Compare(favMarkerY.BasicTooltipText, favMarkerX.BasicTooltipText,
                                                  StringComparison.InvariantCultureIgnoreCase);
                    if (favorite != 0)
                    {
                        return(favorite);
                    }
                }

                return(string.Compare(Path.GetFileNameWithoutExtension(x.BasicTooltipText),
                                      Path.GetFileNameWithoutExtension(y.BasicTooltipText),
                                      StringComparison.InvariantCultureIgnoreCase));
            });
        }
コード例 #2
0
        private Panel BuildSettingPanel(Rectangle panelBounds)
        {
            var etPanel = new Panel()
            {
                CanScroll = false,
                Size      = panelBounds.Size
            };

            var ddSortMethod = new Dropdown()
            {
                Location = new Point(etPanel.Right - 150 - Dropdown.Standard.ControlOffset.X, Dropdown.Standard.ControlOffset.Y),
                Width    = 150,
                Parent   = etPanel,
            };

            int topOffset = ddSortMethod.Bottom + Panel.MenuStandard.ControlOffset.Y;

            var menuSection = new Panel {
                Title      = "Event Categories",
                ShowBorder = true,
                Size       = Panel.MenuStandard.Size - new Point(0, topOffset + Panel.MenuStandard.ControlOffset.Y),
                Location   = new Point(Panel.MenuStandard.PanelOffset.X, topOffset),
                Parent     = etPanel
            };

            var eventPanel = new FlowPanel()
            {
                FlowDirection  = ControlFlowDirection.LeftToRight,
                ControlPadding = new Vector2(8, 8),
                Location       = new Point(menuSection.Right + Panel.MenuStandard.ControlOffset.X, menuSection.Top),
                Size           = new Point(ddSortMethod.Right - menuSection.Right - Control.ControlStandard.ControlOffset.X, menuSection.Height),
                CanScroll      = true,
                Parent         = etPanel
            };

            GameService.Overlay.QueueMainThreadUpdate((gameTime) => {
                var searchBox = new TextBox()
                {
                    PlaceholderText = "Event Search",
                    Width           = menuSection.Width,
                    Location        = new Point(ddSortMethod.Top, menuSection.Left),
                    Parent          = etPanel
                };

                searchBox.TextChanged += delegate(object sender, EventArgs args) {
                    eventPanel.FilterChildren <DetailsButton>(db => db.Text.ToLower().Contains(searchBox.Text.ToLower()));
                };
            });

            foreach (var meta in Meta.Events)
            {
                var setting = _watchCollection.DefineSetting("watchEvent:" + meta.Name, true);

                meta.IsWatched = setting.Value;

                var es2 = new DetailsButton {
                    Parent           = eventPanel,
                    BasicTooltipText = meta.Category,
                    Text             = meta.Name,
                    IconSize         = DetailsIconSize.Small,
                    ShowVignette     = false,
                    HighlightType    = DetailsHighlightType.LightHighlight,
                    ShowToggleButton = true
                };

                if (meta.Texture.HasTexture)
                {
                    es2.Icon = meta.Texture;
                }

                var nextTimeLabel = new Label()
                {
                    Size                = new Point(65, es2.ContentRegion.Height),
                    Text                = meta.NextTime.ToShortTimeString(),
                    BasicTooltipText    = GetTimeDetails(meta),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Middle,
                    Parent              = es2,
                };

                Adhesive.Binding.CreateOneWayBinding(() => nextTimeLabel.Height, () => es2.ContentRegion, (rectangle => rectangle.Height), true);

                if (!string.IsNullOrEmpty(meta.Wiki))
                {
                    var glowWikiBttn = new GlowButton {
                        Icon             = GameService.Content.GetTexture("102530"),
                        ActiveIcon       = GameService.Content.GetTexture("glow-wiki"),
                        BasicTooltipText = "Read about this event on the wiki.",
                        Parent           = es2,
                        GlowColor        = Color.White * 0.1f
                    };

                    glowWikiBttn.Click += delegate {
                        if (UrlIsValid(meta.Wiki))
                        {
                            Process.Start(meta.Wiki);
                        }
                    };
                }

                if (!string.IsNullOrEmpty(meta.Waypoint))
                {
                    var glowWaypointBttn = new GlowButton {
                        Icon             = GameService.Content.GetTexture("waypoint"),
                        ActiveIcon       = GameService.Content.GetTexture("glow-waypoint"),
                        BasicTooltipText = $"Nearby waypoint: {meta.Waypoint}",
                        Parent           = es2,
                        GlowColor        = Color.White * 0.1f
                    };

                    glowWaypointBttn.Click += delegate {
                        System.Windows.Forms.Clipboard.SetText(meta.Waypoint);

                        ScreenNotification.ShowNotification("Waypoint copied to clipboard.");
                    };
                }

                var toggleFollowBttn = new GlowButton()
                {
                    Icon             = _textureWatch,
                    ActiveIcon       = _textureWatchActive,
                    BasicTooltipText = "Click to toggle tracking for this event.",
                    ToggleGlow       = true,
                    Checked          = meta.IsWatched,
                    Parent           = es2,
                };

                toggleFollowBttn.Click += delegate {
                    meta.IsWatched = toggleFollowBttn.Checked;
                    setting.Value  = toggleFollowBttn.Checked;
                };

                meta.OnNextRunTimeChanged += delegate {
                    UpdateSort(ddSortMethod, EventArgs.Empty);

                    nextTimeLabel.Text             = meta.NextTime.ToShortTimeString();
                    nextTimeLabel.BasicTooltipText = GetTimeDetails(meta);
                };

                _displayedEvents.Add(es2);
            }

            // Add menu items for each category (and built-in categories)
            var eventCategories = new Menu {
                Size           = menuSection.ContentRegion.Size,
                MenuItemHeight = 40,
                Parent         = menuSection,
                CanSelect      = true
            };

            List <IGrouping <string, Meta> > submetas = Meta.Events.GroupBy(e => e.Category).ToList();

            var evAll = eventCategories.AddMenuItem(EC_ALLEVENTS);

            evAll.Select();
            evAll.Click += delegate {
                eventPanel.FilterChildren <DetailsButton>(db => true);
            };

            foreach (IGrouping <string, Meta> e in submetas)
            {
                var ev = eventCategories.AddMenuItem(e.Key);
                ev.Click += delegate {
                    eventPanel.FilterChildren <DetailsButton>(db => string.Equals(db.BasicTooltipText, e.Key));
                };
            }

            // TODO: Hidden events/timers to be added later
            //eventCategories.AddMenuItem(EC_HIDDEN);

            // Add dropdown for sorting events
            ddSortMethod.Items.Add(DD_ALPHABETICAL);
            ddSortMethod.Items.Add(DD_NEXTUP);

            ddSortMethod.ValueChanged += delegate(object sender, ValueChangedEventArgs args) {
                switch (args.CurrentValue)
                {
                case DD_ALPHABETICAL:
                    eventPanel.SortChildren <DetailsButton>((db1, db2) => string.Compare(db1.Text, db2.Text, StringComparison.CurrentCultureIgnoreCase));
                    break;

                case DD_NEXTUP:
                    break;
                }
            };

            ddSortMethod.SelectedItem = DD_NEXTUP;
            //UpdateSort(ddSortMethod, EventArgs.Empty);

            return(etPanel);
        }
コード例 #3
0
        private Panel BuildModulePanel(WindowBase wnd)
        {
            var homePanel = new Panel
            {
                Parent = wnd,
                Size   = new Point(WindowWidth, WindowHeight)
            };

            thumbnailFlowPanel = new FlowPanel
            {
                Parent         = homePanel,
                Size           = new Point(homePanel.ContentRegion.Size.X - 70, homePanel.ContentRegion.Size.Y - 130),
                Location       = new Point(35, 50),
                FlowDirection  = ControlFlowDirection.LeftToRight,
                ControlPadding = new Vector2(5, 5),
                CanCollapse    = false,
                CanScroll      = true,
                Collapsed      = false,
                ShowTint       = true,
                ShowBorder     = true
            };
            var searchBox = new TextBox
            {
                Parent          = homePanel,
                Location        = new Point(thumbnailFlowPanel.Location.X, thumbnailFlowPanel.Location.Y - 40),
                Size            = new Point(200, 40),
                PlaceholderText = SearchBoxPlaceHolder
            };
            var deleteSearchBoxContentButton = new Blish_HUD.Controls.Image
            {
                Parent   = homePanel,
                Location = new Point(searchBox.Right - 20 - PanelMargin, searchBox.Location.Y + PanelMargin),
                Size     = new Point(20, 20),
                Texture  = _deleteSearchBoxContentIcon,
                Visible  = false
            };

            deleteSearchBoxContentButton.Click += delegate
            {
                searchBox.Text = "";
                deleteSearchBoxContentButton.Hide();
            };
            deleteSearchBoxContentButton.MouseEntered += delegate
            {
                if (deleteSearchBoxContentButton.Visible)
                {
                    GameService.Animation.Tweener.Tween(deleteSearchBoxContentButton, new { Opacity = 1.0f }, 0.2f);
                }
            };
            deleteSearchBoxContentButton.MouseLeft += delegate
            {
                if (deleteSearchBoxContentButton.Visible)
                {
                    GameService.Animation.Tweener.Tween(deleteSearchBoxContentButton, new { Opacity = 0.8f }, 0.2f);
                }

                deleteSearchBoxContentButton.Size     = new Point(20, 20);
                deleteSearchBoxContentButton.Location = new Point(searchBox.Right - 20 - PanelMargin,
                                                                  searchBox.Location.Y + PanelMargin);
            };
            deleteSearchBoxContentButton.LeftMouseButtonPressed += delegate
            {
                deleteSearchBoxContentButton.Width   -= 2;
                deleteSearchBoxContentButton.Height  -= 2;
                deleteSearchBoxContentButton.Location = new Point(deleteSearchBoxContentButton.Location.X + 2,
                                                                  deleteSearchBoxContentButton.Location.Y + 2);
            };
            searchBox.InputFocusChanged += delegate { SortThumbnails(); };
            searchBox.TextChanged       += delegate
            {
                deleteSearchBoxContentButton.Visible = !searchBox.Text.Equals(string.Empty);
                thumbnailFlowPanel.SortChildren(delegate(Panel x, Panel y)
                {
                    var fileNameX  = Path.GetFileNameWithoutExtension(x.BasicTooltipText);
                    var fileNameY  = Path.GetFileNameWithoutExtension(y.BasicTooltipText);
                    x.Visible      = fileNameX.Contains(searchBox.Text);
                    y.Visible      = fileNameY.Contains(searchBox.Text);
                    var favMarkerX = (Blish_HUD.Controls.Image)x.Children.FirstOrDefault(m =>
                                                                                         m.BasicTooltipText != null && (m.BasicTooltipText.Equals(FavoriteMarkerTooltip) ||
                                                                                                                        m.BasicTooltipText.Equals(UnfavoriteMarkerTooltip)));
                    var favMarkerY = (Blish_HUD.Controls.Image)y.Children.FirstOrDefault(m =>
                                                                                         m.BasicTooltipText != null && (m.BasicTooltipText.Equals(FavoriteMarkerTooltip) ||
                                                                                                                        m.BasicTooltipText.Equals(UnfavoriteMarkerTooltip)));
                    if (favMarkerX != null && favMarkerY != null)
                    {
                        var favorite = string.Compare(favMarkerY.BasicTooltipText, favMarkerX.BasicTooltipText,
                                                      StringComparison.InvariantCultureIgnoreCase);
                        if (favorite != 0)
                        {
                            return(favorite);
                        }
                    }

                    return(string.Compare(fileNameX, fileNameY, StringComparison.InvariantCultureIgnoreCase));
                });
            };
            homePanel.Hidden += ToggleFileSystemWatchers;
            homePanel.Hidden += ToggleFileSystemWatchers;
            homePanel.Shown  += LoadImages;
            homePanel.Hidden += DisposeDisplayedThumbnails;
            return(homePanel);
        }