public MemberAdd(HmiApplication app, HmiPage page, HmiObject obj) { m_app = app; m_page = page; m_obj = obj; InitializeComponent(); Utility.Translate(this); }
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]; }
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(); }
private void mi_Copy_Click(object sender, EventArgs e) { if (m_page != null) { if (m_obj != null && m_obj.Attributes[0].Data[0] != HmiObjType.PAGE) { m_copyObj = m_obj; mi_Paste.Enabled = true; } else MessageBox.Show("Please select component".Translate()); } else MessageBox.Show("Please select page".Translate()); }
private void loadObj(HmiObject obj) { HmiObjectEdit objEdit = new HmiObjectEdit(); try { objEdit.HmiObject = obj; objEdit.Location = new Point(m_objXPos, 5); objEdit.Width = 40; objEdit.Height = 40; objEdit.IsMove = false; if (objEdit.Width < 3) objEdit.Width = 3; if (base.Height < 3) objEdit.Height = 3; objEdit.BackColor = (obj.Attributes[0].Data[0] == HmiObjType.PAGE) ? Color.FromArgb(0, 72, 149, 253) : Color.FromArgb(50, 72, 149, 253); objEdit.IsShowName = m_app.IsShowName; objEdit.HmiRunScreen = runScreen; objEdit.ObjMouseUp += new EventHandler(runScreen.T_objMouseUp); objEdit.ObjChange += new EventHandler(runScreen.T_ObjChange); objEdit.SetApp(m_app); objEdit.BackgroundImageLayout = ImageLayout.None; panel9.Controls.Add(objEdit); objEdit.MakeBackground(); objEdit.BringToFront(); objEdit.Visible = true; objEdit.Anchor = AnchorStyles.Left | AnchorStyles.Bottom; if (m_objXPos == 0) panel9.Visible = true; m_objXPos += 50; setControlsTop(); } catch (Exception ex) { MessageBox.Show("Error occurred during loading components ".Translate() + ex.Message); } }
private void listBox2_SelectedIndexChanged(object sender, EventArgs e) { List<byte[]> bts = new List<byte[]>(); m_obj = m_page.HmiObjects[int.Parse(listBox2.SelectedItem.ToString())]; textBox3.Text = Utility.ToStrings(m_obj.GetCodes()); m_obj.CompileCodes(bts); textBox1.Text = Utility.ToStrings(bts); m_compiler.RefreshObject(m_app, m_page, m_page.HmiObjects[int.Parse(listBox2.SelectedItem.ToString())]); }
/// <summary> /// /// </summary> /// <param name="delete_all">1 = all components, 0 = current conponent</param> private void deleteObj(int delete_all) { bool flag = false; if (m_page == null) { MessageBox.Show("Please select page".Translate()); return; } if (delete_all == 1) { m_page.DeleteAllObj(); refreshPage(); } else if (delete_all != 2) { if (m_obj == null) { MessageBox.Show("Please select component".Translate()); return; } if (m_obj.Attributes[0].Data[0] == HmiObjType.PAGE) { MessageBox.Show("Please select component".Translate()); return; } m_obj.Page.delobj(m_obj); if (m_objEdit.HmiObject.Attributes[0].Data[0] == HmiObjType.TIMER || m_objEdit.HmiObject.Attributes[0].Data[0] == HmiObjType.VAR ) flag = true; m_objEdit.Dispose(); runScreen.HmiObjectEdit.Dispose(); } m_obj = null; m_objEdit = null; runScreen.HmiObjectEdit = null; m_compiler.RefreshObject(m_app, m_page, m_obj); m_attributeEdit.RefreshObject(m_app, m_page, m_obj); m_app.ChangeApplication(true); if (flag) refreshTimerVar(); }
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 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 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 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); } }
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 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; }
public void delobj(HmiObject obj) { HmiObjects.RemoveAt(obj.ObjId); App.RefreshObjId(this); }
private void panelView_MouseUp(object sender, MouseEventArgs e) { if (m_app != null) { if (m_objEdit != null) m_objEdit.SetSelected(false); m_objEdit = null; m_obj = null; m_compiler.RefreshObject(m_app, m_page, m_obj); m_attributeEdit.RefreshObject(m_app, m_page, m_obj); mi_Copy.Enabled = false; } }
// 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 refreshPage() { m_obj = null; if (runScreen.HmiObjectEdit != null) { runScreen.HmiObjectEdit.Dispose(); runScreen.HmiObjectEdit = null; } if (m_page != null) { textBox2.Text = Utility.ToStrings(m_page.Codes); if (!runScreen.Visible) { runScreen.GuiInit(HmiOptions.RunFilePath, m_app, true); runScreen.Visible = true; } m_objEdit = null; listBox2.Items.Clear(); for (int i = 0; i < m_page.HmiObjects.Count; i++) listBox2.Items.Add(i.ToString()); } runScreen.RefreshPageEdit(m_page); m_compiler.RefreshObject(m_app, m_page, m_obj); m_attributeEdit.RefreshObject(m_app, m_page, m_obj); mi_Copy.Enabled = false; refreshTimerVar(); }
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; }
private void runScreen_ObjMouseUp(object sender, EventArgs e) { List<byte[]> bts = new List<byte[]>(); HmiObjectEdit objedit = (HmiObjectEdit)sender; if ((m_app != null) && (m_page != null)) { if (objedit != null) { m_objEdit = objedit; m_obj = m_objEdit.HmiObject; textBox3.Text = Utility.ToStrings(m_obj.GetCodes()); m_obj.CompileCodes(bts); textBox1.Text = Utility.ToStrings(bts); } else m_obj = m_page.HmiObjects[0]; m_compiler.RefreshObject(m_app, m_page, m_obj); m_attributeEdit.RefreshObject(m_app, m_page, m_obj); mi_Copy.Enabled = true; } }
private void addComponent(byte lei, byte mark) { try { if (m_page != null) { HmiObject item = new HmiObject(m_app, m_page); if (lei == 2) { if (m_copyObj == null) { MessageBox.Show("Please copy component".Translate()); return; } item = m_copyObj.CopyObject(m_app, m_page); } else if (lei == 0) { item.ObjInfo.Panel.X = 0; item.ObjInfo.Panel.Y = 0; item.ObjInfo.Panel.EndX = 100; item.ObjInfo.Panel.EndY = 100; item.ObjInfo.Panel.loadlei = 1; } else if (lei > 2) item.Attributes = ObjAttOperation.CreateAttrByType(mark, ref item.ObjInfo.Panel); item.ObjInfo.Panel.EndX = (ushort)(item.ObjInfo.Panel.EndX - item.ObjInfo.Panel.X); item.ObjInfo.Panel.EndY = (ushort)(item.ObjInfo.Panel.EndY - item.ObjInfo.Panel.Y); item.ObjInfo.Panel.X = 0; item.ObjInfo.Panel.Y = 0; item.ObjInfo.ObjType = mark; m_page.HmiObjects.Add(item); m_app.MakeObjName(m_page, item, mark); m_app.RefreshObjId(m_page); m_app.ChangeApplication(true); if (item.Attributes[0].Data[0] == HmiObjType.TIMER || item.Attributes[0].Data[0] == HmiObjType.VAR) loadObj(item); else runScreen.LoadObj(item); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }
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; }