public void InitBG() { if (Map.Background != "" && !File.Exists(Map.Background)) { NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("BG_Loss_Tip_Text")); Map.Background = ""; } if (Map.Background == "") { using (var s = new MemoryStream()) { Resources.defaultBG.Save(s, ImageFormat.Png); s.Seek(0, SeekOrigin.Begin); _bgTexture = Texture2D.FromFile(device, s); } } else { using (var s = new FileStream(Map.Background, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { _bgTexture = Texture2D.FromFile(device, s); } } _bgScale = Math.Min((float)_showRect.Width / _bgTexture.Width, (float)_showRect.Height / _bgTexture.Height); _bgCenter = new Vector2((float)_bgTexture.Width / 2, (float)_bgTexture.Height / 2); }
private void Main_Tool_Export_Playlist_MP3_Click(object sender, EventArgs e) { var dialog = new FolderBrowserDialog(); if (DialogResult.OK != dialog.ShowDialog()) { return; } var worker = new BackgroundWorker(); worker.DoWork += delegate { foreach (var song in Core.PlayList) { Core.Allsets[song].SaveAudios(dialog.SelectedPath); } foreach ( var file in Directory.GetFiles(dialog.SelectedPath) .Select(filename => new FileInfo(filename)) .Where(file => file.Extension == ".bak")) { file.Delete(); } }; worker.RunWorkerCompleted += delegate { NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Save_Complete")); }; NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Saving")); worker.RunWorkerAsync(); }
private void Main_Option_Sync_QQ_Click(object sender, EventArgs e) { if (Settings.Default.SyncQQ && Settings.Default.QQuin != "0") { NotifySystem.ClearText(); } }
/// <summary> /// 初始化Set的总方法,从文件读取或从osu!.db读取 /// </summary> private static void Initset() { if (DBSupporter.LoadList() && (Allsets != null)) { Initplaylist(); } else { if (File.Exists(Path.Combine(Settings.Default.OSUpath, "osu!.db"))) { try { OsuDB.ReadDb(Path.Combine(Settings.Default.OSUpath, "osu!.db")); } catch (Exception) { NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), "Fallback client detected, reloading..."); OsuDB.ReadDb(Path.Combine(Settings.Default.OSUpath, "osu!.db"), "fallback"); } } Initplaylist(); NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), string.Format(LanguageManager.Get("Core_Init_Finish_Text"), Allsets.Count)); _needsave = true; } CurrentSet = Allsets[PlayList[0]]; CurrentBeatmap = CurrentSet.GetBeatmaps()[0]; TmpSet = CurrentSet; TmpBeatmap = CurrentBeatmap; }
private void Start() { NotifySystem.Listen(10001, ListenOne); NotifySystem.Listen(10002, ListenTwo); NotifySystem.Listen(10003, ListenThree); NotifySystem.Listen(10001, ListenOne2); NotifySystem.Listen(10001, ListenOne3); }
static void Main() { Application.SetCompatibleTextRenderingDefault(false); //设置应用程序处理异常方式:ThreadException处理 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //处理UI线程异常 Application.ThreadException += Application_ThreadException; //处理非UI线程异常 AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.EnableVisualStyles(); try { bool ret; _mutex = new Mutex(true, Application.ProductName, out ret); if (!ret) { MessageBox.Show(@"The Program is already running!", @"Tips", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.ExitThread(); return; } var filename = Assembly.GetExecutingAssembly().Location; if (File.Exists(filename + ".detele")) { File.Delete(filename + ".delete"); } if (!File.Exists("bass_fx.dll")) { if (File.Exists(Properties.Settings.Default.OSUpath + "\\bass_fx.dll")) { File.Copy(Properties.Settings.Default.OSUpath + "\\bass_fx.dll", "bass_fx.dll"); } else { MessageBox.Show(@"如果不能播放,请重新下载完整包!\nPlease re-download the full pack if it can't play!", @"Tips", MessageBoxButtons.OK, MessageBoxIcon.Information); } } Un4seen.Bass.BassNet.Registration(PrivateConfig.BassEmail, PrivateConfig.BassReg); Un4seen.Bass.AddOn.Fx.BassFx.LoadMe(); LanguageManager.InitLanguage(System.Globalization.CultureInfo.CurrentCulture.Name); /*var mainwindow = new Main(); * mainwindow.Show(); * while (mainwindow.Created) * { * Application.DoEvents(); * Core.Render(); * Thread.Sleep(5); * }*/ Application.Run(new Main()); } #region 异常处理 catch (Exception ex) { GetExceptionMsg(ex); NotifySystem.Showtip(1000, "发生了一些令人悲伤的事情><", "错误已上报,程序将试图继续运行", ToolTipIcon.Error); } }
/// <summary> /// 全局初始化 /// </summary> /// <param name="shandle">显示区域的handle</param> /// <param name="ssize">显示区域的大小</param> public static void Init(IntPtr shandle, Size ssize) { _player = new Player(shandle, ssize); NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Init_Text")); Getpath(); new Thread(Selfupdate.check_update).Start(); Initset(); _renderThread = new Thread(Render); _renderThread.Start(); }
public static void Exit() { NotifySystem.ClearText(); _player.Dispose(); if (_renderThread != null) { _renderThread.Abort(); } if (_needsave) { DBSupporter.SaveList(); } }
private void OnGUI() { GUILayout.Space(150); if (GUILayout.Button("Remove 10001")) { NotifySystem.RemoveListen(10001, ListenOne2); } if (GUILayout.Button("Remove All 10001")) { NotifySystem.RemoveListen(10001); } }
public void SetUp() { NotifySystem notifySystem = new NotifySystem(); DownLoad downLoad = new DownLoad(notifySystem); UpLoad upLoad = new UpLoad(notifySystem); downLoad.RegisterNotifier(upLoad); upLoad.UpLoadSomething(); upLoad.UpLoadSomething(); downLoad.RegisterNotifier(upLoad); downLoad = null; upLoad.UpLoadSomething(); }
private void OnGUI() { if (GUILayout.Button("Send Msg:(NotifySystem.Send (10001))")) { NotifySystem.Send(10001); } if (GUILayout.Button("Send Msg:(NotifySystem.Send (10002, \"Notify System Test...\"))")) { NotifySystem.Send(10002, "Notify System Test..."); } if (GUILayout.Button("Send Msg:(NotifySystem.Send (noticeObj))")) { INoticeObj noticeObj = new NoticeObj(10003, "Notice Object Test..."); NotifySystem.Send(noticeObj); } }
public static void PauseOrResume() { if (_player.Isplaying) { _player.Pause(); NotifySystem.ClearText(); } else { if (_player.Position == -1.0) { return; } _player.Resume(); NotifySystem.SetText(CurrentBeatmap.NameToString()); } }
public static void Play() { if (!CurrentSet.Detailed) { CurrentSet.GetDetail(); } if (!CurrentBeatmap.Detailed) { CurrentBeatmap.GetDetail(); } if (!File.Exists(CurrentBeatmap.Audio)) { NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Missing_MP3_Text")); return; } _player.Play(); NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Current_Playing_Text") + CurrentBeatmap.NameToString()); NotifySystem.SetText(CurrentBeatmap.NameToString()); }
private void Main_Mini_Switcher_Click(object sender, EventArgs e) { Visible = false; UpdateTimer.Enabled = false; _hotkeyHelper.UnregisterHotkeys(); NotifySystem.RegisterClick(null); using (var dialog = new Mini()) { dialog.ShowDialog(); } NotifySystem.RegisterClick(TaskbarIconClickHandler); _playKey = _hotkeyHelper.RegisterHotkey(Keys.F5, KeyModifiers.Alt); _prevKey = _hotkeyHelper.RegisterHotkey(Keys.Left, KeyModifiers.Alt); _nextKey = _hotkeyHelper.RegisterHotkey(Keys.Right, KeyModifiers.Alt); _hotkeyHelper.OnHotkey += OnHotkey; Main_PlayList.SelectedIndices.Clear(); int currentset = Core.CurrentSetIndex; if (currentset == -1) { currentset = 0; } Main_PlayList.SelectedIndices.Add(currentset); Main_PlayList.EnsureVisible(currentset); Main_PlayList.Focus(); Core.SetBG(); if (Core.Isplaying) { Main_Time_Trackbar.MaxValue = (int)Core.Durnation * 1000; Main_Time_Trackbar.Enabled = true; UpdateTimer.Enabled = true; Main_Play.Text = LanguageManager.Get("Main_Pause_Text"); Main_Stop.Enabled = true; } else { Main_Time_Trackbar.Enabled = false; UpdateTimer.Enabled = false; Main_Play.Text = LanguageManager.Get("Main_Play_Text"); Main_Stop.Enabled = false; } Visible = true; }
public static bool SetSet(int value, bool p = false) { TmpSet = Allsets[PlayList[value]]; if (!TmpSet.Check()) { NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Missing_Song_Text")); Remove(TmpSet.GetHash()); return(true); } if (!TmpSet.Detailed) { TmpSet.GetDetail(); } if (p) { Tmp2Current(true); } return(false); }
public static bool SetMap(int value, bool p = false) { TmpBeatmap = TmpSet.GetBeatmaps()[value]; if (!TmpBeatmap.Detailed) { TmpBeatmap.GetDetail(); } if (!File.Exists(TmpBeatmap.Audio)) { NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Missing_Song_Text")); Remove(TmpSet.GetHash()); return(true); } if (p) { Tmp2Current(false); } return(false); }
public static bool SetSet(int value, bool p = false) { TmpSet = Allsets[PlayList[value]]; if (!TmpSet.Check()) { NotifySystem.Showtip(1000, LanguageManager.Get("OSUplayer"), LanguageManager.Get("Core_Missing_Song_Text")); Remove(TmpSet.GetHash()); #if THROW throw new Exception("Set net found, text is " + TmpSet.location); #endif return(true); } if (!TmpSet.Detailed) { TmpSet.GetDetail(); } if (p) { Tmp2Current(true); } return(false); }
private void Main_Shown(object sender, EventArgs e) { CenterToScreen(); Core.Init(Main_Main_Display.Handle, Main_Main_Display.Size); SetForm(); RefreshList(); VisibleChanged += Main_VisibleChanged; SizeChanged += Main_SizeChanged; NotifySystem.RegisterClick(TaskbarIconClickHandler); Core.MainIsVisible = true; _hotkeyHelper = new HotkeyHelper(Handle); _playKey = _hotkeyHelper.RegisterHotkey(Keys.F5, KeyModifiers.Alt); _playKey1 = _hotkeyHelper.RegisterHotkey(Keys.Play, KeyModifiers.None); _playKey2 = _hotkeyHelper.RegisterHotkey(Keys.Pause, KeyModifiers.None); _prevKey = _hotkeyHelper.RegisterHotkey(Keys.Left, KeyModifiers.Alt); _prevKey1 = _hotkeyHelper.RegisterHotkey(Keys.MediaPreviousTrack, KeyModifiers.None); _nextKey = _hotkeyHelper.RegisterHotkey(Keys.Right, KeyModifiers.Alt); _nextKey1 = _hotkeyHelper.RegisterHotkey(Keys.MediaNextTrack, KeyModifiers.None); _hotkeyHelper.OnHotkey += OnHotkey; Main_Main_Display.ResumeLayout(); }
static void FacadeInvoke() { string courseName = "设计模式"; string studentName = "小明"; SelectSystem selectSystem = new SelectSystem(); NotifySystem notifySystem = new NotifySystem(); if (selectSystem.CheckAvailable(courseName)) { Console.WriteLine($"{courseName}课程已经不可选"); } else { Console.WriteLine($"{courseName}课程选择成功"); if (notifySystem.Notify(studentName)) { Console.WriteLine($"通知学生{studentName}成功"); } else { Console.WriteLine($"通知学生{studentName}失败"); } } //Facade pattern SelectCourseFacade facade = new SelectCourseFacade(); if (facade.SelectCourse(courseName, studentName)) { Console.WriteLine("成功"); } else { Console.WriteLine("失败"); } }
public UpLoad(NotifySystem notifySystem) { this.m_notifySystem = notifySystem; }
public DownLoad(NotifySystem notifySystem) { // Register for notification in IUpload this.m_notifySystem = notifySystem; m_notifySystem.Register(Notification.For<IUploadNotify>().By(typeof(UpLoad)).To(this.ListenToUpLoad).Validate(OnValidate)); }
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { GetExceptionMsg(e.Exception); NotifySystem.Showtip(1000, "发生了一些令人悲伤的事情><", "错误已上报,程序将试图继续运行", ToolTipIcon.Error); }
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { GetExceptionMsg(e.ExceptionObject as Exception); NotifySystem.Showtip(1000, "发生了一些令人悲伤的事情><", "错误已上报,程序将试图继续运行", ToolTipIcon.Error); }