Exemplo n.º 1
0
        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);
            };
        }
Exemplo n.º 2
0
        private void RemoveHook()
        {
            SetTitle(MainWindow.m_AppName);
            m_Source.RemoveHook(WndProc);
            isHooked = false;

            AniDBAPI.AppendDebugLine("MPC-HC hook removed");
        }
Exemplo n.º 3
0
 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();
     }
 }
Exemplo n.º 4
0
        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
        }
Exemplo n.º 5
0
        private void RemoveFromList_Click(object sender, RoutedEventArgs e)
        {
            FileEntry fEntry = (FileEntry)(sender as MenuItem).Tag;

            if (m_aniDBAPI.MyListDel(fEntry.lid))
            {
                if (!String.IsNullOrEmpty(fEntry.path))
                {
                    AniDBAPI.AppendDebugLine(String.Format("Removed {0} from mylist.", Path.GetFileName(fEntry.path)));
                }

                m_myList.DeleteFile(fEntry.lid);
                MylistTreeListView.Refresh();
            }
        }
Exemplo n.º 6
0
 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();
     }
 }
Exemplo n.º 7
0
        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
        }
Exemplo n.º 8
0
        public MainWindow(AniDBAPI api)
        {
            m_aniDBAPI = api;
            AniDBAPI.AppendDebugLine("Welcome to AniDBmini, connected to: " + m_aniDBAPI.APIServer);

            InitializeComponent();

            SetMylistVisibility();

            m_mpcProcWatcher = new MPCProcWatcher();
            m_mpcProcWatcher.OnMPCStarted += new MPCStartedHandler(OnMPCStarted);
            m_mpcProcWatcher.StartUp();

            mylistStats.ItemsSource     = mylistStatsList;
            debugListBox.ItemsSource    = m_aniDBAPI.DebugLog;
            hashingListBox.ItemsSource  = hashFileList;
            animeTabControl.ItemsSource = animeTabList;

            animeTabList.OnCountChanged += new CountChangedHandler(animeTabList_OnCountChanged);

            m_aniDBAPI.OnFileHashingProgress += new FileHashingProgressHandler(OnFileHashingProgress);
            m_aniDBAPI.OnAnimeTabFetched     += new AnimeTabFetchedHandler(OnAnimeTabFetched);
            m_aniDBAPI.OnFileInfoFetched     += new FileInfoFetchedHandler(OnFileInfoFetched);
        }
Exemplo n.º 9
0
        public MainWindow(AniDBAPI api)
        {
            m_aniDBAPI = api;
            AniDBAPI.AppendDebugLine("Welcome to AniDBmini, connected to: " + m_aniDBAPI.APIServer);

            InitializeComponent();

            SetMylistVisibility();

            m_mpcProcWatcher = new MPCProcWatcher();
            m_mpcProcWatcher.OnMPCStarted += new MPCStartedHandler(OnMPCStarted);
            m_mpcProcWatcher.StartUp();

            mylistStats.ItemsSource = mylistStatsList;
            debugListBox.ItemsSource = m_aniDBAPI.DebugLog;
            hashingListBox.ItemsSource = hashFileList;
            animeTabControl.ItemsSource = animeTabList;

            animeTabList.OnCountChanged += new CountChangedHandler(animeTabList_OnCountChanged);

            m_aniDBAPI.OnFileHashingProgress += new FileHashingProgressHandler(OnFileHashingProgress);
            m_aniDBAPI.OnAnimeTabFetched += new AnimeTabFetchedHandler(OnAnimeTabFetched);
            m_aniDBAPI.OnFileInfoFetched += new FileInfoFetchedHandler(OnFileInfoFetched);
        }