コード例 #1
0
 public PianoKey(PianoControl piano, int noteId)
 {
     owner    = piano;
     TabStop  = false;
     NoteID   = noteId;
     offBrush = new SolidBrush(new HSLColor(160.0, 0.0, KeyTypeTable[noteID % 12] == KeyType.White ? noteID / 12 % 2 == 0 ? 240.0 : 120.0 : 0.0));
 }
コード例 #2
0
        private MainForm()
        {
            for (int i = 0; i < 0x10; i++)
            {
                PianoTracks[i] = true;
            }

            components = new Container();

            // Main Menu
            openSDATToolStripMenuItem = new ToolStripMenuItem {
                Text = "Open SDAT", ShortcutKeys = Keys.Control | Keys.O
            };
            openSDATToolStripMenuItem.Click += OpenSDAT;

            configToolStripMenuItem = new ToolStripMenuItem {
                Text = "Refresh Config", ShortcutKeys = Keys.Control | Keys.R
            };
            configToolStripMenuItem.Click += ReloadConfig;

            fileToolStripMenuItem = new ToolStripMenuItem {
                Text = "File"
            };
            fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { openSDATToolStripMenuItem, configToolStripMenuItem });


            mainMenu = new MenuStrip {
                Size = new Size(iWidth, 24)
            };
            mainMenu.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });

            // Buttons
            playButton = new ThemedButton {
                ForeColor = Color.MediumSpringGreen, Location = new Point(5, 3), Text = "Play"
            };
            playButton.Click += (o, e) => Play();
            pauseButton       = new ThemedButton {
                ForeColor = Color.DeepSkyBlue, Location = new Point(85, 3), Text = "Pause"
            };
            pauseButton.Click += (o, e) => Pause();
            stopButton         = new ThemedButton {
                ForeColor = Color.MediumVioletRed, Location = new Point(166, 3), Text = "Stop"
            };
            stopButton.Click += (o, e) => Stop();

            playButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false;
            playButton.Size    = stopButton.Size = new Size(75, 23);
            pauseButton.Size   = new Size(76, 23);

            // Numericals
            songNumerical = new ThemedNumeric {
                Enabled = false, Location = new Point(246, 4), Minimum = ushort.MinValue
            };

            songNumerical.Size          = new Size(45, 23);
            songNumerical.ValueChanged += (o, e) => LoadSong();

            // Timer
            timer       = new Timer(components);
            timer.Tick += UpdateUI;

            // Piano
            piano = new PianoControl {
                Anchor = AnchorStyles.Bottom, Location = new Point(0, 125 - 50 - 1), Size = new Size(iWidth, 50)
            };

            // Volume bar
            int sWidth = (int)(iWidth / sfWidth);
            int sX     = iWidth - sWidth - 4;

            volumeBar = new ColorSlider
            {
                Enabled     = false,
                LargeChange = 20,
                Location    = new Point(83, 45),
                Maximum     = 100,
                Size        = new Size(155, 27),
                SmallChange = 5
            };
            volumeBar.ValueChanged += VolumeBar_ValueChanged;

            // Playlist box
            songsComboBox = new ComboBox
            {
                Anchor   = AnchorStyles.Top | AnchorStyles.Right,
                Enabled  = false,
                Location = new Point(sX, 4),
                Size     = new Size(sWidth, 23)
            };
            songsComboBox.SelectedIndexChanged += SongsComboBox_SelectedIndexChanged;

            // Track info
            trackInfo = new TrackInfoControl
            {
                Dock = DockStyle.Fill,
                Size = new Size(iWidth, 690)
            };

            // Split container
            splitContainer = new SplitContainer
            {
                BackColor        = Theme.TitleBar,
                Dock             = DockStyle.Fill,
                FixedPanel       = FixedPanel.Panel1,
                IsSplitterFixed  = true,
                Orientation      = Orientation.Horizontal,
                Size             = new Size(iWidth, iHeight),
                SplitterDistance = 125,
                SplitterWidth    = 1
            };
            splitContainer.Panel1.Controls.AddRange(new Control[] { playButton, pauseButton, stopButton, songNumerical, songsComboBox, piano, volumeBar });
            splitContainer.Panel2.Controls.Add(trackInfo);

            // MainForm
            AutoScaleDimensions = new SizeF(6, 13);
            AutoScaleMode       = AutoScaleMode.Font;
            ClientSize          = new Size(iWidth, iHeight);
            Controls.AddRange(new Control[] { splitContainer, mainMenu });
            MainMenuStrip = mainMenu;
            MinimumSize   = new Size(8 + iWidth + 8, 30 + iHeight + 8); // Borders
            SongPlayer.Instance.SongEnded += SongEnded;
            Resize += OnResize;
            Text    = "NDS Music Studio";

            // Taskbar Buttons
            if (TaskbarManager.IsPlatformSupported)
            {
                prevTButton          = new ThumbnailToolBarButton(Resources.IconPrevious, "Previous Song");
                prevTButton.Click   += (o, e) => PlayPreviousSong();
                toggleTButton        = new ThumbnailToolBarButton(Resources.IconPlay, "Play");
                toggleTButton.Click += (o, e) => TogglePlayback();
                nextTButton          = new ThumbnailToolBarButton(Resources.IconNext, "Next Song");
                nextTButton.Click   += (o, e) => PlayNextSong();
                prevTButton.Enabled  = toggleTButton.Enabled = nextTButton.Enabled = false;
                TaskbarManager.Instance.ThumbnailToolBars.AddButtons(Handle, prevTButton, toggleTButton, nextTButton);
            }
        }