private void LoadOptions() { adbmUsernameTextBox.Text = ConfigFile.Read("username").ToString(); adbmPasswordPasswordBox.Password = ConfigFile.Read("password").ToString(); adbmLocalPortTextBox.Text = ConfigFile.Read("localPort").ToString(); adbmAutoLoginCheckBox.IsChecked = ConfigFile.Read("autoLogin").ToBoolean(); adbmRememberUserCheckBox.IsChecked = ConfigFile.Read("rememberUser").ToBoolean(); MPCAPI.MPC_WATCHED mpcMarkedWatched = (MPCAPI.MPC_WATCHED)ConfigFile.Read("mpcMarkWatched").ToInt32(); mpchcLocationTextBox.Text = ConfigFile.Read("mpcPath").ToString(); if (mpcMarkedWatched == MPCAPI.MPC_WATCHED.AFTER_FINISHED) { mpcMarkAfter.IsChecked = true; } else if (mpcMarkedWatched == MPCAPI.MPC_WATCHED.DURING_TICKS) { mpcMarkDuring.IsChecked = true; } mpcWatchedPercSlider.Value = ConfigFile.Read("mpcMarkWatchedPerc").ToInt32(); mpcShowFileInTitle.IsChecked = ConfigFile.Read("mpcShowTitle").ToBoolean(); mpcShowWatchedOSD.IsChecked = ConfigFile.Read("mpcShowOSD").ToBoolean(); mpcClose.IsChecked = ConfigFile.Read("mpcClose").ToBoolean(); mpcOSDPos.SelectedIndex = ConfigFile.Read("mpcOSDPos").ToInt32() - 1; mpcOSDDurMS.SelectedIndex = ConfigFile.Read("mpcOSDDurMS").ToInt32() / 1000 - 1; }
public MPCAPI(MainWindow main) { m_MainWindow = main; m_hWnd = new WindowInteropHelper(m_MainWindow).Handle; m_Source = HwndSource.FromHwnd(m_hWnd); m_Source.AddHook(WndProc); AniDBAPI.AppendDebugLine("MPC-HC hook added"); using (Process MPC = new Process()) { MPC.StartInfo = new ProcessStartInfo(ConfigFile.Read("mpcPath").ToString(), String.Format("/slave {0}", m_hWnd.ToInt32())); MPC.Start(); m_mpcProcID = MPC.Id; } m_PlayTimer = new DispatcherTimer(); m_PlayTimer.Interval = TimeSpan.FromMilliseconds(1000); m_PlayTimer.Tick += delegate { ++m_currentFileTick; SendData(MPCAPI_SENDCOMMAND.CMD_GETCURRENTPOSITION, String.Empty); }; }
public void LoadConfig() { m_watchedWhen = (MPC_WATCHED)ConfigFile.Read("mpcMarkWatched").ToInt32(); m_watchedWhenPerc = ConfigFile.Read("mpcMarkWatchedPerc").ToInt32() * .01; m_ShowInFileTitle = ConfigFile.Read("mpcShowTitle").ToBoolean(); m_OSDMSGPos = (OSD_MESSAGEPOS)ConfigFile.Read("mpcOSDPos").ToInt32(); m_OSDMSGDur = ConfigFile.Read("mpcOSDDurMS").ToInt32(); }
private void OnClose(object sender, System.ComponentModel.CancelEventArgs e) { if (ConfigFile.Read("mpcClose").ToBoolean() && m_mpcAPI != null && m_mpcAPI.isHooked) { m_mpcAPI.CloseMPC(); } m_myList.Close(); m_aniDBAPI.Logout(); m_notifyIcon.Dispose(); m_notifyIcon = null; }
private void loginButton_Click(object sender, RoutedEventArgs e) { if (usernameTextBox.Text == String.Empty || !System.Text.RegularExpressions.Regex.IsMatch(usernameTextBox.Text, @"^[A-z0-9_-]+$") || passwordPasswordBox.Password == String.Empty) { MessageBox.Show("Enter a valid username and password!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } loginButton.IsEnabled = false; string[] server = serverComboBox.SelectionBoxItem.ToString().Split(':'); #if !DEBUG if ((m_aniDB = new AniDBAPI(server[0], int.Parse(server[1]), ConfigFile.Read("localPort").ToInt32())).isConnected && m_aniDB.Login(usernameTextBox.Text, passwordPasswordBox.Password)) { #endif if (autoLoginCheckBox.IsChecked == true) { ConfigFile.Write("autoLogin", "True"); ConfigFile.Write("rememberUser", "True"); ConfigFile.Write("username", usernameTextBox.Text); ConfigFile.Write("password", passwordPasswordBox.Password); ConfigFile.Write("server", server[0]); ConfigFile.Write("port", server[1]); } else if (rememberUserCheckBox.IsChecked == true) { ConfigFile.Write("rememberUser", "True"); ConfigFile.Write("username", usernameTextBox.Text); } else { ConfigFile.Write("autoLogin", "False"); ConfigFile.Write("rememberUser", "False"); ConfigFile.Write("username", string.Empty); ConfigFile.Write("password", string.Empty); } StartMainWindow(); #if !DEBUG } else { loginButton.IsEnabled = true; } #endif }
private void OnInitialized(object sender, EventArgs e) { if (ConfigFile.Read("autoLogin").ToBoolean() && (m_aniDB = new AniDBAPI(ConfigFile.Read("server").ToString(), ConfigFile.Read("port").ToInt32(), ConfigFile.Read("localPort").ToInt32())).isConnected && m_aniDB.Login(ConfigFile.Read("username").ToString(), ConfigFile.Read("password").ToString())) { StartMainWindow(); } else if (ConfigFile.Read("rememberUser").ToBoolean()) { rememberUserCheckBox.IsChecked = true; usernameTextBox.Text = ConfigFile.Read("username").ToString(); } }
/// <summary> /// Launches or focuses MPC-HC. /// </summary> private void mpchcLaunch(object sender, RoutedEventArgs e) { if (m_mpcAPI == null || !m_mpcAPI.isHooked || !m_mpcAPI.FocusMPC()) { if (File.Exists(ConfigFile.Read("mpcPath").ToString())) { m_mpcAPI = new MPCAPI(this); m_mpcAPI.OnFileWatched += new FileWatchedHandler(OnFileWatched); } else if (MessageBox.Show("Please ensure you have located the mpc-hc executable inside the options.\nWould you like to set mpc-hc's location now?", "Media Player Classic - Home Cinema not found!", MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes && SetMPCHCLocation()) { mpchcLaunch(sender, e); } } }
/// <summary> /// Adds completed hash item to mylist. /// </summary> private void FinishHash(HashItem item) { ppSize += item.Size; if (item.FromMPC) { m_aniDBAPI.MyListAdd(item); if (ConfigFile.Read("mpcShowOSD").ToBoolean() && m_mpcAPI != null && m_mpcAPI.isHooked) { m_mpcAPI.OSDShowMessage(String.Format("{0}: File marked as watched{1}", m_AppName, m_mpcAPI.CurrentFileName != item.Name ? String.Format(", ({0})", item.Name) : String.Empty)); } } else if (addToMyListCheckBox.IsChecked == true) { item.Watched = (bool)watchedCheckBox.IsChecked; item.State = stateComboBox.SelectedIndex; m_aniDBAPI.MyListAdd(item); } }
/// <summary> /// Load current config file settings. /// </summary> private void InitializeConfig() { m_aLang = ConfigFile.Read("aLang").ToString(); m_eLang = ConfigFile.Read("eLang").ToString(); }