コード例 #1
1
ファイル: Form1.cs プロジェクト: modulexcite/cDashboard
        /// <summary>
        /// Will read settings not directly related to stickies
        /// </summary>
        /// <param name="settings_list"></param>
        private void otherSettings(ref List<List<string>> settings_list)
        {
            string FSFN = ""; //Favorite Sticky Font Name
            float FSFS = -1; //Favorite Sticky Font Size
            bool BoardlessMode = false;

            foreach (List<string> currentline in settings_list)
            {
                //cReminders
                if (currentline[0] == "cReminders")
                {
                    //handle empty cReminders list
                    if (currentline.Count == 1)
                    {
                        continue;
                    }

                    List<string> cReminders = currentline;
                    cReminders.RemoveAt(0);

                    if (cReminders.Count % 2 != 0)
                    {
                        MessageBox.Show("No message for certain cReminder?, this shouldn't happen.");
                    }
                    else
                    {
                        for (int i = 0; i < cReminders.Count; i++)
                        {
                            long ticks = Convert.ToInt64(cReminders[i]);
                            string msg = cReminders[i + 1];
                            dict_cReminders.Add(ticks, msg);
                            i++;
                        }
                    }
                }

                //Most global cDash settings
                //set backcolor of the Dash from settings
                if (currentline[0] == "cDash")
                {
                    //set Key1
                    if (currentline[1] == "Key1")
                    {
                        Key1 = (Keys)Convert.ToInt16(currentline[2]);
                    }

                    //set Key2
                    if (currentline[1] == "Key2")
                    {
                        Key2 = (Keys)Convert.ToInt16(currentline[2]);
                    }

                    //updates ui to signify auto checking
                    if (currentline[1] == "AutoUpdateCheck")
                    {
                        if (currentline[2] == "True")
                        {
                            automaticallyCheckForUpdatesToolStripMenuItem.Checked = true;

                            new System.Threading.Thread(() => updateCheck(true)).Start();
                        }
                    }

                    //handle BoardlessMode setting
                    if (currentline[1] == "BoardlessMode")
                    {
                        if (currentline[2] == "True")
                        {
                            BoardlessMode = true;
                            boardlessModeToolStripMenuItem.Checked = true;
                        }
                    }

                    //special handling for global cWeather settings
                    if (currentline[1] == "cWeather")
                    {
                        if (currentline[2] == "Unit")
                        {
                            if (currentline[3] == "F")
                            {
                                fToolStripMenuItem.Checked = true;
                                celciusToolStripMenuItem.Checked = false;
                            }
                            else
                            {
                                celciusToolStripMenuItem.Checked = true;
                                fToolStripMenuItem.Checked = false;
                            }
                        }
                    }

                    if (currentline[1] == "BackColor")
                    {
                        this.BackColor = Color.FromArgb(Convert.ToInt32(currentline[2]), Convert.ToInt32(currentline[3]), Convert.ToInt32(currentline[4]));
                        //line removed so that transparent color works
                        //menuStrip1.BackColor = this.BackColor;
                    }

                    if (currentline[1] == "Opacity")
                    {
                        OpacityLevel = Convert.ToInt32(currentline[2]);
                        textbox_opacity.Text = currentline[2];
                    }

                    if (currentline[1] == "FadeLengthInMilliseconds")
                    {
                        int_fade_milliseconds = Convert.ToInt32(currentline[2]);
                    }

                    if (currentline[1] == "DateTimeStripColor")
                    {
                        button_time.ForeColor = Color.FromArgb(Convert.ToInt32(currentline[2]), Convert.ToInt32(currentline[3]), Convert.ToInt32(currentline[4]));
                        button_date.ForeColor = Color.FromArgb(Convert.ToInt32(currentline[2]), Convert.ToInt32(currentline[3]), Convert.ToInt32(currentline[4]));
                        menuStrip1.ForeColor = Color.FromArgb(Convert.ToInt32(currentline[2]), Convert.ToInt32(currentline[3]), Convert.ToInt32(currentline[4]));
                    }

                    if (currentline[1] == "FavoriteStickyColor")
                    {
                        if (currentline[2] == "NULL")
                        {
                            //don't initialize FavoriteStickyColor
                        }
                        else
                        {
                            FavoriteStickyColor = Color.FromArgb(Convert.ToInt32(currentline[2]), Convert.ToInt32(currentline[3]), Convert.ToInt32(currentline[4]));
                        }
                    }

                    if (currentline[1] == "FavoriteStickyFontName")
                    {
                        FSFN = currentline[2];
                    }

                    if (currentline[1] == "FavoriteStickyFontSize")
                    {
                        FSFS = Convert.ToSingle(currentline[2]);
                    }

                    //setup cDash wallpaper
                    if (currentline[1] == "Wallpaper")
                    {
                        UseWallpaperImage = Convert.ToBoolean(currentline[2]);

                        //if we are using a wallpaper image, grab it from file
                        if (UseWallpaperImage)
                        {
                            this.BackgroundImage = Image.FromFile(getSpecificSetting(new string[] { "cDash", "WallpaperImage" })[0]);
                        }
                    }

                    //set cDash wallpaper layout
                    if (currentline[1] == "WallpaperImageLayout")
                    {
                        if (currentline[2] == "Center")
                        {
                            this.BackgroundImageLayout = ImageLayout.Center;
                        }
                        else if (currentline[2] == "None")
                        {
                            this.BackgroundImageLayout = ImageLayout.None;
                        }
                        else if (currentline[2] == "Stretch")
                        {
                            this.BackgroundImageLayout = ImageLayout.Stretch;
                        }
                        else if (currentline[2] == "Tile")
                        {
                            this.BackgroundImageLayout = ImageLayout.Tile;
                        }
                        else if (currentline[2] == "Zoom")
                        {
                            this.BackgroundImageLayout = ImageLayout.Zoom;
                        }
                    }
                }
                //Handling for cBattery
                else if (currentline[0] == "cBattery")
                {
                    //this would mean that this form already exists
                    if (!(Controls.Find(currentline[1], true).Length > 0))
                    {
                        cBattery cBattery_new = new cBattery();
                        cBattery_new.Name = currentline[1];
                        cBattery_new.TopLevel = false;
                        cBattery_new.Parent = this;
                        Controls.Add(cBattery_new);
                    }

                    //get form by name
                    cBattery this_cBattery = (cBattery)this.Controls.Find(currentline[1], true)[0];

                    if (currentline[2] == "Location")
                    {
                        this_cBattery.Location = new Point(Convert.ToInt16(currentline[3]), Convert.ToInt16(currentline[4]));
                    }

                    this_cBattery.Show();
                    this_cBattery.BringToFront();
                }
                //Handling for cMote
                else if (currentline[0] == "cMote")
                {
                    //this would mean that this form already exists
                    if (!(Controls.Find(currentline[1], true).Length > 0))
                    {
                        cMote cMote_new = new cMote();
                        cMote_new.Name = currentline[1];
                        cMote_new.TopLevel = false;
                        cMote_new.Parent = this;
                        Controls.Add(cMote_new);
                    }

                    //get form by name
                    cMote this_cMote = (cMote)this.Controls.Find(currentline[1], true)[0];

                    if (currentline[2] == "Location")
                    {
                        this_cMote.Location = new Point(Convert.ToInt16(currentline[3]), Convert.ToInt16(currentline[4]));
                    }

                    this_cMote.Show();
                    this_cMote.BringToFront();
                }
                //Handling for cRViewer
                else if (currentline[0] == "cRViewer")
                {
                    //this would mean that this form already exists
                    if (!(Controls.Find(currentline[1], true).Length > 0))
                    {
                        cRViewer cRViewer_new = new cRViewer();
                        cRViewer_new.Name = currentline[1];
                        cRViewer_new.TopLevel = false;
                        cRViewer_new.Parent = this;
                        Controls.Add(cRViewer_new);
                    }

                    //get form by name
                    cRViewer this_cRViewer = (cRViewer)this.Controls.Find(currentline[1], true)[0];

                    if (currentline[2] == "Location")
                    {
                        this_cRViewer.Location = new Point(Convert.ToInt16(currentline[3]), Convert.ToInt16(currentline[4]));
                    }
                    else if (currentline[2] == "Size")
                    {
                        this_cRViewer.Size = new Size(Convert.ToInt16(currentline[3]), Convert.ToInt16(currentline[4]));
                    }

                    this_cRViewer.Show();
                    this_cRViewer.BringToFront();
                }
                //Handling for cWeather
                else if (currentline[0] == "cWeather")
                {
                    //this would mean that this form already exists
                    if (!(Controls.Find(currentline[1], true).Length > 0))
                    {
                        cWeather cWeather_new = new cWeather();
                        cWeather_new.Name = currentline[1];
                        cWeather_new.TopLevel = false;
                        cWeather_new.Parent = this;
                        Controls.Add(cWeather_new);
                    }

                    //get form by name
                    cWeather this_cWeather = (cWeather)this.Controls.Find(currentline[1], true)[0];

                    if (currentline[2] == "Location")
                    {
                        this_cWeather.Location = new Point(Convert.ToInt16(currentline[3]), Convert.ToInt16(currentline[4]));
                    }

                    if (currentline[2] == "WOEID")
                    {
                        this_cWeather.WOEID = currentline[3];

                        //if WOEID is set, get weather info
                        if (this_cWeather.WOEID != "NULL")
                        {
                            this_cWeather.getWeatherInfo();
                        }
                    }

                    this_cWeather.Show();
                    this_cWeather.BringToFront();
                }
                else if (currentline[0] == "cPic")
                {
                    //this would mean that this form already exists
                    if (!(Controls.Find(currentline[1], true).Length > 0))
                    {
                        cPic cPic_new = new cPic();
                        cPic_new.Name = currentline[1];

                        //randomize files in folder
                        randomizeFiles(currentline[1]);

                        //use 1st image
                        cPic_new.BackgroundImage = Image.FromFile(SETTINGS_LOCATION + currentline[1] + "\\1");
                        cPic_new.Tag = 1;

                        cPic_new.TopLevel = false;
                        cPic_new.Parent = this;
                        Controls.Add(cPic_new);
                    }

                    //get form by name
                    cPic this_cPic = (cPic)this.Controls.Find(currentline[1], true)[0];

                    if (currentline[2] == "ImageLayout")
                    {
                        if (currentline[3] == "Center")
                        {
                            this_cPic.BackgroundImageLayout = ImageLayout.Center;
                        }
                        else if (currentline[3] == "None")
                        {
                            this_cPic.BackgroundImageLayout = ImageLayout.None;
                        }
                        else if (currentline[3] == "Stretch")
                        {
                            this_cPic.BackgroundImageLayout = ImageLayout.Stretch;
                        }
                        else if (currentline[3] == "Tile")
                        {
                            this_cPic.BackgroundImageLayout = ImageLayout.Tile;
                        }
                        else if (currentline[3] == "Zoom")
                        {
                            this_cPic.BackgroundImageLayout = ImageLayout.Zoom;
                        }
                    }
                    else if (currentline[2] == "Size")
                    {
                        this_cPic.Size = new Size(Convert.ToInt16(currentline[3]), Convert.ToInt16(currentline[4]));
                    }
                    else if (currentline[2] == "Location")
                    {
                        this_cPic.Location = new Point(Convert.ToInt16(currentline[3]), Convert.ToInt16(currentline[4]));
                    }

                    this_cPic.Show();
                    this_cPic.BringToFront();
                }
                else if (currentline[0] == "cStopwatch")
                {
                    //this would mean that this form already exists
                    if (!(Controls.Find(currentline[1], true).Length > 0))
                    {
                        cStopwatch cStopwatch_new = new cStopwatch();
                        cStopwatch_new.Name = currentline[1];
                        cStopwatch_new.TopLevel = false;
                        cStopwatch_new.Parent = this;
                        Controls.Add(cStopwatch_new);
                    }

                    //get form by name
                    cStopwatch this_cStopwatch = (cStopwatch)this.Controls.Find(currentline[1], true)[0];

                    if (currentline[2] == "Location")
                    {
                        this_cStopwatch.Location = new Point(Convert.ToInt16(currentline[3]), Convert.ToInt16(currentline[4]));
                    }

                    this_cStopwatch.Show();
                    this_cStopwatch.BringToFront();
                }
            }
            FavoriteStickyFont = new Font(FSFN, FSFS);

            if (BoardlessMode)
            {
                goBoardless();
            }

            //move dash to set monitor
            moveToPrimaryMonitor();
        }
コード例 #2
0
 public static bool KeyPressed(Keys key)
 {
     if (lastKeyboardState.IsKeyUp(key) &&
         currentKeyboardState.IsKeyDown(key))
         return true;
     else return false;
 }
コード例 #3
0
 public GlobalHotkey(int modifier, Keys key, Form form)
 {
     this.modifier = modifier;
     this.key = (int) key;
     this.hWnd = form.Handle;
     this.id = GetHashCode();
 }
コード例 #4
0
 public static bool KeyReleased(Keys key)
 {
     return lastKeyboardState.IsKeyDown(key) &&
         currentKeyboardState.IsKeyUp(key);
 }
コード例 #5
0
 public static bool KeyDown(Keys key)
 {
     return currentKeyboardState.IsKeyDown(key);
 }
コード例 #6
0
ファイル: ScreenShot.cs プロジェクト: rayel/CSharpScreenShot
 private static extern bool RegisterHotKey(IntPtr hWnd, uint id, KeyModifys fsModifiers, Keys vk);
コード例 #7
0
        protected override bool ProcessCmdKey(ref Message m, Keys keyData)
        {
            bool blnProcess = false;

            if (keyData == Keys.Right)
            {
                // Process the keystroke
                blnProcess = true;
                if (blnSubMenu)
                    mTrainingVideoRunner.nextSubFrame();
                else
                    mTrainingVideoRunner.nextFrame();
            }
            else if (keyData == Keys.Left)
            {
                // Process the keystroke
                blnProcess = true;
                if (blnSubMenu)
                    mTrainingVideoRunner.previousSubFrame();
                else
                    mTrainingVideoRunner.previousFrame();
            }
            else if (keyData == Keys.Up)
            {
                // Process the keystroke
                blnProcess = true;
                blnSubMenu = false;
            }
            else if (keyData == Keys.Down)
            {
                // Process the keystroke
                blnProcess = true;
                blnSubMenu = true;
            }

            if (blnProcess == true)
                return true;
            else
                return base.ProcessCmdKey(ref m, keyData);
        }
コード例 #8
0
 public void KeyPressed(Keys key)
 {
     _menuItemView.KeyPressed(key);
 }
コード例 #9
0
        void gkh_KeyDown(object sender, KeyEventArgs e)
        {
            Console.WriteLine("Down\t" + e.KeyCode.ToString());
            if ((lastKey == Keys.LControlKey) && (e.KeyCode == Keys.C))
            {
                showWordAndMeaningNotifyIcon();

            }
            lastKey = e.KeyCode;
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: modulexcite/cDashboard
        /// <summary>
        /// Sets variables for proper key hooking and begins the hook
        /// </summary>
        /// <param name="unhook_first">should we unhook previous before hooking</param>
        private void keyHookSetup(bool unhook_first)
        {
            if (unhook_first)
            {
                KeyHook.HookedKeys.Clear();
                KeyHook.unhook();
                Key1 = (Keys)Convert.ToInt16(getSpecificSetting(new string[] { "cDash", "Key1" })[0]);
                Key2 = (Keys)Convert.ToInt16(getSpecificSetting(new string[] { "cDash", "Key2" })[0]);
            }

            //add Key1 and Key2 to the list of hooked keys
            KeyHook.HookedKeys.Add(Key2);
            KeyHook.HookedKeys.Add(Key1);
            //begin hook
            KeyHook.hook();
            //Setup Key Event Handlers
            KeyHook.KeyDown += new KeyEventHandler(KeyHook_KeyDown);
            KeyHook.KeyUp += new KeyEventHandler(KeyHook_KeyUp);
        }
コード例 #11
0
ファイル: CameraController.cs プロジェクト: yxrkt/ProjectGosu
 bool KeyDown( Keys key )
 {
     return nextKeyboardState.IsKeyDown( key );
 }