Exemple #1
0
 public void SuspendButtonClick(Button sender, ref TimeSet timeset, ref Timer timer, ref Label lblHour, ref Label lblMinute, ref Label lblSecond)
 {
     if (timeset.flag == false && timeset.stopflag == true)
     {
         TimeSpan _ts    = new TimeSpan(int.Parse(lblHour.Text), int.Parse(lblMinute.Text), int.Parse(lblSecond.Text));
         DateTime _dtNow = DateTime.Now;
         timeset.tDate    = _dtNow + _ts;
         timeset.flag     = true;
         timeset.stopflag = false;
         timer.Start();
         sender.Text = "一時停止";
     }
     else
     {
         timer.Stop();
         timeset.stopflag = true;
         timeset.flag     = false;
         sender.Text      = "再 生";
     }
 }
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            string  _tName = inputName.Text;
            int     _tMaxLP, _tCurrentLP, _tRecoverCycle;
            TimeSet _TimeSet = new TimeSet();

            _tMaxLP        = (int)inputMaxLP.Value;
            _tCurrentLP    = (int)inputCurrentLP.Value;
            _tRecoverCycle = (int)inputRecoverCycle.Value;

            try
            {
                ParentForm.SetTimer(_tName, _tMaxLP, _tCurrentLP, _tRecoverCycle, out _TimeSet.tName, out _TimeSet.tHour, out _TimeSet.tMinute, out _TimeSet.tSecond, out _TimeSet.tDate);
                ParentForm.CreatetForm(_TimeSet);

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Nortification", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            string _tName = inputName.Text;
            int _tMaxLP, _tCurrentLP, _tRecoverCycle;
            TimeSet _TimeSet = new TimeSet();

            _tMaxLP = (int)inputMaxLP.Value;
            _tCurrentLP = (int)inputCurrentLP.Value;
            _tRecoverCycle = (int)inputRecoverCycle.Value;

            try
            {
                ParentForm.SetTimer(_tName, _tMaxLP, _tCurrentLP, _tRecoverCycle, out _TimeSet.tName, out _TimeSet.tHour, out _TimeSet.tMinute, out _TimeSet.tSecond, out _TimeSet.tDate);
                ParentForm.CreatetForm(_TimeSet);

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Nortification", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #4
0
        public void CreatetForm(TimeSet timeset)
        {
            tForm = new Form();

            tForm.SuspendLayout();
            TimeSet newTS = new TimeSet();
            newTS.tLabels = new Label[5];

            newTS.tTimer = new Timer();
            for (int i = 0; i < newTS.tLabels.Length; i++)
            {
                newTS.tLabels[i] = new Label();
                newTS.tLabels[i].AutoSize = true;
                newTS.tLabels[i].Font = new System.Drawing.Font("Century", 20);

            }

            tForm.Name = timeset.tName;
            tForm.Text = timeset.tName + " (Next " + timeset.tDate.Hour.ToString("d2") + ":" + timeset.tDate.Minute.ToString("d2") + "." + timeset.tDate.Second.ToString("d2") + ")";
            tForm.MaximizeBox = false;
            tForm.FormBorderStyle = FormBorderStyle.FixedToolWindow;

            tForm.Size = new System.Drawing.Size(220, 130);

            newTS.tLabels[0].Text = timeset.tHour.ToString();
            newTS.tLabels[0].Location = new Point(40, 10);

            newTS.tLabels[1].Text = ":";
            newTS.tLabels[1].Location = new Point(80, 10);

            newTS.tLabels[2].Text = timeset.tMinute.ToString();
            newTS.tLabels[2].Location = new Point(100, 10);

            newTS.tLabels[3].Text = timeset.tSecond.ToString();
            newTS.tLabels[3].Font = new System.Drawing.Font("Century", 16);
            newTS.tLabels[3].Location = new Point(140, 15);

            newTS.tButton = new Button();
            newTS.tButton.Text = "一時停止";
            newTS.tButton.Location = new Point(50, 50);
            newTS.tButton.Click += delegate(object sender, EventArgs e)
            {
                SuspendButtonClick(newTS.tButton, ref timeset, ref newTS.tTimer, ref newTS.tLabels[0], ref newTS.tLabels[2], ref newTS.tLabels[3]);
            };

            // タイマーの実装
            newTS.tTimer.Interval = 100;
            newTS.tTimer.Tick += delegate(object sender, EventArgs e)
            {
                RefreshTimeText(ref timeset, ref newTS.tLabels[0], ref newTS.tLabels[2], ref newTS.tLabels[3]);
            };
            timeset.flag = false;
            timeset.stopflag = false;

            tForm.Controls.Add(newTS.tLabels[0]);
            tForm.Controls.Add(newTS.tLabels[1]);
            tForm.Controls.Add(newTS.tLabels[2]);
            tForm.Controls.Add(newTS.tLabels[3]);
            tForm.Controls.Add(newTS.tButton);

            tForm.ResumeLayout(false);
            tForm.Show();

            timeset.flag = true;
            newTS.tTimer.Start();
        }
Exemple #5
0
 private void 既存のタイマーToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ofd = new OpenFileDialog();
     ofd.Multiselect = true;
     ofd.Filter = "XMLファイル(*.xml)|*.xml|すべてのファイル(*.*)|*.*";
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         try
         {
             for (int i = 0; i < ofd.FileNames.Length; i++)
             {
                 TimeSet _TimeSet = new TimeSet();
                 XmlSerializer _serializer = new XmlSerializer(typeof(LoadTimeSet));
                 StreamReader sr = new StreamReader(ofd.FileNames[i], new System.Text.UTF8Encoding(false));
                 LoadTimeSet newTimeSet = (LoadTimeSet)_serializer.Deserialize(sr);
                 sr.Close();
                 SetTimer(newTimeSet.tName, newTimeSet.tMaxLP, newTimeSet.tCurrrentLP, newTimeSet.tRecoverCycle, out _TimeSet.tName, out _TimeSet.tHour, out _TimeSet.tMinute, out _TimeSet.tSecond, out _TimeSet.tDate);
                 CreatetForm(_TimeSet);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(this, ex.Message, "Nortification", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #6
0
 public void SuspendButtonClick(Button sender, ref TimeSet timeset, ref Timer timer, ref Label lblHour, ref Label lblMinute, ref Label lblSecond)
 {
     if (timeset.flag == false && timeset.stopflag == true)
     {
         TimeSpan _ts = new TimeSpan(int.Parse(lblHour.Text), int.Parse(lblMinute.Text), int.Parse(lblSecond.Text));
         DateTime _dtNow = DateTime.Now;
         timeset.tDate = _dtNow + _ts;
         timeset.flag = true;
         timeset.stopflag = false;
         timer.Start();
         sender.Text = "一時停止";
     }
     else
     {
         timer.Stop();
         timeset.stopflag = true;
         timeset.flag = false;
         sender.Text = "再 生";
     }
 }
Exemple #7
0
        public void RefreshTimeText(ref TimeSet timeset, ref Label lblHour, ref Label lblMinute, ref Label lblSecond)
        {
            TimeSpan CurrentTS = new TimeSpan(0, 0, 0);
            DateTime dtnow = DateTime.Now;
            CurrentTS = timeset.tDate - dtnow;

            lblHour.Text = CurrentTS.Hours.ToString("d2");
            lblMinute.Text = CurrentTS.Minutes.ToString("d2");
            lblSecond.Text = CurrentTS.Seconds.ToString("d2");
            
        }
Exemple #8
0
        public void CreatetForm(TimeSet timeset)
        {
            tForm = new Form();

            tForm.SuspendLayout();
            TimeSet newTS = new TimeSet();

            newTS.tLabels = new Label[5];

            newTS.tTimer = new Timer();
            for (int i = 0; i < newTS.tLabels.Length; i++)
            {
                newTS.tLabels[i]          = new Label();
                newTS.tLabels[i].AutoSize = true;
                newTS.tLabels[i].Font     = new System.Drawing.Font("Century", 20);
            }

            tForm.Name            = timeset.tName;
            tForm.Text            = timeset.tName + " (Next " + timeset.tDate.Hour.ToString("d2") + ":" + timeset.tDate.Minute.ToString("d2") + "." + timeset.tDate.Second.ToString("d2") + ")";
            tForm.MaximizeBox     = false;
            tForm.FormBorderStyle = FormBorderStyle.FixedToolWindow;

            tForm.Size = new System.Drawing.Size(220, 130);

            newTS.tLabels[0].Text     = timeset.tHour.ToString();
            newTS.tLabels[0].Location = new Point(40, 10);

            newTS.tLabels[1].Text     = ":";
            newTS.tLabels[1].Location = new Point(80, 10);

            newTS.tLabels[2].Text     = timeset.tMinute.ToString();
            newTS.tLabels[2].Location = new Point(100, 10);

            newTS.tLabels[3].Text     = timeset.tSecond.ToString();
            newTS.tLabels[3].Font     = new System.Drawing.Font("Century", 16);
            newTS.tLabels[3].Location = new Point(140, 15);

            newTS.tButton          = new Button();
            newTS.tButton.Text     = "一時停止";
            newTS.tButton.Location = new Point(50, 50);
            newTS.tButton.Click   += delegate(object sender, EventArgs e)
            {
                SuspendButtonClick(newTS.tButton, ref timeset, ref newTS.tTimer, ref newTS.tLabels[0], ref newTS.tLabels[2], ref newTS.tLabels[3]);
            };

            // タイマーの実装
            newTS.tTimer.Interval = 100;
            newTS.tTimer.Tick    += delegate(object sender, EventArgs e)
            {
                RefreshTimeText(ref timeset, ref newTS.tLabels[0], ref newTS.tLabels[2], ref newTS.tLabels[3]);
            };
            timeset.flag     = false;
            timeset.stopflag = false;

            tForm.Controls.Add(newTS.tLabels[0]);
            tForm.Controls.Add(newTS.tLabels[1]);
            tForm.Controls.Add(newTS.tLabels[2]);
            tForm.Controls.Add(newTS.tLabels[3]);
            tForm.Controls.Add(newTS.tButton);

            tForm.ResumeLayout(false);
            tForm.Show();

            timeset.flag = true;
            newTS.tTimer.Start();
        }
        private void buttonCreateAsDefault_Click(object sender, EventArgs e)
        {
            string _tName = inputName.Text;
            int _tMaxLP, _tCurrentLP, _tRecoverCycle;
            TimeSet _TimeSet = new TimeSet();
            LoadTimeSet _NewLoadTimeSet = new LoadTimeSet();

            _NewLoadTimeSet.tName = inputName.Text;
            _tMaxLP = (int)inputMaxLP.Value;
            _NewLoadTimeSet.tMaxLP = (int)inputMaxLP.Value;
            _tCurrentLP = (int)inputCurrentLP.Value;
            _NewLoadTimeSet.tCurrrentLP = (int)inputCurrentLP.Value;
            _tRecoverCycle = (int)inputRecoverCycle.Value;
            _NewLoadTimeSet.tRecoverCycle = (int)inputRecoverCycle.Value;

            try
            {
                XmlSerializer _serializer = new XmlSerializer(typeof(LoadTimeSet));
                System.IO.StreamWriter sw = new System.IO.StreamWriter(inputName.Text + ".xml", false, new System.Text.UTF8Encoding(false));
                _serializer.Serialize(sw, _NewLoadTimeSet);
                sw.Close();

                ParentForm.SetTimer(_tName, _tMaxLP, _tCurrentLP, _tRecoverCycle, out _TimeSet.tName, out _TimeSet.tHour, out _TimeSet.tMinute, out _TimeSet.tSecond, out _TimeSet.tDate);
                ParentForm.CreatetForm(_TimeSet);

                this.Close();
                
            }catch(Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Nortification", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }