Beispiel #1
0
        public void RefreshObject(HmiApplication app, HmiPage page, HmiObject obj)
        {
            if (app == null || page == null || obj == null)
            {
                Clear();
                return;
            }

            m_app = app;
            m_page = page;
            m_obj = obj;

            dataGrid.Rows.Clear();
            cbAttrValues.Visible = false;
            m_selectedRow = -1;

            if (m_obj.Attributes.Count < 1)
            {
                MessageBox.Show("Control property data header error".Translate());
                return;
            }

            byte[] buffer = new byte[1];
            byte[] buffer2 = new byte[1];
            string objType = "";
            int num3, row;

            dataGrid.Rows.Add();
            row = dataGrid.Rows.Count - 1;
            dataGrid.Rows[row].Cells["colValue"].Value = m_obj.ObjName;
            dataGrid.Rows[row].Cells["colName"].Value = "objname";
            dataGrid.Rows[row].Cells["colType"].Value = "objname";
            dataGrid.Rows[row].Cells["colInfo"].Value = "Component name".Translate();
            if (m_obj.Attributes[0].Data[0] == HmiObjType.PAGE)
                dataGrid.Rows[row].Cells["colValue"].ReadOnly = true;
            else
                dataGrid.Rows[row].Cells["colValue"].ReadOnly = false;

            DataGridViewCellStyle style = new DataGridViewCellStyle
            {
                Font = new Font(dataGrid.Font.FontFamily, dataGrid.Font.Size, FontStyle.Regular)
            };
            dataGrid.Rows[row].DefaultCellStyle = style;
            m_obj.IsBinding = 0;
            for (int i = 1; i < m_obj.Attributes.Count; i++)
            {
                HmiAttribute attr = m_obj.Attributes[i];
                if ((m_obj.checkAttribute(attr)
                    && (i != 1
                        || (m_obj.Attributes[0].Data[0] != HmiObjType.OBJECT_TYPE_CURVE
                            && m_obj.Attributes[0].Data[0] != HmiObjType.TIMER
                            )
                        )
                    )
                 && attr.InfoAttribute.AttrType < 15
                    )
                {
                    dataGrid.Rows.Add();
                    row = dataGrid.Rows.Count - 1;
                    if (attr.InfoAttribute.AttrType < HmiAttributeType.String)
                    {
                        if (attr.InfoAttribute.Length == 1)
                        {
                            if (attr.InfoAttribute.AttrType == 5)
                            {
                                num3 = m_obj.GetNoteLength(Utility.GetString(attr.Name), true) - 1;
                                dataGrid.Rows[row].Cells["colValue"].Value = num3.ToString();
                            }
                            else if (attr.InfoAttribute.AttrType == HmiAttributeType.Selection)
                            {
                                style = new DataGridViewCellStyle
                                {
                                    BackColor = Color.FromArgb(0xe0, 0xe0, 0xe0),
                                    ForeColor = Color.Black
                                };
                                dataGrid.Rows[row].Cells["colValue"].Value = attr.Data[0].ToString();
                                string[] strArray = Utility.GetString(attr.Note).Split(Utility.CHAR_COLON);
                                if (strArray.Length > 1)
                                {
                                    strArray = strArray[1].Split(Utility.CHAR_SEMICOLON);
                                    if (Utility.GetInt(attr.Data[0].ToString()) < strArray.Length)
                                    {
                                        strArray = strArray[Utility.GetInt(attr.Data[0].ToString())].Split(Utility.CHAR_MINUS);
                                        if (strArray.Length == 2)
                                            dataGrid.Rows[row].Cells["colValue"].Value = strArray[1];
                                    }
                                }
                                dataGrid.Rows[row].DefaultCellStyle = style;
                            }
                            else
                                dataGrid.Rows[row].Cells["colValue"].Value = attr.Data[0].ToString();
                        }
                        else if (attr.InfoAttribute.Length == 2)
                        {
                            if (attr.InfoAttribute.AttrType == 1 && attr.Data.ToU16() == 0x350b)
                                dataGrid.Rows[row].Cells["colValue"].Value = "";
                            else if (attr.InfoAttribute.AttrType == 2 && attr.Data.ToU16() == 0xffff)
                                dataGrid.Rows[row].Cells["colValue"].Value = "";
                            else
                                dataGrid.Rows[row].Cells["colValue"].Value = attr.Data.ToU16().ToString();
                        }
                        else if (attr.InfoAttribute.Length == 4)
                            dataGrid.Rows[row].Cells["colValue"].Value = attr.Data.ToU32().ToString();
                    }
                    else
                        dataGrid.Rows[row].Cells["colValue"].Value = Utility.GetString(attr.Data);

                    dataGrid.Rows[row].Cells["colName"].Value = Utility.GetString(attr.Name);
                    dataGrid.Rows[row].Cells["colType"].Value = attr.InfoAttribute.AttrType.ToString();
                    dataGrid.Rows[row].Cells["colInfo"].Value = Utility.GetString(attr.Note, Encoding.ASCII.GetBytes("~")[0]);
                    dataGrid.Rows[row].Cells["colIsBinding"].Value = attr.InfoAttribute.IsBinding.ToString();
                    dataGrid.Rows[row].Cells["colCanModify"].Value = attr.InfoAttribute.IsBinding.ToString();

                    if (attr.InfoAttribute.AttrType == HmiAttributeType.PicId
                     || attr.InfoAttribute.AttrType == HmiAttributeType.Color
                     || attr.InfoAttribute.AttrType == HmiAttributeType.Selection)
                        dataGrid.Rows[row].Cells["colValue"].ReadOnly = true;
                    else
                        dataGrid.Rows[row].Cells["colValue"].ReadOnly = false;

                    style = new DataGridViewCellStyle();
                    if (attr.InfoAttribute.CanModify == 1)
                    {
                        style.BackColor = Color.White;
                        style.ForeColor = Color.Green;
                        dataGrid.Rows[row].DefaultCellStyle = style;
                    }

                    if (attr.InfoAttribute.IsReturn == 1)
                    {
                        style.Font = new Font(dataGrid.Font.FontFamily, dataGrid.Font.Size, FontStyle.Bold);
                        dataGrid.Rows[row].DefaultCellStyle = style;
                    }
                }
            }

            if (m_obj.Attributes[0].Data[0] != HmiObjType.PAGE
             && m_obj.ObjInfo.ObjType != HmiObjType.TIMER
             && m_obj.ObjInfo.ObjType != HmiObjType.VAR
                )
            {
                dataGrid.Rows.Add();
                row = dataGrid.Rows.Count - 1;
                dataGrid.Rows[row].Cells["colValue"].Value = m_obj.ObjInfo.Panel.X.ToString();
                dataGrid.Rows[row].Cells["colName"].Value = "x";
                dataGrid.Rows[row].Cells["colType"].Value = "x";
                dataGrid.Rows[row].Cells["colInfo"].Value = "Coordinate X".Translate();
                dataGrid.Rows[row].Cells["colValue"].ReadOnly = false;

                dataGrid.Rows.Add();
                row = dataGrid.Rows.Count - 1;
                dataGrid.Rows[row].Cells["colValue"].Value = m_obj.ObjInfo.Panel.Y.ToString();
                dataGrid.Rows[row].Cells["colName"].Value = "y";
                dataGrid.Rows[row].Cells["colType"].Value = "y";
                dataGrid.Rows[row].Cells["colInfo"].Value = "Coordinate Y".Translate();
                dataGrid.Rows[row].Cells["colValue"].ReadOnly = false;
                dataGrid.Rows.Add();

                row = dataGrid.Rows.Count - 1;
                num3 = (m_obj.ObjInfo.Panel.EndX - m_obj.ObjInfo.Panel.X) + 1;
                dataGrid.Rows[row].Cells["colValue"].Value = num3.ToString();
                dataGrid.Rows[row].Cells["colName"].Value = "w";
                dataGrid.Rows[row].Cells["colType"].Value = "w";
                dataGrid.Rows[row].Cells["colInfo"].Value = "Width".Translate();
                dataGrid.Rows[row].Cells["colValue"].ReadOnly = false;
                dataGrid.Rows.Add();

                row = dataGrid.Rows.Count - 1;
                dataGrid.Rows[row].Cells["colValue"].Value = ((m_obj.ObjInfo.Panel.EndY - m_obj.ObjInfo.Panel.Y) + 1).ToString();
                dataGrid.Rows[row].Cells["colName"].Value = "h";
                dataGrid.Rows[row].Cells["colType"].Value = "h";
                dataGrid.Rows[row].Cells["colInfo"].Value = "Height".Translate();
                dataGrid.Rows[row].Cells["colValue"].ReadOnly = false;
            }

            if (m_obj.Attributes.Count > 0
             && Utility.GetString(m_obj.Attributes[0].Name) == "lei"
                )
                objType = Utility.GetString(m_obj.Attributes[0].Note, Encoding.ASCII.GetBytes("~")[0]);

            tbAttrDescription.Text = "Click the attribute to display corresponding notes".Translate();
            tbObjIdType.Text = "ID:" + m_obj.ObjId.ToString() + " " + objType;

            if (dataGrid.Rows.Count > 0)
                dataGrid.Rows[0].Cells[0].Selected = false;
        }
Beispiel #2
0
        private bool objDetect(RichTextBox textCompile, HmiObject obj)
        {
            bool flag = true;

            if (obj.ObjInfo.Panel.X < 0
             || obj.ObjInfo.Panel.EndX >= App.LcdWidth
             || obj.ObjInfo.Panel.Y < 0
             || obj.ObjInfo.Panel.EndY >= App.LcdHeight
                )
            {
                textCompile.AddRichTextString(
                    string.Concat("Page:".Translate(), Name, " Error:".Translate(), obj.ObjName, " Position Invalid:".Translate()),
                    Color.Red
                    );
                App.Errors++;
                flag = false;
            }

            for (int i = 0; i < obj.Attributes.Count; i++)
            {
                if (obj.Attributes[i].InfoAttribute.AttrType < 15
                 && obj.Attributes[i].InfoAttribute.CanModify == 1
                 && obj.checkAttribute(obj.Attributes[i])
                    )
                {
                    string err = obj.CheckAttributeValue(obj.Attributes[i]);
                    if (err != "")
                    {
                        textCompile.AddRichTextString(
                            string.Concat(
                                "Page:".Translate(),
                                Name,
                                " Error:".Translate(),
                                obj.ObjName + "." + obj.Attributes[i].Name.ToString(),
                                " InputVal Invalid:".Translate(),
                                err),
                            Color.Red);
                        App.Errors++;
                        flag = false;
                    }
                }
            }
            return flag;
        }