Example #1
0
 private static void SerializeTask(TasksView listOfTasksSerialize, string fileName)
 {
     try
     {
         using (Stream stream = File.Open(fileName, FileMode.Create))
         {
             BinaryFormatter bin = new BinaryFormatter();
             bin.Serialize(stream, listOfTasksSerialize);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Example #2
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));
        }
Example #3
0
 private void DeserializeTasks(string fileName)
 {
     try
     {
         if (File.Exists(fileName))
         {
             using (Stream stream = File.Open(fileName, FileMode.Open))
             {
                 BinaryFormatter bin = new BinaryFormatter();
                 _listOfTasks         = (TasksView)bin.Deserialize(stream);
                 TaskList.ItemsSource = _listOfTasks;
                 TaskList.Items.Refresh();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }