private void BuildWidget() { tableCounters.NRows = (uint)ViewModel.Counters.Count; uint nrow = 0; var converter = new NumbersToStringConverter(); foreach (var counter in ViewModel.Counters.Values) { var label = new yLabel(); label.Xalign = 1; label.Binding .AddFuncBinding(counter, c => c.Title + ":", w => w.LabelProp) .InitializeFromSource(); tableCounters .Attach(label, 0, 1, nrow, nrow + 1, AttachOptions.Fill, AttachOptions.Shrink, 0, 0); var labelCount = new yLabel(); labelCount.WidthChars = 5; labelCount.Binding .AddBinding(counter, c => c.Count, w => w.LabelProp, converter) .InitializeFromSource(); tableCounters .Attach(labelCount, 1, 2, nrow, nrow + 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); nrow++; } tableCounters.ShowAll(); }
private void ConfigureDlg() { hboxExtension.Children.ToList().ForEach(x => x.Destroy()); foreach (var item in ViewModel.PermissionExtensionStore.PermissionExtensions) { var extensionLabel = new yLabel(); extensionLabel.UseMarkup = true; extensionLabel.Markup = $"<b>{item.Name}</b>"; extensionLabel.WidthRequest = 100; extensionLabel.Wrap = true; extensionLabel.LineWrapMode = Pango.WrapMode.WordChar; extensionLabel.Data.Add("permission_id", item.PermissionId); extensionLabel.TooltipText = item.Description; hboxExtension.Add(extensionLabel); hboxExtension.SetChildPacking(extensionLabel, false, false, 0, PackType.Start); } viewModel.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { if (e.PropertyName == nameof(viewModel.PermissionsList)) { ConfidureList(); } }; if (viewModel.PermissionsList != null) { ConfidureList(); } }
private void SizeBuild() { var sizes = ViewModel.SizeService .GetSize(ViewModel.UoW, null, true); var excludeSizes = Entity.Sizes .Where(s => s.Size.UseInEmployee == false) .Select(x => x.Size); //добавляем исключенные размеры если они уже привязаны к сотруднику, чтобы они не проподали при пересохранении sizes.AddRange(excludeSizes); var sizeTypes = ViewModel.SizeService.GetSizeType(ViewModel.UoW, true).OrderBy(x => x.Position).ToList(); for (var index = 1; index < sizeTypes.Count + 1; index++) { var sizeType = sizeTypes[index - 1]; var employeeSize = Entity.Sizes.FirstOrDefault(x => x.SizeType.Id == sizeType.Id); var label = new yLabel { LabelProp = sizeType.Name + ":" }; label.Xalign = 1; if (sizes.All(x => x.SizeType.Id != sizeType.Id)) { continue; } var list = new SpecialListComboBox { ItemsList = sizes.Where(x => x.SizeType.Id == sizeType.Id) }; list.SetRenderTextFunc <Size>(x => x.Name); list.ShowSpecialStateNot = true; list.SelectedItemStrictTyped = true; if (employeeSize != null) { list.SelectedItem = employeeSize.Size; } list.Changed += SetSizes; table.Attach(label, 0, 1, (uint)index, (uint)(index + 1), AttachOptions.Fill, AttachOptions.Fill | AttachOptions.Expand, 0, 0); table.Attach(list, 1, 2, (uint)index, (uint)(index + 1), AttachOptions.Fill, AttachOptions.Fill | AttachOptions.Expand, 0, 0); } SizeContainer.Homogeneous = false; SizeContainer.ShowAll(); }
public void RefreshColumnsWidgets() { foreach (var label in columnsLabels) { tableColumns.Remove(label); } foreach (var combo in columnsTypeCombos) { tableColumns.Remove(combo); } tableColumns.NRows = (uint)ViewModel.ImportModel.MaxSourceColumns; columnsLabels.Clear(); columnsTypeCombos.Clear(); uint nRow = 0; foreach (var column in ViewModel.ImportModel.DisplayColumns) { var label = new yLabel(); label.Xalign = 1; label.Binding .AddBinding(column, nameof(IDataColumn.Title), w => w.LabelProp) .InitializeFromSource(); columnsLabels.Add(label); tableColumns .Attach(label, 0, 1, nRow, nRow + 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); var combo = new yEnumComboBox(); combo.ItemsEnum = ViewModel.ImportModel.DataTypeEnum; combo.Binding .AddBinding(column, nameof(IDataColumn.DataType), w => w.SelectedItem) .InitializeFromSource(); columnsTypeCombos.Add(combo); tableColumns .Attach(combo, 1, 2, nRow, nRow + 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); nRow++; } tableColumns.ShowAll(); }
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); }