コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: rearintok/SideNote
        private void loadTextBox()
        {
            myTextBox.FontSize   = Convert.ToDouble(StorageHolder.readSetting(Key_FontSize));
            myTextBox.FontFamily = new System.Windows.Media.FontFamily(StorageHolder.readSetting(Key_FontFamily));

            readNotes();
        }
コード例 #2
0
 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));
         }
     }
 }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: rearintok/SideNote
        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();
        }
コード例 #4
0
        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;
                }
            }
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: rearintok/SideNote
 // 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();
     }
 }
コード例 #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);
        }
コード例 #7
0
 private void AppThemeDrop_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     StorageHolder.writeSetting(MainWindow.Key_AppTheme, AppThemeDrop.SelectedValue.ToString());
     ThemeEngine.applyTheme(AppThemeDrop.SelectedValue.ToString());
 }
コード例 #8
0
 private void FontSizeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     StorageHolder.writeSetting(MainWindow.Key_FontSize, FontSizeSlider.Value.ToString());
     updateTextBox();
 }
コード例 #9
0
 // Events
 private void FontFamilyDrop_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     StorageHolder.writeSetting(MainWindow.Key_FontFamily, FontFamilyDrop.SelectedValue.ToString());
     updateTextBox();
 }
コード例 #10
0
ファイル: MainWindow.xaml.cs プロジェクト: rearintok/SideNote
 private void saveNotes()
 {
     StorageHolder.writeText(myTextBox.Text);
 }
コード例 #11
0
ファイル: MainWindow.xaml.cs プロジェクト: rearintok/SideNote
 private void readNotes()
 {
     myTextBox.Text = StorageHolder.readText();
 }