public HmiPage AddPage() { HmiPage page = new HmiPage(this); string name = "page"; int idx = 0; for (; idx < 0xffff; idx++) { if (!FindPageByName(name + idx.ToString())) { break; } } page.Name = name + idx.ToString(); HmiPages.Add(page); RefreshPageId(); HmiObject hmiObject = new HmiObject(this, page); hmiObject.ObjName = page.Name; page.HmiObjects.Add(hmiObject); RefreshObjId(page); hmiObject.SetScreenXY(); return(HmiPages[HmiPages.Count - 1]); }
public HmiPage InsertPage(int index) { HmiPage item = new HmiPage(this); string name = "newpage"; int idx = 0; while (idx < 0xffff) { if (!FindPageByName(name + idx.ToString())) { break; } ++idx; } item.Name = name + idx.ToString(); HmiPages.Insert(index, item); RefreshPageId(); HmiObject mobj = new HmiObject(this, item) { App = this, ObjName = item.Name }; item.HmiObjects.Add(mobj); mobj.SetScreenXY(); RefreshObjId(item); return(item); }
public void RefreshObjId(HmiPage page) { for (int i = 0; i < page.HmiObjects.Count; i++) { page.HmiObjects[i].ObjId = i; } }
public MemberAdd(HmiApplication app, HmiPage page, HmiObject obj) { m_app = app; m_page = page; m_obj = obj; InitializeComponent(); Utility.Translate(this); }
public HmiObject(HmiApplication app, HmiPage page) { App = app; Page = page; Codes[0] = new List<byte[]>(); Codes[1] = new List<byte[]>(); Codes[2] = new List<byte[]>(); Codes[3] = new List<byte[]>(); }
public bool FindObjByName(HmiPage page, HmiObject obj, string name) { name = Utility.ToBytes(name, 4).ToString(); foreach (HmiObject mobj in page.HmiObjects) { if (mobj.ObjName == name && mobj != obj) { return(true); } } return(false); }
public HmiPage CopyPage(int index) { HmiPage page = AddPage(); page.HmiObjects[0] = HmiPages[index].HmiObjects[0].CopyObject(this, page); page.HmiObjects[0].ObjName = page.Name; for (int i = 1; i < HmiPages[index].HmiObjects.Count; i++) { HmiObject copyeobj = HmiPages[index].HmiObjects[i].CopyObject(this, page); copyeobj.ObjName = HmiPages[index].HmiObjects[i].ObjName; page.HmiObjects.Add(copyeobj); } RefreshObjId(page); return(page); }
public bool RenameObj(HmiPage page, HmiObject obj, string newname) { int length = newname.ToBytes().Length; if ((length == 0) || (length > 14)) { MessageBox.Show("Min Length 1 byte, Max Length 14 byte".Translate()); return(false); } if (!Utility.IsNameValid(newname)) { return(false); } if (FindObjByName(page, obj, newname)) { MessageBox.Show("Duplicate Name!".Translate()); return(false); } obj.ObjName = newname; return(true); }
public HmiPage AddPage() { HmiPage page = new HmiPage(this); string name = "page"; int idx = 0; for (; idx < 0xffff; idx++) if (!FindPageByName(name + idx.ToString())) break; page.Name = name + idx.ToString(); HmiPages.Add(page); RefreshPageId(); HmiObject hmiObject = new HmiObject(this, page); hmiObject.ObjName = page.Name; page.HmiObjects.Add(hmiObject); RefreshObjId(page); hmiObject.SetScreenXY(); return HmiPages[HmiPages.Count - 1]; }
public void MakeObjName(HmiPage page, HmiObject obj, byte mark) { try { string str = ""; string newname = ""; str = HmiObjType.GetNamePrefix(mark); for (int i = 0; i < 0xff; i++) { newname = str + i.ToString(); if (!FindObjByName(page, obj, newname)) { obj.ObjName = newname; break; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// private static List<InfoObject> m_Objects = new List<InfoObject>(); // private static List<InfoPage> m_Pages = new List<InfoPage>(); // private static List<byte[]> m_StringDatas = new List<byte[]>(); // private static List<InfoString> m_Strings = new List<InfoString>(); private bool readInfoApp(HmiApplication app, StreamReader reader) { List<InfoObject> m_Objects = new List<InfoObject>(); List<InfoPage> m_Pages = new List<InfoPage>(); List<byte[]> m_StringDatas = new List<byte[]>(); List<InfoString> m_Strings = new List<InfoString>(); InfoApp infoApp; // = new InfoApp(); try { int idx; // Load Application Info reader.BaseStream.Position = 0L; byte[] buffer = new byte[HmiOptions.InfoAppSize]; reader.BaseStream.Read(buffer, 0, buffer.Length); infoApp = Utility.ToStruct<InfoApp>(buffer); // Load Pictures and PictureImage app.Pictures.Clear(); app.PictureImages.Clear(); if (infoApp.PictureCount != 0) { reader.BaseStream.Position = infoApp.PictureStart; buffer = new byte[HmiOptions.InfoPictureSize]; for (idx = 0; idx < infoApp.PictureCount; idx++) { reader.BaseStream.Read(buffer, 0, buffer.Length); app.Pictures.Add(Utility.ToStruct<InfoPicture>(buffer)); } reader.BaseStream.Position = infoApp.PictureImageStart; for (idx = 0; idx < app.Pictures.Count; idx++) { buffer = new byte[app.Pictures[idx].Size]; reader.BaseStream.Read(buffer, 0, buffer.Length); app.PictureImages.Add(buffer); } } // Load Fonts with FontImage app.Fonts.Clear(); app.FontImages.Clear(); if (infoApp.FontCount != 0) { reader.BaseStream.Position = infoApp.FontStart; buffer = new byte[HmiOptions.InfoFontSize]; for (idx = 0; idx < infoApp.FontCount; idx++) { reader.BaseStream.Read(buffer, 0, buffer.Length); app.Fonts.Add(Utility.ToStruct<InfoFont>(buffer)); } reader.BaseStream.Position = infoApp.FontImageStart; for (idx = 0; idx < app.Fonts.Count; idx++) { buffer = new byte[app.Fonts[idx].Size]; reader.BaseStream.Read(buffer, 0, buffer.Length); app.FontImages.Add(buffer); } } if (infoApp.StringCount != 0) { reader.BaseStream.Position = infoApp.StringStart; buffer = new byte[HmiOptions.InfoStringSize]; for (idx = 0; idx < infoApp.StringCount; idx++) { reader.BaseStream.Read(buffer, 0, buffer.Length); m_Strings.Add(Utility.ToStruct<InfoString>(buffer)); } reader.BaseStream.Position = infoApp.StringDataStart; for (idx = 0; idx < m_Strings.Count; idx++) { buffer = new byte[m_Strings[idx].Size]; reader.BaseStream.Read(buffer, 0, buffer.Length); m_StringDatas.Add(buffer); } } if (infoApp.PageCount != 0) { reader.BaseStream.Position = infoApp.PageStart; buffer = new byte[HmiOptions.InfoPageSize]; for (idx = 0; idx < infoApp.PageCount; idx++) { reader.BaseStream.Read(buffer, 0, buffer.Length); m_Pages.Add(Utility.ToStruct<InfoPage>(buffer)); } } if (infoApp.ObjectCount != 0) { reader.BaseStream.Position = infoApp.ObjectStart; buffer = new byte[HmiOptions.InfoObjectSize]; for (idx = 0; idx < infoApp.ObjectCount; idx++) { reader.BaseStream.Read(buffer, 0, buffer.Length); m_Objects.Add(Utility.ToStruct<InfoObject>(buffer)); } } reader.Close(); reader.Dispose(); app.IsPotrait = (infoApp.IsPotrait == 1 ? true : false); app.LcdWidth = (app.IsPotrait ? infoApp.ScreenHeight : infoApp.ScreenWidth); app.LcdHeight = (app.IsPotrait ? infoApp.ScreenWidth : infoApp.ScreenHeight); if (infoApp.VersionMajor == 0 && infoApp.VersionMinor < 30) { HmiOptions.OpenTransparent = false; for (int j = 0; j < app.PictureImages.Count; j++) { idx = 0; while (idx < (app.PictureImages[j].Length - 1)) { if ((app.PictureImages[j][idx] == HmiOptions.ColorTransparent) && (app.PictureImages[j][idx + 1] == 0)) app.PictureImages[j][idx] = (byte)HmiOptions.ColorTransparentReplace; idx += 2; } } } else HmiOptions.OpenTransparent = false; app.HmiPages.Clear(); List<byte[]> strings = new List<byte[]>(); for (int i = 0; i < m_Pages.Count; i++) { HmiPage hmiPage = new HmiPage(app) { Name = Utility.GetString(Utility.ToBytes(m_Pages[i].Name)) }; if (m_Pages[i].ObjStart != 0xffff && m_Pages[i].ObjEnd != 0xffff) { for (idx = m_Pages[i].ObjStart; idx <= m_Pages[i].ObjEnd; idx++) { HmiObject hmiObject = new HmiObject(app, hmiPage) { ObjInfo = m_Objects[idx], ObjName = Utility.GetString(Utility.ToBytes(m_Objects[idx].Name)) }; strings.Clear(); for (int k = m_Objects[idx].StringInfoStart; k <= m_Objects[idx].StringInfoEnd; k++) strings.Add(m_StringDatas[k]); hmiObject.PutCodes(strings); hmiPage.HmiObjects.Add(hmiObject); } } app.HmiPages.Add(hmiPage); } app.RefreshAllId(); if (infoApp.VersionMajor == 0 && infoApp.VersionMinor == 8) { foreach (HmiPage mpage2 in app.HmiPages) if (mpage2.HmiObjects[0].Attributes.Count == 4 && Utility.GetString(mpage2.HmiObjects[0].Attributes[2].Name) == "pco" ) mpage2.HmiObjects[0].Attributes[2].Name = Utility.ToBytes("bco", 8); } return true; } catch (Exception ex) { reader.Close(); reader.Dispose(); MessageBox.Show(ex.Message); return false; } }
public bool RenameObj(HmiPage page, HmiObject obj, string newname) { int length = newname.ToBytes().Length; if ((length == 0) || (length > 14)) { MessageBox.Show("Min Length 1 byte, Max Length 14 byte".Translate()); return false; } if (!Utility.IsNameValid(newname)) { return false; } if (FindObjByName(page, obj, newname)) { MessageBox.Show("Duplicate Name!".Translate()); return false; } obj.ObjName = newname; return true; }
public void RefreshObjId(HmiPage page) { for (int i = 0; i < page.HmiObjects.Count; i++) page.HmiObjects[i].ObjId = i; }
// private static List<InfoObject> m_Objects = new List<InfoObject>(); // private static List<InfoPage> m_Pages = new List<InfoPage>(); // private static List<byte[]> m_StringDatas = new List<byte[]>(); // private static List<InfoString> m_Strings = new List<InfoString>(); private bool readInfoApp(HmiApplication app, StreamReader reader) { List <InfoObject> m_Objects = new List <InfoObject>(); List <InfoPage> m_Pages = new List <InfoPage>(); List <byte[]> m_StringDatas = new List <byte[]>(); List <InfoString> m_Strings = new List <InfoString>(); InfoApp infoApp; // = new InfoApp(); try { int idx; // Load Application Info reader.BaseStream.Position = 0L; byte[] buffer = new byte[HmiOptions.InfoAppSize]; reader.BaseStream.Read(buffer, 0, buffer.Length); infoApp = Utility.ToStruct <InfoApp>(buffer); // Load Pictures and PictureImage app.Pictures.Clear(); app.PictureImages.Clear(); if (infoApp.PictureCount != 0) { reader.BaseStream.Position = infoApp.PictureStart; buffer = new byte[HmiOptions.InfoPictureSize]; for (idx = 0; idx < infoApp.PictureCount; idx++) { reader.BaseStream.Read(buffer, 0, buffer.Length); app.Pictures.Add(Utility.ToStruct <InfoPicture>(buffer)); } reader.BaseStream.Position = infoApp.PictureImageStart; for (idx = 0; idx < app.Pictures.Count; idx++) { buffer = new byte[app.Pictures[idx].Size]; reader.BaseStream.Read(buffer, 0, buffer.Length); app.PictureImages.Add(buffer); } } // Load Fonts with FontImage app.Fonts.Clear(); app.FontImages.Clear(); if (infoApp.FontCount != 0) { reader.BaseStream.Position = infoApp.FontStart; buffer = new byte[HmiOptions.InfoFontSize]; for (idx = 0; idx < infoApp.FontCount; idx++) { reader.BaseStream.Read(buffer, 0, buffer.Length); app.Fonts.Add(Utility.ToStruct <InfoFont>(buffer)); } reader.BaseStream.Position = infoApp.FontImageStart; for (idx = 0; idx < app.Fonts.Count; idx++) { buffer = new byte[app.Fonts[idx].Size]; reader.BaseStream.Read(buffer, 0, buffer.Length); app.FontImages.Add(buffer); } } if (infoApp.StringCount != 0) { reader.BaseStream.Position = infoApp.StringStart; buffer = new byte[HmiOptions.InfoStringSize]; for (idx = 0; idx < infoApp.StringCount; idx++) { reader.BaseStream.Read(buffer, 0, buffer.Length); m_Strings.Add(Utility.ToStruct <InfoString>(buffer)); } reader.BaseStream.Position = infoApp.StringDataStart; for (idx = 0; idx < m_Strings.Count; idx++) { buffer = new byte[m_Strings[idx].Size]; reader.BaseStream.Read(buffer, 0, buffer.Length); m_StringDatas.Add(buffer); } } if (infoApp.PageCount != 0) { reader.BaseStream.Position = infoApp.PageStart; buffer = new byte[HmiOptions.InfoPageSize]; for (idx = 0; idx < infoApp.PageCount; idx++) { reader.BaseStream.Read(buffer, 0, buffer.Length); m_Pages.Add(Utility.ToStruct <InfoPage>(buffer)); } } if (infoApp.ObjectCount != 0) { reader.BaseStream.Position = infoApp.ObjectStart; buffer = new byte[HmiOptions.InfoObjectSize]; for (idx = 0; idx < infoApp.ObjectCount; idx++) { reader.BaseStream.Read(buffer, 0, buffer.Length); m_Objects.Add(Utility.ToStruct <InfoObject>(buffer)); } } reader.Close(); reader.Dispose(); app.IsPotrait = (infoApp.IsPotrait == 1 ? true : false); app.LcdWidth = (app.IsPotrait ? infoApp.ScreenHeight : infoApp.ScreenWidth); app.LcdHeight = (app.IsPotrait ? infoApp.ScreenWidth : infoApp.ScreenHeight); if (infoApp.VersionMajor == 0 && infoApp.VersionMinor < 30) { HmiOptions.OpenTransparent = false; for (int j = 0; j < app.PictureImages.Count; j++) { idx = 0; while (idx < (app.PictureImages[j].Length - 1)) { if ((app.PictureImages[j][idx] == HmiOptions.ColorTransparent) && (app.PictureImages[j][idx + 1] == 0)) { app.PictureImages[j][idx] = (byte)HmiOptions.ColorTransparentReplace; } idx += 2; } } } else { HmiOptions.OpenTransparent = false; } app.HmiPages.Clear(); List <byte[]> strings = new List <byte[]>(); for (int i = 0; i < m_Pages.Count; i++) { HmiPage hmiPage = new HmiPage(app) { Name = Utility.GetString(Utility.ToBytes(m_Pages[i].Name)) }; if (m_Pages[i].ObjStart != 0xffff && m_Pages[i].ObjEnd != 0xffff) { for (idx = m_Pages[i].ObjStart; idx <= m_Pages[i].ObjEnd; idx++) { HmiObject hmiObject = new HmiObject(app, hmiPage) { ObjInfo = m_Objects[idx], ObjName = Utility.GetString(Utility.ToBytes(m_Objects[idx].Name)) }; strings.Clear(); for (int k = m_Objects[idx].StringInfoStart; k <= m_Objects[idx].StringInfoEnd; k++) { strings.Add(m_StringDatas[k]); } hmiObject.PutCodes(strings); hmiPage.HmiObjects.Add(hmiObject); } } app.HmiPages.Add(hmiPage); } app.RefreshAllId(); if (infoApp.VersionMajor == 0 && infoApp.VersionMinor == 8) { foreach (HmiPage mpage2 in app.HmiPages) { if (mpage2.HmiObjects[0].Attributes.Count == 4 && Utility.GetString(mpage2.HmiObjects[0].Attributes[2].Name) == "pco" ) { mpage2.HmiObjects[0].Attributes[2].Name = Utility.ToBytes("bco", 8); } } } return(true); } catch (Exception ex) { reader.Close(); reader.Dispose(); MessageBox.Show(ex.Message); return(false); } }
private void main_Load(object sender, EventArgs e) { // runScreen.MouseWheel += new MouseEventHandler(runScreen_MouseWheel); panel9.HorizontalScroll.Value = panel9.HorizontalScroll.Maximum; m_app_ChangeEvent(false); closeHMI(); Text = HmiOptions.SoftName; base.Icon = HmiOptions.Icon; m_page = null; m_compiler.RefreshObject(null, null, null); m_attributeEdit.RefreshObject(null, null, null); string[] commandLineArgs = Environment.GetCommandLineArgs(); foreach (string filename in commandLineArgs) if (Path.GetExtension(filename).ToLowerInvariant() == ".hmi" && File.Exists(Path.Combine(Application.StartupPath, filename)) ) { fileOperation("open", Path.Combine(Application.StartupPath, filename)); break; } picAdmin.SetSizeToParent(); fontAdmin.SetSizeToParent(); pageAdmin.SetSizeToParent(); m_attributeEdit.SetSizeToParent(); }
private void closeHMI() { m_app = null; m_page = null; m_compiler.RefreshObject(null, null, null); m_attributeEdit.RefreshObject(null, null, null); pageAdmin.SetAppInfo(m_app); fontAdmin.SetAppInfo(m_app); picAdmin.SetAppInfo(m_app); runScreen.RunStop(); runScreen.Visible = false; m_obj = null; m_objEdit = null; m_binpath = ""; mi_Save.Enabled = false; mi_Copy.Enabled = false; mi_Paste.Enabled = false; mi_DeleteComponent.Enabled = false; mi_Resolution.Enabled = false; mi_ID.Enabled = false; mi_XY.Enabled = false; mi_Compile.Enabled = false; mi_AddComponent.Enabled = false; if (m_app != null) m_app.ChangeApplication(false); refreshTimerVar(); }
private bool prepareToSave( ref InfoApp infoApp, bool compile, RichTextBox textCompile, SaveToFileData data ) { infoApp.IsPotrait = (byte)(IsPotrait ? 1 : 0); infoApp.ScreenWidth = (IsPotrait ? LcdHeight : LcdWidth); infoApp.ScreenHeight = (IsPotrait ? LcdWidth : LcdHeight); bool success = true; ushort customDataLength = 0; OverBytes = Utility.ToBytes((uint)customDataLength); if (compile) { for (int idxPage = 0; idxPage < HmiPages.Count; idxPage++) { HmiPage hmiPage = HmiPages[idxPage]; for (int idxObj = 0; idxObj < hmiPage.HmiObjects.Count; ++idxObj) { HmiObject hmiObj = hmiPage.HmiObjects[idxObj]; hmiObj.ObjInfo.ObjType = hmiObj.Attributes[0].Data[0]; hmiObj.ObjInfo.IsCustomData = hmiObj.Attributes[1].Data[0]; if (hmiObj.ObjInfo.IsCustomData == 1) { hmiObj.ObjInfo.AttributeStart = customDataLength; int objRambytes = hmiObj.GetObjRamBytes(ref OverBytes, customDataLength); if (objRambytes != 0) { hmiObj.ObjInfo.AttributeLength = (ushort)objRambytes; customDataLength += hmiObj.ObjInfo.AttributeLength; } } } } } addString(OverBytes, data); List <byte[]> bts = new List <byte[]>(); for (int idxPage = 0; idxPage < HmiPages.Count; idxPage++) { HmiPage hmiPage = HmiPages[idxPage]; if (compile && !hmiPage.Compile(textCompile)) { success = false; } else { Application.DoEvents(); InfoPage infoPage = new InfoPage { ObjCount = (byte)hmiPage.HmiObjects.Count, Name = Utility.ToStruct <InfoName>(Utility.ToBytes(hmiPage.Name, 14)) }; if (infoPage.ObjCount > 0) { infoPage.ObjStart = (ushort)data.m_infoObjects.Count; for (int idxObj = 0; idxObj < hmiPage.HmiObjects.Count; idxObj++) { HmiObject hmiObj = hmiPage.HmiObjects[idxObj]; hmiObj.ObjInfo.Name = Utility.ToStruct <InfoName>(Utility.ToBytes(hmiObj.ObjName, 14)); bts.Clear(); if (compile) { hmiObj.CompileCodes(bts); } else { hmiObj.GetCodes(bts); } if (bts.Count > 0) { hmiObj.ObjInfo.StringInfoStart = (ushort)data.m_infoStrings.Count; for (int k = 0; k < bts.Count; k++) { addString(bts[k], data); } hmiObj.ObjInfo.StringInfoEnd = (ushort)((hmiObj.ObjInfo.StringInfoStart + bts.Count) - 1); } else { MessageBox.Show("Detect the component code is 0, error will occur when save the source file".Translate()); hmiObj.ObjInfo.StringInfoStart = 0xffff; hmiObj.ObjInfo.StringInfoEnd = 0xffff; } data.m_infoObjects.Add(hmiObj.ObjInfo); } infoPage.ObjEnd = (ushort)((infoPage.ObjStart + hmiPage.HmiObjects.Count) - 1); } else { infoPage.ObjStart = 0xffff; infoPage.ObjEnd = 0xffff; } if (compile) { infoPage.InstStart = (ushort)data.m_infoStrings.Count; for (int num5 = 0; num5 < hmiPage.Codes.Count; num5++) { addString(hmiPage.Codes[num5], data); } infoPage.InstEnd = (ushort)(data.m_infoStrings.Count - 1); } else { infoPage.InstStart = 0xffff; infoPage.InstEnd = 0xffff; } data.m_infoPages.Add(infoPage); } } if (success) { infoApp.PageCount = (ushort)data.m_infoPages.Count; infoApp.ObjectCount = (ushort)data.m_infoObjects.Count; infoApp.FontCount = (ushort)Fonts.Count; infoApp.PictureCount = (ushort)Pictures.Count; infoApp.PictureImageStart = (uint)HmiOptions.InfoAppSize; if (compile) { infoApp.PictureImageStart = 0x1000; } infoApp.FontImageStart = infoApp.PictureImageStart + ((uint)getPictureImagesSize()); infoApp.StringDataStart = infoApp.FontImageStart + ((uint)getFontImagesSize()); if (compile) { uint num6 = infoApp.StringDataStart % 0x1000; if (num6 != 0) { infoApp.StringDataStart += 0x1000 - num6; } } infoApp.FirmwareStart = infoApp.StringDataStart + (uint)data.m_stringDataAddress; infoApp.FirmwareSize = 0; if (compile) { // Add bootloader if compile StreamReader reader = new StreamReader(Path.Combine(Application.StartupPath, "fwc.bin")); infoApp.FirmwareSize = (uint)reader.BaseStream.Length; reader.Close(); } infoApp.PageStart = infoApp.FirmwareStart + infoApp.FirmwareSize; infoApp.ObjectStart = infoApp.PageStart + ((uint)(data.m_infoPages.Count * HmiOptions.InfoPageSize)); infoApp.PictureStart = infoApp.ObjectStart + ((uint)(infoApp.ObjectCount * HmiOptions.InfoObjectSize)); infoApp.StringStart = infoApp.PictureStart + ((uint)(HmiOptions.InfoPictureSize * infoApp.PictureCount)); infoApp.StringCount = (uint)data.m_infoStrings.Count; infoApp.FontStart = infoApp.StringStart + ((uint)(HmiOptions.InfoStringSize * data.m_infoStrings.Count)); infoApp.FontDataStart = infoApp.FontStart + ((uint)(HmiOptions.InfoFontSize * infoApp.FontCount)); } return(success); }
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; } }
public void RefreshObject(HmiApplication app, HmiPage page, HmiObject obj) { try { SaveCodes(); tabControl.Tag = "stop"; if (app == null || page == null || obj == null) { Clear(); return; } m_AppInf = app; m_Page = page; m_Object = obj; if (obj.ObjId == 0) { rbAutoLoad.Visible = rbLoadCommands.Visible = false; } else { rbAutoLoad.Visible = rbLoadCommands.Visible = true; } tabControl.Enabled = tbUserCode.Enabled = true; rbAutoLoad.Enabled = rbLoadCommands.Enabled = true; cbTPPressCompId.Enabled = cbTPReleaseCompId.Enabled = true; if (obj.ObjInfo.Panel.loadlei == 1) { rbAutoLoad.Checked = true; } else { rbLoadCommands.Checked = true; } cbTPPressCompId.Checked = ((obj.ObjInfo.Panel.SendKey & 2) > 0); cbTPReleaseCompId.Checked = ((obj.ObjInfo.Panel.SendKey & 1) > 0); int selectedIndex = tabControl.SelectedIndex; if (obj.Attributes[0].Data[0] == HmiObjType.OBJECT_TYPE_SLIDER) { if (!tabControl.TabPages.Contains(pageTouchPressEvent)) { tabControl.TabPages.Add(pageTouchPressEvent); } if (!tabControl.TabPages.Contains(pageTouchReleaseEvent)) { tabControl.TabPages.Add(pageTouchReleaseEvent); } if (!tabControl.TabPages.Contains(pageTouchMove)) { tabControl.TabPages.Add(pageTouchMove); } pageInitialization.Tag = "Initialization".Translate(); pageTouchPressEvent.Tag = "Touch Press Event".Translate(); pageTouchReleaseEvent.Tag = "Touch Release Event".Translate(); pageTouchMove.Tag = "Touch Move".Translate(); } else if (obj.Attributes[0].Data[0] == HmiObjType.TIMER) { if (tabControl.TabPages.Contains(pageTouchPressEvent)) { tabControl.TabPages.Remove(pageTouchPressEvent); } if (tabControl.TabPages.Contains(pageTouchReleaseEvent)) { tabControl.TabPages.Remove(pageTouchReleaseEvent); } if (tabControl.TabPages.Contains(pageTouchMove)) { tabControl.TabPages.Remove(pageTouchMove); } pageInitialization.Tag = "Timer Event".Translate(); rbAutoLoad.Visible = false; rbLoadCommands.Visible = false; } else { if (!tabControl.TabPages.Contains(pageTouchPressEvent)) { tabControl.TabPages.Add(pageTouchPressEvent); } if (!tabControl.TabPages.Contains(pageTouchReleaseEvent)) { tabControl.TabPages.Add(pageTouchReleaseEvent); } if (tabControl.TabPages.Contains(pageTouchMove)) { tabControl.TabPages.Remove(pageTouchMove); } pageInitialization.Tag = "Initialization".Translate(); pageTouchPressEvent.Tag = "Touch Press Event".Translate(); pageTouchReleaseEvent.Tag = "Touch Release Event".Translate(); } if (selectedIndex >= tabControl.TabPages.Count) { selectedIndex = 0; } tabControl.SelectedIndex = selectedIndex; attrLoad(selectedIndex); RefreshHead(); tabControl.Tag = "save"; } catch (Exception ex) { MessageBox.Show("Load Component Error".Translate() + " " + ex.Message); } }
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; }
public bool FindObjByName(HmiPage page, HmiObject obj, string name) { name = Utility.ToBytes(name, 4).ToString(); foreach (HmiObject mobj in page.HmiObjects) if (mobj.ObjName == name && mobj != obj) return true; return false; }
private void pageAdmin_SelectEnter(object sender, EventArgs e) { int num = (int)sender; if (num != 0xffff) m_page = m_app.HmiPages[num]; else m_page = null; m_obj = null; refreshPage(); }
public HmiPage InsertPage(int index) { HmiPage item = new HmiPage(this); string name = "newpage"; int idx = 0; while (idx < 0xffff) { if (!FindPageByName(name + idx.ToString())) break; ++idx; } item.Name = name + idx.ToString(); HmiPages.Insert(index, item); RefreshPageId(); HmiObject mobj = new HmiObject(this, item) { App = this, ObjName = item.Name }; item.HmiObjects.Add(mobj); mobj.SetScreenXY(); RefreshObjId(item); return item; }
public void RefreshObject(HmiApplication app, HmiPage page, HmiObject obj) { try { SaveCodes(); tabControl.Tag = "stop"; if (app == null || page == null || obj == null) { Clear(); return; } m_AppInf = app; m_Page = page; m_Object = obj; if (obj.ObjId == 0) rbAutoLoad.Visible = rbLoadCommands.Visible = false; else rbAutoLoad.Visible = rbLoadCommands.Visible = true; tabControl.Enabled = tbUserCode.Enabled = true; rbAutoLoad.Enabled = rbLoadCommands.Enabled = true; cbTPPressCompId.Enabled = cbTPReleaseCompId.Enabled = true; if (obj.ObjInfo.Panel.loadlei == 1) rbAutoLoad.Checked = true; else rbLoadCommands.Checked = true; cbTPPressCompId.Checked = ((obj.ObjInfo.Panel.SendKey & 2) > 0); cbTPReleaseCompId.Checked = ((obj.ObjInfo.Panel.SendKey & 1) > 0); int selectedIndex = tabControl.SelectedIndex; if (obj.Attributes[0].Data[0] == HmiObjType.OBJECT_TYPE_SLIDER) { if (!tabControl.TabPages.Contains(pageTouchPressEvent)) tabControl.TabPages.Add(pageTouchPressEvent); if (!tabControl.TabPages.Contains(pageTouchReleaseEvent)) tabControl.TabPages.Add(pageTouchReleaseEvent); if (!tabControl.TabPages.Contains(pageTouchMove)) tabControl.TabPages.Add(pageTouchMove); pageInitialization.Tag = "Initialization".Translate(); pageTouchPressEvent.Tag = "Touch Press Event".Translate(); pageTouchReleaseEvent.Tag = "Touch Release Event".Translate(); pageTouchMove.Tag = "Touch Move".Translate(); } else if (obj.Attributes[0].Data[0] == HmiObjType.TIMER) { if (tabControl.TabPages.Contains(pageTouchPressEvent)) tabControl.TabPages.Remove(pageTouchPressEvent); if (tabControl.TabPages.Contains(pageTouchReleaseEvent)) tabControl.TabPages.Remove(pageTouchReleaseEvent); if (tabControl.TabPages.Contains(pageTouchMove)) tabControl.TabPages.Remove(pageTouchMove); pageInitialization.Tag = "Timer Event".Translate(); rbAutoLoad.Visible = false; rbLoadCommands.Visible = false; } else { if (!tabControl.TabPages.Contains(pageTouchPressEvent)) tabControl.TabPages.Add(pageTouchPressEvent); if (!tabControl.TabPages.Contains(pageTouchReleaseEvent)) tabControl.TabPages.Add(pageTouchReleaseEvent); if (tabControl.TabPages.Contains(pageTouchMove)) tabControl.TabPages.Remove(pageTouchMove); pageInitialization.Tag = "Initialization".Translate(); pageTouchPressEvent.Tag = "Touch Press Event".Translate(); pageTouchReleaseEvent.Tag = "Touch Release Event".Translate(); } if (selectedIndex >= tabControl.TabPages.Count) selectedIndex = 0; tabControl.SelectedIndex = selectedIndex; attrLoad(selectedIndex); RefreshHead(); tabControl.Tag = "save"; } catch (Exception ex) { MessageBox.Show("Load Component Error".Translate() + " " + ex.Message); } }
public HmiObject CopyObject(HmiApplication hmiApp, HmiPage hmiPage) { HmiObject hmiObj = new HmiObject(hmiApp, hmiPage) { ObjInfo = ObjInfo }; hmiObj.Codes[0] = Codes[0].CopyListBytes(); hmiObj.Codes[1] = Codes[1].CopyListBytes(); hmiObj.Codes[2] = Codes[2].CopyListBytes(); hmiObj.Codes[3] = Codes[3].CopyListBytes(); foreach (HmiAttribute attr in Attributes) hmiObj.Attributes.Add(attr.Clone()); return hmiObj; }