Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            // move in separate func
            try
            {
                // add in try/catch bcz we cant gurantee setting will load correct from file
                // get preferences from settings

                string fColor     = Properties.Settings.Default.fontColor;
                string bckColor   = Properties.Settings.Default.backgroundColor;
                string fFamily    = Properties.Settings.Default.fontFamily;
                double fSize      = Properties.Settings.Default.fontSize;
                bool   is12Format = Properties.Settings.Default.Is12HrFormat;

                double top  = Properties.Settings.Default.top;
                double left = Properties.Settings.Default.left;

                if (top != 0 && left != 0)
                {
                    // set window position
                    this.Top  = top;
                    this.Left = left;
                }

                Color backgroundColor = _getArgb(bckColor);
                Color foreground      = _getArgb(fColor);

                // create default preference
                // should load with defaults
                preference = new Preference(foreground, backgroundColor, new FontFamily(fFamily), fSize, is12Format);
            }
            catch (Exception e) {
                // fallback to default
                preference = new Preference();
            }

            // TODO: start timer and update every ~1
            // set time

            /*string time = DateTime.Now.ToString("h:mm:ss tt");
             * this.timerLabel.Content = time;*/

            // set window to allows be on top
            this.Topmost    = true;
            this.ResizeMode = ResizeMode.NoResize;

            preferenceDelegate += new PreferenceDelegate(on_SetSavedPreference);

            //  DispatcherTimer setup
            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();

            // set ui to saved preference
            updateUI();
        }
        public PreferenceDialog(PreferenceDelegate del, Preference pref)
        {
            InitializeComponent();

            // set delegate
            preferenceDelegate = del;
            preference         = pref;

            InstalledFontCollection installedFontCollection = new InstalledFontCollection();

            // get font names
            IList <string> fontNames = installedFontCollection.Families.Select(f => f.Name).ToList();

            PreferenceFontFamilyCombo.ItemsSource = fontNames;

            // set to defaults
            setUIPreference();
        }