예제 #1
0
        private void 重命名ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = treeview1.SelectedNode;

            MainSubView.UpdataView view = new MainSubView.UpdataView(node.Name);
            string       originName     = node.Name;
            DialogResult result         = view.ShowDialog();

            if (result == DialogResult.OK)
            {
                string   where_cmd  = "viewname='" + originName + "'";
                string[] updata_cmd = new string[1];
                updata_cmd[0] = "viewname='" + MainSubView.UpdataView.View_Name + "'";
                bool success = Main_DataBase_Builder.Updata("AllView", where_cmd, updata_cmd);
                if (success == true)
                {
                    Main_DataBase_Builder.Updata_Table_Name(originName, MainSubView.UpdataView.View_Name);
                }
                TreeNode viewnode = FindTreeNodeWithName("画面", treeview1);
                if (viewnode != null)
                {
                    Reflush_TreeView_ViewNode(viewnode);               // 刷新画面的父结点的信息
                }
                /// 其他的修改
            }
        }
예제 #2
0
        bool Vertical_Pressed = false;                                     // 竖起的滑块按下

        public MyChart(DataRow dr, SQL_Connect_Builder builder)
        {
            InitializeComponent();
            timer1.Interval = 1000;
            timer1.Elapsed += new System.Timers.ElapsedEventHandler(Draw);
            timer1.Enabled  = true;

            // mytreeview.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(Jump_Window_Event);
            // 注册滑动块的路由事件


            this.drawgrid.AddHandler(Slider.MouseLeftButtonDownEvent, new RoutedEventHandler(this.slider_MouseLeftButtonDown));
            this.drawgrid.AddHandler(Slider.MouseMoveEvent, new RoutedEventHandler(this.slider_MouseMove));
            this.drawgrid.AddHandler(Slider.MouseLeftButtonUpEvent, new RoutedEventHandler(this.slider_MouseLeftButtonUp));

            //slider.Value = 5;

            try
            {
                if (dr == null || builder == null)
                {
                    return;
                }

                // 变量传输
                mydr      = dr;
                mybuilder = builder;

                this.Name   = dr[0].ToString();
                this.Width  = double.Parse(dr[3].ToString());
                this.Height = double.Parse(dr[4].ToString());

                // 横对齐解析
                switch (dr[5].ToString())
                {
                case "Left":
                    HorizontalAlignment = HorizontalAlignment.Left;
                    break;

                case "Right":
                    HorizontalAlignment = HorizontalAlignment.Right;
                    break;

                case "Center":
                    HorizontalAlignment = HorizontalAlignment.Center;
                    break;

                case "Stretch":
                    HorizontalAlignment = HorizontalAlignment.Stretch;
                    break;

                default:
                    HorizontalAlignment = HorizontalAlignment.Center;
                    break;
                }

                // 纵对齐解析
                switch (dr[6].ToString())
                {
                case "Top":
                    VerticalAlignment = VerticalAlignment.Top;
                    break;

                case "Bottom":
                    VerticalAlignment = VerticalAlignment.Bottom;
                    break;

                case "Center":
                    VerticalAlignment = VerticalAlignment.Center;
                    break;

                case "Stretch":
                    VerticalAlignment = VerticalAlignment.Stretch;
                    break;

                default:
                    VerticalAlignment = VerticalAlignment.Center;
                    break;
                }

                double MarginLeft   = double.Parse(dr[7].ToString());
                double MarginRight  = double.Parse(dr[8].ToString());
                double MarginTop    = double.Parse(dr[9].ToString());
                double MarginBottom = double.Parse(dr[10].ToString());

                this.Margin = new Thickness(MarginLeft, MarginTop, MarginRight, MarginBottom);


                // 通过 minvalue maxvalue 与 interval来决定纵坐标的数量与布局
                // 如果没有布局相关就直接退出下面的设置
                if (dr[11].ToString() == "" || dr[12].ToString() == "" || dr[13].ToString() == "")
                {
                    return;
                }
                try
                {
                    minvalue = double.Parse(dr[11].ToString());
                    maxvalue = double.Parse(dr[12].ToString());
                    interval = double.Parse(dr[13].ToString());
                    if (interval == 0)
                    {
                        return;                                                            // 除数是0 不成立
                    }
                    label_count = (int)((maxvalue - minvalue) / interval + 1);
                    for (int i = 0; i < label_count; i++)
                    {
                        Label newlabel = new Label();
                        newlabel.Content = minvalue + interval * i;

                        newlabel.Margin = new Thickness(100, subgrid.Margin.Top + subgrid.Height - (subgrid.Height / (label_count - 1)) * i - fixvalue, 0, 0);
                        drawgrid.Children.Add(newlabel);
                    }
                }


                catch { return; }

                // 解析线的情况
                // 线01
                if (dr[17].ToString() != "" && dr[18].ToString() != "")
                {
                    myline_Struct line = new myline_Struct(dr[17].ToString(), dr[18].ToString());
                    allline.Add(line);
                }

                // 线02
                if (dr[19].ToString() != "" && dr[20].ToString() != "")
                {
                    myline_Struct line = new myline_Struct(dr[19].ToString(), dr[20].ToString());
                    allline.Add(line);
                }

                // 线03
                if (dr[21].ToString() != "" && dr[22].ToString() != "")
                {
                    myline_Struct line = new myline_Struct(dr[21].ToString(), dr[22].ToString());
                    allline.Add(line);
                }

                // 线04
                if (dr[23].ToString() != "" && dr[24].ToString() != "")
                {
                    myline_Struct line = new myline_Struct(dr[23].ToString(), dr[24].ToString());
                    allline.Add(line);
                }

                // 线05
                if (dr[25].ToString() != "" && dr[26].ToString() != "")
                {
                    myline_Struct line = new myline_Struct(dr[25].ToString(), dr[26].ToString());
                    allline.Add(line);
                }

                // 线06
                if (dr[27].ToString() != "" && dr[28].ToString() != "")
                {
                    myline_Struct line = new myline_Struct(dr[27].ToString(), dr[28].ToString());
                    allline.Add(line);
                }

                // 线07
                if (dr[29].ToString() != "" && dr[30].ToString() != "")
                {
                    myline_Struct line = new myline_Struct(dr[29].ToString(), dr[30].ToString());
                    allline.Add(line);
                }

                // 线08
                if (dr[31].ToString() != "" && dr[32].ToString() != "")
                {
                    myline_Struct line = new myline_Struct(dr[31].ToString(), dr[32].ToString());
                    allline.Add(line);
                }

                // 线09
                if (dr[33].ToString() != "" && dr[34].ToString() != "")
                {
                    myline_Struct line = new myline_Struct(dr[33].ToString(), dr[34].ToString());
                    allline.Add(line);
                }

                // 线10
                if (dr[35].ToString() != "" && dr[36].ToString() != "")
                {
                    myline_Struct line = new myline_Struct(dr[35].ToString(), dr[36].ToString());
                    allline.Add(line);
                }
                // 通过TimeSpan Timeinterval 和 StartTime来决定横坐标的数量与布局
                if (dr[14].ToString() == "" || dr[15].ToString() == "")
                {
                    return;
                }
                try
                {
                    timespan     = double.Parse(dr[14].ToString());
                    timeinterval = double.Parse(dr[15].ToString());
                    if (dr[16].ToString() == "")
                    {
                        starttime = DateTime.Now;
                        string   where_cmd  = "ChartName='" + dr[0].ToString() + "'";
                        string[] update_cmd = new string[1];
                        update_cmd[0] = "StartTime='" + starttime.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                        builder.Updata("ALLMyChart", where_cmd, update_cmd);
                    }
                    else
                    {
                        starttime = DateTime.Parse(dr[16].ToString());
                    }

                    timelabelcount = (int)(timespan / timeinterval + 1);
                    for (int i = 0; i < timelabelcount; i++)
                    {
                        Label newlabel = new Label();
                        newlabel.Content = (starttime + TimeSpan.FromMinutes(timeinterval * i)).ToString("yyyy/MM/dd \n HH:mm:ss");
                        newlabel.Margin  = new Thickness(subgrid.Margin.Left + (subgrid.Width / (timelabelcount - 1)) * i - fixvalue_y, 250, 0, 0);
                        drawgrid.Children.Add(newlabel);
                    }
                }
                catch { return; }
            }
            catch { }
        }
예제 #3
0
        private void thread()
        {
            if (isupdate == false)
            {
                isupdate = true;
            }
            else
            {
                return;
            }
            ArrayList list = FileCaozuo.Read_All_Files("D://data//", "*.txt");


            int count = 0;

            try
            {
                string    where_cmd = "mykey='mynum'";
                DataTable dt        = builder.Select_Table("tiaonum", where_cmd);
                count = int.Parse(dt.Rows[0][1].ToString());
            }
            catch { }

            for (int i = count; i < list.Count; i++)
            {
                CreateSqlValueType[] create_cmd = new CreateSqlValueType[2];
                create_cmd[0] = new CreateSqlValueType("float", "pos", true);
                create_cmd[1] = new CreateSqlValueType("float", "value");

                string name     = (string)list[i];
                string filename = string_caozuo.Get_Dian_String(name, 1);
                builder.Create_Table("data" + string_caozuo.Get_HengGang_String(filename, 1) + string_caozuo.Get_HengGang_String(filename, 2), create_cmd);

                wenjian     = i;
                wenjianzong = list.Count;


                string   mywhere_cmd = "mykey='mynum'";
                string[] update_cmd  = new string[1];
                update_cmd[0] = "num='" + i.ToString() + "'";

                builder.Updata("tiaonum", mywhere_cmd, update_cmd);

                // 读取全部数据
                string[] jizhun_list = FileCaozuo.Read_All_Line("D:\\data\\" + name);
                for (int j = 0; j < jizhun_list.Length; j++)
                {
                    try
                    {
                        shuju     = j;
                        shujuzong = jizhun_list.Length;
                        string pos   = string_caozuo.Get_Table_String(jizhun_list[j], 1);
                        string value = string_caozuo.Get_Table_String(jizhun_list[j], 2);



                        string[] insert_cmd = new string[2];
                        insert_cmd[0] = pos;
                        insert_cmd[1] = value;
                        bool result = builder.Insert("data" + string_caozuo.Get_HengGang_String(filename, 1) + string_caozuo.Get_HengGang_String(filename, 2), insert_cmd);
                    }
                    catch { }
                }
            }
            isupdate = false;
        }