Exemplo n.º 1
0
        public BaseComponent CreateNewVersionOfComponent(BaseComponent previous)
        {
            previous.Hide();

            _selectorMode = false;

            ClearComponent();

            BaseComponent newVersion = BaseComponent.Create(previous.Type, _canvas);

            newVersion.PreviousVersion = previous;
            newVersion.DisplayOrder    = previous.DisplayOrder;

            newVersion.CopyComponent(previous);

            _components.Add(newVersion);
            newVersion.IsEdited = false;

            _currentComponent = newVersion;
            _currentComponent.OnComponentActionCompleted = OnComponentActionCompleted;
            _currentComponent.OnComponentActionUpdated   = OnComponentActionUpdated;

            ComponentSelected?.Invoke();

            _canvas.Invalidate();

            return(newVersion);
        }
Exemplo n.º 2
0
        public void AddComponent(BaseComponent.ComponentType type, Point?location)
        {
            _selectorMode = false;

            ClearComponent();

            _currentComponent = BaseComponent.Create(type, _canvas);

            _currentComponent.OnComponentActionCompleted = OnComponentActionCompleted;
            _currentComponent.OnComponentActionUpdated   = OnComponentActionUpdated;

            // now try and see what the last component of this type has for options and copy it over
            var lastComponent = FindLastComponent(type);

            _currentComponent.CopyOptions(lastComponent);
            _currentComponent.Color = ActiveColor;
            if (location != null)
            {
                _currentComponent.SetLocation((float)location.Value.X, (float)location.Value.Y);
            }

            var currrentHighestDisplayPriority = _components?.OrderByDescending(c => c.DisplayOrder).FirstOrDefault()?.DisplayOrder;

            _currentComponent.DisplayOrder = (currrentHighestDisplayPriority ?? 0) + 1;

            ComponentSelected?.Invoke();

            _canvas.Invalidate();
        }