Пример #1
0
        private void EmailLogin_OnClick(object sender, RoutedEventArgs e)
        {
            _newEmailPerson = new EmailLogin(_newEmailer);

            _newEmailPerson.ShowDialog();

            if (!string.IsNullOrEmpty(_newEmailPerson.EmailUser))
            {
            }

            try
            {
                _newEmailer = new PersonEmail(_newEmailPerson.EmailUser, _newEmailPerson.EmailPass)
                {
                    SendingTo = _newEmailPerson.SendToEmail
                };

                if (_newEmailPerson.WillSerialize)
                {
                    SerializeTask(_newEmailer, _emailInfo);
                }

                _emailer = new EmailProcess(_newEmailer.EmailAddress, _newEmailer.Password, _newEmailer.SendingTo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Email information was not entered", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
        public EmailLogin(PersonEmail savedEmail)
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            //load user info
            UsernameTxt.Text     = savedEmail.EmailAddress;
            PasswordTxt.Password = savedEmail.Password;
            SendToTxt.Text       = savedEmail.SendingTo;

            SaveLoginInfo.IsChecked = true;
        }
Пример #3
0
 private static void SerializeTask(PersonEmail savedEmail, string fileName)
 {
     try
     {
         using (Stream stream = File.Open(fileName, FileMode.Create))
         {
             BinaryFormatter bin = new BinaryFormatter();
             bin.Serialize(stream, savedEmail);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Пример #4
0
        private void DeserializeEmail(string fileName)
        {
            try
            {
                using (Stream stream = File.Open(fileName, FileMode.Open))
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    _newEmailer = (PersonEmail)bin.Deserialize(stream);
                }

                _isEmailSaved = true;
            }
            catch (Exception)
            {
                _isEmailSaved = false;
            }
        }
Пример #5
0
        public MainWindow()
        {
            InitializeComponent();

            _notifyIcon.Icon              = new Icon(Resource.notepad2, 40, 40);
            this.StateChanged            += new EventHandler(Window_Resize);
            _notifyIcon.MouseDoubleClick += new MouseEventHandler(Window_Unminimize);

            DeserializeEmail(_emailInfo); //check if saved email login exists

            //with no saved login, prompt user
            if (_isEmailSaved == false)
            {
                _newEmailPerson.ShowDialog();

                _newEmailer = new PersonEmail(_newEmailPerson.EmailUser, _newEmailPerson.EmailPass)
                {
                    SendingTo = _newEmailPerson.SendToEmail
                };

                if (_newEmailPerson.WillSerialize)
                {
                    SerializeTask(_newEmailer, _emailInfo);
                }
            }

            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            _checkTime.Elapsed  += checkTime_Elapsed;
            _checkTime.Enabled   = true;
            _emailer             = new EmailProcess(_newEmailer.EmailAddress, _newEmailer.Password, _newEmailer.SendingTo);
            _listOfTasks         = new TasksView();
            TaskList.ItemsSource = _listOfTasks;
            TaskList.Items.Refresh();
            DeserializeTasks(_taskData);

            //if (_taskData.Count() > 0) // if tasks were loaded, auto select first time
            //{
            //    TaskList.SelectedIndex = 0;
            //}
            //MessageBox.Show(System.IO.Path.GetDirectoryName(
            //    System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase));
        }