Exemple #1
0
        private void RefreshSettingDisplay()
        {
            panel1.Visible = true;

            timePointChart.ChartAreas[0].AxisX.Minimum           = 0;
            timePointChart.ChartAreas[0].AxisX.Maximum           = 1440;
            timePointChart.ChartAreas[0].AxisX.Interval          = 360;
            timePointChart.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
            for (int i = 0; i < 1439; i++)
            {
                if (i % 360 == 0)
                {
                    CustomLabel customLabel = new CustomLabel(i, i + 50, HelperTool.ConverMinutes2DateTime(i), 0, LabelMarkStyle.None);

                    timePointChart.ChartAreas[0].AxisX.CustomLabels.Add(customLabel);
                }
            }

            timePointChart.ChartAreas[0].AxisY.Maximum           = 100;
            timePointChart.ChartAreas[0].AxisY.MajorGrid.Enabled = false;

            CreateTimePointList(currentControllerItem);
            DrawChart(currentControllerItem);
            if (currentControllerItem.OnTimerCount == 0 && currentControllerItem.OffTimerCount == 0)
            {
                enableCheckBox.Checked = false;
            }
            else
            {
                enableCheckBox.Checked = true;
            }
        }
Exemple #2
0
        /// <summary>
        /// 设置打开时间点列表
        /// </summary>
        /// <param name="onTimerCount"></param>
        /// <param name="onTimersMinutes"></param>
        private void SetOnTimerDataGridView(int onTimerCount, List <int> onTimersMinutes, List <List <int> > onTimersColorValues)
        {
            onTimerDataGridView.Rows.Clear();

            onTimerDataGridView.ColumnCount     = 7;
            onTimerDataGridView.Columns[0].Name = "时间";
            onTimerDataGridView.Columns[1].Name = "Channel 1";
            onTimerDataGridView.Columns[2].Name = "Channel 2";
            onTimerDataGridView.Columns[3].Name = "Channel 3";
            onTimerDataGridView.Columns[4].Name = "Channel 4";
            onTimerDataGridView.Columns[5].Name = "Channel 5";
            onTimerDataGridView.Columns[6].Name = "Channel 6";

            for (int i = 0; i < onTimerCount; i++)
            {
                List <string> row = new List <string>();

                row.Add(HelperTool.ConverMinutes2DateTime(onTimersMinutes[i]));
                foreach (var item in onTimersColorValues[i])
                {
                    row.Add(item.ToString());
                }

                onTimerDataGridView.Rows.Add(row.ToArray());
            }
        }
Exemple #3
0
        /// <summary>
        /// 设置关断时间点列表
        /// </summary>
        /// <param name="offTimerCount"></param>
        /// <param name="offTimersMinutes"></param>
        private void SetOffTimerDataGridView(int offTimerCount, List <int> offTimersMinutes)
        {
            offTimerDataGridView.ColumnCount     = 1;
            offTimerDataGridView.Columns[0].Name = "时间点";
            offTimerDataGridView.Rows.Clear();

            for (int i = 0; i < currentControllerItem.OffTimerCount; i++)
            {
                offTimerDataGridView.Rows.Add(HelperTool.ConverMinutes2DateTime(currentControllerItem.OffTimersMinutes[i]));
            }
        }
Exemple #4
0
        private void CreateTimePointList(ControllerItem item)
        {
            //if (item.OnTimersMinutes == null)
            //{
            //    CreateAddTimePointRow(timePanel, new Point(7, 20 + 0), rowHeight, "Add Time Point", 0, addTurnOnTimePointBtnTag);
            //    return;
            //}

            //if (item.OffTimersMinutes == null)
            //{
            //    CreateAddTimePointRow(timePanel, new Point(299, 20 + 0), rowHeight, "Add Turn Off Time", 299, addTurnOffTimePointBtnTag);
            //    return;
            //}

            timePanel.Controls.Clear();
            turnOffTimerLabels.Clear();
            turnOnTimerLabels.Clear();
            // 创建打开定时器
            for (int i = 0; i < item.OnTimersMinutes.Count; i++)
            {
                var onTimer = item.OnTimersMinutes[i];

                CreateTimePointRow(timePanel, 10000, i, rowHeight, HelperTool.ConverMinutes2DateTime(onTimer), 0);
            }

            // 创建增加打开定时器按钮
            CreateAddTimePointRow(timePanel, new Point(7, 20 + item.OnTimersMinutes.Count * rowHeight), rowHeight, "Add Time Point", 0, addTurnOnTimePointBtnTag);

            // 创建关闭定时器
            for (int i = 0; i < item.OffTimersMinutes.Count; i++)
            {
                var offTimer = item.OffTimersMinutes[i];

                CreateTimePointRow(timePanel, 20000, i, rowHeight, HelperTool.ConverMinutes2DateTime(offTimer), 299);
            }

            // 创建增加关闭定时器按钮
            CreateAddTimePointRow(timePanel, new Point(299, 20 + item.OffTimersMinutes.Count * rowHeight), rowHeight, "Add Turn Off Time", 299, addTurnOffTimePointBtnTag);
        }
Exemple #5
0
        /// <summary>
        /// 修改时间点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TimPointDateTimePicker_ValueChanged(object sender, EventArgs e)
        {
            DateTimePicker dateTimePicker = (DateTimePicker)sender;
            int            minutes        = HelperTool.ConverDateTime2Minutes(dateTimePicker.Value);

            if (isEditTurnOnTimer)
            {
                currentControllerItem.OnTimersMinutes[currentTimerIndex] = minutes;

                // 更新列表中label显示
                turnOnTimerLabels[currentTimerIndex].Text = HelperTool.ConverMinutes2DateTime(minutes);
            }
            else
            {
                currentControllerItem.OffTimersMinutes[currentTimerIndex] = minutes;

                // 更新列表中label显示
                turnOffTimerLabels[currentTimerIndex].Text = HelperTool.ConverMinutes2DateTime(minutes);
            }

            // 重绘曲线图
            DrawChart(currentControllerItem);
        }
Exemple #6
0
        /// <summary>
        /// 增加时间点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddBtn_Click(object sender, EventArgs e)
        {
            saveButton.Visible = true;

            Button btn     = (Button)sender;
            Panel  panel   = (Panel)btn.Parent;
            int    minutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;

            if ((int)panel.Tag == addTurnOnTimePointBtnTag)
            {
                if (currentControllerItem.OnTimerCount >= 8)
                {
                    MessageBox.Show("Eight time points at most!");
                    return;
                }

                // 增加一个时间点
                CreateTimePointRow(timePanel, 10000, currentControllerItem.OnTimerCount, rowHeight, HelperTool.ConverMinutes2DateTime(minutes), 0);

                // 往下移动添加按钮
                btn.Parent.Location = new Point(btn.Parent.Location.X, btn.Parent.Location.Y + rowHeight);

                currentControllerItem.OnTimersMinutes.Add(HelperTool.GetDefaultMinutes());

                var defaultColorValues = HelperTool.GetDefaultColorValues(HelperTool.GetChannelNum());

                currentControllerItem.OnTimersColorValues.Add(defaultColorValues);

                // SetTrackBarColorValue(this.trackBars, this.labels, currentControllerItem.OnTimersColorValues[currentControllerItem.OnTimerCount].ToArray());

                currentControllerItem.OnTimerCount++;
            }
            else if ((int)panel.Tag == addTurnOffTimePointBtnTag)
            {
                if (currentControllerItem.OffTimerCount >= 8)
                {
                    MessageBox.Show("Eight time points at most!");
                    return;
                }

                // 增加一个时间点
                CreateTimePointRow(timePanel, 20000, currentControllerItem.OffTimerCount, rowHeight, HelperTool.ConverMinutes2DateTime(minutes), 299);

                currentControllerItem.OffTimersMinutes.Add(HelperTool.GetDefaultMinutes());

                // 往下移动添加按钮
                btn.Parent.Location = new Point(btn.Parent.Location.X, btn.Parent.Location.Y + rowHeight);

                currentControllerItem.OffTimerCount++;
            }

            DrawChart(currentControllerItem);
        }