private void HandleControl(Control control, Dictionary <Type, ColorSet> colorSet) { FirefoxButton button = control as FirefoxButton; PanelBox pb = control as PanelBox; LinkLabel linkLabel = control as LinkLabel; FirefoxCheckBox cb = control as FirefoxCheckBox; if (button != null && colorSet.ContainsKey(button.GetType())) { var colorset = colorSet[button.GetType()]; button.BackColor = colorset.BackColor.Value; button.BackColorOverride = colorset.BackColor.Value; button.ForeColor = colorset.ForeColor.Value; button.HoverColor = colorset.HoverColor.Value; button.HoverForeColor = colorset.HoverForeColor.Value; } else if (pb != null && colorSet.ContainsKey(pb.GetType())) { var colorset = colorSet[pb.GetType()]; pb.BackColor = colorset.BackColor.Value; pb.ForeColor = colorset.ForeColor.Value; pb.HeaderColor = colorset.HeaderColor.Value; } else if (linkLabel != null && colorSet.ContainsKey(linkLabel.GetType())) { var colorset = colorSet[linkLabel.GetType()]; linkLabel.BackColor = colorset.BackColor.Value; linkLabel.ForeColor = colorset.ForeColor.Value; linkLabel.LinkColor = colorset.LinkColor.Value; } else { if (colorSet.ContainsKey(control.GetType())) { var colorset = colorSet[control.GetType()]; control.BackColor = colorset.BackColor ?? control.BackColor; control.ForeColor = colorset.ForeColor ?? control.ForeColor; } else { var colorset = colorSet[typeof(Control)]; control.BackColor = colorset.BackColor ?? control.BackColor; control.ForeColor = colorset.ForeColor ?? control.ForeColor; } } if (cb != null) { cb.IsDarkMode = !_isLightMode; } control.Invalidate(); control.Update(); }
private async void Play_SoundAsync(object sender, EventArgs e) { LinkLabel b = (LinkLabel)(sender); try { if (b.Text == "Sound") { b.Text = "Stop"; Panel p = (Panel)b.Parent.Parent.Parent; foreach (LinkLabel l in Helper.GetAll(p, b.GetType()).Where(a => a.Text != "Detail" && a != b)) { l.Text = "Sound"; } disposeWave(); await GetWave((int)b.Tag); if (waveOutDevice == null) { waveOutDevice = new WaveOut(); } if (audioFileReader == null) { audioFileReader = new AudioFileReader(@"video.wav"); } waveOutDevice.Init(audioFileReader); waveOutDevice.PlaybackStopped += (send, args) => AutoPlaySoundAsync(send, args, (int)b.Tag); waveOutDevice.Play(); } else { b.Text = "Sound"; waveOutDevice?.Stop(); audioFileReader?.Dispose(); waveOutDevice?.Dispose(); audioFileReader = null; waveOutDevice = null; } } catch (Exception ex) { //MessageBox.Show(ex.Message); //throw; Action action = () => { b.BackColor = Color.Red; }; b.SafeInvoke(action, true); } }
/// <summary> /// クリックです。 /// </summary> /// <param name="linklabel">リンクラベル。</param> static void EmulateLinkClickInTarget(LinkLabel linklabel) { linklabel.Focus(); linklabel.GetType().GetMethod("OnLinkClicked", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(linklabel, new object[] { new LinkLabelLinkClickedEventArgs(new LinkLabel.Link()) }); }