private void randomExcuse_Click(object sender, EventArgs e)
 {
     string[] fileNames = Directory.GetFiles(selectedFolder, "*.excuse");
     if (fileNames.Length == 0)
     {
         MessageBox.Show("Please specify a folder with excuse files in it",
                         "No excuse files found");
     }
     else
     {
         try
         {
             if (CheckChanged() == true)
             {
                 currentExcuse = new Excuse(random, selectedFolder);
             }
         }
         catch (SerializationException)
         {
             currentExcuse             = new Excuse();
             currentExcuse.Description = "";
             currentExcuse.Results     = "";
             currentExcuse.LastUsed    = DateTime.Now;
             MessageBox.Show(
                 "Your excuse file was invalid.",
                 "Unable to open a random excuse");
         }
         finally
         {
             UpdateForm(false);
         }
     }
 }
 private void randomButton_Click(object sender, EventArgs e)
 {
     if (checkChanged())
     {
         currentExcuse = new Excuse(random, excusePath);
     }
     updateForm(false);
 }
Exemple #3
0
 private void btnRandom_Click(object sender, RoutedEventArgs e)
 {
     if (CheckChanged())
     {
         currentExcuse = new Excuse(random, folderName);
         UpdateForm(false);
     }
 }
Exemple #4
0
 private void button_Random_Click(object sender, EventArgs e)
 {
     if (this.CheckChanged())
     {
         Excuse _excuse = new Excuse(selectedFolder, true);
         UpdateForm(_excuse);
     }
 }
Exemple #5
0
 private void buttonRandom_Click(object sender, EventArgs e)
 {
     if (CheckChengen())
     {
         currentExcuse = new Excuse(random, folderPath);
         UpdateForm(false);
     }
 }
Exemple #6
0
 private void btRandom_Click(object sender, EventArgs e)
 {
     if(CheckChanged())
     {
         currentExcuse = new Excuse(random, currentFolder);
         UpdateForm(false);
     }
 }
 private void randomButton_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         currentExcuse = new Excuse(random, selectedFolder);
         UpdateForm(false);
     }
 }
 public Form1()
 {
     InitializeComponent();
     currentExcuse          = new Excuse();
     currentExcuse.LastUsed = date.Value;
     formChanged            = false;
     excusePath             = "";
 }
 public Form1()
 {
     InitializeComponent();
     selectedFolder         = @"C:\Temp\Excuse manager";
     random                 = new Random();
     currentExcuse          = new Excuse();
     currentExcuse.LastUsed = lastUsed.Value;
     UpdateForm(formChanged);
 }
 public FormExcuseManager()
 {
     InitializeComponent();
     _currentExcuse = new Excuse
     {
         Description = txtDescription.Text,
         Results     = txtResults.Text,
         LastUsed    = dtpLastUsed.Value
     };
 }
Exemple #11
0
        private void randomExcuse_Click(object sender, EventArgs e)
        {
            if (!Continue())
            {
                return;
            }

            currentExcuse = new Excuse(selectedFolder, random);
            currentExcuse.OpenFile(currentExcuse.ExcusePath);
            UpdateForm(false);
        }
 public static bool checkSavedExcuse(Excuse lastSavedExcuse, Excuse currentExcuse)
 {
     if (lastSavedExcuse.Explanation == currentExcuse.Explanation &&
         lastSavedExcuse.Reaction == currentExcuse.Reaction &&
         lastSavedExcuse.DataDate == currentExcuse.DataDate &&
         lastSavedExcuse.LastUsed == currentExcuse.LastUsed)
     {
         return(true);
     }
     return(false);
 }
Exemple #13
0
 private void buttonRandom_Click(object sender, EventArgs e)
 {
     if (Directory.GetFiles(folder).Length == 0)
     {
         MessageBox.Show("There are no excuse files in the selected folder.");
     }
     else if (CheckChanged())
     {
         currentExcuse = new Excuse(random, folder);
         UpdateForm(false);
     }
 }
Exemple #14
0
 private void UpdateForm(Excuse _excuse)
 {
     this.textBox_Excuse.Text           = _excuse.Description;
     this.textBox_Result.Text           = _excuse.Results;
     this.dateTimePicker_LastUsed.Value = _excuse.LastUsed;
     if (!String.IsNullOrEmpty(_excuse.ExcusePath))
     {
         label_FileDate.Text = File.GetLastWriteTime(_excuse.ExcusePath).ToString();
     }
     this.Text        = "Excuse MAnager";
     this.formChanged = false;
 }
Exemple #15
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            Excuse _excuse = new Excuse(this.textBox_Excuse.Text,
                                        this.textBox_Result.Text,
                                        this.dateTimePicker_LastUsed.Value
                                        );

            _excuse.Save(selectedFolder);
            this.Text        = "Excuse Manager";
            this.formChanged = false;
            MessageBox.Show("Excuse written");
        }
Exemple #16
0
 private void btLoad_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         ofdOpen.InitialDirectory = currentFolder;
         ofdOpen.FileName = currentExcuse.CurrentDescription;
         if (ofdOpen.ShowDialog() == DialogResult.OK)
         {
             currentExcuse = new Excuse(ofdOpen.FileName);
             UpdateForm(false);
         }
     }
 }
Exemple #17
0
 private void buttonOpen_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         openFileDialog1.InitialDirectory = folder;
         saveFileDialog1.Filter           = "Excuse files (*.excuse)|*.excuse|All files (*.*)|*.*";
         DialogResult result = openFileDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             currentExcuse = new Excuse(openFileDialog1.FileName);
             UpdateForm(false);
         }
     }
 }
 private void openButton_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         openFileDialog1.InitialDirectory = selectedFolder;
         openFileDialog1.Filter           = "Dat files (*.dat)|*.dat|All files (*.*)|*.*";
         openFileDialog1.FileName         = description.Text + ".dat";
         DialogResult result = openFileDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             currentExcuse = new Excuse(openFileDialog1.FileName);
             UpdateForm(false);
         }
     }
 }
Exemple #19
0
 private void btnOpen_Click(object sender, RoutedEventArgs e)
 {
     if (CheckChanged())
     {
         OpenFileDialog dlg = new OpenFileDialog();
         dlg.InitialDirectory = folderName;
         dlg.Filter           = "Text documents (.txt)|*.txt|All files (*.*)|*.*";
         var result = dlg.ShowDialog();
         if (result == true)
         {
             currentExcuse = new Excuse(dlg.FileName);
             UpdateForm(false);
         }
     }
 }
Exemple #20
0
 private void open_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         openFileDialog1.InitialDirectory = selectedFolder;
         openFileDialog1.Filter =
           "Excuse files (*.excuse)|*.excuse|All files (*.*)|*.*";
         openFileDialog1.FileName = description.Text + ".txt";
         DialogResult result = openFileDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             currentExcuse = new Excuse(openFileDialog1.FileName);
             UpdateForm(false);
         }
     }
 }
 private void open_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         openFileDialog1.InitialDirectory = selectedFolder;
         openFileDialog1.Filter           =
             "Excuse files (*.excuse)|*.excuse|All files (*.*)|*.*";
         openFileDialog1.FileName = description.Text + ".excuse";
         DialogResult result = openFileDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             bool clearForm = false;
             try
             {
                 currentExcuse = new Excuse(openFileDialog1.FileName);
                 try
                 {
                     UpdateForm(false);
                 }
                 catch (ArgumentOutOfRangeException)
                 {
                     MessageBox.Show("The excuse file ‘"
                                     + openFileDialog1.FileName + "’ had a invalid data",
                                     "Unable to open the excuse");
                     clearForm = true;
                 }
             }
             catch (SerializationException ex)
             {
                 MessageBox.Show("An error occurred while opening the excuse ‘"
                                 + openFileDialog1.FileName + "’\n" + ex.Message,
                                 "Unable to open the excuse", MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);
                 clearForm = true;
             }
             finally
             {
                 if (clearForm)
                 {
                     description.Text = "";
                     results.Text     = "";
                     lastUsed.Value   = DateTime.Now;
                 }
             }
         }
     }
 }
Exemple #22
0
 private void button_Open_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         openFileDialog1.Title            = "Open file with excuse";
         openFileDialog1.Filter           = "Text files (*.txt)|*.txt";
         openFileDialog1.InitialDirectory = selectedFolder;
         openFileDialog1.CheckFileExists  = true;
         openFileDialog1.CheckPathExists  = false;
         DialogResult result = openFileDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             Excuse _excuse = new Excuse(openFileDialog1.FileName);
             UpdateForm(_excuse);
         }
     }
 }
Exemple #23
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            Excuse currentExcuse = new Excuse();

            currentExcuse.Explanation = txt_Excuse.Text;
            currentExcuse.Reaction    = txt_Reaction.Text;
            currentExcuse.DataDate    = txt_Date.Text;
            currentExcuse.LastUsed    = datePicker_lastUsed.Text;

            if (!Excuse.checkSavedExcuse(mostRecentSave, currentExcuse))
            {
                if (MessageBox.Show("Die neuesten Änderungen wurden noch nicht gesichert, möchtest du diese Speichern?",
                                    "Ungesicherte Änderungen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning).ToString() == "Yes")
                {
                    btn_Save_Click(new object(), new EventArgs());
                }
            }
        }
Exemple #24
0
        private void open_Click(object sender, EventArgs e)
        {
            if (!Continue())
            {
                return;
            }

            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.InitialDirectory = selectedFolder;
            openDialog.FileName         = FileName();
            openDialog.Filter           = STRING_FILTER;
            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                currentExcuse = new Excuse(openDialog.FileName);
                currentExcuse.OpenFile(openDialog.FileName);
                UpdateForm(false);
            }
        }
Exemple #25
0
        private void btn_LoadSerializable_Click(object sender, EventArgs e)
        {
            IFormatter     formatter = new BinaryFormatter();
            OpenFileDialog dialog    = new OpenFileDialog();

            dialog.InitialDirectory = Excuse.Path;
            dialog.Filter           = "bin files (*.bin)|*.bin|All files (*.*)|*.*";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Stream stream = new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                Excuse obj    = (Excuse)formatter.Deserialize(stream);
                stream.Close();
                txt_Excuse.Text          = obj.Explanation;
                txt_Reaction.Text        = obj.Reaction;
                txt_Date.Text            = obj.DataDate;
                datePicker_lastUsed.Text = obj.LastUsed;
                updateMostRecentSave();
            }
        }
Exemple #26
0
        private void btn_Serialize_Click(object sender, EventArgs e)
        {
            Excuse serializeObject = new Excuse();

            serializeObject.Explanation = txt_Excuse.Text;
            serializeObject.Reaction    = txt_Reaction.Text;
            serializeObject.DataDate    = txt_Date.Text;
            serializeObject.LastUsed    = datePicker_lastUsed.Text;

            IFormatter     formatter = new BinaryFormatter();
            SaveFileDialog dialog    = new SaveFileDialog();

            dialog.Filter = "bin files (*.bin)|*.bin|All files (*.*)|*.*";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Stream stream = new FileStream(dialog.FileName, FileMode.Create, FileAccess.Write, FileShare.None);

                formatter.Serialize(stream, serializeObject);
                stream.Close();
            }
        }
Exemple #27
0
 private void open_Click(object sender, EventArgs e)
 {
     if (CheckChanged())
     {
         openFileDialog1.InitialDirectory = selectedFolder;
         openFileDialog1.Filter =
           "Excuse files (*.excuse)|*.excuse|All files (*.*)|*.*";
         openFileDialog1.FileName = description.Text + ".excuse";
         DialogResult result = openFileDialog1.ShowDialog();
         if (result == DialogResult.OK)
         {
             bool clearForm = false;
             try
             {
                 currentExcuse = new Excuse(openFileDialog1.FileName);
                 try
                 {
                     UpdateForm(false);
                 }
                 catch (ArgumentOutOfRangeException)
                 {
                     MessageBox.Show("The excuse file ‘"
                         + openFileDialog1.FileName + "’ had a invalid data",
                         "Unable to open the excuse");
                     clearForm = true;
                 }
             }
             catch (SerializationException ex)
             {
                 MessageBox.Show("An error occurred while opening the excuse ‘"
                     + openFileDialog1.FileName + "’\n" + ex.Message,
                     "Unable to open the excuse", MessageBoxButtons.OK,
                     MessageBoxIcon.Error);
                 clearForm = true;
             }
             finally
             {
                 if (clearForm)
                 {
                     description.Text = "";
                     results.Text = "";
                     lastUsed.Value = DateTime.Now;
                 }
             }
         }
     }
 }
 private void BtnRandomExcuse_Click(object sender, EventArgs e)
 {
     _currentExcuse = new Excuse(_random, _currentPath);
     UpdateForm(false);
 }
Exemple #29
0
 public Form1()
 {
     InitializeComponent();
     currentExcuse          = new Excuse();
     currentExcuse.LastUsed = lastUsed.Value;
 }
Exemple #30
0
        private void randomExcuse_Click(object sender, EventArgs e)
        {
            string[] fileNames = Directory.GetFiles(selectedFolder, "*.excuse");
            if (fileNames.Length == 0)
            {
                MessageBox.Show("Please specify a folder with excuse files in it",
                                "No excuse files found");
            }
            else
            {
                try
                {
                    if (CheckChanged() == true)
                    {
                        currentExcuse = new Excuse(random, selectedFolder);
                    }
                }
                catch (SerializationException)
                {
                    currentExcuse = new Excuse();
                    currentExcuse.Description = "";
                    currentExcuse.Results = "";
                    currentExcuse.LastUsed = DateTime.Now;
                    MessageBox.Show(
                      "Your excuse file was invalid.",
                      "Unable to open a random excuse");
                }
                finally
                {
                    UpdateForm(false);
                }
            }

        }
Exemple #31
0
        private void open_Click(object sender, EventArgs e)
        {
            if (!Continue()) { return; }

            OpenFileDialog openDialog = new OpenFileDialog();
            openDialog.InitialDirectory = selectedFolder;
            openDialog.FileName = FileName();
            openDialog.Filter = STRING_FILTER;
            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                currentExcuse = new Excuse(openDialog.FileName);
                currentExcuse.OpenFile(openDialog.FileName);
                formLoaded = true;
                UpdateForm(false);
            }
        }
Exemple #32
0
        private void randomExcuse_Click(object sender, EventArgs e)
        {
            if (!Continue()) { return; }

            currentExcuse = new Excuse(selectedFolder, random);
            currentExcuse.OpenFile(currentExcuse.ExcusePath);
            formLoaded = true;
            UpdateForm(false);
        }