public bool Run() { if (MessageAlert) { new Thread((x) => { KeyValuePair <string, string> ayy = (KeyValuePair <string, string>)x; MessageBox.Show(ayy.Value, ayy.Key, MessageBoxButtons.OK, MessageBoxIcon.Information); }).Start(new KeyValuePair <string, string>(msgTitle, msgText)); } if (SoundAlert) { WMPLib.WindowsMediaPlayerClass player = new WMPLib.WindowsMediaPlayerClass(); player.URL = SoundFile; player.play(); } if (RunProcess) { Process.Start(ProcessFile, ProcessParameters, null, null); } if (ExecuteBatch) { Process.Start(batchFile); } if (execErrDay == -1) { File.Delete("tasks\\" + TaskID.ToString("X") + ".task"); return(true); } return(false); }
static void Main(string[] args) { if (args.Length < 1) { System.Console.WriteLine("Syntax: ExportWMPMetadataToCSV.exe <outfile> [<top>]"); return; } int?top = null; if (args.Length >= 2) { top = int.Parse(args[1]); } string output_filename = args[0]; var normalized_names = new Dictionary <string, string>(); foreach (var attr in all_attributes) { string name = attr.Replace("/", "_"); normalized_names[attr] = name; } var wmp = new WMPLib.WindowsMediaPlayerClass(); var item_collection = wmp.getAll(); using (var writer = File.CreateText(output_filename)) using (var csv = new CsvWriter(writer)) { // Write CSV Header for (int i = 0; i < all_attributes.Length; i++) { string h = normalized_names[all_attributes[i]]; csv.WriteField(h); } csv.NextRecord(); for (int i = 0; i < item_collection.count; i++) { if (top.HasValue && i >= top.Value) { break; } System.Console.WriteLine("WMP Item #: {0}", i + 1); // write a csv line for each item in the collection var item = item_collection.get_Item(i); for (int j = 0; j < all_attributes.Length; j++) { var attr_value = item.getItemInfo(all_attributes[j]) ?? ""; csv.WriteField(attr_value); } csv.NextRecord(); } } System.Console.WriteLine("DONE"); }
static void Main(string[] args) { if (args.Length < 1) { System.Console.WriteLine("Syntax: ExportWMPMetadataToCSV.exe <outfile> [<top>]"); return; } int? top = null; if (args.Length >= 2) { top = int.Parse(args[1]); } string output_filename = args[0]; var normalized_names = new Dictionary<string, string>(); foreach (var attr in all_attributes) { string name = attr.Replace("/", "_"); normalized_names[attr] = name; } var wmp = new WMPLib.WindowsMediaPlayerClass(); var item_collection = wmp.getAll(); using (var writer = File.CreateText(output_filename)) using (var csv = new CsvWriter(writer)) { // Write CSV Header for (int i = 0; i < all_attributes.Length; i++) { string h = normalized_names[all_attributes[i]]; csv.WriteField(h); } csv.NextRecord(); for (int i = 0; i < item_collection.count; i++) { if (top.HasValue && i>= top.Value) { break; } System.Console.WriteLine("WMP Item #: {0}", i + 1); // write a csv line for each item in the collection var item = item_collection.get_Item(i); for (int j = 0; j < all_attributes.Length; j++) { var attr_value = item.getItemInfo(all_attributes[j]) ?? ""; csv.WriteField(attr_value); } csv.NextRecord(); } } System.Console.WriteLine("DONE"); }
public DummyService() { timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; timer.Tick += timer_Tick; wmplayer = new WMPLib.WindowsMediaPlayerClass(); wmplayer.PositionChange += wmplayer_PositionChange; }
private void ButInfo_Click(object sender, EventArgs e) { if (this.optFile.FileName != "optFile") //当打开文件的文件名不为“optFile” { c = new WMPLib.WindowsMediaPlayerClass(); //实例化WindowsMediaPlayerClass类的对象 m = c.newMedia(this.optFile.FileName); //为IWMPMedia对象赋值 //获取媒体详细信息 MessageBox.Show("歌手名:" + m.getItemInfo("Author") + "\r\n" + "歌 名:" + m.getItemInfo("Title")); } }
private void Form1_Load(object sender, EventArgs e) { mplayer = new WMPLib.WindowsMediaPlayerClass(); tbDateTime.Text = DateTime.Now.ToString(DateTimeOffsetFormatString); LoadConfig(); Players.Add( new PlayerInstance("Spotify", new Controllers.Players.Spotify())); comboBox1.DisplayMember = "Name"; comboBox1.ValueMember = "Instance"; comboBox1.DataSource = Players; }
private void Form1_Load(object sender, EventArgs e) { mplayer = new WMPLib.WindowsMediaPlayerClass(); tbDateTime.Text = DateTime.Now.ToString(DateTimeOffsetFormatString); LoadConfig(); Players.Add(new PlayerInstance("Spotify", new Controllers.Players.Spotify())); comboBox1.DisplayMember = "Name"; comboBox1.ValueMember = "Instance"; comboBox1.DataSource = Players; }
private void MediaElementSelectedMedia_MediaOpened(object sender, RoutedEventArgs e) { // Just before playing media these lines of codes get duration of media // and set the Maximum property of Slider to Duration of Media WMPLib.WindowsMediaPlayerClass mp = new WMPLib.WindowsMediaPlayerClass(); WMPLib.IWMPMedia mediainfo = mp.newMedia(MediaElementSelectedMedia.Source.ToString()); SliderMediaPosition.Maximum = mediainfo.duration; // // Start the timer that moves Slider every one minute timerUpdateSliderPosition.Enabled = true; timerUpdateSliderPosition.Start(); // }
/// <summary> /// 获取MP3文件播放时长 /// </summary> /// <param name="SongPath">文件的绝对地址</param> /// <returns></returns> public static string GetMp3FileTime(string SongPath) { WMPLib.WindowsMediaPlayerClass wmp = new WMPLib.WindowsMediaPlayerClass(); WMPLib.IWMPMedia media = wmp.newMedia(SongPath); var totalLong = media.durationString; var arr = totalLong.Split(':'); var timeLong = ""; if (arr.Count() == 3) { timeLong = arr[0] + "时" + arr[1] + "分" + arr[2] + "秒"; } if (arr.Count() == 2) { timeLong = arr[0] + "分" + arr[1] + "秒"; } if (arr.Count() == 1) { timeLong = arr[0] + "秒"; } return(timeLong); //return media.getItemInfo("Duration"); }
//keep通信 public void keep() { int i = 0; while (true) { Thread.Sleep(25000); aaa.KeepSession(UserID, Token); i++; if (i == 23) { //播放webAAA的提示音 WMPLib.WindowsMediaPlayerClass player = new WMPLib.WindowsMediaPlayerClass(); player.URL = @"http://aaa.nsu.edu.cn/nsuaaaws/webaaa/notice.wav"; player.uiMode = "None"; player.settings.volume = 100; player.settings.playCount = 1; player.play(); //BeepUp.Beep(500, 700); MessageBox.Show("请再次输入验证码!"); } } }
public Double Duration(String file) { WMPLib.WindowsMediaPlayer wmp = new WMPLib.WindowsMediaPlayerClass(); WMPLib.IWMPMedia mediainfo = wmp.newMedia(file); return mediainfo.duration; }
private void halbsekundengeber_Tick(object sender, EventArgs e) { #region Pleite-EndGame if (Statics.Guthaben <= 1) EndGame("Pleite"); #endregion #region Pumpen #region Pumpe 1 if (pumpe1_progressbar.Value < Statics.P1l) //Wenn der Wert der Progressbar unter dem der Leistung ist, wird er erhöht pumpe1_progressbar.Value++; else //andernfalls abgesenkt try { pumpe1_progressbar.Value--; } catch (Exception) { pumpe1_progressbar.Value = 0; } if (Statics.Pumpe1_working) { if (pumpe1_ein_btn.Checked) //Wenn die Pumpe an ist.. { if (sollp1l != Statics.P1l) //..und die Istleistung ungleich der Sollleistung ist.. { if (sollp1l > Statics.P1l) //..nimmt die Leistung zu, bzw ab. Statics.P1l++; else Statics.P1l--; } } else //Wenn die Pumpe defekt ist, wird die Leistung schrittweise auf 0 gesetzt. if (Statics.P1l > 0) Statics.P1l--; } #endregion #region Pumpe 2 if (pumpe2_progressbar.Value < Statics.P2l) //gleiches Schema wie Pumpe 1 weiter oben pumpe2_progressbar.Value++; else try { pumpe2_progressbar.Value--; } catch (Exception) { pumpe2_progressbar.Value = 0; } if (Statics.Pumpe2_working) { if (pumpe2_ein_btn.Checked) { if (sollp2l != Statics.P2l) { if (sollp2l > Statics.P2l) Statics.P2l++; else Statics.P2l--; } } else if (Statics.P2l > 0) Statics.P2l--; } #endregion #region Ersatzpumpe if (ersatzpumpe_progressbar.Value < Statics.Epl) //gleiches Schema wie Pumpe 1 weiter oben ersatzpumpe_progressbar.Value++; else try { ersatzpumpe_progressbar.Value--; } catch (Exception) { ersatzpumpe_progressbar.Value = 0; } if (Statics.Ersatzpumpe_working) { if (ersatzpumpe_ein_btn.Checked) { if (sollepl != Statics.Epl) { if (sollepl > Statics.Epl) Statics.Epl++; else Statics.Epl--; } } else if (Statics.Epl > 0) Statics.Epl--; } #endregion #region Pumpenleistungswarnung if ((Statics.P1l + Statics.P2l + Statics.Epl - (decimal)(Statics.FilterVerstopfung - 20) < 100)) //Wenn die Pumpenleistung zu niedrig ist, erhöht sich die Temperatur und eine Warnung wird angezeigt { pumpenleistungswarn_panel.Visible = true; Statics.Temperatur++; } else pumpenleistungswarn_panel.Visible = false; Statics.Gesamtpumpenleistung = Statics.P1l + Statics.P2l + Statics.Epl - (decimal)(Statics.FilterVerstopfung - 20); //Formel zur Berechnung der Pumpenleistung #endregion #endregion #region Waterbox if (waterbox.Value < 0) waterbox.Value = 0; if (waterbox.Value == 0) //Wenn der Kühlwasserbehälter leer ist, werden die Pumpen abgeschaltet { if (Statics.Pumpe1_working) { pumpe1_aus_btn.Checked = true; pumpe1_aus_btn.Enabled = false; pumpe1_ein_btn.Enabled = false; p1_trackbar.Enabled = false; } if (Statics.Pumpe2_working) { pumpe2_aus_btn.Checked = true; pumpe2_aus_btn.Enabled = false; pumpe2_ein_btn.Enabled = false; p2_trackbar.Enabled = false; } if (Statics.Ersatzpumpe_working) { ersatzpumpe_aus_btn.Checked = true; ersatzpumpe_aus_btn.Enabled = false; ersatzpumpe_ein_btn.Enabled = false; ep_trackbar.Enabled = false; } } else { if (!emergency) //Wenn SCRAM -> Pumpenbuttons etc kontrollieren { if (Statics.Pumpe1_working) { pumpe1_aus_btn.Enabled = true; pumpe1_ein_btn.Enabled = true; p1_trackbar.Enabled = true; } else { if (!Statics.Reparing) { pumpe1_aus_btn.Enabled = true; pumpe1_ein_btn.Enabled = true; p1_trackbar.Enabled = true; } } if (Statics.Pumpe2_working) { pumpe2_aus_btn.Enabled = true; pumpe2_ein_btn.Enabled = true; p2_trackbar.Enabled = true; } else { if (!Statics.Reparing) { pumpe2_aus_btn.Enabled = true; pumpe2_ein_btn.Enabled = true; p2_trackbar.Enabled = true; } } if (Statics.Ersatzpumpe_working) { ersatzpumpe_aus_btn.Enabled = true; ersatzpumpe_ein_btn.Enabled = true; ep_trackbar.Enabled = true; } else { if (!Statics.Reparing) { ersatzpumpe_aus_btn.Enabled = true; ersatzpumpe_ein_btn.Enabled = true; ep_trackbar.Enabled = true; } } if(!Statics.Steuerstaberror) steuerstab_trackbar.Enabled = true; } } #endregion #region reaktorleistung und Temperatur #region Leistung if (Statics.GeneratorError || Statics.TurbineError || !schaltplan.generator_ein_btn.Checked || Statics.Eventname == "Synchronisieren") { Statics.Istleistung = 0; //Wenn Turbine/Generator/Synchronisationsevent -> gelieferte Leistung = 0 if (Statics.Istleistung >= 0 && Statics.Istleistung <= 1500) { if((int)Statics.Leistung >=0) steuerstab_progressbar.Value = (int)Statics.Leistung; } } else { if (!leistungsrandomizer.Enabled) { if (Statics.Istleistung < Statics.Leistung) //Wenn die Sollleistung nicht erreicht ist -> erhöhen bzw verringern { leistungsrandomizer.Enabled = false; Statics.Istleistung += 10; } else { if (Statics.Istleistung > Statics.Leistung) { leistungsrandomizer.Enabled = false; Statics.Istleistung -= 10; } } if (Statics.Istleistung >= 0 && Statics.Istleistung <= 1500) steuerstab_progressbar.Value = (int)Statics.Istleistung; if (Statics.Istleistung == Statics.Leistung) //Wenn Sollleistung erreicht -> Leistung schwanken lassen leistungsrandomizer.Enabled = true; } } AKW_leistung_label.Text = Statics.Istleistung.ToString() + "MW"; lieferleistung_display.Number = (float)Statics.Istleistung; if ((Statics.Istleistung + 10) < Statics.Demandleistung) //Anzeigefarbe der geliferten Leistung demandleistung_display.FontColor = Color.Red; else demandleistung_display.FontColor = Color.YellowGreen; if (Statics.TurbineError) schaltplan.turbine_progressbar.Value = 0; else { if (schaltplan.turbine_progressbar.Value < Statics.Leistung) //Turbinen-Progressbar anpassen schaltplan.turbine_progressbar.Value += 9; else if (schaltplan.turbine_progressbar.Value > Statics.Istleistung) schaltplan.turbine_progressbar.Value += -9; } if (Statics.GeneratorError) schaltplan.generator_progressbar.Value = 0; else { if (schaltplan.generator_ein_btn.Checked) { if (schaltplan.generator_progressbar.Value < Statics.Istleistung) //Generator-Progressbar anpassen schaltplan.generator_progressbar.Value += 9; else if (schaltplan.generator_progressbar.Value > Statics.Istleistung) { try { schaltplan.generator_progressbar.Value += -9; } catch { schaltplan.generator_progressbar.Value = 0; } } } } #endregion #region Temperatur if (waterbox.Value > 0) { if (Statics.FilterVerstopfung < 100) { if (((Statics.P1l - ((decimal)Statics.FilterVerstopfung-20)) + (Statics.P2l - ((decimal)Statics.FilterVerstopfung-20)) + (Statics.Epl - ((decimal)Statics.FilterVerstopfung-20))) >= 100 && ((Statics.P1l - ((decimal)Statics.FilterVerstopfung-20)) + (Statics.P2l - ((decimal)Statics.FilterVerstopfung-20)) + (Statics.Epl - ((decimal)Statics.FilterVerstopfung-20))) <= 150) //Berechnung der Pumpenleistung mit Filterverschmutzung { if (Statics.Temperatur < solltemperatur) Statics.Temperatur++; else { if (Statics.Temperatur > solltemperatur) Statics.Temperatur--; } } if (((Statics.P1l - ((decimal)Statics.FilterVerstopfung-20)) + (Statics.P2l - ((decimal)Statics.FilterVerstopfung-20)) + (Statics.Epl - ((decimal)Statics.FilterVerstopfung-20))) >= 150 && ((Statics.P1l - ((decimal)Statics.FilterVerstopfung-20)) + (Statics.P2l - ((decimal)Statics.FilterVerstopfung-20)) + (Statics.Epl - ((decimal)Statics.FilterVerstopfung-20))) <= 225) { if (Statics.Temperatur > 60) { if (Statics.Temperatur < solltemperatur - 50) Statics.Temperatur += (decimal)0.8; else { if (Statics.Temperatur > solltemperatur - 50) Statics.Temperatur -= (decimal)0.8; } } else { Random rnd = new Random(); Statics.Temperatur = rnd.Next(58, 62); //Temperatur schwanken lassen } } if (((Statics.P1l - ((decimal)Statics.FilterVerstopfung-20)) + (Statics.P2l - ((decimal)Statics.FilterVerstopfung-20)) + (Statics.Epl - ((decimal)Statics.FilterVerstopfung-20))) > 225) //Temperatur { if (Statics.Temperatur > 58) { if (Statics.Temperatur < solltemperatur - 70) Statics.Temperatur += (decimal)0.8; else { if (Statics.Temperatur > solltemperatur - 70) Statics.Temperatur -= (decimal)0.8; } } else { Random rnd = new Random(); Statics.Temperatur = rnd.Next(56, 61); //Temperatur schwanken lassen } } } else Statics.Temperatur++; } else Statics.Temperatur++; Temperaturanzeige.Value = (int)Statics.Temperatur; #endregion #endregion #region GameOver Generator if(Statics.Eventname == "Synchronisieren") if(!schaltplan.generator_ein_btn.Checked) EndGame("Synchronisation nicht abgewartet und damit Stromnetz gefährdet"); #region Meltdown if (Statics.Temperatur > 1850) { WMPLib.WindowsMediaPlayerClass explosionplayer = new WMPLib.WindowsMediaPlayerClass(); explosionplayer.URL = Application.StartupPath + @"\Sounds\Explosion.mp3"; EndGame("Meltdown!"); } #endregion #region Guthaben zu gross if (Statics.Guthaben >= 9999998) { MessageBox.Show("WoW, du hast es geschafft, Gratulation! Das Guthaben ist ans Limit geraten.\n\nFalls dies die Regel ist, kontaktiere doch bitte den Autor, sodass eine Limiterhöhung vorgenommen werden kann. Danke!", "Limit erreicht", MessageBoxButtons.OK, MessageBoxIcon.Information); EndGame("Guthaben zu hoch"); } #endregion #region zu viele SCRAMs if (EMails.SCRAMcounter >= 4) { EndGame("Zu viele SCRAMs ausgelöst"); } #endregion #endregion #region HypeRep #region Checkboxen aktivieren/deaktivieren if (Statics.Pumpe1_working || !p1_technikrufen_btn.Enabled) //Wenn die Komponente nicht kaputt oder Jim bereits auf dem Weg zu ihr ist -> Checkboxen im HypeRep Fenster deaktiviern { hyperep.hyperep_kuhlwasserpumpe1_chkbx.Enabled = false; hyperep.hyperep_kuhlwasserpumpe1_chkbx.Checked = false; } else hyperep.hyperep_kuhlwasserpumpe1_chkbx.Enabled = true; if (Statics.Pumpe2_working || !p2_technikrufen_btn.Enabled) { hyperep.hyperep_kuhlwasserpumpe2_chkbx.Enabled = false; hyperep.hyperep_kuhlwasserpumpe2_chkbx.Checked = false; } else hyperep.hyperep_kuhlwasserpumpe2_chkbx.Enabled = true; if (Statics.Ersatzpumpe_working || !ep_technikrufen_btn.Enabled) { hyperep.hyperep_ersatzkuhlwasserpumpe_chkbx.Enabled = false; hyperep.hyperep_ersatzkuhlwasserpumpe_chkbx.Checked = false; } else hyperep.hyperep_ersatzkuhlwasserpumpe_chkbx.Enabled = true; if (!Statics.Steuerstaberror || !repairsteuerstab_btn.Enabled) { hyperep.hyperep_steuerstab_chkbx.Enabled = false; hyperep.hyperep_steuerstab_chkbx.Checked = false; } else hyperep.hyperep_steuerstab_chkbx.Enabled = true; if (!Statics.GeneratorError || !schaltplan.generatorrep_btn.Enabled) { hyperep.hyperep_generator_chkbx.Enabled = false; hyperep.hyperep_generator_chkbx.Checked = false; } else hyperep.hyperep_generator_chkbx.Enabled = true; if (!Statics.TurbineError || !schaltplan.turbinerep_btn.Enabled) { hyperep.hyperep_turbine_chkbx.Enabled = false; hyperep.hyperep_turbine_chkbx.Checked = false; } else hyperep.hyperep_turbine_chkbx.Enabled = true; if (!Statics.KuhlwasserNachfullPumpeError || !schaltplan.kuhlwassernachfullpumpeRep_btn.Enabled) { hyperep.hyperep_kuhlwassernachfullpumpe_chkbx.Enabled = false; hyperep.hyperep_kuhlwassernachfullpumpe_chkbx.Checked = false; } else hyperep.hyperep_kuhlwassernachfullpumpe_chkbx.Enabled = true; if (!schaltplan.filterreinigen_btn.Enabled || Statics.FilterVerstopfung <= 0) { hyperep.hyperep_filterreinigen_chkbx.Enabled = false; hyperep.hyperep_filterreinigen_chkbx.Checked = false; } else hyperep.hyperep_filterreinigen_chkbx.Enabled = true; #endregion #region Pumpenreparatur HypeRep if (Statics.Pumpe1_working) //Sicherstellen, dass die Komponenten nach der Reparatur einsatzbereit sind { pumpe1_statustimer.Enabled = true; if (pumpe1_ein_btn.Checked) { pumpe1_status.Text = "In Betrieb"; pumpe1_status.ForeColor = pumpeworking_color; } else { pumpe1_status.Text = "Außer Betrieb"; pumpe1_status.ForeColor = pumpedisabled_color; } } if (Statics.Pumpe2_working) { pumpe2_statustimer.Enabled = true; if (pumpe2_ein_btn.Checked) { pumpe2_status.Text = "In Betrieb"; pumpe2_status.ForeColor = pumpeworking_color; } else { pumpe2_status.Text = "Außer Betrieb"; pumpe2_status.ForeColor = pumpedisabled_color; } } if (Statics.Ersatzpumpe_working) { ersatzpumpe_statustimer.Enabled = true; if (ersatzpumpe_ein_btn.Checked) { ersatzpumpe_status.Text = "In Betrieb"; ersatzpumpe_status.ForeColor = pumpeworking_color; } else { ersatzpumpe_status.Text = "Außer Betrieb"; ersatzpumpe_status.ForeColor = pumpedisabled_color; } } if (!Statics.Steuerstaberror) { Statics.Steuerstaberror = false; Steuerstab_statuslabel.Text = "Normal"; Steuerstab_statuslabel.ForeColor = Color.Green; if(!emergency) steuerstab_trackbar.Enabled = true; repairsteuerstab_btn.Visible = false; repairsteuerstab_btn.Enabled = true; } #endregion #endregion }
private void LoginSounds_DoWork(object sender, DoWorkEventArgs e) { WMPLib.WindowsMediaPlayerClass player = new WMPLib.WindowsMediaPlayerClass(); player.URL = Application.StartupPath + @"\Sounds\Welcome.mp3"; }