public PicSelect(HmiApplication app, FormParams formParams) { m_params = formParams; m_app = app; InitializeComponent(); Utility.Translate(this); }
public PicSelect(HmiApplication app, FormParams formParams) { m_params = formParams; m_app = app; InitializeComponent(); Utility.Translate(this); }
public FontView(HmiApplication app, int fontIndex, FormParams formParams) { m_app = app; m_fontIndex = fontIndex; m_params = formParams; InitializeComponent(); Utility.Translate(this); }
public FontView(HmiApplication app, int fontIndex, FormParams formParams) { m_app = app; m_fontIndex = fontIndex; m_params = formParams; InitializeComponent(); Utility.Translate(this); }
public AddPicture(HmiApplication app, int index) { m_app = app; m_addIndex = index; InitializeComponent(); Utility.Translate(this); }
public AddPicture(HmiApplication app, int index) { m_app = app; m_addIndex = index; InitializeComponent(); Utility.Translate(this); }
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 MemberAdd(HmiApplication app, HmiPage page, HmiObject obj) { m_app = app; m_page = page; m_obj = obj; InitializeComponent(); Utility.Translate(this); }
public void SetAppInfo(HmiApplication app) { m_app = app; if (app == null) { listFonts.Items.Clear(); btnDelAll.Enabled = false; btnPreview.Enabled = false; btnDelete.Enabled = false; btnAdd.Enabled = false; } else { btnDelAll.Enabled = true; btnPreview.Enabled = true; btnDelete.Enabled = true; btnAdd.Enabled = true; } }
public void SetAppInfo(HmiApplication app) { m_app = app; if (app == null) { panel1.Controls.Clear(); bt_DeleteAll.Enabled = false; bt_Insert.Enabled = false; bt_Delete.Enabled = false; bt_Add.Enabled = false; bt_Copy.Enabled = false; } else { bt_DeleteAll.Enabled = true; bt_Insert.Enabled = true; bt_Copy.Enabled = true; bt_Delete.Enabled = true; bt_Add.Enabled = true; } }
public void SetAppInfo(HmiApplication app) { m_app = app; if (app == null) { panelList.Controls.Clear(); ButtonDeleteAll.Enabled = false; ButtonInsert.Enabled = false; ButtonReplace.Enabled = false; btn_Delete.Enabled = false; btn_Add.Enabled = false; } else { ButtonDeleteAll.Enabled = true; ButtonInsert.Enabled = true; ButtonReplace.Enabled = true; btn_Delete.Enabled = true; btn_Add.Enabled = true; } }
public HmiPage(HmiApplication app) { App = app; }
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) { 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 SetApp(HmiApplication app) { m_app = app; }
// 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 PicView(HmiApplication app, int picIndex) { m_app = app; m_picIndex = picIndex; InitializeComponent(); }
public DeviceParameters(HmiApplication app) { m_app = app; InitializeComponent(); Utility.Translate(this); }
public DeviceParameters(HmiApplication app) { m_app = app; InitializeComponent(); Utility.Translate(this); }
// 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 bool fileOperation(string cmd, string filename) { if (cmd != null) { SaveFileDialog dialog; #region add if (cmd == "add") { if (m_app != null && m_app.ChangeApp) { switch (MessageBox.Show(" Do you want to save changes made? ".Translate(), "Confirm".Translate(), MessageBoxButtons.YesNoCancel)) { case DialogResult.Yes: if (!fileOperation("save", "")) return false; break; case DialogResult.Cancel: return false; } } dialog = new SaveFileDialog(); dialog.Filter = "HMI File|*.HMI|All File|*.*".Translate(); Utility.SetInitialPath(dialog, "file"); if (dialog.ShowDialog() != DialogResult.OK) return false; closeHMI(); m_app = new HmiApplication(); m_app.ChangeApplication = new HmiApplication.AppChangEvent(m_app_ChangeEvent); m_app.FileSave = new HmiApplication.AppFileSave(m_app_FileSaveEvent); m_app.ChangeApplication(false); m_app.AddPage(); if (new DeviceParameters(m_app).ShowDialog() != DialogResult.OK) return false; runScreen.RunStop(); m_openFile = dialog.FileName; Utility.SavePath(dialog, "file"); m_app.SaveFile(m_openFile, false, null); closeHMI(); m_app = new HmiApplication(); m_app.ChangeApplication = new HmiApplication.AppChangEvent(m_app_ChangeEvent); m_app.FileSave = new HmiApplication.AppFileSave(m_app_FileSaveEvent); m_app.ChangeApplication(false); if (!m_app.Open(m_openFile)) return false; if (!Utility.DeleteFileWait(HmiOptions.RunFilePath)) return false; File.Copy(m_openFile, HmiOptions.RunFilePath); runScreen.GuiInit(HmiOptions.RunFilePath, m_app, true); runScreen.Visible = true; pageAdmin.SetAppInfo(m_app); picAdmin.SetAppInfo(m_app); fontAdmin.SetAppInfo(m_app); pageAdmin.RefreshObject(0); picAdmin.RefreshPictures(); fontAdmin.RefreshFonts(); mi_Compile.Enabled = true; mi_AddComponent.Enabled = true; mi_DeleteComponent.Enabled = true; mi_Resolution.Enabled = true; mi_ID.Enabled = true; mi_XY.Enabled = true; } #endregion #region open else if (cmd == "open") { if (m_app != null && m_app.ChangeApp) { switch (MessageBox.Show( " Do you want to save changes made? ".Translate(), "Confirm".Translate(), MessageBoxButtons.YesNoCancel )) { case DialogResult.Yes: if (!fileOperation("save", "")) return false; break; case DialogResult.Cancel: return false; } } OpenFileDialog op = new OpenFileDialog(); if (filename == "") { op.Filter = "HMI File|*.HMI|All File|*.*".Translate(); Utility.SetInitialPath(op, "file"); if (op.ShowDialog() != DialogResult.OK) return false; Utility.SavePath(op, "file"); m_openFile = op.FileName; } else m_openFile = filename; closeHMI(); m_app = new HmiApplication(); m_app.ChangeApplication = new HmiApplication.AppChangEvent(m_app_ChangeEvent); m_app.FileSave = new HmiApplication.AppFileSave(m_app_FileSaveEvent); m_app.ChangeApplication(false); if (!m_app.Open(m_openFile)) return false; if (!Utility.DeleteFileWait(HmiOptions.RunFilePath)) return false; File.Copy(m_openFile, HmiOptions.RunFilePath); runScreen.GuiInit(HmiOptions.RunFilePath, m_app, true); runScreen.Visible = true; pageAdmin.SetAppInfo(m_app); picAdmin.SetAppInfo(m_app); fontAdmin.SetAppInfo(m_app); pageAdmin.RefreshObject(0); picAdmin.RefreshPictures(); fontAdmin.RefreshFonts(); mi_Compile.Enabled = true; mi_AddComponent.Enabled = true; mi_DeleteComponent.Enabled = true; mi_Resolution.Enabled = true; mi_ID.Enabled = true; mi_XY.Enabled = true; } #endregion #region save / savexml else if (cmd == "save" || cmd == "savexml") { if (m_app == null || m_openFile == null || HmiOptions.RunFilePath == null ) return false; runScreen.PauseScreen(); if (cmd == "save") { m_compiler.SaveCodes(); m_binpath = ""; if (!m_app.SaveFile(HmiOptions.RunFilePath, false, null)) { runScreen.StartFile(); return false; } if (!Utility.DeleteFileWait(m_openFile)) { runScreen.StartFile(); return false; } File.Copy(HmiOptions.RunFilePath, m_openFile); } else { dialog = new SaveFileDialog(); dialog.Filter = "XML File|*.xml|All File|*.*".Translate(); dialog.FileName = Path.GetFileNameWithoutExtension(m_openFile) + ".xml"; Utility.SetInitialPath(dialog, "file"); if (dialog.ShowDialog() != DialogResult.OK) return false; try { if (File.Exists(dialog.FileName)) File.Delete(dialog.FileName); using (TextWriter writer = new StreamWriter(dialog.FileName, false, Encoding.UTF8)) { XmlSerializer xs = new XmlSerializer(runScreen.GuiApp.GetType()); xs.Serialize(writer, runScreen.GuiApp); writer.Close(); } // xdoc.Save(dialog.FileName); } catch(Exception ex) { MessageBox.Show("Export XML:".Translate() + "\n" + ex.Message); } } runScreen.StartFile(); m_app.ChangeApplication(false); } #endregion #region compile else if (cmd == "compile") { if (m_app == null || m_openFile == null) return false; if (m_app.ChangeApp) { runScreen.PauseScreen(); m_compiler.SaveCodes(); if (!m_app.SaveFile(HmiOptions.RunFilePath, false, null)) { runScreen.StartFile(); return false; } if (!Utility.DeleteFileWait(m_openFile)) { runScreen.StartFile(); return false; } File.Copy(HmiOptions.RunFilePath, m_openFile); runScreen.StartFile(); m_app.ChangeApplication(false); } if (!Directory.Exists(HmiOptions.AppDataBinPath)) Directory.CreateDirectory(HmiOptions.AppDataBinPath); m_binpath = Path.Combine(HmiOptions.AppDataBinPath, Path.GetFileNameWithoutExtension(m_openFile) + ".tft"); label2.ForeColor = Color.Black; if (m_app.SaveFile(m_binpath, true, tbCompilerOutput)) m_app.ChangeApplication(false); else { m_binpath = ""; label2.ForeColor = Color.Red; return false; } } #endregion #region saveAs else if (cmd == "saveAs" && m_app != null) { dialog = new SaveFileDialog { Filter = "HMI File|*.HMI|All File|*.*".Translate() }; Utility.SetInitialPath(dialog, "file"); if (dialog.ShowDialog() != DialogResult.OK) return false; m_openFile = dialog.FileName; Utility.SavePath(dialog, "file"); runScreen.PauseScreen(); if (m_app.SaveFile(HmiOptions.RunFilePath, false, null)) { if (!Utility.DeleteFileWait(m_openFile)) { runScreen.StartFile(); return false; } File.Copy(HmiOptions.RunFilePath, m_openFile); } runScreen.StartFile(); refreshPage(); m_app.ChangeApplication(false); return true; } #endregion } if (m_app != null) showUsageSpace(); panelView.Refresh(); return true; }
private void miImport_Click(object sender, EventArgs e) { if (m_app == null) { MessageBox.Show("Please open the project".Translate()); } else { int num = 0; HmiApplication _inf = new HmiApplication(); OpenFileDialog op = new OpenFileDialog { Filter = "HMI File|*.HMI|All File|*.*".Translate() }; Utility.SetInitialPath(op, "file"); if (op.ShowDialog() == DialogResult.OK) { Utility.SavePath(op, "file"); if (_inf.Open(op.FileName)) { for (num = 0; num < _inf.HmiPages.Count; num++) { for (int i = 0; i < _inf.HmiPages[num].HmiObjects.Count; i++) { _inf.HmiPages[num].HmiObjects[i].App = m_app; } _inf.HmiPages[num].App = m_app; m_app.HmiPages.Add(_inf.HmiPages[num]); pageAdmin.RefreshObject(0); } for (num = 0; num < _inf.Fonts.Count; num++) { m_app.Fonts.Add(_inf.Fonts[num]); m_app.FontImages.Add(_inf.FontImages[num]); fontAdmin.RefreshFonts(); } for (num = 0; num < _inf.Pictures.Count; num++) { m_app.Pictures.Add(_inf.Pictures[num]); m_app.PictureImages.Add(_inf.PictureImages[num]); picAdmin.RefreshPictures(); } _inf = null; m_app.ChangeApplication(true); } } } }
public HmiPage(HmiApplication app) { App = app; }
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(); }
public void SetAppInfo(HmiApplication app) { m_app = app; if (app == null) { panelList.Controls.Clear(); ButtonDeleteAll.Enabled = false; ButtonInsert.Enabled = false; ButtonReplace.Enabled = false; btn_Delete.Enabled = false; btn_Add.Enabled = false; } else { ButtonDeleteAll.Enabled = true; ButtonInsert.Enabled = true; ButtonReplace.Enabled = true; btn_Delete.Enabled = true; btn_Add.Enabled = true; } }
public PicView(HmiApplication app, int picIndex) { m_app = app; m_picIndex = picIndex; InitializeComponent(); }
public void SetApp(HmiApplication app) { m_app = app; }
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; }