コード例 #1
0
        public ComboColourProject()
        {
            ColourPoints = new ObservableCollection <ColourPoint>();
            ComboColours = new ObservableCollection <SpecialColour>();

            MaxBurstLength = 1;

            AddColourPointCommand = new CommandImplementation(_ => {
                double time = ColourPoints.Count > 1 ?
                              ColourPoints.Count(o => o.IsSelected) > 0 ? ColourPoints.Where(o => o.IsSelected).Max(o => o.Time) :
                              ColourPoints.Last().Time
                    : 0;
                if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                {
                    try {
                        time = EditorReaderStuff.GetEditorTime();
                    } catch (Exception ex) {
                        ex.Show();
                    }
                }

                ColourPoints.Add(GenerateNewColourPoint(time));
            });

            RemoveColourPointCommand = new CommandImplementation(_ => {
                if (ColourPoints.Any(o => o.IsSelected))
                {
                    ColourPoints.RemoveAll(o => o.IsSelected);
                    return;
                }
                if (ColourPoints.Count > 0)
                {
                    ColourPoints.RemoveAt(ColourPoints.Count - 1);
                }
            });

            AddComboCommand = new CommandImplementation(_ => {
                if (ComboColours.Count >= 8)
                {
                    return;
                }
                ComboColours.Add(ComboColours.Count > 0
                    ? new SpecialColour(ComboColours[ComboColours.Count - 1].Color, $"Combo{ComboColours.Count + 1}")
                    : new SpecialColour(Colors.White, $"Combo{ComboColours.Count + 1}"));
            });

            RemoveComboCommand = new CommandImplementation(_ => {
                if (ComboColours.Count > 0)
                {
                    ComboColours.RemoveAt(ComboColours.Count - 1);
                }
            });
        }