Пример #1
0
        private void flowMain_DragOver(object sender, DragEventArgs e)
        {
            UserSplitSettings oldItem     = (UserSplitSettings)e.Data.GetData(typeof(UserSplitSettings));
            FlowLayoutPanel   destination = (FlowLayoutPanel)sender;
            Point             point       = destination.PointToClient(new Point(e.X, e.Y));
            UserSplitSettings newItem     = destination.GetChildAtPoint(point) as UserSplitSettings;
            int newIndex = destination.Controls.GetChildIndex(newItem, false);

            e.Effect = DragDropEffects.Move;
            int oldIndex = destination.Controls.GetChildIndex(oldItem);

            if (oldIndex != newIndex)
            {
                string segment = oldItem.UserSplit.Name;
                oldItem.UserSplit.Name = newItem.UserSplit.Name;
                newItem.UserSplit.Name = segment;
                Split split = Settings.Autosplits[oldIndex];
                Settings.Autosplits[oldIndex] = Settings.Autosplits[newIndex];
                Settings.Autosplits[newIndex] = split;
                oldItem.UpdateControls(false, false);
                newItem.UpdateControls(false, false);
                destination.Controls.SetChildIndex(oldItem, newIndex);
                destination.Invalidate();
            }
        }
Пример #2
0
        private void FixSplits()
        {
            int  index   = 1;
            bool changed = false;

            if (Settings.Autosplits.Count == 0)
            {
                Settings.Autosplits.Add(new Split()
                {
                    Name = "Auto Start", Type = SplitType.GameStart
                });
                changed = true;
            }
            else
            {
                Settings.Autosplits[0].Name = "Auto Start";
            }

            foreach (ISegment segment in State.Run)
            {
                if (index < Settings.Autosplits.Count)
                {
                    Split split = Settings.Autosplits[index++];
                    if (split.Name != segment.Name)
                    {
                        split.Name = segment.Name;
                        changed    = true;
                    }
                }
                else
                {
                    index++;
                    if (State.Run.Count == 4)
                    {
                        Settings.Autosplits.Add(new Split()
                        {
                            Name = segment.Name, Type = SplitType.Album, Value = "Any"
                        });
                    }
                    else
                    {
                        Settings.Autosplits.Add(new Split()
                        {
                            Name = segment.Name, Type = SplitType.Track, Value = "Any"
                        });
                    }
                    changed = true;
                }
            }

            while (index < Settings.Autosplits.Count)
            {
                Settings.Autosplits.RemoveAt(Settings.Autosplits.Count - 1);
                changed = true;
            }

            if (changed)
            {
                flowMain.SuspendLayout();
                flowMain.Controls.Clear();

                foreach (Split split in Settings.Autosplits)
                {
                    UserSplitSettings setting = new UserSplitSettings();
                    setting.UserSplit = split;
                    setting.UpdateControls(true);
                    flowMain.Controls.Add(setting);
                }

                flowMain.ResumeLayout(true);
            }
        }