HBox GetSnackBarLayout(Container?container, SnackBarOptions arguments) { var snackBarLayout = new HBox(); snackBarLayout.ModifyBg(StateType.Normal, arguments.BackgroundColor.ToGtkColor()); var message = new Gtk.Label(arguments.MessageOptions.Message); message.ModifyFont(new FontDescription { AbsoluteSize = arguments.MessageOptions.Font.FontSize, Family = arguments.MessageOptions.Font.FontFamily }); message.ModifyFg(StateType.Normal, arguments.MessageOptions.Foreground.ToGtkColor()); message.SetPadding((int)arguments.MessageOptions.Padding.Left, (int)arguments.MessageOptions.Padding.Top); snackBarLayout.Add(message); snackBarLayout.SetChildPacking(message, false, false, 0, PackType.Start); foreach (var action in arguments.Actions) { var button = new Gtk.Button { Label = action.Text }; button.ModifyFont(new FontDescription { AbsoluteSize = action.Font.FontSize, Family = action.Font.FontFamily }); button.ModifyBg(StateType.Normal, action.BackgroundColor.ToGtkColor()); button.ModifyFg(StateType.Normal, action.ForegroundColor.ToGtkColor()); button.Clicked += async(sender, e) => { snackBarTimer?.Stop(); if (action.Action != null) { await action.Action(); } arguments.SetResult(true); container?.Remove(snackBarLayout); }; snackBarLayout.Add(button); snackBarLayout.SetChildPacking(button, false, false, 0, PackType.End); } return(snackBarLayout); }
private void Reparent(Widget widget, HBox box, int index) { if (widget.Parent == box) { return; } if (widget.Parent == null) { box.PackStart(widget, false, false, 0); } else { widget.Reparent(box); box.SetChildPacking(widget, false, false, 0, PackType.Start); } box.ReorderChild(widget, index); widget.Show(); }
private void DrawNewRow(Phone newPhone) { if (hBoxList?.FirstOrDefault() == null) { hBoxList = new List <HBox>(); } HBox hBox = new HBox(); var phoneDataCombo = new yListComboBox(); phoneDataCombo.WidthRequest = 100; phoneDataCombo.SetRenderTextFunc((PhoneType x) => x.Name); phoneDataCombo.ItemsList = viewModel.PhoneTypes; phoneDataCombo.Binding.AddBinding(newPhone, e => e.PhoneType, w => w.SelectedItem).InitializeFromSource(); phoneDataCombo.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.Sensitive).InitializeFromSource(); hBox.Add(phoneDataCombo); hBox.SetChildPacking(phoneDataCombo, true, true, 0, PackType.Start); Label textPhoneLabel = new Label("+7"); hBox.Add(textPhoneLabel); hBox.SetChildPacking(textPhoneLabel, false, false, 0, PackType.Start); var phoneDataEntry = new yValidatedEntry(); phoneDataEntry.ValidationMode = ValidationType.phone; phoneDataEntry.Tag = newPhone; phoneDataEntry.WidthRequest = 125; phoneDataEntry.WidthChars = 19; phoneDataEntry.Binding.AddBinding(newPhone, e => e.Number, w => w.Text).InitializeFromSource(); phoneDataEntry.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.IsEditable).InitializeFromSource(); hBox.Add(phoneDataEntry); hBox.SetChildPacking(phoneDataEntry, false, false, 0, PackType.Start); HandsetView handset = new HandsetView(newPhone.DigitsNumber); hBox.Add(handset); hBox.SetChildPacking(handset, false, false, 0, PackType.Start); var textAdditionalLabel = new Gtk.Label("доб."); hBox.Add(textAdditionalLabel); hBox.SetChildPacking(textAdditionalLabel, false, false, 0, PackType.Start); var additionalDataEntry = new yEntry(); additionalDataEntry.WidthRequest = 50; additionalDataEntry.MaxLength = 10; additionalDataEntry.Binding.AddBinding(newPhone, e => e.Additional, w => w.Text).InitializeFromSource(); additionalDataEntry.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.IsEditable).InitializeFromSource(); hBox.Add(additionalDataEntry); hBox.SetChildPacking(additionalDataEntry, false, false, 0, PackType.Start); var labelName = new Label("имя:"); hBox.Add(labelName); hBox.SetChildPacking(labelName, false, false, 0, PackType.Start); var entryName = new yEntry(); entryName.MaxLength = 150; entryName.Binding.AddBinding(newPhone, e => e.Name, w => w.Text).InitializeFromSource(); entryName.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.IsEditable).InitializeFromSource(); hBox.Add(entryName); hBox.SetChildPacking(entryName, true, true, 0, PackType.Start); yButton deleteButton = new yButton(); Image image = new Image(); image.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-delete", IconSize.Menu); deleteButton.Image = image; deleteButton.Clicked += (sender, e) => viewModel.DeleteItemCommand.Execute(hBox.Data["phone"] as Phone); deleteButton.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.Sensitive).InitializeFromSource(); hBox.Add(deleteButton); hBox.SetChildPacking(deleteButton, false, false, 0, PackType.Start); hBox.Data.Add("phone", newPhone); //Для свзяки виджета и телефона hBox.ShowAll(); vboxPhones.Add(hBox); vboxPhones.ShowAll(); hBoxList.Add(hBox); }
private void DrawNewRow(IPermissionNode node) { if (hBoxList?.FirstOrDefault() == null) { hBoxList = new List <HBox>(); } HBox hBox = new HBox(); hBox.Spacing = hboxHeader.Spacing; yButton deleteButton = new yButton(); Image image = new Image(); image.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-delete", IconSize.Menu); deleteButton.Image = image; deleteButton.Clicked += (sender, e) => viewModel.DeleteItemCommand.Execute(((yButton)sender).Parent.Data["permission"] as IPermissionNode); deleteButton.Binding.AddFuncBinding(viewModel, e => !e.ReadOnly, w => w.Sensitive).InitializeFromSource(); deleteButton.WidthRequest = 40; hBox.Add(deleteButton); hBox.SetChildPacking(deleteButton, false, true, 0, PackType.Start); var documentLabel = new yLabel(); documentLabel.Wrap = true; documentLabel.LineWrap = true; documentLabel.LineWrapMode = Pango.WrapMode.WordChar; documentLabel.WidthRequest = ylabelDocument.WidthRequest - deleteButton.WidthRequest; documentLabel.Binding.AddBinding(node.TypeOfEntity, e => e.CustomName, w => w.Text).InitializeFromSource(); hBox.Add(documentLabel); hBox.SetChildPacking(documentLabel, false, true, 0, PackType.Start); var readPermCheckButton = new yCheckButton(); readPermCheckButton.WidthRequest = ylabelPermView.WidthRequest; readPermCheckButton.Binding.AddBinding(node.EntityPermission, e => e.CanRead, w => w.Active).InitializeFromSource(); hBox.Add(readPermCheckButton); hBox.SetChildPacking(readPermCheckButton, false, true, 0, PackType.Start); var createPermCheckButton = new yCheckButton(); createPermCheckButton.WidthRequest = ylabelPermCreate.WidthRequest; createPermCheckButton.Binding.AddBinding(node.EntityPermission, e => e.CanCreate, w => w.Active).InitializeFromSource(); hBox.Add(createPermCheckButton); hBox.SetChildPacking(createPermCheckButton, false, true, 0, PackType.Start); var editPermCheckButton = new yCheckButton(); editPermCheckButton.WidthRequest = ylabelPermEdit.WidthRequest; editPermCheckButton.Binding.AddBinding(node.EntityPermission, e => e.CanUpdate, w => w.Active).InitializeFromSource(); hBox.Add(editPermCheckButton); hBox.SetChildPacking(editPermCheckButton, false, true, 0, PackType.Start); var deletePermCheckButton = new yCheckButton(); deletePermCheckButton.WidthRequest = ylabelPermDelete.WidthRequest; deletePermCheckButton.Binding.AddBinding(node.EntityPermission, e => e.CanDelete, w => w.Active).InitializeFromSource(); hBox.Add(deletePermCheckButton); hBox.SetChildPacking(deletePermCheckButton, false, true, 0, PackType.Start); foreach (var header in hboxExtension.Children.OfType <yLabel>()) { var item = node.EntityPermissionExtended.FirstOrDefault(x => x.PermissionId == (header.Data["permission_id"] as string)); Widget widget; var permission = ViewModel.PermissionExtensionStore.PermissionExtensions.FirstOrDefault(x => x.PermissionId == item.PermissionId); if (permission.IsValidType(TypeOfEntityRepository.GetEntityType(node.TypeOfEntity.Type))) { widget = new NullableCheckButton(); widget.WidthRequest = header.WidthRequest; (widget as NullableCheckButton)?.Binding.AddBinding(item, e => e.IsPermissionAvailable, w => w.Active).InitializeFromSource(); } else { widget = new Label(); widget.WidthRequest = header.WidthRequest; widget.Sensitive = false; widget.Visible = false; } hBox.Add(widget); hBox.SetChildPacking(widget, false, true, 0, PackType.Start); } hBox.Data.Add("permission", node); //Для свзяки виджета и права hBox.ShowAll(); vboxPermissions.Add(hBox); hBoxList.Add(hBox); }