コード例 #1
0
 private void saveOnlineMenuItem_Click(object sender, RoutedEventArgs e)
 {
     if (storageFile != null)
     {
         this.Cursor = Cursors.Wait;
         using (MemoryStream ms = new MemoryStream())
         {
             try
             {
                 editor.SaveFile(ms, storageFile.Title);
                 ms.Position      = 0;
                 storageFile.Body = Convert.ToBase64String(ms.ToArray());
                 MVService.UpdateFile(storageFile);
             }
             catch
             {
                 MessageBox.Show("An error occurred. File could not be uploaded", "Error!");
                 editor.Dirty = true;
             }
         }
         this.Cursor = Cursors.Arrow;
     }
     else
     {
         ProcessSaveAsOnline();
     }
 }
コード例 #2
0
        public void RefreshFileList()
        {
            this.Cursor = Cursors.Wait;
            var onlineFiles = MVService.GetFiles();

            files.Clear();
            foreach (var file in onlineFiles)
            {
                files.Add(file);
            }
            this.Cursor = Cursors.Arrow;
        }
コード例 #3
0
        private void deleteFileButton_Click(object sender, RoutedEventArgs e)
        {
            StorageFile sf = (sender as Control).DataContext as StorageFile;

            if (sf != null)
            {
                if (MessageBox.Show("Are you sure you want to delete this file.\r\n" + sf.Title, "Please confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    try
                    {
                        MVService.DeleteFile(sf.ID);
                        files.Remove(sf);
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show(exp.Message, "Error");
                    }
                }
            }
        }
コード例 #4
0
 private void loginButton_Click(object sender, EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     try
     {
         if ((MVService.Login(userNameBox.Text, passwordBox.Text, rememberCheckBox.Checked)))
         {
             this.Close();
         }
         else
         {
             errorLabel.Text = "Login failed. Please try again.";
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message, "Error");
     }
     this.Cursor = Cursors.Arrow;
 }
コード例 #5
0
        private void okButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            string name      = titleBox.Text.Trim();
            string extension = ".med";

            if (!name.EndsWith(extension))
            {
                name += extension;
            }
            if (name.Length == extension.Length)
            {
                //name = Guid.NewGuid().ToString("N") + extension;
                MessageBox.Show("Please type a name for the file", "Message");
                return;
            }
            using (MemoryStream ms = new MemoryStream())
            {
                try
                {
                    editor.SaveFile(ms, name);
                    ms.Position = 0;
                    string meXml = Convert.ToBase64String(ms.ToArray());
                    if (MVService.AddFile(name, meXml))
                    {
                        MessageBox.Show("File uploaded successfully", "Congratulations!");
                        this.Cursor = Cursors.Arrow;
                        FileSavedOnline(name);
                        this.Close();
                        return;
                    }
                }
                catch { }
            }
            editor.Dirty = true;
            MessageBox.Show("An error occurred. File could not be uploaded", "Error!");
            this.Cursor = Cursors.Arrow;
        }
コード例 #6
0
 private void registerButton_Click(object sender, EventArgs e)
 {
     if (userNameBox.Text.Trim().Length <= 0)
     {
         errorLabel.Text = "User name cannot be empty";
     }
     else if (firstNameBox.Text.Trim().Length <= 0)
     {
         errorLabel.Text = "First name cannot be empty";
     }
     else if (lastNameBox.Text.Trim().Length <= 0)
     {
         errorLabel.Text = "Last name cannot be empty";
     }
     else if (emailBox.Text.Trim().Length <= 0)
     {
         errorLabel.Text = "Email cannot be empty";
     }
     else if (!EmailIsValid(emailBox.Text.Trim()))
     {
         errorLabel.Text = "Email address format is invalid";
     }
     else if (passwordBox.Text.Length <= 0)
     {
         errorLabel.Text = "Password cannot be empty";
     }
     else if (passwordBox.Text != confirmPasswordBox.Text)
     {
         errorLabel.Text = "Password and Confirm password do not match";
     }
     else
     {
         RegisterModel registerModel = new RegisterModel()
         {
             Username        = userNameBox.Text.Trim(),
             FirstName       = firstNameBox.Text.Trim(),
             LastName        = lastNameBox.Text.Trim(),
             Email           = emailBox.Text.Trim(),
             Password        = passwordBox.Text,
             PasswordConfirm = confirmPasswordBox.Text
         };
         try
         {
             this.Cursor     = Cursors.WaitCursor;
             errorLabel.Text = "";
             RegisterResult registerResult = MVService.Register(registerModel);
             if (registerResult.Success)
             {
                 this.Close();
                 MessageBox.Show("Account registration successful.\r\nPlease check your email account for activation email.", "Congratulations");
             }
             else
             {
                 errorLabel.Text = registerResult.Message;
             }
         }
         catch (Exception exp)
         {
             MessageBox.Show(exp.Message, "An error occured");
         }
         finally
         {
             this.Cursor = Cursors.Arrow;
         }
     }
 }
コード例 #7
0
 private void logoutMenuItem_Click(object sender, RoutedEventArgs e)
 {
     MVService.Logout();
 }