Ejemplo n.º 1
0
        public UIElementGroupConstArg(
            int columnCountConstraint,
            int rowCountConstraint,
            bool topToBottom,
            bool leftToRight,
            bool rowToColumn,

            IUIManager uim,
            IUISystemProcessFactory processFactory,
            IUIElementFactory uieFactory,
            IUIElementGroupAdaptor uia,
            IUIImage image,
            ActivationMode activationMode

            ) : base(
                uim,
                processFactory,
                uieFactory,
                uia,
                image,
                activationMode
                )
        {
            thisColumnCountConstraint = columnCountConstraint;
            thisRowCountConstraint    = rowCountConstraint;
            thisTopToBottom           = topToBottom;
            thisLeftToRight           = leftToRight;
            thisRowToColumn           = rowToColumn;
        }
Ejemplo n.º 2
0
        public GenericSingleElementScrollerConstArg(
            Vector2 relativeCursorLength,
            ScrollerAxis scrollerAxis,
            Vector2 rubberBandLimitMultiplier,
            Vector2 relativeCursorPosition,
            bool isEnabledInertia,
            float newScrollSpeedThreshold,

            IUIManager uim,
            IUISystemProcessFactory processFactory,
            IUIElementFactory uieFactory,
            IGenericSingleElementScrollerAdaptor uia,
            IUIImage image,
            ActivationMode activationMode

            ) : base(
                scrollerAxis,
                relativeCursorPosition,
                rubberBandLimitMultiplier,
                isEnabledInertia,
                newScrollSpeedThreshold,

                uim,
                processFactory,
                uieFactory,
                uia,
                image,
                activationMode
                )
        {
            thisRelativeCursorLength = relativeCursorLength;
        }
Ejemplo n.º 3
0
        public QuantityRollerConstArg(
            IUIManager uim,
            IUISystemProcessFactory processFactory,
            IUIElementFactory uiElementFactory,
            IQuantityRollerAdaptor quaRolAdaptor,
            IUIImage image,

            int maxQuantity,
            Vector2 panelDim,
            Vector2 padding,
            Vector2 rollerNormalizedPos
            ) : base(
                uim,
                processFactory,
                uiElementFactory,
                quaRolAdaptor,
                image,
                ActivationMode.None
                )
        {
            thisMaxQuantity         = maxQuantity;
            thisUIEFactory          = uieFactory;
            thisPanelDim            = panelDim;
            thisPadding             = padding;
            thisRollerNormalizedPos = rollerNormalizedPos;
        }
Ejemplo n.º 4
0
        public PopUpConstArg(
            IUIManager uim,
            IUISystemProcessFactory processFactory,
            IUIElementFactory uiElementFactory,
            IPopUpAdaptor popUpAdaptor,
            IUIImage image,
            ActivationMode activationMode,

            IPopUpManager popUpManager,
            bool hidesOnTappingOthers,
            PopUpMode popUpMode

            ) : base(
                uim,
                processFactory,
                uiElementFactory,
                popUpAdaptor,
                image,
                activationMode
                )
        {
            thisPopUpManager         = popUpManager;
            thisHidesOnTappingOthers = hidesOnTappingOthers;
            thisPopUpMode            = popUpMode;
        }
Ejemplo n.º 5
0
        public ScrollerConstArg(
            ScrollerAxis scrollerAxis,
            Vector2 relativeCursorPosition,
            Vector2 rubberBandLimitMultiplier,
            bool isEnabledInertia,
            float newScrollSpeedThreshold,

            IUIManager uim,
            IUISystemProcessFactory processFactory,
            IUIElementFactory uieFactory,
            IScrollerAdaptor uia,
            IUIImage uiImage,
            ActivationMode activationMode
            ) : base(
                uim,
                processFactory,
                uieFactory,
                uia,
                uiImage,
                activationMode
                )
        {
            thisScrollerAxis              = scrollerAxis;
            thisRelativeCursorPos         = relativeCursorPosition;
            thisRubberBandLimitMultiplier = rubberBandLimitMultiplier;
            thisIsEnabledInertia          = isEnabledInertia;
            thisNewScrollSpeedThreshold   = newScrollSpeedThreshold;
        }
Ejemplo n.º 6
0
        IDigitPanel CreateDigitPanel(Vector2 panelDim, Vector2 padding, bool isLesser)
        {
            float             lesserPanelLocalPosY  = padding.y;
            float             greaterPanelLocalPosY = lesserPanelLocalPosY + panelDim.y + padding.y;
            IUIElementFactory factory    = thisUIElementFactory;
            IDigitPanel       digitPanel = factory.CreateDigitPanel(this, panelDim, isLesser?lesserPanelLocalPosY: greaterPanelLocalPosY);

            return(digitPanel);
        }
Ejemplo n.º 7
0
 protected virtual IUIAdaptorBaseInitializationData CreateRootUIEBaseConstData(
     IProcessFactory processFactory,
     IUIElementFactory uiElementFactory
     )
 {
     return(new RootUIAActivationData(
                this,
                (IUISystemProcessFactory)processFactory,
                uiElementFactory
                ));
 }
Ejemplo n.º 8
0
        private void GroupInto(IUIElementFactory factory)
        {
            var targetPanelType = (factory as UIElementFromSystemLibrary)?.Type;

            if (targetPanelType == null)
            {
                throw new NotSupportedException("Grouping elements into a user library type isn't supported.");
            }
            if (!typeof(Panel).IsAssignableFrom(targetPanelType))
            {
                throw new ArgumentException(@"The target type isn't a panel", nameof(targetPanelType));
            }

            if (SelectedContent.Count == 0)
            {
                return;
            }

            // Ensure that the selected elements are sibling.
            var allParents = SelectedItems.Select(x => x.Parent).OfType <UIHierarchyItemViewModel>().ToList();
            var parent     = allParents[0];

            if (allParents.Any(x => x != parent))
            {
                throw new InvalidOperationException("This operation can only be executed on a selection of sibling elements.");
            }

            using (var transaction = UndoRedoService.CreateTransaction())
            {
                var children = SelectedItems.ToList();
                // Create the new panel into which we'll insert the selection
                var newPanel       = (Panel)Activator.CreateInstance(targetPanelType);
                var newPanelDesign = new UIElementDesign(newPanel);
                // Create a hierarchy containing all children and the panel
                var hierarchy = UIAssetPropertyGraph.CloneSubHierarchies(Asset.Session.AssetNodeContainer, Asset.Asset, children.Select(c => c.Id.ObjectId), SubHierarchyCloneFlags.None, out _);
                hierarchy.RootParts.Add(newPanel);
                hierarchy.Parts.Add(newPanelDesign);
                // Remove all children from their partDesign panel.
                foreach (var child in children)
                {
                    child.Asset.AssetHierarchyPropertyGraph.RemovePartFromAsset(child.UIElementDesign);
                }
                // Add the new panel in place of the selected content.
                parent.Asset.InsertUIElement(hierarchy.Parts, newPanelDesign, (parent as UIElementViewModel)?.AssetSideUIElement);
                // Add the children into the new panel.
                foreach (var child in children)
                {
                    parent.Asset.InsertUIElement(hierarchy.Parts, hierarchy.Parts[child.Id.ObjectId], newPanel);
                }
                UndoRedoService.SetName(transaction, $"Group into {targetPanelType.Name}");
            }
        }
Ejemplo n.º 9
0
        public UIElementConstArg(
            IUIManager uim,
            IUISystemProcessFactory processFactory,
            IUIElementFactory uiElementFactory,
            IUIAdaptor uia,
            IUIImage image,
            ActivationMode activationMode

            )
        {
            thisUIM              = uim;
            thisProcessFactory   = processFactory;
            thisUIElementFactory = uiElementFactory;
            thisUIA              = uia;
            thisImage            = image;
            thisActivationMode   = activationMode;
        }
        public CyclableUIElementGroupScrollerConstArg(
            bool[] isCycleEnabled,
            int initiallyCursoredElementIndex,
            int[] cursorSize,
            float startSearchSpeed,
            bool activatesCursoredElementsOnly,

            Vector2 relativeCursorPosition,
            ScrollerAxis scrollerAxis,
            Vector2 rubberBandLimitMultiplier,
            bool isEnabledInertia,
            bool swipeToSnapNext,
            float newScrollSpeedThreshold,

            IUIManager uim,
            IUISystemProcessFactory processFactory,
            IUIElementFactory uieFactory,
            IUIElementGroupScrollerAdaptor uia,
            IUIImage image,
            ActivationMode activationMode
            ) : base(
                initiallyCursoredElementIndex,
                cursorSize,
                startSearchSpeed,
                activatesCursoredElementsOnly,

                relativeCursorPosition,
                scrollerAxis,
                rubberBandLimitMultiplier,
                isEnabledInertia,
                swipeToSnapNext,
                newScrollSpeedThreshold,

                uim,
                processFactory,
                uieFactory,
                uia,
                image,
                activationMode
                )
        {
            thisIsCycleEnabled = isCycleEnabled;
        }
    TestGenericSingleElementScroller CreateGenericSingleElementScroller(Vector2 relativeCursorLength)
    {
        ScrollerAxis            scrollerAxis = ScrollerAxis.Both;
        Vector2                 rubberBandLimitMultiplier = new Vector2(.1f, .1f);
        Vector2                 relativeCursorPosition    = new Vector2(.5f, .5f);
        IUIManager              uim              = Substitute.For <IUIManager>();
        IUISystemProcessFactory processFactory   = Substitute.For <IUISystemProcessFactory>();
        IUIElementFactory       uieFactory       = Substitute.For <IUIElementFactory>();
        IGenericSingleElementScrollerAdaptor uia = Substitute.For <IGenericSingleElementScrollerAdaptor>();
        Rect scrollerRect = new Rect(Vector2.zero, new Vector2(200f, 100f));

        uia.GetRect().Returns(scrollerRect);
        IUIElement child       = Substitute.For <IUIElement>();
        IUIAdaptor childUIA    = Substitute.For <IUIAdaptor>();
        Rect       elementRect = new Rect(Vector2.zero, new Vector2(100f, 100f));

        childUIA.GetRect().Returns(elementRect);
        child.GetUIAdaptor().Returns(childUIA);
        List <IUIElement> returnedList = new List <IUIElement>(new IUIElement[] { child });

        uia.GetChildUIEs().Returns(returnedList);
        IUIImage image = Substitute.For <IUIImage>();
        float    newScrollSpeedThreshold = 200f;

        IGenericSingleElementScrollerConstArg arg = new GenericSingleElementScrollerConstArg(
            relativeCursorLength,
            scrollerAxis,
            rubberBandLimitMultiplier,
            relativeCursorPosition,
            true,
            newScrollSpeedThreshold,

            uim,
            processFactory,
            uieFactory,
            uia,
            image,
            ActivationMode.None
            );

        return(new TestGenericSingleElementScroller(arg));
    }
Ejemplo n.º 12
0
        public DigitPanelSetConstArg(
            IUIManager uim,
            IUISystemProcessFactory processFactory,
            IUIElementFactory uiElementFactory, IUIAdaptor uia,
            IUIImage image,

            int digitPlace,
            Vector2 panelDim,
            Vector2 padding
            ) : base(
                uim,
                processFactory,
                uiElementFactory,
                uia,
                image,
                ActivationMode.None
                )
        {
            thisDigitPlace = digitPlace;
        }
Ejemplo n.º 13
0
        public DigitPanelConstArg(
            IUIManager uim,
            IUISystemProcessFactory processFactory,
            IUIElementFactory uiElementFactory,
            IDigitPanelAdaptor digitPanelAdaptor,
            IUIImage image,

            Vector2 panelDim,
            float localPosY
            ) : base(
                uim,
                processFactory,
                uiElementFactory,
                digitPanelAdaptor,
                image,
                ActivationMode.None
                )
        {
            thisPanelDim  = panelDim;
            thisLocalPosY = localPosY;
        }
Ejemplo n.º 14
0
        public ColorChangeButtonConstArg(
            IUIManager uim,
            IUISystemProcessFactory processFactory,
            IUIElementFactory uieFactory,
            IColorChangeButtonAdaptor uia,
            IUIImage uiImage,

            IUIAdaptor targetUIAdaptor,
            Color targetColor,
            Text targetText
            ) : base(
                uim,
                processFactory,
                uieFactory,
                uia,
                uiImage,
                ActivationMode.None
                )
        {
            thisTargetUIAdaptor = targetUIAdaptor;
            thisTargetColor     = targetColor;
            thisText            = targetText;
        }
Ejemplo n.º 15
0
 protected IDE()
 {
     Elements       = new List <UIElement>();
     ElementFactory = CreateFactory();
 }
Ejemplo n.º 16
0
        private void ChangeLayoutType([NotNull] IUIElementFactory factory)
        {
            var targetType = (factory as UIElementFromSystemLibrary)?.Type;

            if (targetType == null)
            {
                throw new NotSupportedException("Changing the panel from a user library type is currently not supported.");
            }
            if (!typeof(Panel).IsAssignableFrom(targetType))
            {
                throw new ArgumentException(@"The target type is not a panel", nameof(targetType));
            }

            // If the target panel type is the same as the current panel type, do nothing
            if (targetType == ElementType)
            {
                return;
            }

            using (var transaction = Editor.UndoRedoService.CreateTransaction())
            {
                Panel targetPanel = null;
                // Try to maintain the layout order depending on the combinaison of currentType/targetType.
                //
                // Notes:
                // - from any panel to a Canvas (tricky case)
                //    - for now don't do anything smart
                //        + later we could try to calculate Canvas absolute or relative position so that elements appear at the same position
                var stackPanel = AssetSidePanel as StackPanel;
                if (stackPanel != null)
                {
                    // from a StackPanel to a Grid or UniformGrid:
                    //   - if the StackPanel's orientation was horizontal, put each element in a different column
                    //   - if the StackPanel's orientation was in-depth, put each element in a different layer
                    //   - if the StackPanel's orientation was vertical, put each element in a different row
                    //   - use StripType.Auto for the Strip definitions of the Grid
                    if (typeof(GridBase).IsAssignableFrom(targetType))
                    {
                        var colums        = 1;
                        var rows          = 1;
                        var layers        = 1;
                        var childrenCount = stackPanel.Children.Count;
                        if (childrenCount > 0)
                        {
                            switch (stackPanel.Orientation)
                            {
                            case Orientation.Horizontal:
                                colums = childrenCount;
                                break;

                            case Orientation.Vertical:
                                rows = childrenCount;
                                break;

                            case Orientation.InDepth:
                                layers = childrenCount;
                                break;

                            default:
                                throw new ArgumentOutOfRangeException();
                            }
                        }

                        if (typeof(Grid).IsAssignableFrom(targetType))
                        {
                            targetPanel = CreateGrid(colums, rows, layers, StripType.Auto);
                        }
                        else if (typeof(UniformGrid).IsAssignableFrom(targetType))
                        {
                            targetPanel = CreateUniformGrid(colums, rows, layers);
                        }

                        if (targetPanel != null)
                        {
                            CopySwapExchange(this, new UIElementDesign(targetPanel));
                            // Set dependency properties
                            PropertyKey <int> propertyKey;
                            switch (stackPanel.Orientation)
                            {
                            case Orientation.Horizontal:
                                propertyKey = GridBase.ColumnPropertyKey;
                                break;

                            case Orientation.Vertical:
                                propertyKey = GridBase.RowPropertyKey;
                                break;

                            case Orientation.InDepth:
                                propertyKey = GridBase.LayerPropertyKey;
                                break;

                            default:
                                throw new ArgumentOutOfRangeException();
                            }
                            for (var i = 0; i < childrenCount; i++)
                            {
                                SetDependencyPropertyValue(targetPanel.Children[i], propertyKey, i);
                            }
                        }
                    }
                    else if (typeof(Canvas).IsAssignableFrom(targetType))
                    {
                        // fallback to default case (for now)
                    }
                }

                var gridBase = AssetSidePanel as GridBase;
                if (gridBase != null)
                {
                    var grid        = gridBase as Grid;
                    var uniformGrid = gridBase as UniformGrid;
                    if (typeof(StackPanel).IsAssignableFrom(targetType))
                    {
                        // from a GridBase to a StackPanel
                        //   - determine the StackPanel's orientation from the GridBase largest dimension (Colums, Rows, Layers)
                        //   - order elements by Rows, Colums and Layers
                        if (grid != null)
                        {
                            targetPanel = new StackPanel
                            {
                                Orientation = GetOrientation(grid.ColumnDefinitions.Count, grid.RowDefinitions.Count, grid.LayerDefinitions.Count),
                            };
                        }
                        else if (uniformGrid != null)
                        {
                            targetPanel = new StackPanel
                            {
                                Orientation = GetOrientation(uniformGrid.Columns, uniformGrid.Rows, uniformGrid.Layers),
                            };
                        }
                        else
                        {
                            // Unknown GridBase implementation
                            targetPanel = new StackPanel();
                        }
                        // Order children in Western reading order: left to right, top to bottom, front to back)
                        CopySwapExchange(this, new UIElementDesign(targetPanel), x => x.OrderBy(e => e.AssetSideUIElement.DependencyProperties.Get(GridBase.RowPropertyKey)).ThenBy(e => e.AssetSideUIElement.DependencyProperties.Get(GridBase.ColumnPropertyKey)).ThenBy(e => e.AssetSideUIElement.DependencyProperties.Get(GridBase.LayerPropertyKey)));
                        // Remove the GridBase related dependency properties
                        foreach (var child in targetPanel.Children)
                        {
                            RemoveDependencyProperty(child, GridBase.ColumnPropertyKey);
                            RemoveDependencyProperty(child, GridBase.ColumnSpanPropertyKey);
                            RemoveDependencyProperty(child, GridBase.RowPropertyKey);
                            RemoveDependencyProperty(child, GridBase.RowSpanPropertyKey);
                            RemoveDependencyProperty(child, GridBase.LayerPropertyKey);
                            RemoveDependencyProperty(child, GridBase.LayerSpanPropertyKey);
                        }
                    }
                    else if (typeof(Grid).IsAssignableFrom(targetType) && uniformGrid != null)
                    {
                        // from a Grid to a UniformGrid
                        //   - keep the same column/layer/row dependency properties
                        //   - create ColumDefinitions, RowDefinitions, LayerDefinitions from Colums, Rows, Layers resp.
                        //   - use StripType.Star
                        targetPanel = CreateGrid(uniformGrid.Columns, uniformGrid.Rows, uniformGrid.Layers, StripType.Star);
                        CopySwapExchange(this, new UIElementDesign(targetPanel));
                    }
                    else if (typeof(UniformGrid).IsAssignableFrom(targetType) && grid != null)
                    {
                        // from a UniformGrid to a Grid
                        //   - keep the same column/layer/row dependency properties
                        //   - set Colums, Rows, Layers by counting ColumDefinitions, RowDefinitions, LayerDefinitions resp.
                        targetPanel = CreateUniformGrid(grid.ColumnDefinitions.Count, grid.RowDefinitions.Count, grid.LayerDefinitions.Count);
                        CopySwapExchange(this, new UIElementDesign(targetPanel));
                    }
                    else if (typeof(Canvas).IsAssignableFrom(targetType))
                    {
                        // from a Canvas to any other panel (tricky case)
                        //   - just add the children with default behavior
                        //     + finding the arrangement based on the relative position of children is a difficult problem (we will need some heuristic)
                        //     + plus the user might want something else anyway, so let's not make its work more complicated

                        // Remove the GridBase related dependency properties
                        foreach (var child in gridBase.Children)
                        {
                            RemoveDependencyProperty(child, GridBase.ColumnPropertyKey);
                            RemoveDependencyProperty(child, GridBase.ColumnSpanPropertyKey);
                            RemoveDependencyProperty(child, GridBase.RowPropertyKey);
                            RemoveDependencyProperty(child, GridBase.RowSpanPropertyKey);
                            RemoveDependencyProperty(child, GridBase.LayerPropertyKey);
                            RemoveDependencyProperty(child, GridBase.LayerSpanPropertyKey);
                        }
                        // fallback to default case (for now)
                    }
                }

                var canvas = AssetSidePanel as Canvas;
                if (canvas != null)
                {
                    // Remove the Canvas related dependency properties
                    foreach (var child in canvas.Children)
                    {
                        RemoveDependencyProperty(child, Canvas.AbsolutePositionPropertyKey);
                        RemoveDependencyProperty(child, Canvas.PinOriginPropertyKey);
                        RemoveDependencyProperty(child, Canvas.RelativePositionPropertyKey);
                        RemoveDependencyProperty(child, Canvas.RelativeSizePropertyKey);
                    }
                    // fallback to default case (for now)
                }

                if (targetPanel == null)
                {
                    // default
                    targetPanel = (Panel)Activator.CreateInstance(targetType);
                    CopySwapExchange(this, new UIElementDesign(targetPanel));
                }

                Editor.UndoRedoService.SetName(transaction, $"Change layout type to {targetType.Name}");
            }
        }
Ejemplo n.º 17
0
 public RootUIAActivationData(IUIManager uim, IUISystemProcessFactory processFactory, IUIElementFactory uiElementFactory) : base(uim, processFactory, uiElementFactory)
 {
 }
Ejemplo n.º 18
0
 public AbsUIAActivationData(IUIManager uim, IUISystemProcessFactory processFactory, IUIElementFactory uiElementFactory)
 {
     thisUIM              = uim;
     thisProcessFactory   = processFactory;
     thisUIElementFactory = uiElementFactory;
 }