陈嘉乐
2020-12-29 bff0a4962f597be1b4ea040be43221a850b8ddb4
2020-12-29-1

优化时间点和时间段代码
7个文件已修改
390 ■■■■■ 已修改文件
.vs/HDL_APP_Project/xs/UserPrefs.xml 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/sqlite3/storage.ide 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TimeView.cs 119 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs 248 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -1,13 +1,14 @@
<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default">
  <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.00008020-001674E61438002E" />
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/CheckView.cs">
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs">
    <Files>
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/FunTpye.cs" Line="21" Column="32" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs" Line="349" Column="67" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/DateView.cs" Line="51" Column="47" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddTarget.cs" Line="95" Column="30" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs" Line="168" Column="23" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/CheckView.cs" Line="40" Column="43" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/DateView.cs" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddTarget.cs" Line="12" Column="27" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs" Line="91" Column="30" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TimeView.cs" Line="158" Column="70" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs" Line="126" Column="25" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs" Line="136" Column="41" />
    </Files>
    <Pads>
      <Pad Id="ProjectPad">
@@ -18,9 +19,8 @@
                <Node name="UI2" expanded="True">
                  <Node name="3-Intelligence" expanded="True">
                    <Node name="Automation" expanded="True">
                      <Node name="LogicView" expanded="True">
                        <Node name="CheckView.cs" selected="True" />
                      </Node>
                      <Node name="LogicView" expanded="True" />
                      <Node name="InpOrOutLogicMethod.cs" selected="True" />
                    </Node>
                  </Node>
                  <Node name="FuntionControlView" expanded="True" />
.vs/HDL_APP_Project/xs/sqlite3/storage.ide
Binary files differ
.vs/HDL_APP_Project/xs/sqlite3/storage.ide-shm
Binary files differ
.vs/HDL_APP_Project/xs/sqlite3/storage.ide-wal
Binary files differ
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TimeView.cs
old mode 100755 new mode 100644
@@ -72,6 +72,7 @@
        /// </summary>
        /// <returns></returns>
        public void FLayoutView(FrameLayout fLayout)
        //public void FLayoutView(FrameLayout fLayout, string currState, Action<string> action)
        {
           
            fLayout.AddChidren(frameLayout);
@@ -79,6 +80,93 @@
            frameLayout.AddChidren(btnCancel);
            frameLayout.AddChidren(btnConfirm);
            frameLayout.AddChidren(btnLine);
            //TimePoint(fLayout, action,currState);
        }
        /// <summary>
        /// 选中时间的方法
        /// </summary>
        /// <param name="fLayout">父控件</param>
        /// <param name="currState">之前状态值</param>
        /// <param name="action">返回时间值</param>
        public void TimePoint(FrameLayout fLayout, string currState, Action<string> action)
        {
            //取消点击事件
            btnCancel.MouseUpEventHandler += (sender, e1) =>
            {
                //移除fLayout界面
                fLayout.RemoveFromParent();
            };
            //加载数据界面的设置方法(列表互不联动)
            mUIPickerView.setNPicker(GethStringList(), GetmStringList(), null);
            var systemHour = DateTime.Now.Hour; //获取小时
            var systeMinute = DateTime.Now.Minute;//获取分钟
            int systemHourIndex = 0;
            int systeMinuteIndex = 0;
            for (int i = 0; i < GethIntList().Count; i++)
            {
                var currhour = GethIntList()[i];
                if (systemHour == currhour)
                {
                    systemHourIndex = i;
                    break;
                }
            }
            for (int i = 0; i < GetmIntList().Count; i++)
            {
                var currminute = GetmIntList()[i];
                if (systeMinute == currminute)
                {
                    systeMinuteIndex = i;
                    break;
                }
            }
            //默认初始选中状态
            mUIPickerView.setCurrentItems(systemHourIndex, systeMinuteIndex, 0);
            string currH = "";
            string currM = "";
            if (systemHour < 10)
            {
                currH = "0" + systemHour.ToString();
            }
            else
            {
                currH = systemHour.ToString();
            }
            if (systeMinute < 10)
            {
                currM = "0" + systeMinute.ToString();
            }
            else
            {
                currM = systeMinute.ToString();
            }
            //定义一个局部变量记录选中时间
            string timepoint = currH + ":" + currM;
            if (currState != "")
            {
                int hIndex = GetValueIndex(currState, 0, 1, GethIntList());
                int mIndex = GetValueIndex(currState, 1, 0, GetmIntList());
                //更新初始状态
                mUIPickerView.setCurrentItems(hIndex, mIndex, 0);
                timepoint = currState;
            }
            //选中时间回调方法,时间变化一次回调一次
            mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) =>
            {
                string hour = GethStringList()[index1].Split(' ')[0];
                string minuet = GetmStringList()[index2].Split(' ')[0];
                timepoint = hour + ":" + minuet;
            };
            //确定点击事件
            btnConfirm.MouseUpEventHandler += (sender, e3) =>
            {
                action(timepoint);
                //移除fLayout界面
                fLayout.RemoveFromParent();
            };
        }
        /// <summary>
        /// 获取1-24小时列表
@@ -193,37 +281,6 @@
                mList.Add(i);
            }
            return mList;
        }
        /// <summary>
        /// 返回指定单位列表
        /// </summary>
        /// <param name="min">最小值</param>
        /// <param name="max">最大值</param>
        /// <param name="name">单位(时,分,秒)</param>
        /// <param name="digit">位数(10以下用(1位还是2位)显示)</param>
        /// <returns></returns>
        public List<string> GetStringList(int min, int max, string name, int digit)
        {
            //初始化列表
            var list = new List<string>();
            for (int i = min; i < max; i++)
            {
                if (i < 10 && digit == 2)
                {
                    var a = "0" + i.ToString();
                    //添加数据
                    list.Add(a + " " + name);
                }
                else
                {
                    //添加数据
                    list.Add(i.ToString() + " " + name);
                }
            }
            return list;
        }
        /// <summary>
HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs
@@ -253,12 +253,12 @@
        }
        /// <summary>
        ///
        /// 超出5个元素该用滑动控件
        /// </summary>
        /// <param name="frame">显示在哪个界面的父控件</param>
        /// <param name="list">显示数据源</param>
        /// <param name="titleText">标题</param>
        /// <param name="action">返回值</param>
        /// <param name="action">返回值索引值</param>
        public void FrameOrVv(FrameLayout frame, List<string>list, int titleText,Action<int> action) { 
            int line = 0;
@@ -379,6 +379,7 @@
                {
                    return;
                }
                //列表索引值
                int indexValue = int.Parse(checkBtn.Tag.ToString());
                action(indexValue);
                //移除fLayout界面
HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs
old mode 100755 new mode 100644
@@ -90,64 +90,8 @@
        /// <param name="index">编辑条件的索引</param>
        public void TimePoint(FrameLayout fLayout, bool edit, int index)
        {
            LogicView.TimeView timePointView = new LogicView.TimeView();
            timePointView.FLayoutView(fLayout);
            EventHandler<MouseEventArgs> removefLayout = (sender, e1) =>
             {
                 //移除fLayout界面
                 fLayout.RemoveFromParent();
             };
            //取消点击事件
            timePointView.btnCancel.MouseUpEventHandler += removefLayout;
            //加载数据界面的设置方法(列表互不联动)
            timePointView.mUIPickerView.setNPicker(timePointView.GethStringList(), timePointView.GetmStringList(), null);
            var systemHour = DateTime.Now.Hour; //获取小时
            var systeMinute = DateTime.Now.Minute;//获取分钟
            int systemHourIndex = 0;
            int systeMinuteIndex = 0;
            for (int i = 0; i < timePointView.GethIntList().Count; i++)
            {
                var currhour = timePointView.GethIntList()[i];
                if (systemHour == currhour)
                {
                    systemHourIndex = i;
                    break;
                }
            }
            for (int i = 0; i < timePointView.GetmIntList().Count; i++)
            {
                var currminute = timePointView.GetmIntList()[i];
                if (systeMinute == currminute)
                {
                    systeMinuteIndex = i;
                    break;
                }
            }
            //默认初始选中状态
            timePointView.mUIPickerView.setCurrentItems(systemHourIndex, systeMinuteIndex, 0);
            string currH = "";
            string currM = "";
            if (systemHour < 10)
            {
                currH = "0" + systemHour.ToString();
            }
            else
            {
                currH = systemHour.ToString();
            }
            if (systeMinute < 10)
            {
                currM = "0" + systeMinute.ToString();
            }
            else
            {
                currM = systeMinute.ToString();
            }
            //定义一个局部变量记录选中时间
            string timepoint = currH + ":" + currM;
            //编辑之前的时间状态值
            string editTime= "";
            if (edit)
            {
                Input inputs = Logic.currlogic.input[index];
@@ -157,25 +101,14 @@
                    foreach (var dic in dicList)
                    {
                        string timeValue = dic["value"];
                        int hIndex = timePointView.GetValueIndex(timeValue, 0, 1, timePointView.GethIntList());
                        int mIndex = timePointView.GetValueIndex(timeValue, 1, 0, timePointView.GetmIntList());
                        //更新初始状态
                        timePointView.mUIPickerView.setCurrentItems(hIndex, mIndex, 0);
                        timepoint = timeValue;
                        editTime = timeValue;
                        break;
                    }
                }
            }
            //选中时间回调方法,时间变化一次回调一次
            timePointView.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) =>
            {
                string hour = timePointView.GethStringList()[index1].Split(' ')[0];
                string minuet = timePointView.GetmStringList()[index2].Split(' ')[0];
                timepoint = hour + ":" + minuet;
            };
            //确定点击事件
            timePointView.btnConfirm.MouseUpEventHandler += (sender, e3) =>
            {
            LogicView.TimeView timePointView = new LogicView.TimeView();
            timePointView.FLayoutView(fLayout);
            timePointView.TimePoint(fLayout, editTime, (timeValue)=>{
                Input inputTime = new Input();
                inputTime.sid = LogicMethod.NewSid();
                inputTime.condition_type = "1";
@@ -183,27 +116,11 @@
                LogicMethod.dictionary(dic, "key", "timepoint");
                LogicMethod.dictionary(dic, "comparator", "=");
                LogicMethod.dictionary(dic, "data_type", "string");
                LogicMethod.dictionary(dic, "value", timepoint);
                LogicMethod.dictionary(dic, "value", timeValue);
                inputTime.condition.Add(dic);
                if (edit)
                {
                    //移除旧数据
                    Logic.currlogic.input.RemoveAt(index);
                    //新数据插入旧数据的位置;
                    Logic.currlogic.input.Insert(index, inputTime);
                }
                else
                {
                    //添加一个新的时间点条件
                    Logic.currlogic.input.Add(inputTime);
                }
                LogicMethod.RemoveAllView();
                AddLogic addLogic = new AddLogic();
                MainPage.BasePageView.AddChidren(addLogic);
                addLogic.Show();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                AddCondition(inputTime, edit, index);
            });
            };
        }
        /// <summary>
        /// 时间范围方法
@@ -324,24 +241,7 @@
                LogicMethod.dictionary(dic, "data_type", "string");
                LogicMethod.dictionary(dic, "value", btnStartTimeText.Text + "-" + btnEndTimeText.Text);
                inputTime.condition.Add(dic);
                if (edit)
                {
                    //移除旧数据
                    Logic.currlogic.input.RemoveAt(index);
                    //新数据插入旧数据的位置
                    Logic.currlogic.input.Insert(index, inputTime);
                    fLayout.RemoveFromParent();
                }
                else
                {
                    //添加一个新的时间点条件
                    Logic.currlogic.input.Add(inputTime);
                }
                LogicMethod.RemoveAllView();
                AddLogic addLogic = new AddLogic();
                MainPage.BasePageView.AddChidren(addLogic);
                addLogic.Show();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                AddCondition(inputTime, edit, index);
            };
@@ -367,76 +267,18 @@
            }
        }
        /// <summary>
        /// 设置时间段时间的方法
        /// 设置时间段值
        /// </summary>
        /// <param name="fLayout"></param>
        /// <param name="btn"></param>
        public void SelectedTimeHorizon(FrameLayout fLayout, Button btn)
        {
            LogicView.TimeView timePointView = new LogicView.TimeView();
            timePointView.FLayoutView(fLayout);
            EventHandler<MouseEventArgs> RemovefLayout = (sender, e1) =>
            {
                //只移除时间弹窗界面
                timePointView.frameLayout.RemoveFromParent();
            };
            //取消点击事件
            timePointView.btnCancel.MouseUpEventHandler += RemovefLayout;
            //加载数据界面的设置方法(列表互不联动)
            timePointView.mUIPickerView.setNPicker(timePointView.GethStringList(), timePointView.GetmStringList(), null);
            var systemHour = DateTime.Now.Hour; //获取小时
            var systeMinute = DateTime.Now.Minute;//获取分钟
            int systemHourIndex = 0;
            int systeMinuteIndex = 0;
            for (int i = 0; i < timePointView.GethIntList().Count; i++)
            {
                var currhour = timePointView.GethIntList()[i];
                if (systemHour == currhour)
                {
                    systemHourIndex = i;
                    break;
                }
            }
            for (int i = 0; i < timePointView.GetmIntList().Count; i++)
            {
                var currminute = timePointView.GetmIntList()[i];
                if (systeMinute == currminute)
                {
                    systeMinuteIndex = i;
                    break;
                }
            }
            //默认初始选中状态
            timePointView.mUIPickerView.setCurrentItems(systemHourIndex, systeMinuteIndex, 0);
            string currH = "";
            string currM = "";
            if (systemHour < 10)
            {
                currH = "0" + systemHour.ToString();
            }
            else
            {
                currH = systemHour.ToString();
            }
            if (systeMinute < 10)
            {
                currM = "0" + systeMinute.ToString();
            }
            else
            {
                currM = systeMinute.ToString();
            }
            //定义一个局部变量记录选中时间
            string timepoint = currH + ":" + currM;
            int sumTime = systemHour*60+ systeMinute;
            //编辑之前的时间状态值
            string editTime = "";
            if (btn.Tag.ToString() != "0")
            {
                string h = "", m = "";
                sumTime = int.Parse(btn.Tag.ToString());
               int  sumTime = int.Parse(btn.Tag.ToString());
                if ((sumTime / 60) < 10)
                {
                    h = "0" + (sumTime / 60).ToString();
@@ -454,34 +296,48 @@
                {
                    m = (sumTime % 60).ToString();
                }
                timepoint = h + ":" + m;
                int hourIndex = timePointView.GetValueIndex(timepoint, 0, 1, timePointView.GethIntList());
                int minuteIndex = timePointView.GetValueIndex(timepoint, 1, 0, timePointView.GetmIntList());
                //更新状态
                timePointView.mUIPickerView.setCurrentItems(hourIndex, minuteIndex, 0);
                editTime = h + ":" + m;
            }
            LogicView.TimeView timePointView = new LogicView.TimeView();
            timePointView.FLayoutView(fLayout);
            timePointView.TimePoint(timePointView.frameLayout, editTime, (timeValue) =>
            {
                int hour = int.Parse(timeValue.Split(':')[0]);
                int minuet = int.Parse(timeValue.Split(':')[1]);
                int intValueTag = hour * 60 + minuet;
                //标记值,用于比较开始时间和结束时间大小;
                btn.Tag = intValueTag;
                //显示时间文本
                btn.Text = timeValue;
            });
            }
            //选中时间回调方法,时间变化一次回调一次
            timePointView.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) =>
        /// <summary>
        /// 添加条件
        /// </summary>
        /// <param name="input"></param>
        private void AddCondition(Input input,bool edit,int index)
            {
                string hour = timePointView.GethStringList()[index1].Split(' ')[0];
                string minuet = timePointView.GetmStringList()[index2].Split(' ')[0];
                timepoint = hour + ":" + minuet;
                sumTime = int.Parse(hour) * 60 + int.Parse(minuet);
            };
            //确定点击事件
            timePointView.btnConfirm.MouseUpEventHandler += (sender1, e3) =>
            if (edit)
            {
                btn.Tag = sumTime;
                btn.Text = timepoint;
                //只移除时间弹窗界面
                timePointView.frameLayout.RemoveFromParent();
            };
                //移除旧数据
                Logic.currlogic.input.RemoveAt(index);
                //新数据插入旧数据的位置
                Logic.currlogic.input.Insert(index, input);
        }
            else
            {
                //添加一个新的时间条件
                Logic.currlogic.input.Add(input);
            }
            LogicMethod.RemoveAllView();
            AddLogic addLogic = new AddLogic();
            MainPage.BasePageView.AddChidren(addLogic);
            addLogic.Show();
            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
        }
        /// <summary>
        /// 灰色弹框父控件
        /// </summary>