コード例 #1
0
ファイル: editnote_page.xaml.cs プロジェクト: whzvee/evennote
        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);
                }
            }
        }
コード例 #2
0
ファイル: notes_page.xaml.cs プロジェクト: whzvee/evennote
 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);
     }
 }
コード例 #3
0
ファイル: login_page.xaml.cs プロジェクト: whzvee/evennote
        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);
            }
        }
コード例 #4
0
ファイル: regist_page.xaml.cs プロジェクト: whzvee/evennote
 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 { }
 }
コード例 #5
0
ファイル: regist_page.xaml.cs プロジェクト: whzvee/evennote
        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");
        }
コード例 #6
0
ファイル: editnote_page.xaml.cs プロジェクト: whzvee/evennote
        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);
        }
コード例 #7
0
ファイル: notes_page.xaml.cs プロジェクト: whzvee/evennote
        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;
        }
コード例 #8
0
ファイル: search_page.xaml.cs プロジェクト: whzvee/evennote
        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);
        }
コード例 #9
0
ファイル: login_page.xaml.cs プロジェクト: whzvee/evennote
        //Проверяем поставленные чекбоксы (если 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;
                }
            }
        }