Ejemplo n.º 1
0
        /// <summary>
        /// Create the stickies from the settings file
        /// </summary>
        private void createStickiesFromFiles(ref List<List<string>> settings_list)
        {
            foreach (List<string> current_item in settings_list)
            {
                if (current_item[0] == "cSticky")
                {
                    //we have a "cSticky"

                    //check if this one has already been made
                    if (this.Controls.Find(current_item[1], true).Length == 0)
                    {
                        //if we make it in here, the control wasn't created yet
                        cSticky cSticky_new = new cSticky();
                        cSticky_new.Name = current_item[1];
                        cSticky_new.TopLevel = false;
                        cSticky_new.Parent = this;
                        Controls.Add(cSticky_new);
                    }

                    //the property is back color
                    if (current_item[2] == "BackColor")
                    {
                        this.Controls.Find(current_item[1], true)[0].Controls.Find("menustrip", false)[0].BackColor = Color.FromArgb(Convert.ToInt32(current_item[3]), Convert.ToInt32(current_item[4]), Convert.ToInt32(current_item[5]));
                        this.Controls.Find(current_item[1], true)[0].BackColor = Color.FromArgb(Convert.ToInt32(current_item[3]), Convert.ToInt32(current_item[4]), Convert.ToInt32(current_item[5]));
                        this.Controls.Find(current_item[1], true)[0].Controls.Find("rtb", false)[0].BackColor = Color.FromArgb(Convert.ToInt32(current_item[3]), Convert.ToInt32(current_item[4]), Convert.ToInt32(current_item[5]));
                    }

                    //the property is location
                    if (current_item[2] == "Location")
                    {
                        this.Controls.Find(current_item[1], true)[0].Location = new Point(Convert.ToInt32(current_item[3]), Convert.ToInt32(current_item[4]));
                    }

                    //the property is size
                    if (current_item[2] == "Size")
                    {
                        this.Controls.Find(current_item[1], true)[0].Size = new Size(Convert.ToInt32(current_item[3]), Convert.ToInt32(current_item[4]));
                    }
                }
            }

            //add stickies to form
            foreach (cSticky cSticky_new in this.Controls.OfType<cSticky>())
            {
                //attempts to load richtextbox files, if the file doesn't exist, it fails gracefully
                if (System.IO.File.Exists(SETTINGS_LOCATION + cSticky_new.Name + ".rtf"))
                {
                    ((RichTextBox)cSticky_new.Controls.Find("rtb", false)[0]).LoadFile(SETTINGS_LOCATION + cSticky_new.Name + ".rtf");
                }
                else
                {
                    ((RichTextBox)cSticky_new.Controls.Find("rtb", false)[0]).Text = "File missing";
                }

                //display control
                cSticky_new.Show();
                cSticky_new.BringToFront();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Makes new sticky of desired color
        /// </summary>
        /// <param name="pickedColor">The desired color</param>
        private void makeNewSticky(Color pickedColor)
        {
            //this code will add a new sticky to the form
            cSticky cSticky_new = new cSticky();
            cSticky_new.Location = new Point(10, 25);
            cSticky_new.Size = new Size(350, 400);
            cSticky_new.BackColor = pickedColor;

            //this will actually change the colors of the new form to match pickedColor
            ((MenuStrip)cSticky_new.Controls.Find("menustrip", false)[0]).BackColor = pickedColor;
            ((RichTextBox)cSticky_new.Controls.Find("rtb", false)[0]).BackColor = pickedColor;
            ((RichTextBox)cSticky_new.Controls.Find("rtb", false)[0]).Font = FavoriteStickyFont;
            cSticky_new.TopLevel = false;
            cSticky_new.Parent = this;
            Controls.Add(cSticky_new);
            cSticky_new.Show();
            cSticky_new.BringToFront();

            //represents the a unique time stamp for use as name of form / image
            long long_unique_timestamp = DateTime.Now.Ticks;
            cSticky_new.Name = long_unique_timestamp.ToString();

            //this code will add this new sticky to the settings file
            if (System.IO.File.Exists(SETTINGS_LOCATION + "cDash Settings.cDash"))
            {
                System.IO.StreamWriter sw = new System.IO.StreamWriter(SETTINGS_LOCATION + "cDash Settings.cDash", true);
                sw.WriteLine("cSticky;" + long_unique_timestamp.ToString() + ";BackColor;" + cSticky_new.BackColor.R.ToString() + ";" + cSticky_new.BackColor.G.ToString() + ";" + cSticky_new.BackColor.B.ToString());
                sw.WriteLine("cSticky;" + long_unique_timestamp.ToString() + ";Location;" + cSticky_new.Location.X.ToString() + ";" + cSticky_new.Location.Y.ToString());
                sw.WriteLine("cSticky;" + long_unique_timestamp.ToString() + ";Size;" + cSticky_new.Size.Width.ToString() + ";" + cSticky_new.Size.Height.ToString());
                sw.WriteLine("cSticky;" + long_unique_timestamp.ToString() + ";FontStyle;" + ((RichTextBox)cSticky_new.Controls.Find("rtb", false)[0]).Font.Name.ToString() + ";" + ((RichTextBox)cSticky_new.Controls.Find("rtb", false)[0]).Font.Size.ToString());
                sw.Close();
            }
            else
            {
                //this error should never EVER be thrown
                MessageBox.Show("System.IO.Exception: File does not exist");
            }

            ((RichTextBox)cSticky_new.Controls.Find("rtb", false)[0]).SaveFile(SETTINGS_LOCATION + long_unique_timestamp.ToString() + ".rtf");
        }