Ejemplo n.º 1
0
        private void OnWindowClosed(object sender, EventArgs e)
        {
            ColorSettings settings = new ColorSettings(textColorPicker.SelectedColor, backgroundColorPicker.SelectedColor);

            using (Stream stream = new FileStream("color.config", FileMode.OpenOrCreate))
            {
                BinaryFormatter serializer = new BinaryFormatter();
                serializer.Serialize(stream, settings);
            }
        }
Ejemplo n.º 2
0
        private void OnLoadedWindow(object sender, RoutedEventArgs e)
        {
            ColorSettings settings;

            using (Stream stream = new FileStream("color.config", FileMode.OpenOrCreate))
            {
                BinaryFormatter serializer = new BinaryFormatter();
                try
                {
                    settings = (ColorSettings)serializer.Deserialize(stream);
                }
                catch
                {
                    settings = new ColorSettings(null, null);
                }
            }
            textColorPicker.SelectedColor       = settings.TextColor;
            backgroundColorPicker.SelectedColor = settings.BackgroundColor;
            textColorChanged(null, null);
            BackgroundColorChanged(null, null);
        }