protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Commands); // Simple command ------------------------------------------- SimpleCommandButton.SetCommand(Vm.SayHelloCommand); // Command and checkbox --------------------------------- MyCheckBox.SetCommand(Vm.SayHelloCommand); // Command and custom event ----------------------------- CustomEventEditText.SetCommand <string, View.FocusChangeEventArgs>( "FocusChange", Vm.ShowMessageCommand, "This message shows on FocusChange"); // Command and static parameter ----------------------------- StaticParameterButton.SetCommand( Vm.ShowMessageCommand, "Hello Evolve, this is a static message!"); // Command and dynamic parameter ---------------------------- var parameterBinding = this.SetBinding(() => MyEditText.Text); _bindings.Add(parameterBinding); DynamicParameterButton.SetCommand(Vm.ShowMessageCommand, parameterBinding); // Subscribing to events to avoid linker issues in release mode --------------------------------- // This "fools" the linker into believing that the events are used. // In fact we don't even subscribe to them. // See https://developer.xamarin.com/guides/android/advanced_topics/linking/ if (_falseFlag) { SimpleCommandButton.Click += (s, e) => { }; StaticParameterButton.Click += (s, e) => { }; DynamicParameterButton.Click += (s, e) => { }; MyCheckBox.CheckedChange += (s, e) => { }; CustomEventEditText.FocusChange += (s, e) => { }; } }
private void SaveConfigForm_Load(object sender, EventArgs e) { int index = 1; foreach (var i in envList) { MyCheckBox myCheckBox = new MyCheckBox(); myCheckBox.Name = index.ToString(); myCheckBox.Location = new Point(0, (index - 1) * 50); myCheckBox.Num = index++; myCheckBox.TaskName = i.Key; myCheckBox.TaskImage = Tools.GetImage(i.Key.ToLower()); // myCheckBox.TaskImage = Image.FromFile($"{Config.IconPath}/{i.Key.ToLower()}.png"); EnvPanel.Controls.Add(myCheckBox); } index = 1; foreach (var i in softwareList) { MyCheckBox myCheckBox = new MyCheckBox(); myCheckBox.Name = index.ToString(); myCheckBox.Location = new Point(0, (index - 1) * 50); myCheckBox.Num = index++; myCheckBox.TaskName = i.Key; myCheckBox.TaskImage = Tools.GetImage(i.Key.ToLower()); // myCheckBox.TaskImage = Image.FromFile($"{Config.IconPath}/{i.Key.ToLower()}.png"); SoftwarePanel.Controls.Add(myCheckBox); } }
private void OnClick(object sender, RoutedEventArgs e) { var bindingExpression = MyCheckBox.GetBindingExpression(ToggleButton.IsCheckedProperty); if (bindingExpression == null) { MessageBox.Show("IsChecked property is not bound!"); } }
//添加菜单checkbox到list public void AddCheckBox(Repeater list) { foreach (Control c in list.Controls) { CheckBox checkbox = (CheckBox)c.FindControl("MenuBox"); string strId = ((HiddenField)c.FindControl("MenuIDHid")).Value; MyCheckBox cb = new MyCheckBox(checkbox, strId); lists.Add(cb); } }
//添加菜单checkbox到list public void AddCheckBox(Repeater list) { foreach (Control c in list.Controls) { CheckBox checkbox = (CheckBox)c.FindControl("MenuBox"); string strId = ((HiddenField)c.FindControl("MenuIDHid")).Value; MyCheckBox cb = new MyCheckBox(checkbox, strId); lists.Add(cb); } }
// 0 1 private StackPanel createTreeViewItem(string value, BitmapImage btmapImg, bool hasMyCheckBox, int level, MyTreeViewItem item) { StackPanel panel = new StackPanel(); panel.Height = 45; panel.Width = 200; panel.Orientation = Orientation.Horizontal; if (btmapImg != null) { Image img = new Image(); img.Source = btmapImg; panel.Children.Add(img); //加入图片 } Label lb = new Label(); lb.FontSize = 17; lb.Foreground = new SolidColorBrush(Color.FromRgb(255, 59, 59)); lb.Content = value; lb.VerticalAlignment = VerticalAlignment.Center; lb.HorizontalAlignment = HorizontalAlignment.Center; lb.Foreground = new SolidColorBrush(Colors.White); panel.Children.Add(lb); //加入文字标签 if (hasMyCheckBox) { MyCheckBox.CheckBoxType t = MyCheckBox.CheckBoxType.unknow; switch (level) { case -1: break; case 0: break; case 1: t = MyCheckBox.CheckBoxType.buildingType; break; case 2: t = MyCheckBox.CheckBoxType.cabTyp; break; case 3: t = MyCheckBox.CheckBoxType.deviceType; break; } MyCheckBox cb = new MyCheckBox(t, item); cb.Click += cb_Checked; panel.Children.Add(cb); //加入最后一个checkbox } return(panel); }
public MyInkCanvas(MyWindow myWindow, MyCheckBox chkbox, int cnt) { this._myWindow = myWindow; this.Children.Add(new TextBlock() { Text = cnt.ToString() }); /* * This exmple is based on a real leak I experienced while developing my SheetMusic Viewer * https://github.com/calvinhsia/SheetMusicViewer * Each instance of the InkCanvas had a rendering of a sheet music page * As I played the piano reading the music, each page I turned was leaked * (and sheet music PDF files consume a lot of memory), eventually * causing an OutOfMemory exception. * Thousands of CheckBox eventhandlers: * Subscribing to the Checked method can cause a leak: the single ChkBox on the form is the Publisher of the Checked Event, * and it holds a list of the subscribers in it's System.Windows.EventHandlersStore _listStore * Children of "-- MyCodeToExecute.MyClass+MyCheckBox 0x21591f6c" * -- MyCodeToExecute.MyClass+MyCheckBox 0x21591f6c * -> _dispatcher = System.Windows.Threading.Dispatcher 0x035feb50 * -> _dType = System.Windows.DependencyObjectType 0x21592064 * -> _effectiveValues = System.Windows.EffectiveValueEntry[] 0x21599554 * -> MyCodeToExecute.MyClass+MyWindow 0x2158d4a0 * -> System.Collections.Generic.List<System.Windows.DependencyObject> 0x215922ec * -> System.Windows.DeferredThemeResourceReference 0x038a8d20 * -> System.Windows.EventHandlersStore 0x21599548 * -> _entries = MS.Utility.SingleObjectMap 0x21599604 * -> _loneEntry = MS.Utility.FrugalObjectList<System.Windows.RoutedEventHandlerInfo> 0x215995f8 * -> _listStore = MS.Utility.ArrayItemList<System.Windows.RoutedEventHandlerInfo> 0x215a41d4 * -> _entries = System.Windows.RoutedEventHandlerInfo[] 0x3a94c858 * -> System.Windows.RoutedEventHandler 0x21599528 * -> System.Windows.RoutedEventHandler 0x21599614 * -> _target = MyCodeToExecute.MyClass+MyInkCanvas 0x21595aa8 * -> System.Windows.RoutedEventHandler 0x2159cf7c * -> _target = MyCodeToExecute.MyClass+MyInkCanvas 0x215996ac * -> System.Windows.RoutedEventHandler 0x215a08a8 * -> _target = MyCodeToExecute.MyClass+MyInkCanvas 0x2159cfd8 * -> System.Windows.RoutedEventHandler 0x215a41e4 * -> _target = MyCodeToExecute.MyClass+MyInkCanvas 0x215a0904 If the event subscriber is an empty lambda, then it doesn't leak: the eventhandler count goes up * */ chkbox.Checked += (o, e) => { var y = arr; // the lambda needs to refer to a mem var else no leak: the # ev handlers goes up, but WPF is smart: they're all the same handler // _myWindow._MyClass.logger.LogMessage("Click" + (_myWindow.numClicks++).ToString()); }; // chkbox.Checked += ChkboxHandler; }
public Admin_Control(User Admin) { AdminName = Admin.GetFullName; InitializeComponent(); lblWelcomAdmin.Text = "Welcome " + AdminName; this.WindowState = FormWindowState.Maximized; MyCheckBox cb = new MyCheckBox(); this.Controls.Add(cb); //populate dropdownList updateDdlist(); lblLastAdminLogin.Text = "Last Login: " + Admin.LastLoginDate.ToString(); }
public Admin_Control(User Admin) { AdminName = Admin.GetFullName; InitializeComponent(); lblWelcomAdmin.Text = "Welcome " + AdminName; this.WindowState = FormWindowState.Maximized; MyCheckBox cb = new MyCheckBox(); this.Controls.Add(cb); //populate dropdownList updateDdlist(); lblLastAdminLogin.Text = "Last Login: " + Admin.LastLoginDate.ToString(); }
public Game() { controlPanel = new MyTableLayoutPanel(3, 1, "AAS300", "A"); { { imageFeedBack = new MyCheckBox("Image Feed Back"); imageFeedBack.Checked = true; controlPanel.AddControl(imageFeedBack, 0, 0); } { showImageFeedBack = new MyCheckBox("Show Image Feed Back"); showImageFeedBack.Checked = false; showImageFeedBack.CheckedChanged += ShowImageFeedBack_CheckedChanged; controlPanel.AddControl(showImageFeedBack, 0, 0); } { Panel pnl = new Panel(); { pnl.Dock = DockStyle.Fill; pnl.AutoScroll = true; { generalSettings = new MyInputField(); generalSettings.Dock = DockStyle.Top; generalSettings.AddField("Image Feed Back Width", imageFeedBackSize.Width.ToString()).TextChanged += (o, e) => { try { imageFeedBackSize.Width = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("Image Feed Back Height", imageFeedBackSize.Height.ToString()).TextChanged += (o, e) => { try { imageFeedBackSize.Height = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("Port", SocketHandler.port.ToString()).TextChanged += (o, e) => { try { SocketHandler.port = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("darryMode", darryMode.ToString()).TextChanged += (o, e) => { try { darryMode = bool.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("max_upward_speed", max_upward_speed.ToString()).TextChanged += (o, e) => { try { max_upward_speed = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("alpha", alpha.ToString()).TextChanged += (o, e) => { try { alpha = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("重利", gravity.ToString()).TextChanged += (o, e) => { try { gravity = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("升力", liftForce.ToString()).TextChanged += (o, e) => { try { liftForce = double.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("可見障礙物數量", obstacleCount.ToString()).TextChanged += (o, e) => { try { obstacleCount = int.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("存活區的範圍", rangeY.ToString()).TextChanged += (o, e) => { try { rangeY = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("障礙物距離的範圍", obstacleDistance.ToString()).TextChanged += (o, e) => { try { obstacleDistance = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("障礙物寬度(通過時間)的範圍", obstacleWidth.ToString()).TextChanged += (o, e) => { try { obstacleWidth = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("障礙物通道底部高度的範圍", obstacleY.ToString()).TextChanged += (o, e) => { try { obstacleY = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; generalSettings.AddField("障礙物通道寬度的範圍", obstacleHeight.ToString()).TextChanged += (o, e) => { try { obstacleHeight = Interval.Parse((o as MyTextBox).Text); } catch (Exception) { MessageBox.Show("格式不正確"); } }; pnl.Controls.Add(generalSettings); } } controlPanel.AddControl(pnl, 2, 0); } } Reset(); Update(true); }
private void updateValidSquaresForSelectedCB(MyCheckBox cb) { if (cb.Checked) { //cb.Image = ResizeImage(Properties.Resources.BlackKnight, cb.Size.Width/2, cb.Size.Height/2); cb.BackColor = MyCheckBox.chessBoardSelectedColor; } else { cb.BackColor = cb.checkerBoardColor; } //Disable All Invalid moves Game currGame = ((Game)gamesListBox.SelectedItem); Board board = currGame.gameBoard; BoardSpace boardPos = cb.getLinkedBoardSpace(); if (boardPos.piece != null && boardPos.piece.color == currGame.color) { List <Move> validMoves = boardPos.piece.getAvailableMoves(board); foreach (Move mv in validMoves) { // Highlight valid Moves bool found = false; for (int row = 1; row <= 8; row++) { for (Char col = 'A'; col <= 'H'; col++) { MyCheckBox itCB = chessBoardList[row - 1, col - 'A']; if (itCB.getLinkedBoardSpace().position.Item2 == mv.toSpace.position.Item2 && itCB.getLinkedBoardSpace().position.Item1 == mv.toSpace.position.Item1) { itCB.BackColor = MyCheckBox.chessBoardValidMoveColor; found = true; break;; } if (found) { break; } } } } } }
/// <summary> /// Repopulates the ScriptPanel with scripts from the current ScriptManager instance. /// </summary> private void RepopulatePanel() { _mainForm.ScriptPanel.Controls.Clear(); _mainForm.CheckBoxList.Clear(); _mainForm.ActionButtonList.Clear(); foreach (var item in _sm.Scripts) { var box = new MyCheckBox(); var button = new MyButton(); button.Script = item; box.Tag = item.ScriptName; box.Text = item.ScriptName; box.Script = item; box.Checked = item.Enabled; _mainForm.AddScriptControlsToPanel(box, button); } }
/// <summary> /// Adds a checkbox to the panel /// </summary> /// <param name="box">MyCheckBox object</param> /// <param name="button">MyButton object</param> public void AddScriptControlsToPanel(MyCheckBox box, MyButton button) { int i = 1; if (_checkBoxList.Count > 0) { i += _checkBoxList[_checkBoxList.Count - 1].Location.Y / 20; } box.Location = new Point(30, i * 20); box.AutoSize = true; box.CheckedChanged += ScriptPanelCheckedChanged; button.Location = new Point(10, (i * 20)); button.Text = "action"; button.Visible = true; button.Size = new Size(15, 15); button.Click += ScriptPanelActionClick; _actionButtonList.Add(button); ScriptPanel.Controls.Add(button); _checkBoxList.Add(box); ScriptPanel.Controls.Add(box); }
///////////////////////////////////////////////////////////////////////////////////// #region [ Private Methods ] /// <summary> /// Adjusts colors for the window and its children in case the MdiForm /// is inactive. /// </summary> /// private static void SetupInactiveColors(Window w) { if (w == null) { return; } w.BackColorInact = Color.Black; w.BorderBackColorInact = Color.Black; w.CaptionBackColorInact = Color.Black; w.BorderForeColorInact = Color.DarkGray; foreach (Window child in w.Children) { child.AccessKeyForeColor = Color.Gray; child.BorderBackColorInact = Color.Black; child.BackColorInact = Color.Black; child.CaptionBackColorInact = Color.Black; child.BorderForeColorInact = Color.DarkGray; if (child is MyGroupBox) { SetupInactiveColors(child); child.ForeColorInact = Color.DarkGray; } else if (child is MyTextBox) { MyTextBox field = child as MyTextBox; field.BorderForeColorInact = field.Multiline ? Color.DarkGray : Color.Black; //field.BorderForeColorInact = Color.Black; field.BorderForeColor = Color.Black; field.ForeColorInact = Color.Gray; } else if (child is MyComboBox) { MyComboBox field = child as MyComboBox; field.HeaderBackColorInact = Color.Black; field.HeaderForeColorInact = Color.Gray; field.BorderForeColorInact = Color.Black; field.ScrollBarForeColorInact = Color.Black; } else if (child is MyListView) { MyListView field = child as MyListView; field.ForeColorInact = Color.DarkGray; field.HeaderBackColorInact = Color.Black; field.FooterBackColorInact = Color.Black; field.CurrentRowBackColorInact = Color.DarkGray; field.CurrentRowForeColorInact = Color.Black; field.HeaderForeColorInact = Color.DarkGray; field.FooterForeColorInact = Color.DarkGray; } else if (child is MyCheckBox) { MyCheckBox field = child as MyCheckBox; field.ForeColorInact = Color.DarkGray; field.ForeColor = Color.DarkGray; field.CaptionForeColorInact = Color.Gray; field.CaptionForeColor = Color.Gray; } else if (child is MyLabel) { child.AccessKeyForeColor = Color.DarkGray; child.ForeColorInact = Color.DarkGray; } } }
public InsertedInformationsPartnersCustomCell() { this.SetBinding(InsertedInformationsPartnersCustomCell.PartnerIdProperty, "Id"); Grid GridWrapper = new Grid() { Padding = new Thickness(5, 0), RowSpacing = 1, ColumnSpacing = 1, HorizontalOptions = LayoutOptions.FillAndExpand }; GridWrapper.SetBinding(Grid.BackgroundColorProperty, "RowColor"); GridWrapper.RowDefinitions = new RowDefinitionCollection() { new RowDefinition() { Height = 35 }, new RowDefinition() { Height = 25 } }; GridWrapper.ColumnDefinitions = new ColumnDefinitionCollection() { new ColumnDefinition() { Width = new GridLength(6, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(5, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(10, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(4, GridUnitType.Star) } }; var CheckboxColumnDefinition = new ColumnDefinition() { }; GridWrapper.ColumnDefinitions.Add(CheckboxColumnDefinition); Label PhoneLabel = null, GroupLabel = null, NameLabel = null, CodeLabel = null, AddressLabel = null; MyCheckBox CheckBox = null; PhoneLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, HorizontalOptions = LayoutOptions.Start, HorizontalTextAlignment = TextAlignment.Start, VerticalOptions = LayoutOptions.Center, FontSize = 16, TextColor = Color.FromHex("222222") }; GroupLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, HorizontalOptions = LayoutOptions.Start, HorizontalTextAlignment = TextAlignment.Start, VerticalOptions = LayoutOptions.Center, FontSize = 16, TextColor = Color.FromHex("222222") }; NameLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16, TextColor = Color.FromHex("222222") }; CodeLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 16, TextColor = Color.FromHex("222222") }; AddressLabel = new Label() { LineBreakMode = LineBreakMode.TailTruncation, HorizontalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Center, FontSize = 13 }; CheckBox = new MyCheckBox() { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center }; GridWrapper.Children.Add(PhoneLabel, 0, 0); GridWrapper.Children.Add(GroupLabel, 1, 0); GridWrapper.Children.Add(NameLabel, 2, 0); GridWrapper.Children.Add(CodeLabel, 3, 0); GridWrapper.Children.Add(AddressLabel, 0, 1); Grid.SetColumnSpan(AddressLabel, 4); GridWrapper.Children.Add(CheckBox, 4, 0); Grid.SetRowSpan(CheckBox, 2); PhoneLabel.SetBinding(Label.TextProperty, "Phone"); GroupLabel.SetBinding(Label.TextProperty, "Group"); NameLabel.SetBinding(Label.TextProperty, "Name"); CodeLabel.SetBinding(Label.TextProperty, "Code"); AddressLabel.SetBinding(Label.TextProperty, "Address"); AddressLabel.SetBinding(Label.TextColorProperty, "DescriptionColor"); CheckboxColumnDefinition.SetBinding(ColumnDefinition.WidthProperty, "CheckBoxColumnWidth"); CheckBox.SetBinding(MyCheckBox.CheckedProperty, "Selected", BindingMode.TwoWay); CheckBox.SetBinding(MyCheckBox.IsVisibleProperty, "CanBeSelectedInMultiselection"); View = GridWrapper; }
private void boardSqaureCheckChanged(object sender, EventArgs e) { MyCheckBox cb = (MyCheckBox)sender; List <MyCheckBox> selectedSpaces = getSelectedSquareInChessBoard(); cb.lastTimeSelected = DateTime.Now; if (selectedSpaces.Count > 2) { if (!cb.Checked) { cb.Checked = false; } } else { if (selectedSpaces.Count == 2) { String move = ""; MyCheckBox fromSpace = null; MyCheckBox toSpace = null; if (DateTime.Compare(selectedSpaces[0].lastTimeSelected, selectedSpaces[1].lastTimeSelected) < 0) { fromSpace = selectedSpaces[0]; toSpace = selectedSpaces[1]; } else { fromSpace = selectedSpaces[1]; toSpace = selectedSpaces[0]; } if (toSpace.BackColor == MyCheckBox.chessBoardValidMoveColor) { move = $"{fromSpace.Name.ToLower()}{toSpace.Name.ToLower()}"; if (!((Game)gamesListBox.SelectedItem).makeMove(move)) { //toSpace.Checked = false; if (toSpace.getLinkedBoardSpace().piece != null && toSpace.getLinkedBoardSpace().piece.color == toSpace.game.color) { // Select this piece instead fromSpace.Checked = false; } else { toSpace.Checked = false; } } else { toSpace.Checked = false; fromSpace.Checked = false; } } else { if (toSpace.getLinkedBoardSpace().piece != null && toSpace.getLinkedBoardSpace().piece.color == toSpace.game.color) { // Select this piece instead resetCheckBoxDefaultColors(visualOnly: true); fromSpace.Checked = false; toSpace.BackColor = MyCheckBox.chessBoardSelectedColor; toSpace.Checked = true; updateValidSquaresForSelectedCB(toSpace); } else { //MessageBox.Show($"Move '{move}' is Invalid."); toSpace.Checked = false; } } } else if (selectedSpaces.Count == 1) { updateValidSquaresForSelectedCB(cb); } else { // Non selected Reset Colors resetCheckBoxDefaultColors(visualOnly: true); } } }
private void gamesListBox_SelectedIndexChanged(object sender, EventArgs e) { ListBox b = (ListBox)sender; // Set Browser foreach (Control item in Controls.OfType <MyCheckBox>()) { Controls.Remove(item); Array.Clear(chessBoardList, 0, chessBoardList.Length); Array.Clear(opBoardList, 0, opBoardList.Length); } if (b.SelectedIndex != -1) { Game currGame = ((Game)b.Items[b.SelectedIndex]); currGame.clockStateUpdated += clockStateUpdated; currGame.BoardUpdated += updateGUIAfterBoardChange; currGame.GameOver += gameHasEnded; currGame.startGameStream(); Console.WriteLine(currGame.getBoard().printBoard(currGame.color)); Console.WriteLine(Environment.NewLine + ((Game)b.Items[b.SelectedIndex]).getBoard().printBoard((currGame.color == ChessmanColor.white) ? ChessmanColor.black : ChessmanColor.white) + Environment.NewLine); // Set Opponent Board and Clock Labels oppBoardNameLbl.Text = $"{currGame.opponentName}'s Board"; oppClockNameLbl.Text = $"{currGame.opponentName}'s Clock"; playerClockNameLbl.Text = $"{currentAccount.username}'s Clock"; oppClockTimeLbl.Location = new Point(playerClockTimeLbl.Location.X, oppClockTimeLbl.Location.Y); oppClockTimeLbl.Width = playerClockTimeLbl.Width = Math.Max(oppClockNameLbl.Width, playerClockNameLbl.Width); int yPos = 0; int xPos = 0; int cbXDim = 100; int cbYDim = 100; int edgeBuffer = 15; Rectangle screenRectangle = RectangleToScreen(ClientRectangle); int titleHeight = screenRectangle.Top - Top; turnLbl.AutoSize = false; turnLbl.Size = new Size((8 * cbXDim), turnLbl.Size.Height); int initialXPos = oppClockNameLbl.Location.X + Math.Max(oppClockNameLbl.Width, playerClockNameLbl.Width) + edgeBuffer; turnLbl.Location = new Point(initialXPos, turnLbl.Location.Y); int initialYPos = turnLbl.Height + turnLbl.Location.Y + edgeBuffer; Size = new Size(initialXPos + (8 * cbXDim) + 2 * edgeBuffer, initialYPos + (8 * cbYDim) + edgeBuffer + titleHeight); if (currGame.color == ChessmanColor.black) { for (int row = 7; row >= 0; row--) { // Initial Cb positon = 333x, 441y int effectiveRow = 8 - row; yPos = initialYPos + (cbYDim * (effectiveRow - 1)); for (int col = 7; col >= 0; col--) { xPos = initialXPos + (col * cbXDim); Char tmp = (Char)('H' - col); //boardState[row, col] = new BoardSpace(tmp, effectiveRow); MyCheckBox cb = new MyCheckBox(tmp, effectiveRow, currGame); cb.GotFocus += opBoardSqaureGotFocus; cb.AutoSize = false; cb.Appearance = Appearance.Button; cb.ImageAlign = ContentAlignment.MiddleCenter; cb.Click += boardSqaureCheckChanged; cb.Name = $"{tmp}{effectiveRow}"; bool legendPrinted = false; if (enableLegends) { if (col == 7 && effectiveRow == 8) // Use As Legend Corner { // Set Row Legends cb.Text = $"{tmp.ToString().ToUpper()}{effectiveRow}"; cb.TextAlign = ContentAlignment.BottomRight; legendPrinted = true; } else if (effectiveRow == 8) // Use As Legend { // Set Column Legends cb.Text = tmp.ToString().ToUpper(); cb.TextAlign = ContentAlignment.BottomCenter; legendPrinted = true; } else if (col == 7) // Use As Legend { // Set Row Legends cb.Text = $"{effectiveRow}"; cb.TextAlign = ContentAlignment.BottomRight; legendPrinted = true; } } if (!legendPrinted) { cb.Text = cb.Name; cb.TextAlign = ContentAlignment.BottomRight; cb.Font = new Font(cb.Font.FontFamily, 8); } cb.Size = new Size(cbXDim, cbYDim); cb.Location = new Point(xPos, yPos); Controls.Add(cb); chessBoardList[row, col] = cb; } } } else { for (int row = 0; row < 8; row++) { // Initial Cb positon = 333x, 441y yPos = initialYPos + (cbYDim * row); for (int col = 0; col < 8; col++) { xPos = initialXPos + (col * cbXDim); Char tmp = (Char)('A' + col); int effectiveRow = 8 - row; //boardState[row, col] = new BoardSpace(tmp, effectiveRow); MyCheckBox cb = new MyCheckBox(tmp, row + 1, currGame); cb.GotFocus += opBoardSqaureGotFocus; cb.AutoSize = false; cb.Appearance = Appearance.Button; cb.ImageAlign = ContentAlignment.MiddleCenter; cb.Click += boardSqaureCheckChanged; cb.Name = $"{tmp}{effectiveRow}"; bool legendPrinted = false; if (enableLegends) { if (col == 0 && effectiveRow == 1) // Use As Legend Corner { // Set Row Legends cb.Text = $"{tmp.ToString().ToUpper()}{effectiveRow}"; cb.TextAlign = ContentAlignment.BottomRight; legendPrinted = true; } else if (effectiveRow == 1) // Use As Legend { // Set Column Legends cb.Text = tmp.ToString().ToUpper(); cb.TextAlign = ContentAlignment.BottomCenter; legendPrinted = true; } else if (col == 0) // Use As Legend { // Set Row Legends cb.Text = $"{effectiveRow}"; cb.TextAlign = ContentAlignment.BottomRight; legendPrinted = true; } } if (!legendPrinted) { cb.Text = cb.Name; cb.TextAlign = ContentAlignment.BottomRight; cb.Font = new Font(cb.Font.FontFamily, 8); } cb.Size = new Size(cbXDim, cbYDim); cb.Location = new Point(xPos, yPos); Controls.Add(cb); chessBoardList[row, col] = cb; } } } // Setup Opponents Board yPos = 0; xPos = 0; edgeBuffer = 15; initialXPos = edgeBuffer; initialYPos = oppBoardNameLbl.Height + oppBoardNameLbl.Location.Y + edgeBuffer; cbXDim = cbYDim = Math.Min((Size.Height - initialYPos - edgeBuffer) / 8, (oppClockNameLbl.Location.X + (Math.Max(oppClockNameLbl.Width, playerClockNameLbl.Width) - initialXPos - 2 * edgeBuffer)) / 8); oppBoardNameLbl.Width = 8 * cbXDim; if (!(currGame.color == ChessmanColor.black)) { for (int row = 7; row >= 0; row--) { // Initial Cb positon = 333x, 441y int effectiveRow = 8 - row; yPos = initialYPos + (cbYDim * (effectiveRow - 1)); for (int col = 7; col >= 0; col--) { xPos = initialXPos + (col * cbXDim); Char tmp = (Char)('H' - col); //boardState[row, col] = new BoardSpace(tmp, effectiveRow); MyCheckBox cb = new MyCheckBox(tmp, effectiveRow, currGame); cb.GotFocus += opBoardSqaureGotFocus; cb.CheckedChanged += opBoardSqaureCheckedChanged; cb.AutoSize = false; cb.Appearance = Appearance.Button; cb.ImageAlign = ContentAlignment.MiddleCenter; cb.Name = $"{tmp}{effectiveRow}"; bool legendPrinted = false; if (enableLegends) { if (col == 7 && effectiveRow == 8) // Use As Legend Corner { // Set Row Legends cb.Text = $"{tmp.ToString().ToUpper()}{effectiveRow}"; cb.TextAlign = ContentAlignment.BottomRight; legendPrinted = true; } else if (effectiveRow == 8) // Use As Legend { // Set Column Legends cb.Text = tmp.ToString().ToUpper(); cb.TextAlign = ContentAlignment.BottomCenter; legendPrinted = true; } else if (col == 7) // Use As Legend { // Set Row Legends cb.Text = $"{effectiveRow}"; cb.TextAlign = ContentAlignment.BottomRight; legendPrinted = true; } } if (!legendPrinted) { cb.Text = cb.Name; cb.TextAlign = ContentAlignment.BottomRight; cb.Font = new Font(cb.Font.FontFamily, 6); } cb.Size = new Size(cbXDim, cbYDim); cb.Location = new Point(xPos, yPos); Controls.Add(cb); opBoardList[row, col] = cb; } } } else { for (int row = 0; row < 8; row++) { // Initial Cb positon = 333x, 441y yPos = initialYPos + (cbYDim * row); for (int col = 0; col < 8; col++) { xPos = initialXPos + (col * cbXDim); Char tmp = (Char)('A' + col); int effectiveRow = 8 - row; //boardState[row, col] = new BoardSpace(tmp, effectiveRow); MyCheckBox cb = new MyCheckBox(tmp, (row + 1), currGame); cb.GotFocus += opBoardSqaureGotFocus; cb.CheckedChanged += opBoardSqaureCheckedChanged; cb.AutoSize = false; cb.Appearance = Appearance.Button; cb.ImageAlign = ContentAlignment.MiddleCenter; cb.Name = $"{tmp}{effectiveRow}"; bool legendPrinted = false; if (enableLegends) { if (col == 0 && effectiveRow == 1) // Use As Legend Corner { // Set Row Legends cb.Text = $"{tmp.ToString().ToUpper()}{effectiveRow}"; cb.TextAlign = ContentAlignment.BottomRight; legendPrinted = true; } else if (effectiveRow == 1) // Use As Legend { // Set Column Legends cb.Text = tmp.ToString().ToUpper(); cb.TextAlign = ContentAlignment.BottomCenter; legendPrinted = true; } else if (col == 0) // Use As Legend { // Set Row Legends cb.Text = $"{effectiveRow}"; cb.TextAlign = ContentAlignment.BottomRight; legendPrinted = true; } } if (!legendPrinted) { cb.Text = cb.Name; cb.TextAlign = ContentAlignment.BottomRight; cb.Font = new Font(cb.Font.FontFamily, 6); } cb.Size = new Size(cbXDim, cbYDim); cb.Location = new Point(xPos, yPos); Controls.Add(cb); opBoardList[row, col] = cb; } } } updateGUIAfterBoardChange(); } }
public Form1() { this.Size = new Size(700, 500); this.FormClosing += Form1_FormClosing; { TLPmain = new MyTableLayoutPanel(2, 1, "PA", "P"); { TXBoutput = new MyTextBox(true); TLPmain.AddControl(TXBoutput, 0, 0); } { TLPbtn = new MyTableLayoutPanel(1, 5, "A", $"AAAPS{Database.scopeSize.Width}"); { BTNstart = new MyButton("Start"); BTNstart.Click += BTNstart_Click; TLPbtn.AddControl(BTNstart, 0, 0); } { BTNscan = new MyButton("Scan"); BTNscan.Click += BTNscan_Click; TLPbtn.AddControl(BTNscan, 0, 1); } { CHBpressKey = new MyCheckBox("Press Key"); CHBpressKey.CheckedChanged += CHBpressKey_CheckedChanged; CHBpressKey.Checked = true; TLPbtn.AddControl(CHBpressKey, 0, 2); } { LBL = new MyLabel(""); TLPbtn.AddControl(LBL, 0, 3); } { PBX = new PictureBox(); PBX.Dock = DockStyle.Fill; PBX.SizeMode = PictureBoxSizeMode.AutoSize; TLPbtn.AddControl(PBX, 0, 4); } TLPmain.AddControl(TLPbtn, 1, 0); } this.Controls.Add(TLPmain); } socketHandler = new SocketHandler(); socketHandler.logAppended += SocketHandler_logAppended; socketHandler.msgReceived += SocketHandler_msgReceived; { Thread thread = new Thread(() => { int pre_count = 0; while (true) { Thread.Sleep(5000); if (socketHandler.dataConnectionCounter != pre_count) SocketHandler_logAppended((pre_count = socketHandler.dataConnectionCounter).ToString() + " communications"); } }); thread.IsBackground = true; thread.Start(); } { Thread thread = new Thread(() => { while (true) { Thread.Sleep(500); PBX.Invoke(new Action(() => { var bmp = getFeedBackImage(); if (bmp == null) LBL.Text = "Unavailable"; else LBL.Text = (IsLive(bmp) ? "Alive" : "Dead"); var preImg = PBX.Image; PBX.Image = bmp; if (preImg != null) preImg.Dispose(); })); } }); thread.IsBackground = true; thread.Start(); }
private void SetItemList() { Font boldFont = new System.Drawing.Font("Arial Narrow", 12, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Font standarFont = new System.Drawing.Font("Arial Narrow", 12, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); int heightSpace = 40; FlowLayoutPanel flowItemHeader = new FlowLayoutPanel { FlowDirection = FlowDirection.LeftToRight, Height = 40, Width = Panel.Width }; int padingSpace = (int)Panel.Width / 10; Label CodeHeader = new Label { Text = $"Code", Width = padingSpace - 10, Height = heightSpace, Font = boldFont }; Label WantedAmountHeader = new Label { Text = $"Desire Amount", Width = padingSpace - 10, Height = heightSpace, Font = boldFont }; Label location = new Label { Text = $"Location", Width = padingSpace - 10, Height = heightSpace, Font = boldFont }; Label kltLabel = new Label { Text = $"KLT", Width = padingSpace - 10, Height = heightSpace, Font = boldFont }; Label bomUnitLabel = new Label { Text = $"BOM unit", Width = padingSpace - 10, Height = heightSpace, Font = boldFont }; Label warehouseUnitLabel = new Label { Text = $"Warehouse unit", Width = padingSpace - 10, Height = heightSpace, Font = boldFont }; Label stockAmountLabel = new Label { Text = $"Stock Amount", Width = padingSpace - 10, Height = heightSpace, Font = boldFont }; Label originLabel = new Label { Text = $"Origin", Width = padingSpace - 10, Height = heightSpace, Font = boldFont }; Label availableAmountHeader = new Label { Text = $"ChosenAmount", Width = padingSpace, Height = heightSpace, Font = boldFont }; Label selectedHeader = new Label { Text = $"", Width = padingSpace, Height = heightSpace, Font = boldFont }; flowItemHeader.Controls.Add(CodeHeader); flowItemHeader.Controls.Add(kltLabel); flowItemHeader.Controls.Add(location); flowItemHeader.Controls.Add(WantedAmountHeader); flowItemHeader.Controls.Add(stockAmountLabel); flowItemHeader.Controls.Add(originLabel); flowItemHeader.Controls.Add(bomUnitLabel); flowItemHeader.Controls.Add(warehouseUnitLabel); flowItemHeader.Controls.Add(availableAmountHeader); flowItemHeader.Controls.Add(selectedHeader); Panel.Controls.Add(flowItemHeader); foreach (MaterialOrder material in materialList) { FlowLayoutPanel flowItem = new FlowLayoutPanel { FlowDirection = FlowDirection.LeftToRight, Height = heightSpace, Width = Panel.Width }; Label code = new Label { Text = $"{material.OriginalCode}", Width = padingSpace, Height = heightSpace, Font = standarFont }; Label locationItem = new Label { Text = $"{material.Location}", Width = padingSpace, Height = heightSpace, Font = standarFont }; Label kltItem = new Label { Text = $"{material.Ktl}", Width = padingSpace, Height = heightSpace, Font = standarFont }; Label wantedAmount = new Label { Text = $"{material.WantedAmount}", Width = padingSpace, Height = heightSpace, Font = standarFont }; Label stockAmount = new Label { Text = $"{material.StockTotal}", Width = padingSpace, Height = heightSpace, Font = standarFont }; Label bomUnit = new Label { Text = $"{material.BOMUnit}", Width = padingSpace, Height = heightSpace, Font = standarFont }; Label warehouseUnit = new Label { Text = $"{material.WarehouseUnit}", Width = padingSpace, Height = heightSpace, Font = standarFont }; Label origin = new Label { Text = $"{material.OriginName}", Width = padingSpace, Height = heightSpace, Font = standarFont }; MyTextBox input = new MyTextBox(material); input.Text = material.AvailableAmount + ""; //input.Width = padingSpace; MyCheckBox checkbox = new MyCheckBox(material); //checkbox.Width = padingSpace; flowItem.Controls.Add(code); flowItem.Controls.Add(kltItem); flowItem.Controls.Add(locationItem); flowItem.Controls.Add(wantedAmount); flowItem.Controls.Add(stockAmount); flowItem.Controls.Add(origin); flowItem.Controls.Add(bomUnit); flowItem.Controls.Add(warehouseUnit); flowItem.Controls.Add(input); flowItem.Controls.Add(checkbox); Panel.Controls.Add(flowItem); } }
public MyWindow(MyClass MyClass) { this._MyClass = MyClass; this.Loaded += (ol, el) => { try { _MyClass._logger.LogMessage("In Form Load"); var strxaml = $@"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:l=""clr-namespace:{this.GetType().Namespace};assembly={ System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location)}"" Margin=""5,5,5,5""> <Grid.RowDefinitions> <RowDefinition Height=""auto""/> <RowDefinition Height=""*""/> </Grid.RowDefinitions> <StackPanel x:Name=""_sp"" Grid.Row=""0"" HorizontalAlignment=""Left"" Height=""30"" VerticalAlignment=""Top"" Orientation=""Horizontal""> </StackPanel> <DockPanel x:Name=""_dp"" Grid.Row=""1""/> </Grid> "; Width = 400; Height = 600; var strReader = new System.IO.StringReader(strxaml); var xamlreader = XmlReader.Create(strReader); var grid = (Grid)(XamlReader.Load(xamlreader)); grid.DataContext = this; this.Content = grid; var sp = (StackPanel)grid.FindName("_sp"); chkBox = new MyCheckBox() { Content = "Check Me" }; sp.Children.Add(chkBox); var btnGo = new MyButton() { Content = "_Go" }; sp.Children.Add(btnGo); dp = (DockPanel)grid.FindName("_dp"); btnGo.Click += (o, e) => { try { for (int i = 0; i < 10; i++) { ChkBoxAction(i); } var lstEventHandlers = GetRoutedEventHandlerList <MyCheckBox>(chkBox, MyCheckBox.CheckedEvent); _MyClass._logger.LogMessage("# evHandlers = " + lstEventHandlers.Length.ToString()); } catch (Exception ex) { this.Content = ex.ToString(); } }; } catch (Exception ex) { this.Content = ex.ToString(); } }; }
/// <summary> /// Adjusts colors for the window and its children in case the MdiForm /// is active (in focus). /// </summary> /// private static void SetupActiveColors(Window w) { if (w == null) { return; } w.BackColorInact = w.BackColor; w.BorderBackColorInact = w.BackColor; w.CaptionBackColorInact = w.BackColor; w.BorderForeColorInact = Application.Theme.BorderForeColorInact; foreach (Window child in w.Children) { child.AccessKeyForeColor = Application.Theme.MenuAccessKeyForeColor; child.BorderBackColorInact = w.BackColor; child.BackColorInact = w.BackColor; child.CaptionBackColorInact = w.BackColor; child.BorderForeColorInact = w.BorderForeColorInact; if (child is MyGroupBox) { SetupActiveColors(child); child.ForeColorInact = Color.DarkCyan; child.ForeColor = Color.DarkCyan; child.BorderForeColor = child.BorderForeColorInact; } else if (child is MyTextBox) { MyTextBox field = child as MyTextBox; field.BorderForeColorInact = field.Multiline ? Color.DarkCyan : w.BackColor; field.BorderForeColor = Color.DarkCyan; field.ForeColorInact = Color.Gray; //field.ForeColorInact = field.TabStop ? Color.Gray : Color.Cyan; } else if (child is MyComboBox) { MyComboBox field = child as MyComboBox; field.HeaderForeColorInact = Color.Gray; field.HeaderBackColor = field.ReadOnly ? Color.DarkCyan : Color.DarkMagenta; field.CurrentRowBackColor = field.HeaderBackColor; field.CurrentRowForeColor = field.HeaderForeColor; field.HeaderBackColorInact = w.BackColor; field.BorderForeColorInact = w.BackColor; field.BorderForeColor = Color.DarkCyan; field.ScrollBarForeColorInact = w.BackColor; } else if (child is MyListView) { MyListView field = child as MyListView; field.ForeColorInact = field.ForeColor; field.HeaderBackColorInact = w.BackColor; field.FooterBackColorInact = w.BackColor; field.CurrentRowBackColorInact = Color.DarkGray; field.CurrentRowForeColorInact = Color.White; field.BorderForeColorInact = field.BorderForeColor; field.HeaderForeColorInact = field.HeaderForeColor; field.FooterForeColorInact = field.FooterForeColor; } else if (child is MyCheckBox) { MyCheckBox field = child as MyCheckBox; field.ForeColorInact = Color.DarkCyan; field.ForeColor = Color.Gray; field.CaptionForeColorInact = Color.Gray; field.CaptionForeColor = Color.White; } else if (child is MyLabel) { child.AccessKeyForeColor = Application.Theme.MenuAccessKeyForeColor; child.ForeColorInact = Color.DarkCyan; } } }
public HitbaseCheckBox(MainCDUserControl dlg) : base(dlg) { checkBox = new MyCheckBox(this); checkBox.Checked += new System.Windows.RoutedEventHandler(checkBox_Checked); }
private void CreateControls(Control panel, EntityStructure entityStructure, List <DefaultValue> dsdefaults) { BindingData = new BindingSource[entityStructure.Fields.Count - 1]; int maxlabelsize = 0; int maxDatasize = 0; foreach (EntityField col in entityStructure.Fields) { int x = getTextSize(col.fieldname); if (maxlabelsize < x) { maxlabelsize = x; } } maxDatasize = this.Width - maxlabelsize - 20; entityStructure.Filters.Clear(); List <string> FieldNames = new List <string>(); var starth = 25; int startleft = maxlabelsize + 90; int valuewidth = 100; for (int i = 0; i < entityStructure.Fields.Count - 1; i++) { ReportFilter r = new ReportFilter(); r.FieldName = entityStructure.Fields[i].fieldname; r.Operator = null; r.FilterValue = null; r.FilterValue1 = null; r.valueType = entityStructure.Fields[i].fieldtype; entityStructure.Filters.Add(r); BindingData[i] = new BindingSource(); BindingData[i].DataSource = r; FieldNames.Add(entityStructure.Fields[i].fieldname); EntityField col = entityStructure.Fields[i]; try { DefaultValue coldefaults = dsdefaults.Where(o => o.propertyName == col.fieldname).FirstOrDefault(); if (coldefaults == null) { coldefaults = dsdefaults.Where(o => col.fieldname.Contains(o.propertyName)).FirstOrDefault(); } string coltype = col.fieldtype; RelationShipKeys FK = entityStructure.Relations.Where(f => f.EntityColumnID == col.fieldname).FirstOrDefault(); //---------------------- Label l = new Label { Top = starth, Left = 10, AutoSize = false, BorderStyle = BorderStyle.FixedSingle, Text = col.fieldname, BackColor = Color.White, ForeColor = Color.Red }; l.Size = TextRenderer.MeasureText(col.fieldname, l.Font); l.Height += 10; l.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; l.Width = maxlabelsize; //--------------------- ComboBox cbcondition = new ComboBox { Left = l.Left + l.Width + 10, Top = starth }; //string DisplayField = FK.EntityColumnID; //cbcondition.DataSource = Visutil.controlEditor.GetDisplayLookup(ds.DatasourceName, FK.ParentEntityID, FK.ParentEntityColumnID); //cbcondition.DisplayMember = DisplayField; //cbcondition.ValueMember = FK.ParentEntityColumnID; cbcondition.DataSource = AddFilterTypes(); cbcondition.DisplayMember = "FilterDisplay"; cbcondition.ValueMember = "FilterValue"; cbcondition.SelectedValueChanged += Cb_SelectedValueChanged; cbcondition.Width = 50; cbcondition.Height = l.Height; // cbcondition.SelectedText cbcondition.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", BindingData[i], "Operator", true, DataSourceUpdateMode.OnPropertyChanged)); // cbcondition.Anchor = AnchorStyles.Top; this.Controls.Add(cbcondition); if (FK != null) { ComboBox cb = new ComboBox { Left = startleft, Top = starth }; string DisplayField = FK.EntityColumnID; cb.DataSource = Visutil.controlEditor.GetDisplayLookup(ds.DatasourceName, FK.ParentEntityID, FK.ParentEntityColumnID); cb.DisplayMember = DisplayField; cb.ValueMember = FK.ParentEntityColumnID; cb.Width = valuewidth; cb.Height = l.Height; cb.DataBindings.Add(new System.Windows.Forms.Binding("TEXT", BindingData[i], "FilterValue", true)); cb.SelectedValueChanged += Cb_SelectedValueChanged; //cb.Anchor = AnchorStyles.Top; this.Controls.Add(cb); starth = l.Bottom + 1; } else { switch (coltype) { case "System.DateTime": DateTimePicker dt = new DateTimePicker { Left = startleft, Top = starth }; dt.DataBindings.Add(new System.Windows.Forms.Binding("Value", BindingData[i], "FilterValue", true)); dt.Width = valuewidth; dt.Height = l.Height; dt.ValueChanged += Dt_ValueChanged; // dt.Anchor = AnchorStyles.Top; dt.Tag = i; dt.Format = DateTimePickerFormat.Short; this.Controls.Add(dt); DateTimePicker dt1 = new DateTimePicker { Left = dt.Left + 10 + dt.Width, Top = starth }; dt1.DataBindings.Add(new System.Windows.Forms.Binding("Value", BindingData[i], "FilterValue1", true)); dt1.Width = valuewidth; dt1.Height = l.Height; dt1.Format = DateTimePickerFormat.Short; dt1.ValueChanged += Dt_ValueChanged; // dt.Anchor = AnchorStyles.Top; dt1.Tag = i; this.Controls.Add(dt1); break; case "System.TimeSpan": TextBox t1 = new TextBox { Left = startleft, Top = starth }; t1.DataBindings.Add(new System.Windows.Forms.Binding("Text", BindingData[i], "FilterValue", true)); t1.TextAlign = HorizontalAlignment.Left; t1.Width = valuewidth; t1.Height = l.Height; t1.Tag = i; t1.TextChanged += T_TextChanged; // t1.KeyPress += T_KeyPress; // t1.Anchor = AnchorStyles.Top; this.Controls.Add(t1); break; case "System.Boolean": CheckBox ch1 = new CheckBox { Left = startleft, Top = starth }; ch1.DataBindings.Add(new System.Windows.Forms.Binding("CheckState", BindingData[i], "FilterValue", true)); ch1.Text = ""; ch1.Width = valuewidth; ch1.Height = l.Height; ch1.CheckStateChanged += Ch1_CheckStateChanged;; // ch1.Anchor = AnchorStyles.Top; ch1.Tag = i; this.Controls.Add(ch1); break; case "System.Char": MyCheckBox ch2 = new MyCheckBox { Left = startleft, Top = starth }; ch2.DataBindings.Add(new System.Windows.Forms.Binding("Checked", BindingData[i], "FilterValue", true)); ch2.Text = ""; ch2.Width = valuewidth; ch2.Height = l.Height; string[] v = coldefaults.propoertValue.Split(','); if (coldefaults != null) { ch2.TrueValue = v[0].ToCharArray()[0]; ch2.FalseValue = v[1].ToCharArray()[0]; } ch2.CheckStateChanged += Ch1_CheckStateChanged;; // ch2.Anchor = AnchorStyles.Top; ch2.Tag = i; this.Controls.Add(ch2); break; case "System.Int16": case "System.Int32": case "System.Int64": case "System.Decimal": case "System.Double": case "System.Single": NumericUpDown t3 = new NumericUpDown(); t3.Left = startleft; t3.Top = starth; t3.DataBindings.Add(new System.Windows.Forms.Binding("Value", BindingData[i], "FilterValue", true)); t3.TextAlign = HorizontalAlignment.Left; t3.Width = valuewidth; t3.Height = l.Height; t3.Tag = i; t3.TextChanged += T_TextChanged; //t.KeyPress += T_KeyPress; if (entityStructure.PrimaryKeys.Where(x => x.fieldname == col.fieldname).FirstOrDefault() != null) { t3.Enabled = false; } this.Controls.Add(t3); NumericUpDown t2 = new NumericUpDown(); t2.Left = t3.Left + t3.Width + 10; t2.Top = starth; t2.DataBindings.Add(new System.Windows.Forms.Binding("Value", BindingData[i], "FilterValue1", true)); t2.TextAlign = HorizontalAlignment.Left; t2.Width = valuewidth; t2.Height = l.Height; t2.Tag = i; t2.TextChanged += T_TextChanged; //t.KeyPress += T_KeyPress; if (entityStructure.PrimaryKeys.Where(x => x.fieldname == col.fieldname).FirstOrDefault() != null) { t2.Enabled = false; } // t.Anchor = AnchorStyles.Top; this.Controls.Add(t2); // t.Anchor = AnchorStyles.Top; break; case "System.String": if (entityStructure.Fields.Where(p => p.fieldname == col.fieldname).FirstOrDefault().Size1 > 1) { t1 = new TextBox { Left = startleft, Top = starth }; t1.DataBindings.Add(new System.Windows.Forms.Binding("Text", BindingData[i], "FilterValue", true)); t1.TextAlign = HorizontalAlignment.Left; t1.Width = valuewidth; t1.Height = l.Height; t1.TextChanged += T_TextChanged; // t1.KeyPress += T_KeyPress; if (entityStructure.PrimaryKeys.Any(x => x.fieldname == col.fieldname)) { if (entityStructure.Relations.Any(x => x.EntityColumnID == col.fieldname)) { t1.Enabled = false; } } this.Controls.Add(t1); t1.Tag = i; // t1.Anchor = AnchorStyles.Top; } else { ch2 = new MyCheckBox { Left = startleft, Top = starth }; ch2.DataBindings.Add(new System.Windows.Forms.Binding("Checked", BindingData[i], "FilterValue", true)); ch2.Text = ""; ch2.Width = valuewidth; ch2.Height = l.Height; ch2.Tag = i; if (coldefaults != null) { v = coldefaults.propoertValue.Split(','); ch2.TrueValue = v[0].ToCharArray()[0]; ch2.FalseValue = v[1].ToCharArray()[0]; } // ch2.CheckStateChanged += Ch1_CheckStateChanged; ; this.Controls.Add(ch2); // ch2.Anchor = AnchorStyles.Top; } break; default: TextBox t = new TextBox(); t.Left = startleft; t.Top = starth; t.DataBindings.Add(new System.Windows.Forms.Binding("Text", BindingData[i], "FilterValue", true)); t.TextAlign = HorizontalAlignment.Left; t.Width = valuewidth; t.Height = l.Height; t.Tag = i; t.TextChanged += T_TextChanged; //t.KeyPress += T_KeyPress; if (entityStructure.PrimaryKeys.Where(x => x.fieldname == col.fieldname).FirstOrDefault() != null) { t.Enabled = false; } // t.Anchor = AnchorStyles.Top; this.Controls.Add(t); break; } } // l.Anchor = AnchorStyles.Top; this.Controls.Add(l); starth = l.Bottom + 1; } catch (Exception ex) { Logger.WriteLog($"Error in Loading View ({ex.Message}) "); } } }
private void _mainForm_FormLoad(object sender, EventArgs e) { foreach (string file in Directory.GetFiles(_mainForm.ScriptsFolder, "*.cs")) { AddScript(file, true); } foreach (string directory in Directory.GetDirectories(_mainForm.ScriptsFolder)) { AddScript(directory, true); } //load script status from json if (_mainForm.LeSettings.ScriptStatus != null) { foreach (string key in _mainForm.LeSettings.ScriptStatus.Keys) { var tempScript = _sm.Scripts.FirstOrDefault(z => z.ScriptName == key); tempScript.Enabled = _mainForm.LeSettings.ScriptStatus[key]; } } else { _mainForm.LeSettings.ScriptStatus = new System.Collections.Generic.Dictionary <string, bool>(); foreach (ExecutableScript scriptName in _sm.Scripts) { _mainForm.LeSettings.ScriptStatus.Add(scriptName.ScriptName, true); } } foreach (var item in _sm.Scripts) { var a = new MenuItem[] { }; var box = new MyCheckBox(); var button = new MyButton(); button.Script = item; box.Tag = item.ScriptName; box.Text = item.ScriptName; box.Script = item; box.Checked = item.Enabled; _mainForm.AddScriptControlsToPanel(box, button); var menuItem = new MenuItem(item.ScriptName); var myMenuEnable = new MyMenuItem(); myMenuEnable.Text = item.Enabled ? "Disable" : "Enable"; myMenuEnable.Click += _mainForm_TrayScriptEnableClick; myMenuEnable.Script = item; var myMenuAction = new MyMenuItem(); myMenuAction.Text = "Action"; myMenuAction.Click += _mainForm_TrayScriptActionClick; myMenuAction.Script = item; menuItem.MenuItems.Add(myMenuEnable); menuItem.MenuItems.Add(myMenuAction); _mainForm.TrayIcon.ContextMenu.MenuItems.Add(menuItem); } RepopulatePanel(); StartLoop(); }
void cb_Checked(object sender, RoutedEventArgs e) { MyCheckBox c = (MyCheckBox)sender; switch (c.type) { case MyCheckBox.CheckBoxType.buildingType: Console.WriteLine(" MyCheckBox.CheckBoxType.buildingType"); break; case MyCheckBox.CheckBoxType.cabTyp: Console.WriteLine(" MyCheckBox.CheckBoxType.cabTyp"); break; case MyCheckBox.CheckBoxType.deviceType: Console.WriteLine(" MyCheckBox.CheckBoxType.deviceType"); break; default: break; } if (c.IsChecked ?? false) //添加 { Console.WriteLine("柜子 " + c.Name + "! "); if (page.Content is CabsPage) //当前 柜子页面 { Console.WriteLine("当前 柜子页面"); checkAllChild(c.TreeNode, true); if (c.type.Equals(MyCheckBox.CheckBoxType.buildingType)) //插入一个楼的全部柜子 { cabspage.insertCab(getPageFrame(), (Building)c.NodeObject); // cabspage.selectBuildings.Add((Building)c.NodeObject); } else { cabspage.insertCab(getPageFrame(), (Cab)c.NodeObject); } } else if (page.Content is DevicePage) //当前实在 设备页面 { Console.WriteLine("当前设备页面"); checkAllChild(c.TreeNode, false); } } else //删除 { if (page.Content is CabsPage) //当前 柜子页面 { Console.WriteLine("当前 柜子页面"); checkAllChild(c.TreeNode, true); if (c.type.Equals(MyCheckBox.CheckBoxType.buildingType)) //插入一个楼的全部柜子 { cabspage.deleteCab(getPageFrame(), (Building)c.NodeObject); } else { cabspage.deleteCab(getPageFrame(), (Cab)c.NodeObject); } checkAllChild(c.TreeNode, false); } else if (page.Content is DevicePage) //当前实在 设备页面 { Console.WriteLine("当前设备页面"); checkAllChild(c.TreeNode, false); } // cabspage.deleteCab(); } }
private void initUC(string responseJson) { initTimer(Parser.FieldParse <string>(responseJson, "timeleft")); // timeLeft - ushhhh var slide = JObject.Parse(responseJson)["slide"]; label3.Text = slide["question"].ToObject <string>(); slideNumber = slide["slideNumber"].ToObject <int>(); if (slideNumber.Equals(0)) // it's the first slide { button1.Visible = false; // can't move back } isOptional = slide["isOptional"].ToObject <bool>(); button2.Enabled = isOptional; string image = imageBase64 = slide["image"].ToObject <string>(); if (image != null && !image.Equals("")) { putImage(image); } else { pictureBox2.Visible = false; panel1.Size = new Size(440, panel1.Height); } label1.Text = $"Вопрос №{(slide["slideOrderNumber"].ToObject<int>() + 1).ToString()}"; if (slide["answerType"].ToObject <string>().Equals("text")) { flowLayoutPanel1.Visible = false; textBox1.Visible = true; textBox1.TextChanged += answerChanged; if (slide["customValue"].ToObject <string>() == null) // VERIFY! { textBox1.GotFocus += removePlaceholder; textBox1.Text = slide["answers"].Children().ToList()[0]["value"].ToObject <string>(); } else { textBox1.Text = slide["customValue"].ToObject <string>(); } } else { linkLabel1.Visible = true; List <Answer> answers = slide["answers"].ToObject <List <Answer> >(); answers = answers.OrderBy(a => a.answerNumber).ToList(); // asc foreach (Answer answer in answers) { ICheckable chOrRad; if (slide["answerType"].ToObject <string>().Equals("many")) { chOrRad = new MyCheckBox(); } else { chOrRad = new MyRadioButton(); } flowLayoutPanel1.Controls.Add((Control)chOrRad); // Dangerous, but it works controls.Add(chOrRad); chOrRad.setOnCheckedChanged(answerChanged); chOrRad.setChecked(answer.isSelected); if (!answer.isCustom) { chOrRad.setText(answer.value); chOrRad.setSize(new Size(433, 20)); } else { chOrRad.setText(""); chOrRad.setSize(new Size(13, 20)); chOrRad.setOnCheckedChanged(customAnswerChanged); TextBox textBox = new TextBox(); textBox.TextChanged += answerChanged; customTextBox = textBox; textBox.Enabled = chOrRad.isChecked(); if (slide["customValue"].ToObject <string>() == null) // verify too { textBox.Text = answer.value; textBox.GotFocus += removePlaceholder; } else { textBox.Text = slide["customValue"].ToObject <string>(); } flowLayoutPanel1.Controls.Add(textBox); } } } }