예제 #1
0
        private void panel1_Resize(object sender, EventArgs e)
        {
            Rectangle rect;
            LabelTag  labelTag = null;

            panel1.Visible = false;
            foreach (Control control in panel1.Controls)
            {
                try
                {
                    labelTag       = (LabelTag)(control.Tag);
                    rect           = new Rectangle();
                    rect.X         = Convert.ToInt32(1.0 * labelTag.ControlX / labelTag.ParentWidth * panel1.Width);
                    rect.Y         = Convert.ToInt32(1.0 * labelTag.ControlY / labelTag.ParentHeight * panel1.Height);
                    control.Bounds = rect;

                    if (control.GetType() == typeof(PictureBox))
                    {
                        control.Size = new System.Drawing.Size((int)(22.0 / labelTag.ParentWidth * panel1.Width), (int)(28.0 / labelTag.ParentHeight * panel1.Height));
                        control.Refresh();
                    }
                }
                catch { }
            }
            panel1.Visible = true;
        }
예제 #2
0
        void control_MouseUp(object sender, MouseEventArgs e)
        {
            control = (Label)sender;
            if (e.Button == MouseButtons.Left)
            {
                if (isDrag)
                {
                    isDrag = false;
                    sSql   = "update YXYHControlConfig set ControlX=" + control.Location.X + ",ControlY=" + control.Location.Y
                             + ",ParentHeight=" + control.Parent.Height + ",ParentWidth=" + control.Parent.Width
                             + " where ControlName='" + control.Name + "'";
                    SQLHelper.ExecuteSql(sSql);
                    control.Location = point;
                    control.Refresh();
                    LabelTag labelTag = null;;
                    try
                    {
                        labelTag = (LabelTag)control.Tag;
                        if (labelTag == null)
                        {
                            labelTag = new LabelTag();
                        }
                    }
                    catch
                    { labelTag = new LabelTag(); }

                    labelTag.ControlX     = point.X;
                    labelTag.ControlY     = point.Y;
                    labelTag.ParentHeight = control.Parent.Height;
                    labelTag.ParentWidth  = control.Parent.Width;
                    control.Tag           = labelTag;
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 设定绑定标签的Text(测点值+测点单位)。
        /// </summary>
        void SetBindingLabelsText()
        {
            try
            {
                Control control, parent;
                parent = panel6;
                LabelTag labelTag = null;
                foreach (DataRow row in YXYHTagLabelBinding.getAllData().Rows)
                {
                    try
                    {
                        //由父控件找到本Label
                        control      = parent.Controls.Find(row["LabelName"].ToString(), false)[0];
                        control.Text = CalTagValue.GetTagValueAndUnitByID(row["TagID"].ToString());
                        control.Refresh();

                        try
                        {
                            labelTag = (LabelTag)control.Tag;
                            if (labelTag.IsSetToolTipText == false)
                            {
                                toolTip1.SetToolTip(control, row["TagDesc"].ToString());
                                labelTag.IsSetToolTipText = true;
                                labelTag.TagID            = int.Parse(row["TagID"].ToString());
                                labelTag.TagDesc          = row["TagDesc"].ToString();
                                control.Tag = labelTag;
                            }
                            if (labelTag.TagID == 0)
                            {
                                labelTag.TagID   = int.Parse(row["TagID"].ToString());
                                labelTag.TagDesc = row["TagDesc"].ToString();
                                control.Tag      = labelTag;
                                WriteLog.WriteLogs("id=0");
                            }
                        }
                        catch
                        {
                            control.Tag = new LabelTag(true, int.Parse(row["TagID"].ToString()), row["TagDesc"].ToString());
                            toolTip1.SetToolTip(control, row["TagDesc"].ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        //WriteLog.WriteLogs(ex.ToString());
                    }
                }
                lblRunOptimizePromptText.Text      = RunOptimizePrompt.GetPromptText();
                lblRunOptimizePromptText.ForeColor = RunOptimizePrompt.GetPromptTextForeColor();
            }
            catch (Exception ex)
            { WriteLog.WriteLogs(ex.ToString()); }
        }
예제 #4
0
 private void Label_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         LabelTag labelTag = (LabelTag)((Label)sender).Tag;
         if (labelTag.TagID > 0)
         {
             HistoryLines m_frmHistoryLines = new HistoryLines();
             m_frmHistoryLines.labelTag.TagID   = labelTag.TagID;
             m_frmHistoryLines.labelTag.TagDesc = labelTag.TagDesc;
             m_frmHistoryLines.ShowDialog();
         }
     }
     catch (Exception ex) { WriteLog.WriteLogs(ex.ToString()); }
 }
예제 #5
0
        void SetLabelsForeColor(Color color)
        {
            LabelTag labelTag = null;

            foreach (Control control in panel6.Controls)
            {
                try
                {
                    labelTag          = (LabelTag)control.Tag;
                    control.ForeColor = color;
                    control.Refresh();
                }
                catch { }
            }
        }
예제 #6
0
        /// <summary>
        /// 设置Label的可见性
        /// </summary>
        public void SetLabelVisible(bool bHCGDChecked)
        {
            Control  control, parent = panel1;
            LabelTag labelTag = null;
            int      i;
            string   sTagID = "";

            string[] sHideIDs;//要隐藏的测点
            if (bHCGDChecked == true)
            {
                sHideIDs = sUnit2HCGR_IDs.Split(',');
            }
            else
            {
                sHideIDs = sUnit2HCGD_IDs.Split(',');
            }

            dtControls = TableControlConfig.getDataTableByRowFilter("[Parent] like 'YXYHMainSix.%' and [TagID] in (" + sUnit2HCGD_IDs + "," + sUnit2HCGR_IDs + ")");
            foreach (DataRow row in dtControls.Rows)
            {
                try
                {
                    //由父控件找到本Label
                    try { control = parent.Controls.Find(row["ControlName"].ToString(), false)[0]; }
                    catch { continue; }
                    labelTag = (LabelTag)control.Tag;

                    control.Visible = true;
                    sTagID          = row["TagID"].ToString();
                    for (i = 0; i < sHideIDs.Length; i++)
                    {
                        if (sTagID == sHideIDs[i])
                        {
                            control.Visible = false;
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteLog.WriteLogs(ex.ToString());
                }
            }
            dtControls.Dispose();
            dtControls = null;
        }
예제 #7
0
        private void contextMenuStrip_Label_SaveLabel_Click(object sender, EventArgs e)
        {
            LabelTag  labelTag = null;
            ArrayList lstSql   = new ArrayList();
            Rectangle rect;

            foreach (Control control in panel6.Controls)
            {
                try
                {
                    labelTag = (LabelTag)(control.Tag);
                    rect     = control.Bounds;
                    lstSql.Add("update YXYHControlConfig set ControlX=" + rect.X + ",ControlY=" + rect.Y + ",ParentHeight=" + panel6.Height
                               + ",ParentWidth=" + panel6.Width + " where ControlName='" + control.Name + "'");
                }
                catch { }
            }
            SQLHelper.ExecuteSql(lstSql);
            MessageBox.Show("保存完成!");
        }
예제 #8
0
        private void panel6_Resize(object sender, EventArgs e)
        {
            Rectangle rect;
            LabelTag  labelTag = null;

            this.Visible = false;
            foreach (Control control in panel6.Controls)
            {
                try
                {
                    labelTag       = (LabelTag)(control.Tag);
                    rect           = new Rectangle();
                    rect.X         = Convert.ToInt32(1.0 * labelTag.ControlX / labelTag.ParentWidth * panel6.Width);
                    rect.Y         = Convert.ToInt32(1.0 * labelTag.ControlY / labelTag.ParentHeight * panel6.Height);
                    control.Bounds = rect;
                }
                catch { }
            }
            this.Visible = true;
        }
예제 #9
0
 public static LabelTag addReSize(LabelTag myLabelTag, string reSize)
 {
     myLabelTag.ReSizeStr = reSize;
     return(myLabelTag);
 }
예제 #10
0
        /// <summary>
        /// 加载程序运行中配置的控件
        /// </summary>
        void AddConfigedControl()
        {
            try
            {
                int       i;
                Control   parent  = null;
                Control   control = null;
                Rectangle rect;
                LabelTag  labelTag = null;
                foreach (DataRow row in dtControls.Rows)
                {
                    parent = panel1;
                    try
                    {
                        if (row["type"].ToString() == "PictureBox")
                        {
                            int controlX = int.Parse(row["ControlX"].ToString());
                            int controlY = int.Parse(row["ControlY"].ToString());
                            control = new PictureBox();
                            ((PictureBox)control).BackgroundImage       = global::KSPrj.Properties.Resources.verticalGreen;
                            ((PictureBox)control).BackgroundImageLayout = ImageLayout.Stretch;
                            control.Name          = row["ControlName"].ToString();
                            rect                  = new Rectangle();
                            rect.X                = controlX;
                            rect.Y                = controlY;
                            labelTag              = new LabelTag();
                            labelTag.ParentHeight = int.Parse(row["ParentHeight"].ToString());
                            labelTag.ParentWidth  = int.Parse(row["ParentWidth"].ToString());
                            labelTag.ControlX     = controlX;
                            labelTag.ControlY     = controlY;
                            labelTag.UnitNo       = byte.Parse(row["UnitNo"].ToString());
                            control.Tag           = labelTag;

                            control.Bounds = rect;
                            control.Size   = new System.Drawing.Size(12, 18);
                            parent.Controls.Add(control);
                            control.Refresh();
                            continue;
                        }

                        //这里先以Label写死;如果以后还有其他类型的控件,则在这里枚举
                        control = new Label();
                        ((Label)control).AutoSize = true;
                        control.Name = row["ControlName"].ToString();
                        control.Text = control.Name;
                        if (row["ControlText"].ToString().Length > 1)
                        {
                            control.Text = row["ControlText"].ToString();
                        }
                        if (row["FontSize"].ToString().Length > 1)
                        {
                            control.Font = new System.Drawing.Font("宋体", float.Parse(row["FontSize"].ToString()), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                        }
                        rect           = new Rectangle();
                        rect.X         = int.Parse(row["ControlX"].ToString());
                        rect.Y         = int.Parse(row["ControlY"].ToString());
                        control.Bounds = rect;
                        try { control.ForeColor = Color.FromArgb(int.Parse(row["ForeColor"].ToString())); }
                        catch { }
                        try { control.BackColor = Color.Transparent; }//Color.FromArgb(int.Parse(row["BackColor"].ToString()));
                        catch { }
                        labelTag              = new LabelTag();
                        labelTag.ControlX     = rect.X;
                        labelTag.ControlY     = rect.Y;
                        labelTag.ParentHeight = int.Parse(row["ParentHeight"].ToString());
                        labelTag.ParentWidth  = int.Parse(row["ParentWidth"].ToString());
                        labelTag.UnitNo       = byte.Parse(row["UnitNo"].ToString());
                        control.Tag           = labelTag;
                        control.DoubleClick  += new EventHandler(Label_DoubleClick);//双击事件
                        parent.Controls.Add(control);
                    }
                    catch { }
                }
            }
            catch (Exception ex)
            { WriteLog.WriteLogs(ex.ToString()); }
        }
예제 #11
0
        /// <summary>
        /// 加载程序运行中配置的控件
        /// </summary>
        void AddConfigedControl()
        {
            try
            {
                //控制添加测点的按钮是否可见
                if (ConstYXYH.IsCanAddLabel)
                {
                    btnAddTag.Visible = true;
                }
                else
                {
                    btnAddTag.Visible = false;
                }

                int       i;
                Control   parent  = null;
                Control   control = null;
                Rectangle rect;
                LabelTag  labelTag = null;
                foreach (DataRow row in dtControls.Rows)
                {
                    parent = panel6;
                    try
                    {
                        //这里先以Label写死;如果以后还有其他类型的控件,则在这里枚举
                        control = new Label();
                        ((Label)control).AutoSize = true;
                        control.Name = row["ControlName"].ToString();
                        control.Text = control.Name;
                        if (row["ControlText"].ToString().Length > 1)
                        {
                            control.Text = row["ControlText"].ToString();
                        }
                        rect           = new Rectangle();
                        rect.X         = int.Parse(row["ControlX"].ToString());
                        rect.Y         = int.Parse(row["ControlY"].ToString());
                        control.Bounds = rect;
                        try { control.ForeColor = Color.FromArgb(int.Parse(row["ForeColor"].ToString())); }
                        catch { }
                        try { control.BackColor = Color.FromArgb(int.Parse(row["BackColor"].ToString())); }
                        catch { }
                        labelTag              = new LabelTag();
                        labelTag.ControlX     = rect.X;
                        labelTag.ControlY     = rect.Y;
                        labelTag.ParentHeight = int.Parse(row["ParentHeight"].ToString());
                        labelTag.ParentWidth  = int.Parse(row["ParentWidth"].ToString());
                        control.Tag           = labelTag;
                        control.DoubleClick  += new EventHandler(Label_DoubleClick);      //双击事件
                        control.MouseDown    += new MouseEventHandler(control_MouseDown); //鼠标按下事件
                        if (ConstYXYH.IsCanMoveLabel)
                        {
                            control.MouseMove       += new MouseEventHandler(control_MouseMove); //移动时的鼠标移动事件
                            control.MouseUp         += new MouseEventHandler(control_MouseUp);   //移动时的鼠标抬起事件
                            control.ContextMenuStrip = contextMenuStrip_Label;                   //添加快捷菜单
                        }
                        parent.Controls.Add(control);
                    }
                    catch { }
                }
            }
            catch (Exception ex)
            { WriteLog.WriteLogs(ex.ToString()); }
        }