Beispiel #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (Clipboard.GetText().ToString() == "")
            {
                return;
            }

            string currentData = Clipboard.GetText();

            if (currentData != lastData)
            {
                mainListbox.BeginUpdate();

                clipObject co = new clipObject();
                co.data = currentData;
                co.time = DateTime.Now.ToString("yyyy-MM-dd, hh: mm: ss tt");
                mainListbox.Items.Insert(0, co);
                lastData = currentData;

                if (mainListbox.Items.Count > Properties.Settings.Default.history_level)
                {
                    mainListbox.Items.RemoveAt(Properties.Settings.Default.history_level - 1);
                }

                mainListbox.EndUpdate();
            }
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - this.Width, Screen.PrimaryScreen.Bounds.Height - this.Height - 40);
            SetStartup();
            unCheckAll();
            if (Properties.Settings.Default.history_level == 10)
            {
                itemsToolStripMenuItem.Checked = true;
            }
            else if (Properties.Settings.Default.history_level == 20)
            {
                itemsToolStripMenuItem1.Checked = true;
            }
            else if (Properties.Settings.Default.history_level == 30)
            {
                itemsToolStripMenuItem2.Checked = true;
            }
            else if (Properties.Settings.Default.history_level == 40)
            {
                itemsToolStripMenuItem3.Checked = true;
            }
            else
            {
                itemsToolStripMenuItem4.Checked = true;
            }

            if (File.Exists(this.mydocpath + @"\data.txt"))
            {
                using (StreamReader r = new StreamReader(this.mydocpath + @"\data.txt"))
                {
                    string        line;
                    clipObject    co       = new clipObject();
                    List <string> itemData = new List <string>();

                    while ((line = r.ReadLine()) != null)
                    {
                        DateTime dateValue;

                        if (DateTime.TryParseExact(line, "yyyy-MM-dd, hh: mm: ss tt", new CultureInfo("en-US"), DateTimeStyles.None, out dateValue))
                        {
                            co.time = dateValue.ToString();
                            co.data = String.Join(Environment.NewLine, itemData);
                            itemData.Clear();
                            mainListbox.Items.Add(co);
                            co = new clipObject();
                        }
                        else
                        {
                            itemData.Add(line);
                        }
                    }
                }
            }
        }