Exemplo n.º 1
0
        private void OnCollapsedChanged(DailyGroup group, bool collapsed)
        {
            var v = Settings.HiddenDailyCategories[group.id];

            if (collapsed)
            {
                v.Value = true;
            }
            else
            {
                v.Clear();
            }
            group.collapsed = collapsed;
            PositionGroups(group.index);
        }
Exemplo n.º 2
0
        private void SetupControls(DailyAchievements.Dailies dailies)
        {
            if (reusable == null)
            {
                reusable = new Util.ReusableControls();
            }
            else
            {
                reusable.ReleaseAll();
            }

            var achievements = reusable.CreateOrAll <DailyAchievement>(dailies.Count,
                                                                       delegate
            {
                var control = new DailyAchievement()
                {
                    BackColor   = Color.White,
                    NameVisible = true,
                    NameFont    = fontName,
                    IconSize    = new Size(32, 32),
                    IconVisible = true,
                    Size        = new Size(panelContent.Width, 50),
                    Anchor      = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top,
                };

                control.MouseEnter += control_MouseEnter;
                control.MouseLeave += control_MouseLeave;

                return(control);
            });

            var bars = reusable.CreateOrAll <DailyCategoryBar>(dailies.Categories.Length + 1,
                                                               delegate
            {
                var bar = new DailyCategoryBar()
                {
                    Font      = fontBar,
                    BackColor = SystemColors.ControlLight,
                    Size      = new Size(panelContent.Width, 35),
                    Anchor    = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top,
                };

                bar.Collapsed += bar_Collapsed;
                bar.Expanded  += bar_Expanded;

                return(bar);
            });

            int x = 0,
                y = 0;

            //var primaryCategories = 3;
            //var lowLevel = new List<Control>(4);

            //int gi = 0,
            //    gii;

            byte id = 0;

            var groups   = this.groups = new DailyGroup[dailies.Categories.Length + 1];
            var lowlevel = new DailyGroup()
            {
                id        = 0,
                dailies   = new DailyAchievements.Daily[4],
                collapsed = Settings.HiddenDailyCategories[0].Value,
            };
            bool addedLow   = false;
            int  firstIndex = 0,
                 lastIndex  = groups.Length - 1;

            foreach (var c in dailies.Categories)
            {
                if (c.Name == "Fractals" && !addedLow)
                {
                    if (lowlevel.collapsed)
                    {
                        groups[lastIndex--] = lowlevel;
                    }
                    else
                    {
                        groups[firstIndex++] = lowlevel;
                    }
                    addedLow = true;
                }

                id++;

                var group = new DailyGroup()
                {
                    id        = id,
                    dailies   = new DailyAchievements.Daily[c.Dailies.Length],
                    collapsed = Settings.HiddenDailyCategories[id].Value,
                };

                foreach (var d in c.Dailies)
                {
                    if (d.MaxLevel < 80)
                    {
                        lowlevel.dailies[lowlevel.count++] = d;
                    }
                    else
                    {
                        group.dailies[group.count++] = d;
                    }
                }

                if (group.count > 0)
                {
                    var bar = group.bar = bars.GetNext();

                    bar.SetState(group.collapsed);
                    bar.Text = c.Name;
                }

                if (group.collapsed)
                {
                    groups[lastIndex--] = group;
                }
                else
                {
                    groups[firstIndex++] = group;
                }
            }

            if (lowlevel.count > 0)
            {
                var bar = lowlevel.bar = bars.GetNext();

                bar.Tag = lowlevel;
                bar.SetState(lowlevel.collapsed);
                bar.Text = "Pre level 80";
            }

            if (!addedLow)
            {
                groups[firstIndex++] = lowlevel;
            }

            if (firstIndex != groups.Length)
            {
                var count = groups.Length - firstIndex;
                if (count > 1)
                {
                    Array.Reverse(groups, firstIndex, count);
                }
            }

            firstIndex = 0;

            foreach (var group in groups)
            {
                group.index = firstIndex++;

                if (group.count > 0)
                {
                    var bar = group.bar;

                    bar.Tag      = group;
                    bar.Location = new Point(x, y);
                    bar.Visible  = true;

                    y += bar.Height + 1;

                    var visible = !group.collapsed;
                    group.controls = new DailyAchievement[group.count];

                    for (var i = 0; i < group.count; i++)
                    {
                        var control = group.controls[i] = achievements.GetNext();
                        var d       = group.dailies[i];

                        control.Daily     = d;
                        control.IconValue = d.Icon != null ? d.Icon : imageDefault;
                        control.Location  = new Point(x, y);
                        control.Visible   = visible;

                        if (visible)
                        {
                            y += control.Height + 1;
                        }
                    }

                    if (visible)
                    {
                        y--;
                    }
                }
            }

            while (bars.HasNext)
            {
                bars.GetNext().Visible = false;
            }

            while (achievements.HasNext)
            {
                achievements.GetNext().Visible = false;
            }

            panelContent.Height = y;
            scrollV.Maximum     = y - panelContainer.Height;

            if (bars.New != null)
            {
                panelContent.Controls.AddRange(bars.New);
            }
            if (achievements.New != null)
            {
                panelContent.Controls.AddRange(achievements.New);
            }
        }