Exemple #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (button4.Text == "Start Service")
            {
                foreach (ListViewItem lvi in listView1.Items)
                {
                    if (lvi.SubItems[0].Text == "Folder")
                    {
                        SyncFolderObject s = new SyncFolderObject();
                        s.f1 = lvi.SubItems[1].Text;
                        s.f2 = lvi.SubItems[2].Text;
                        s.Interval = interval;
                        s.Start();
                        syncs.Add(s);
                    }
                    else
                    {
                        SyncFileObject s = new SyncFileObject();
                        s.f1 = lvi.SubItems[1].Text;
                        s.f2 = lvi.SubItems[2].Text;
                        s.Interval = interval;
                        s.Start();
                        syncs.Add(s);
                    }
                }

                notifyIcon1.BalloonTipTitle = "SyncTool";
                notifyIcon1.BalloonTipText = "Synchronizing started!";
                notifyIcon1.ShowBalloonTip(1000);
                button4.Text = "Stop Service";
                this.Opacity = 0;
                this.ShowInTaskbar = false;
            }
            else {
                foreach (Object sync in syncs)
                {
                    if (sync.GetType().ToString() == "SyncTool.SyncFileObject")
                        ((SyncFileObject)sync).Stop();
                    else
                        ((SyncFolderObject)sync).Stop();
                }
                System.Diagnostics.Process.Start(Application.ExecutablePath);
                Application.ExitThread();
            }
        }
Exemple #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.SelectedIndex = 1;
            notifyIcon1.Visible = true;
            notifyIcon1.Text = "SyncTool";
            notifyIcon1.Icon = this.Icon;

            if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "winstart.ppst")))
                checkBox1.Checked = true;
            else
                checkBox1.Checked = false;

            if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "interval.ppst")))
            {
                StreamReader sr = new StreamReader(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "interval.ppst"));
                interval = Convert.ToInt32(sr.ReadLine());
                sr.Close();
                textBox1.Text = interval.ToString();
            }
            else
            {
                interval = 1000;
                textBox1.Text = interval.ToString();
            }

            if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "slots.ppst")))
            {
                StreamReader sr = new StreamReader(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "slots.ppst"));
                while (!sr.EndOfStream)
                    slots.Add(sr.ReadLine().Split(';').ToList<string>());
                sr.Close();
                foreach (List<string> slot in slots) {
                    ListViewItem lvi = listView1.Items.Add(slot[0]);
                    lvi.SubItems.Add(slot[1]);
                    lvi.SubItems.Add(slot[2]);
                }
            }
            if (Environment.GetCommandLineArgs().ToList<string>().Contains("/silent"))
            {
                if (!checkBox1.Checked)
                    Application.ExitThread();
                foreach (ListViewItem lvi in listView1.Items)
                {
                    if (lvi.SubItems[0].Text == "Folder")
                    {
                        SyncFolderObject s = new SyncFolderObject();
                        s.f1 = lvi.SubItems[1].Text;
                        s.f2 = lvi.SubItems[2].Text;
                        s.Interval = interval;
                        s.Start();
                        syncs.Add(s);
                    }
                    else
                    {
                        SyncFileObject s = new SyncFileObject();
                        s.f1 = lvi.SubItems[1].Text;
                        s.f2 = lvi.SubItems[2].Text;
                        s.Interval = interval;
                        s.Start();
                        syncs.Add(s);
                    }
                }
                button4.Text = "Stop Service";
                this.Opacity = 0;
                this.ShowInTaskbar = false;
            }
            timer1.Start();
        }