Beispiel #1
0
        private void menuItemSave_Click(object sender, RoutedEventArgs e)
        {
            if (filename == null)
            {
                SaveFileDialog fileDialog = new SaveFileDialog();

                fileDialog.DefaultExt = ".txt";
                fileDialog.Filter = "Text files (txt)|*.txt";
                if (fileDialog.ShowDialog() == true)
                    filename = fileDialog.FileName;
                else
                    return;
                Serializer sl = new Serializer(filename, true);
                sl.WriteObject(fac);
                sl.Close();
            }
            else
            {
                Serializer sl = new Serializer(filename, true);
                sl.WriteObject(fac);
                sl.Close();
            }
        }
Beispiel #2
0
        private void menuItemOpen_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.DefaultExt = ".txt";
            fileDialog.Filter = "Text documents (txt)|*.txt";
            if (fileDialog.ShowDialog() == true)
                filename = fileDialog.FileName;
            else
                return;
            fac.ClearFaculty();
            Serializer sl = new Serializer(filename, false);
            fac = (Faculty)sl.ReadObject();
            sl.Close();
            listbox1.ItemsSource = fac;
        }