private void frmMain_Load(object sender, EventArgs e) { //UControls.UC_WebBrowser frm = new UControls.UC_WebBrowser(); UC_Main frm = new UC_Main(); frm.Dock = DockStyle.Fill; this.Controls.Add(frm); if (!UserConfig.getIsActive()) { if (UserConfig.getTimeLeft() > 0) { t.Interval = 1000; t.Enabled = true; t.Tick += T_Tick; } else { if (this.Controls.Count > 0) { this.Controls[0].Enabled = false; } t.Enabled = false; this.Text = "[Blocked] " + title; this.ControlBox = true; } } }
private void removeNode(int nodeId, ToggleButton tb, UC_Main ucMain){ if (tb.IsChecked==true){ ((ToggleButton)buttons_panel.Children[0]).IsChecked = true; } buttons_panel.Children.Remove(tb); if (buttons_panel.Children.Count == 1) buttons_panel.Visibility = Visibility.Collapsed; CAN_Common.Instance.RemoveNode(nodeId); Globals.Vm_scis.First(x => x.VM_UC_Main.NodeId == nodeId).Release(); }
public void AddNode(int nodeId, bool isCANInterface = true){ UC_Main uc_main; if (isCANInterface) { if (CAN_Common.Instance.dic_CanChanels.ContainsKey(nodeId)) return; uc_main = new UC_Main(nodeId) { Visibility = Visibility.Collapsed }; CAN_Common.OpenAllConnections(); } else{ CAN_Common._instance = new CAN_Common(activeInterface:Common.Consts.INTERFACE_RS232); uc_main = new UC_Main(nodeId) { Visibility = Visibility.Collapsed }; } var tb = makeButton(nodeId, uc_main); gridPresenter.Children.Add(uc_main); }
private ToggleButton makeButton(int nodeId, UC_Main uc_main){ Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)}); grid.ColumnDefinitions.Add(new ColumnDefinition(){Width = GridLength.Auto}); TextBlock text = new TextBlock(){Text = "Node "+nodeId, MinWidth = 60, TextAlignment = TextAlignment.Center}; var btnClose = new BtnRemoveNode(); Grid.SetColumn(text,0); Grid.SetColumn(btnClose,1); grid.Children.Add(text); grid.Children.Add(btnClose); ToggleButton tb = new ToggleButton() { Content = grid, Focusable = false, }; //tb.SetValue(ToggleButtonExtensions.GroupNameProperty, "NodeGroup"); buttons_panel.Children.Add(tb); buttons_panel.Visibility = buttons_panel.Children.Count > 1 ? Visibility.Visible : Visibility.Collapsed; btnClose.Click += (a, e) => removeNode(nodeId, tb, uc_main); tb.Checked += (a, e) =>{ uc_main.Visibility = Visibility.Visible; setTbChecked(tb); }; tb.Unchecked += (a, e) => { uc_main.Visibility = Visibility.Collapsed; }; tb.IsChecked = true; return tb; }
public UI_MainWindow() { Content = new UC_Main(); InitializeComponent(); }