Example #1
0
        /// <summary>
        /// 保存配置文件
        /// </summary>
        /// <param name="vm"></param>
        //private static void SaveConfig(TabViewModel vm)
        //{
        //    var saveDg = new System.Windows.Forms.SaveFileDialog
        //    {
        //        InitialDirectory = Directory.GetCurrentDirectory(),
        //        Filter = "(*.lmf)|*.lmf",
        //        FileName = string.Concat("untitled_", DateTime.Now.ToString("yyyyMMdd")),
        //        AddExtension = true,
        //        RestoreDirectory = true
        //    };

        //    if (saveDg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        //    {
        //        try
        //        {
        //            string iniFilePath = saveDg.FileName;
        //            File.Create(iniFilePath);

        //            OperateIniFile.WriteIniData("Settings", "SrcDir", vm.SrcDir, iniFilePath);
        //            OperateIniFile.WriteIniData("Settings", "DestDir", vm.DestDir, iniFilePath);
        //            OperateIniFile.WriteIniData("Settings", "FileFilter", vm.FileFilter, iniFilePath);
        //            OperateIniFile.WriteIniData("Settings", "ExcludeFilter", vm.ExcludeFilter, iniFilePath);
        //            OperateIniFile.WriteIniData("Settings", "Hours", vm.Hours, iniFilePath);
        //        }
        //        catch (Exception ex)
        //        {
        //            System.Windows.MessageBox.Show(ex.Message, "异常", MessageBoxButton.OK, MessageBoxImage.Error);
        //        }
        //    }
        //}

        private void HandleKeyDownEvent(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter && e.Source is TextBox tb && tb != null)
            {
                FindButton.Focus();
                Find(_vm, _container, Dispatcher);
            }
 private void MyContext_AfterPerformFind(object sender, EventArgs e)
 {
     EnableDisableControls();
     if (MyContext.SearchResultItems.Count > 0)
     {
         //ResultGrid.Focus();
         //ResultGrid.MoveFocus(new TraversalRequest(FocusNavigationDirection.Down));
         FindButton.Focus();
     }
 }
Example #3
0
 private async void EnableControls()             //called to enable the controls after the Discord Client connects
 {
     while (!Program.FirstConnectionEstablished) //while were not connected
     {
         await Task.Delay(25);                   //wait a bit
     }
     //at this point we have connected at least once
     foreach (Control ControlObj in this.Controls) //for all of the controls in the form
     {
         ControlObj.Enabled = true;                //enable the control
     }
     FindButton.Focus();
 }
Example #4
0
 private async void EnableControls()
 {
     while (!FirstConnectionEstablished)
     {
         await Task.Delay(25);
     }
     foreach (Control ControlObj in this.Controls)
     {
         ControlObj.Enabled = true;
     }
     FindButton.Focus();
     YoutubeGetButton.Enabled = false;
     YoutubeBox.Enabled       = false;
 }
Example #5
0
 } // Window_MouseMove
 
 /// <summary>
 /// On Check button click gets id and checks whether such id exists
 /// </summary>
 /// <param name="sender">event source</param>
 /// <param name="e">event parametres</param>
 private void CheckButton_Click(object sender, RoutedEventArgs e)
 {
     // If not logged in remember about it
     if (token == null || currentUser == null)
     {
         ErrorText.Foreground = new SolidColorBrush(Color.FromRgb(223, 0, 0));
         LoginButton.Focus();
         System.Media.SystemSounds.Exclamation.Play();
         return;
     } // if (token == null || currentUser == null)
     // Send request
     string req = "https://api.vk.com/method/users.get.xml?";
     req += "uids=" + FindIDTextBox.Text + "&fields=first_name,last_name&access_token=" + token;
     WebRequest request = WebRequest.Create(req);
     WebResponse response = request.GetResponse();
     XmlDocument xml = new XmlDocument();
     xml.LoadXml(new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd());
     // If there is an error in response show it for user
     if (xml["error"] != null)
     {
         string errorCode = xml["error"]["error_code"].InnerText;
         ErrorText.Content = "Шаг 2: введите адрес и нажмите Проверить";
         System.Media.SystemSounds.Exclamation.Play();
         // If there was earlier finded user delete him
         searchedUser = null;
         // Show info about error
         switch (errorCode)
         {
             case "113": MessageBox.Show("Такой страницы не существует", "Ошибка");
                 ErrorText.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0)); return;
             case "6": MessageBox.Show("Сервер перегружен запросами, повторите попытку через несколько секунд", "Ошибка"); return;
             case "5": MessageBox.Show("Ошибка авторизации. Попробуйте войти еще раз", "Ошибка");
                 ErrorText.Content = "Шаг 1: войдите ВКонтакте, нажав Войти"; token = null; currentUser = null;
                 LoginButton.Focus(); return;
             case "4": goto case "5";
             case "2": MessageBox.Show("Приложение отключено. Попробуйте повторить попытку через несколько минут", "Ошибка"); return;
             default: MessageBox.Show("ВКонтакте сообщил о неизвестной ошибке. Попробуйте еще раз", "Ошибка"); return;
         } // switch (errorCode)
     } // if (xml["error"] != null)
     // If user is DELETED there is no such user
     if (xml["response"]["user"]["first_name"].InnerText == "DELETED" &&
         xml["response"]["user"]["last_name"].InnerText == "")
     {
         System.Media.SystemSounds.Exclamation.Play();
         MessageBox.Show("Такой страницы не существует", "Ошибка");
         ErrorText.Content = "Шаг 2: введите адрес и нажмите Проверить";
         ErrorText.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
         // If there was earlier finded user delete him
         searchedUser = null;
     } // if first_name == DELETED && last_name == ""
     // save finded user and go to step 3
     else
     {
         searchedUser = new User(xml["response"]["user"]);
         ErrorText.Content = "Шаг 3: нажмите Найти путь";
         ErrorText.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
         MessageBox.Show(xml["response"]["user"]["first_name"].InnerText +
             " " + xml["response"]["user"]["last_name"].InnerText, "Пользователь найден");
         FindButton.Focus();
     } // if !(if first_name == DELETED && last_name == "")
 } // CheckButton_Click