protected CompLedRound CreateLedRound(int left, int top, Control parent, Helper.CompLedRound.LEDType ledType = CompLedRound.LEDType.Normal) { int width = 25; int height = 25; CompLedRound comp_led_round = null; comp_led_round = new Helper.CompLedRound(); comp_led_round.SetBounds(left, top, width, height); comp_led_round.Type = ledType; comp_led_round.Name = this.m_formularManager.GetDynamicControlName("compLedRound"); parent.Controls.Add(comp_led_round); return(comp_led_round); }
public static void CreateLedRound(CompLedRound Component, int Left, int Top, Helper.CompLedRound.LEDType LedType) { komCounter++; string compName = "ledRoundDyn_" + komCounter; Component.Left = Left; Component.Top = Top; Component.Margin = new System.Windows.Forms.Padding(4); Component.Name = compName; Component.Size = new System.Drawing.Size(25, 25); Component.State = Helper.CompLedRectangle.CompLedState.LedOff; Component.Type = LedType; }
private void LoadError() { string sql_command = ""; //0 , 1 , 2 , 3 , 4 , 5 , 6 sql_command += "Select S7Adress, S7Symbol, S7SymbolType, S7Comment, SymbolType, cast(RankingGroup as integer) as RankingGroup, GroupComment, "; //7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 sql_command += "cast(RankingSymbol as integer) as RankingSymbol, Comment, Unit, SymbolFormat, UpperLimit, LowerLimit, UserRightEnable, UserRightVisible, "; //15 sql_command += "Column "; if (this.m_formularType == FormularType.Error) { sql_command += "from plcitems where (SymbolType='E') order by RankingGroup, RankingSymbol"; } if (this.m_formularType == FormularType.Release) { sql_command += "from plcitems where (SymbolType='R') order by RankingGroup, RankingSymbol"; } this.m_sqliteCommand.CommandText = sql_command; if (this.m_sqliteDataReader != null) { this.m_sqliteDataReader.Close(); this.m_sqliteDataReader = null; } this.m_sqliteDataReader = this.m_sqliteCommand.ExecuteReader(); TabControl tab_control = this.CreateTabControl(4, 20, this.GbxOutput.Width - 8, this.GbxOutput.Height - 25, this.GbxOutput); tab_control.TabStop = false; this.m_tabControl = tab_control; TabPage tab_page = null; int page_no = 0; tab_page = this.CreateTabPage("Seite " + (page_no + 1), tab_control); int gbx_row = 0; int gbx_col = 0; GroupBox group_box = null; Label label_text = null; PlcItemList plc_item_list; CompLedRound led_round = null; string old_group_comment = ""; int row_comp = 0; int gbx_width = (tab_control.DisplayRectangle.Width + 10) / GlobalVar.ConstNumberOfColumns - (GlobalVar.ConstNumberOfColumns + 1) * 4; while (this.m_sqliteDataReader.Read()) { plc_item_list.S7Adress = this.m_sqliteDataReader.GetValue(0).ToString(); plc_item_list.S7Symbol = this.m_sqliteDataReader.GetValue(1).ToString(); plc_item_list.S7SymbolType = this.m_sqliteDataReader.GetValue(2).ToString(); plc_item_list.SymbolType = this.m_sqliteDataReader.GetValue(4).ToString(); plc_item_list.GroupComment = this.m_sqliteDataReader.GetValue(6).ToString(); plc_item_list.RankingSymbol = Convert.ToInt32(this.m_sqliteDataReader.GetValue(7).ToString()); plc_item_list.Comment = this.m_sqliteDataReader.GetValue(8).ToString(); plc_item_list.Unit = this.m_sqliteDataReader.GetValue(9).ToString(); plc_item_list.Format = this.m_sqliteDataReader.GetValue(10).ToString(); plc_item_list.Column = Convert.ToInt32(this.m_sqliteDataReader.GetValue(15).ToString()); plc_item_list.UpperLimit = Convert.ToDouble(this.m_sqliteDataReader.GetValue(11).ToString()); plc_item_list.LowerLimit = Convert.ToDouble(this.m_sqliteDataReader.GetValue(12).ToString()); plc_item_list.UserRightEnable = Convert.ToInt32(this.m_sqliteDataReader.GetValue(13).ToString()); string[] adress_info = plc_item_list.S7Adress.Split('.'); string db_number = adress_info[0]; string varname = db_number + "." + plc_item_list.S7Symbol; plc_item_list.Varname = varname; int top = 0; int left = 0; if (old_group_comment != plc_item_list.GroupComment) { old_group_comment = plc_item_list.GroupComment; top = 0; left = 0; if (gbx_row == 0) { top = 4; left = 4; gbx_row++; } else { left = group_box.Left; top = group_box.Top + group_box.Height + 4; } group_box = this.CreateGroupBox(left, top, gbx_width, 50, plc_item_list.GroupComment, tab_page); row_comp = 0; } int height = (row_comp) * 27 + 50; int height_max = height + group_box.Top; if (height_max > tab_control.DisplayRectangle.Height) { gbx_col++; if (gbx_col > 2) { page_no++; tab_page = this.CreateTabPage("Seite " + (page_no + 1), tab_control); gbx_row = 0; gbx_col = 0; } else { left = gbx_col * (gbx_width + 4) + 4; top = 4; group_box = this.CreateGroupBox(left, top, gbx_width, 50, plc_item_list.GroupComment, tab_page); row_comp = 0; } } height = (row_comp) * 27 + 50; group_box.Height = height; int top_comp = row_comp * 27 + 20; int left_comp = 4; if (this.m_formularType == FormularType.Release) { led_round = this.CreateLedRound(left_comp, top_comp, group_box, CompLedRound.LEDType.Release); } if (this.m_formularType == FormularType.Error) { led_round = this.CreateLedRound(left_comp, top_comp, group_box, CompLedRound.LEDType.Error); } this.m_dataBinding.AddList(this, led_round.Name.ToString(), "State", varname); label_text = this.CreateLabel(left_comp + 40, top_comp, 200, 25, plc_item_list.Comment, group_box, ContentAlignment.MiddleLeft); row_comp++;; } this.m_sqliteDataReader.Close(); this.m_sqliteDataReader = null; }