Exemple #1
0
        private void CreateComponent(ETypeOfElement name, Point point, int id, string text)
        {
            BaseViewModelComponent newComponent;

            if (name == ETypeOfElement.Input)
            {
                CreateInput(point, _surface, id, text);
            }
            switch (name)
            {
            case ETypeOfElement.And:
                newComponent = new GenericViewModelComponent <ComponentUIAnd, ElementAnd>(point, _surface, id);
                break;

            case ETypeOfElement.AndNot:
                newComponent = new GenericViewModelComponent <ComponentUIAndNot, ElementAndNot>(point, _surface, id);
                break;

            case ETypeOfElement.Output:
                newComponent = new GenericViewModelComponent <ComponentUIOutput, ElementOutput>(point, _surface, id);
                break;

            case ETypeOfElement.Or:
                newComponent = new GenericViewModelComponent <ComponentUIOr, ElementOr>(point, _surface, id);
                break;

            case ETypeOfElement.OrNot:
                newComponent = new GenericViewModelComponent <ComponentUIOrNot, ElementOrNot>(point, _surface, id);
                break;

            case ETypeOfElement.Xor:
                newComponent = new GenericViewModelComponent <ComponentUIXor, ElementXor>(point, _surface, id);
                break;

            case ETypeOfElement.XorNot:
                newComponent = new GenericViewModelComponent <ComponentUIXorNot, ElementXorNot>(point, _surface, id);
                break;

            case ETypeOfElement.Check:
                newComponent = new GenericViewModelComponent <ComponentUICheck, ElementCheck>(point, _surface, id);
                break;

            case ETypeOfElement.Not:
                newComponent = new GenericViewModelComponent <ComponentUINot, ElementNot>(point, _surface, id);
                break;

            case ETypeOfElement.Label:
                newComponent = new ViewModelLabel(point, _surface, id);
                break;

            default:
                return;
            }
            newComponent.strength = text;
            _elements.Add(newComponent);
            _elements[_elements.Count - 1].OnPinElementDropped += OnElementPinDropped;
            _elements[_elements.Count - 1].OnElementDelete     += Delete;
        }
Exemple #2
0
        private void CreateInput(Point point, Canvas surface, int id = -1, string text = "")
        {
            ComponentUIInput componentUi;
            ElementInput     element;
            ElementLabel     elementLabel;

            var labelVM = new ViewModelLabel();

            if (id < 0)
            {
                componentUi  = new ComponentUIInput(point, BaseElement.IdCounter);
                element      = new ElementInput(BaseElement.IdCounter);
                elementLabel = new ElementLabel(BaseElement.IdCounter);
                text         = "Подпись";
            }
            else
            {
                componentUi  = new ComponentUIInput(point, id);
                element      = new ElementInput(id);
                elementLabel = new ElementLabel(id);
            }
            BaseViewModelComponent baseViewModelComponent = new BaseViewModelComponent {
                element = element
            };

            baseViewModelComponent.strength = text;
            componentUi.DataContext         = element;
            surface.Children.Add(componentUi);
            componentUi.OnPinDropped     += baseViewModelComponent.OnPinDrop;
            componentUi.OnDeleteElement  += baseViewModelComponent.OnDelete;
            labelVM.element               = elementLabel;
            componentUi.Label.DataContext = baseViewModelComponent;
            componentUi.Label.OnEdit     += baseViewModelComponent.OnEdit;
            _elements.Add(baseViewModelComponent);
            _elements[_elements.Count - 1].OnPinElementDropped += OnElementPinDropped;
            _elements[_elements.Count - 1].OnElementDelete     += Delete;
        }
Exemple #3
0
 public ComponentLabel() : base(ETypeOfElement.Label)
 {
     InitializeComponent();
     DataContext = new ViewModelLabel();
 }