private void open_button_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); openFileDialog1.Filter = @"Evennote File(*.note)|*.note"; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == true) { Note temp = Evennote.OpenNoteFromFile(openFileDialog1.FileName); titleTextBox.Text = temp.Title; using (MemoryStream mem = new MemoryStream()) { TextRange range = new TextRange(temp.Text.ContentStart, temp.Text.ContentEnd); range.Save(mem, DataFormats.XamlPackage); mem.Position = 0; TextRange kange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd); kange.Load(mem, DataFormats.XamlPackage); } } }
private void sendnote_btn_Click(object sender, RoutedEventArgs e) { try { Evennote.SyncNotes(); //Dispatcher.BeginInvoke(new ThreadStart(Evennote.SyncNotes)); //Executes the specified delegate asynchronously with the specified arguments, at the specified priority, on the thread that the Dispatcher was created on. RefreshStatusBackup(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button_Click(object sender, RoutedEventArgs e) { if (Evennote.OfflineMode) { if (!Directory.Exists(String.Format("C:\\Users\\{0}\\Documents\\evennote\\{1}\\", Environment.UserName, login.Text))) { return; } Evennote.SetUserDirectory(login.Text); //Считываем с диска существующие заметки Notebook.LoadNotes(); (Application.Current.MainWindow as MainWindow).ChangePage("pages/menu_page.xaml"); return; } string pass = password.Password; try { //Если авторизация успешна то.. if (Evennote.Authorization(login.Text, password.Password)) { //Пересылаем окно на страницу меню приложения (Application.Current.MainWindow as MainWindow).ChangePage("pages/menu_page.xaml"); //Создаем пользовательскую директорию Evennote.SetUserDirectory(login.Text); //Считываем с диска существующие заметки Notebook.LoadNotes(); Evennote.user.online = true; //Сохраняем логин пароль для автовхода if (checkBox.IsChecked.Value) { Evennote.WriteConfigFile(login.Text + " " + pass, "3v3nn0t3"); } } else { MessageBox.Show("Login or password incorrect."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void selectbutton_Click(object sender, RoutedEventArgs e) { try { using (FileStream fs = new FileStream(Evennote.OpenImageInWindow().ToString().Remove(0, 8), FileMode.Open, FileAccess.Read)) { imagelabel.Content = fs.Name.Split('\\').Last(); image = new byte[fs.Length]; fs.Read(image, 0, (int)fs.Length); fs.Close(); } } catch { } }
private void button_Click(object sender, RoutedEventArgs e) { Regex x = new Regex(@"^[\w.]+@\w+[.]\w+$"); if (login.Text == "login" || password.Password == "password" || password.Password != repeat_password.Password || datepicker.SelectedDate == null || email.Text == "*****@*****.**" || !x.IsMatch(email.Text)) { MessageBox.Show("Something wrong!", "Error!"); return; } Evennote.Registration(login.Text, password.Password, datepicker.SelectedDate.Value, email.Text, image); (Application.Current.MainWindow as MainWindow).ChangePage("pages/login_page.xaml"); }
private void open_image_button(object sender, RoutedEventArgs e) { BitmapFrame image = Evennote.OpenImageInWindow(); if (image == null) { return; } var temp = Clipboard.GetDataObject(); Clipboard.SetImage(image); richTextBox.Paste(); Clipboard.Clear(); Clipboard.SetDataObject(temp); }
public void RefreshStatusBackup() { int temp = Evennote.GetCountNotesFromDB(); string result = ""; if (temp == -1) { result = "You are offline."; } else { result = String.Format("Backup: {0}", temp); } statusBackup.Content = result; }
private void searchBtn_Click(object sender, RoutedEventArgs e) { //Если пользователь ищет сам себя, просто перенаправляем его на страницу своего профиля. if (textBox.Text == Evennote.user.username) { Evennote.contextUser = Evennote.user; ((Application.Current.MainWindow as MainWindow).mainframe.Content as menu_page).frame.Source = new Uri("profile_page.xaml", UriKind.Relative); return; } Evennote.contextUser = Evennote.GetUserData(textBox.Text); if (Evennote.contextUser == null) { MessageBox.Show("User " + textBox.Text + " not exist!"); return; } ((Application.Current.MainWindow as MainWindow).mainframe.Content as menu_page).frame.Source = new Uri("profile_page.xaml", UriKind.Relative); }
//Проверяем поставленные чекбоксы (если remember me == true то авторизируем пользователя) private void Page_Initialized(object sender, EventArgs e) { if (!File.Exists(Evennote.ConfigFile)) { if (Evennote.AutoLogin) { Evennote.SetConfigurateFile(); } return; } else { checkBox.IsChecked = true; string config = Evennote.ReadConfigFile("3v3nn0t3"); if (config.Equals("")) { return; } try { if (Evennote.Authorization(config.Split(' ').First(), config.Split(' ').Last())) { (Application.Current.MainWindow as MainWindow).ChangePage("pages/menu_page.xaml"); Evennote.SetUserDirectory(config.Split(' ').First()); Evennote.user.online = true; //Считываем с диска существующие заметки Notebook.LoadNotes(); } else { MessageBox.Show("Login or password incorrect."); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } }