Beispiel #1
1
        /// <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();
        }
Beispiel #2
0
        /// <summary>
        /// add a new cStopwatch cForm to the cDash
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newCStopwatchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //represents the a unique time stamp for use as name of form
            long long_unique_timestamp = DateTime.Now.Ticks;

            //add the cStopwatch to settings
            System.IO.StreamWriter sw = new System.IO.StreamWriter(SETTINGS_LOCATION + "cDash Settings.cDash", true);
            sw.WriteLine("cStopwatch;" + long_unique_timestamp.ToString() + ";Location;10;25");
            sw.WriteLine("cStopwatch;" + long_unique_timestamp.ToString() + ";StartDateTime;NULL");
            sw.WriteLine("cStopwatch;" + long_unique_timestamp.ToString() + ";TimerRunning;False");
            sw.WriteLine("cStopwatch;" + long_unique_timestamp.ToString() + ";EndDateTime;NULL");
            sw.WriteLine("cStopwatch;" + long_unique_timestamp.ToString() + ";Laps");
            sw.WriteLine("cStopwatch;" + long_unique_timestamp.ToString() + ";LapTime;NULL");
            sw.Close();

            cStopwatch cStopwatch_new = new cStopwatch();
            cStopwatch_new.Name = long_unique_timestamp.ToString();
            cStopwatch_new.Location = new Point(10, 25);
            cStopwatch_new.TopLevel = false;
            cStopwatch_new.Parent = this;

            Controls.Add(cStopwatch_new);
            cStopwatch_new.Show();
            cStopwatch_new.BringToFront();
        }