private void timer_Callback(object state) { if (this.m_adTrack == null) { return; } var si = new SongInfo(this); if (this.Get(si, IntPtr.Zero, this.m_adTrack)) { DecchiCore.Run(si); } }
public static void DefaultADCallback(object args) { var rule = (IParseRule)args; var si = rule.GetFromPlayer(null); if (si != null) { // 같은 곡이 아님 if (IParseRule.m_befTitle != si.Title) { DecchiCore.Run(si); } IParseRule.m_befTitle = si.Title; } rule.m_timer.Change(IParseRule.RefreshTimeSpan, 0); }
public async void ShowSelectWindow() { this.ShowWindow(); var songinfo = (SongInfo)(await this.ShowBaseMetroDialog(new ClientSelectionDialog(this))); if (songinfo != null && !await Task.Factory.StartNew <bool>(new Func <bool>(() => TwitterCommunicator.Instance.Publish(songinfo)))) { MainWindow.Instance.PublishError(); } SongInfo.AllClear(); this.SetButtonState(true); DecchiCore.Sync(); if (DecchiCore.IsRunOnBackground) { WindowState = WindowState.Minimized; } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// WPF Binding 에서 프로퍼티 수정했을때 콜백되는 함수 /// </summary> private static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { var globals = (Globals)d; if (e.Property == PublishFormatProp) { if (string.IsNullOrWhiteSpace(e.NewValue as string)) { globals.SetValue(PublishFormatProp, SongInfo.defaultFormat); } else { globals.m_publishFormat = (string)e.NewValue; } } else if (e.Property == UseShortcutProp || e.Property == ShortcutProp) { DecchiCore.HookSetting(); } else if (e.Property == WinStartupProp) { if ((bool)e.NewValue) { using (var reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) reg.SetValue("Decchi", App.ExePath); } else { using (var reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) reg.DeleteValue("Decchi"); } } else if (e.Property == WBDetailSearchProp) { globals.m_wbDetailSearch = (bool)e.NewValue; } else if (e.Property == TopMostProp && MainWindow.Instance != null) { MainWindow.Instance.Topmost = (bool)e.NewValue; } else if (e.Property == WindowOpacityProp && MainWindow.Instance != null) { MainWindow.Instance.Opacity = (double)e.NewValue; } else if (e.Property == SkipFullscreenProp) { globals.m_skipFullscreen = (bool)e.NewValue; } else if (e.Property == AutoSelectProp) { globals.m_autoSelect = (bool)e.NewValue; } else if (e.Property == AutoDecchiProp) { var oldValue = e.OldValue as IParseRule; if (oldValue != null) { oldValue.DisableAD(); } var newValue = e.NewValue as IParseRule; if (newValue != null) { newValue.EnableAD(); } DecchiCore.DisableKeyEvent = newValue != null; if (MainWindow.Instance != null) { MainWindow.Instance.Dispatcher.Invoke(new Action <bool>(MainWindow.Instance.SetButtonState), false); } } }
private async void MetroWindow_Loaded(object sender, RoutedEventArgs e) { // 왜인지 몰라도 Login 함수에 async 시켜서 실행하면 씹고 다음라인 실행하더라 if (!DecchiCore.Login()) { this.ToNormalMode(); var requestToken = await Task.Factory.StartNew <OAuth.TokenPair>(TwitterCommunicator.Instance.OAuth.RequestToken); Globals.OpenWebSite("https://api.twitter.com/oauth/authorize?oauth_token=" + requestToken.Token); var key = await MainWindow.Instance.ShowBaseMetroDialog(new VerifierDialog(this)) as string; if (string.IsNullOrWhiteSpace(key)) { await this.ShowMessageAsync("X(", "트위터에 로그인 하지 못했어요"); Application.Current.Shutdown(); return; } TwitterCommunicator.Instance.OAuth.User.Token = requestToken.Token; TwitterCommunicator.Instance.OAuth.User.Secret = requestToken.Secret; var userToken = await Task.Factory.StartNew <OAuth.TokenPair>(new Func <OAuth.TokenPair>(() => TwitterCommunicator.Instance.OAuth.AccessToken(key))); if (userToken == null) { await this.ShowMessageAsync("X(", "트위터에 로그인 하지 못했어요"); Application.Current.Shutdown(); return; } Globals.Instance.TwitterToken = TwitterCommunicator.Instance.OAuth.User.Token = userToken.Token; Globals.Instance.TwitterSecret = TwitterCommunicator.Instance.OAuth.User.Secret = userToken.Secret; Globals.Instance.SaveSettings(); } // 두개 병렬처리 var thdTwitter = Task.Factory.StartNew <TwitterUser>(TwitterCommunicator.Instance.RefrashMe); var thdUpdate = Task.Factory.StartNew(new Func <bool>(() => App.CheckNewVersion(out m_updateUrl))); // 폼에 트위터 유저 정보 매핑 var me = await thdTwitter; if (me == null) { this.ToNormalMode(); await this.ShowMessageAsync("X(", "트위터에서 정보를 가져오지 못했어요"); Globals.Instance.TwitterToken = null; Globals.Instance.TwitterSecret = null; Globals.Instance.SaveSettings(); Application.Current.Shutdown(); return; } this.ctlName.Text = me.Name; this.ctlScreenName.Text = "@" + me.ScreenName; var image = new BitmapImage(); image.CacheOption = BitmapCacheOption.OnDemand; image.CreateOptions = BitmapCreateOptions.DelayCreation; image.BeginInit(); image.UriSource = new Uri(me.ProfileImageUrl.Replace("_normal", "")); image.EndInit(); image.DownloadCompleted += (ls, le) => { this.ctlShowSetting.IsEnabled = true; this.ctlToNormalMode.IsEnabled = true; this.ctlElements.Visibility = Visibility.Visible; this.ctlShowPlugin.IsEnabled = true; this.ctlPluginsList.ItemsSource = IParseRule.RulesPipe; DecchiCore.Inited(); }; this.ctlProfileImage.ImageSource = image; // 패치노트 읽을 것인지 물어봄 if (App.ShowPatchNote && !Globals.Instance.MiniMode) { if (await this.ShowMessageAsync(": )", "이번 패치노트 읽어볼래요?", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "좋아요!", NegativeButtonText = "됐어요:(" }) == MessageDialogResult.Affirmative) { Globals.OpenWebSite(string.Format("https://github.com/Usagination/Decchi/releases/tag/{0}", App.Version)); } } // 업데이트를 확인함 this.m_updatable = await thdUpdate; if (this.m_updatable && !Globals.Instance.MiniMode) { this.ctlUpdate.Visibility = Visibility.Visible; } }
private void ctlTweet_Click(object sender, RoutedEventArgs e) { DecchiCore.Run(); }