Exemplo n.º 1
0
        private void UnbindTreeViewItemFromModel(EntryRulesEditorTreeViewItem item)
        {
            var id = item.ControlId;

            _itemDisposables[id].Dispose();
            _itemDisposables.Remove(id);
        }
Exemplo n.º 2
0
        private void BindTreeViewItemToModel(EntryRulesEditorTreeViewItem item)
        {
            var disposables = new CompositeDisposable();

            ReadOnlyEntryRule GetRule() => _entryRulesService.GetState().Get(item.ControlId);

            item.AddressablePathRule.Skip(1).Subscribe(x =>
            {
                var newValue = item.AddressablePathRule.Value;
                var oldValue = GetRule().AddressablePathRule.Value;
                _history.Register($"{nameof(OnTreeViewItemAdded)}_{nameof(item.AddressablePathRule)}",
                                  () => _entryRulesService.UpdateRule(item.ControlId,
                                                                      new EntryRuleUpdateCommand(newValue)),
                                  () => _entryRulesService.UpdateRule(item.ControlId,
                                                                      new EntryRuleUpdateCommand(oldValue)));
            }).DisposeWith(disposables);
            item.AddressingMode.Skip(1).Subscribe(x =>
            {
                var newValue = item.AddressingMode.Value;
                var oldValue = GetRule().AddressingMode.Value;
                _history.Register($"{nameof(OnTreeViewItemAdded)}_{nameof(item.AddressingMode)}",
                                  () => _entryRulesService.UpdateRule(item.ControlId,
                                                                      new EntryRuleUpdateCommand(addressingMode: newValue)),
                                  () => _entryRulesService.UpdateRule(item.ControlId,
                                                                      new EntryRuleUpdateCommand(addressingMode: oldValue)));
            }).DisposeWith(disposables);
            item.GroupNameRule.Skip(1).Subscribe(x =>
            {
                var newValue = item.GroupNameRule.Value;
                var oldValue = GetRule().GroupNameRule.Value;
                _history.Register($"{nameof(OnTreeViewItemAdded)}_{nameof(item.GroupNameRule)}",
                                  () => _entryRulesService.UpdateRule(item.ControlId,
                                                                      new EntryRuleUpdateCommand(groupNameRule: newValue)),
                                  () => _entryRulesService.UpdateRule(item.ControlId,
                                                                      new EntryRuleUpdateCommand(groupNameRule: oldValue)));
            }).DisposeWith(disposables);
            item.LabelRules.Skip(1).Subscribe(x =>
            {
                var newValue = item.LabelRules.Value;
                var oldValue = GetRule().LabelRules.Value;
                _history.Register($"{nameof(OnTreeViewItemAdded)}_{nameof(item.LabelRules)}",
                                  () => _entryRulesService.UpdateRule(item.ControlId,
                                                                      new EntryRuleUpdateCommand(labelRules: newValue)),
                                  () => _entryRulesService.UpdateRule(item.ControlId,
                                                                      new EntryRuleUpdateCommand(labelRules: oldValue)));
            }).DisposeWith(disposables);
            _itemDisposables.Add(item.ControlId, disposables);
        }
        public SetOnlyEntryRulesEditorTreeViewItem AddItem(EntityId entityId, string addressablePathRule,
                                                           AddressingMode addressingMode, string groupNameRule, string labelRules)
        {
            var item = new EntryRulesEditorTreeViewItem(entityId)
            {
                id          = EntityIdToIntId(entityId),
                displayName = addressablePathRule
            };

            item.AddressablePathRule.Value = addressablePathRule;
            item.AddressingMode.Value      = addressingMode;
            item.GroupNameRule.Value       = groupNameRule;
            item.LabelRules.Value          = labelRules;
            AddItemAndSetParent(item, -1);
            return(new SetOnlyEntryRulesEditorTreeViewItem(item));
        }
        private static string GetText(EntryRulesEditorTreeViewItem item, int columnIndex)
        {
            switch ((Columns)columnIndex)
            {
            case Columns.AddressablePathRule:
                return(item.AddressablePathRule.Value);

            case Columns.AddressingMode:
                return(item.AddressingMode.Value.ToString());

            case Columns.GroupNameRule:
                return(item.GroupNameRule.Value);

            case Columns.LabelRules:
                return(item.LabelRules.Value);

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 5
0
 public SetOnlyEntryRulesEditorTreeViewItem(EntryRulesEditorTreeViewItem source)
 {
     _source = source;
 }