Beispiel #1
0
        private void loadTextBox()
        {
            myTextBox.FontSize   = Convert.ToDouble(StorageHolder.readSetting(Key_FontSize));
            myTextBox.FontFamily = new System.Windows.Media.FontFamily(StorageHolder.readSetting(Key_FontFamily));

            readNotes();
        }
 private void updateTextBox()
 {
     foreach (Window window in Application.Current.Windows)
     {
         if (window.GetType() == typeof(MainWindow))
         {
             (window as MainWindow).myTextBox.FontFamily = new System.Windows.Media.FontFamily(StorageHolder.readSetting(MainWindow.Key_FontFamily));
             (window as MainWindow).myTextBox.FontSize   = Double.Parse(StorageHolder.readSetting(MainWindow.Key_FontSize));
         }
     }
 }
Beispiel #3
0
        public MainWindow()
        {
            InitializeComponent();

            writeAutostart();
            initializeIni();

            ThemeEngine.applyTheme(StorageHolder.readSetting(MainWindow.Key_AppTheme));

            // Set up buttons
            TitlebarCloseButton.Click    += TitlebarCloseButton_Click;
            TitlebarSettingsButton.Click += TitlebarSettingsButton_Click;
            TitlebarResizeButton.Click   += TitlebarHideButton_Click;

            // Set up window properties
            this.AllowsTransparency = true;
            this.Topmost            = true;
            this.WindowState        = System.Windows.WindowState.Normal;
            this.Show();

            this.Left      = ScreenWidth - this.ActualWidth;
            this.Top       = 0;
            this.MinHeight = ScreenHeight;
            this.MaxHeight = ScreenHeight;

            // Set up animations
            Animation_Hide_Move.To   = Animation_Show_Move.From = ScreenWidth;
            Animation_Hide_Move.From = Animation_Show_Move.To = ScreenWidth - this.ActualWidth;
            Animation_Close_Move.To  = ScreenHeight;

            // Timers
            KeyHookTimer.Interval = TimeSpan.FromSeconds(0.1);
            KeyHookTimer.Tick    += KeyHookTimerTick;
            KeyHookTimer.Start();

            QuickSaveTimer.Tick    += QuickSaveTimerTick;
            QuickSaveTimer.Interval = new TimeSpan(0, 0, 20);
            QuickSaveTimer.Start();

            // Load window content
            loadTextBox();

            // Set up the settings window
            SettingsWindow = new SideNote.SettingsWindow();
            SettingsWindow.Show();
            SettingsWindow.WindowState = System.Windows.WindowState.Normal;
            SettingsWindow.Hide();
        }
        private void loadSettings()
        {
            System.Windows.Media.FontFamily[] FontFamilyArray = Fonts.SystemFontFamilies.ToArray();
            for (int i = 0; i < FontFamilyArray.GetLength(0); i++)
            {
                if (FontFamilyArray[i].ToString() == StorageHolder.readSetting(MainWindow.Key_FontFamily))
                {
                    FontFamilyDrop.SelectedIndex = i;
                }
            }

            FontSizeSlider.Value = Double.Parse(StorageHolder.readSetting(MainWindow.Key_FontSize));


            for (int i = 0; i < ThemeChoices.Count; i++)
            {
                if (ThemeChoices[i].ToString() == StorageHolder.readSetting(MainWindow.Key_AppTheme))
                {
                    AppThemeDrop.SelectedIndex = i;
                }
            }
        }
Beispiel #5
0
 // Helper functions
 private void initializeIni()
 {
     try
     {
         if (String.IsNullOrEmpty(StorageHolder.readSetting(Key_FontSize)))
         {
             StorageHolder.writeSetting(Key_FontSize, Default_FontSize);
         }
         if (String.IsNullOrEmpty(StorageHolder.readSetting(Key_FontFamily)))
         {
             StorageHolder.writeSetting(Key_FontFamily, Default_FontFamily);
         }
         if (String.IsNullOrEmpty(StorageHolder.readSetting(Key_AppTheme)))
         {
             StorageHolder.writeSetting(Key_AppTheme, ThemeEngine.DefaultTheme);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("An error occured while trying to set up the settings:\n\n" + e.ToString());
         Application.Current.Shutdown();
     }
 }
Beispiel #6
0
        public static void applyTheme(string name)
        {
            ResourceDictionary dict = new ResourceDictionary();

            string Resource_URI = "pack://application:,,,/Themes/" + name + ".xaml";



            Application.Current.Resources.MergedDictionaries.Clear();

            try
            {
                dict.Source = new Uri(Resource_URI);
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong while loading the theme and it has been reverted to the light one.", "Sorry");
                dict.Source = new Uri(Default_Theme_URI);
                StorageHolder.writeSetting(MainWindow.Key_AppTheme, DefaultTheme);
            }

            Application.Current.Resources.MergedDictionaries.Add(dict);
        }
 private void AppThemeDrop_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     StorageHolder.writeSetting(MainWindow.Key_AppTheme, AppThemeDrop.SelectedValue.ToString());
     ThemeEngine.applyTheme(AppThemeDrop.SelectedValue.ToString());
 }
 private void FontSizeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     StorageHolder.writeSetting(MainWindow.Key_FontSize, FontSizeSlider.Value.ToString());
     updateTextBox();
 }
 // Events
 private void FontFamilyDrop_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     StorageHolder.writeSetting(MainWindow.Key_FontFamily, FontFamilyDrop.SelectedValue.ToString());
     updateTextBox();
 }
Beispiel #10
0
 private void saveNotes()
 {
     StorageHolder.writeText(myTextBox.Text);
 }
Beispiel #11
0
 private void readNotes()
 {
     myTextBox.Text = StorageHolder.readText();
 }