Exemplo n.º 1
0
        private void UnpackContent()
        {
            // creating children
            List <FieldList> children = Content.GetItems <FieldList>(NaviAgentFieldID.BlockData);

            AtomicBlock        title      = null;
            List <AtomicBlock> itemTitles = new List <AtomicBlock>();
            List <FrameBlock>  items      = new List <FrameBlock>();

            for (int i = 0; i < children.Count; i++)
            {
                int            childDefinitionID = children[i][MessageOutFieldID.DefinitionID].AsInteger() ?? 0;
                DefinitionBase definition        = Core.Definitions.Find(ParentNode.ApplicationID, childDefinitionID, true);

                if ((definition != null) && (definition is BlockDefinition))
                {
                    BlockBase newBlock = Core.UIFactory.CreateAndInitialiseBlock(Host, ParentNode, this, definition as BlockDefinition, children[i], false);

                    if (newBlock != null)
                    {
                        if (newBlock is AtomicBlock)
                        {
                            if (((BlockDefinition)definition).HintedType == UIHintedType.PanoramaTitle)
                            {
                                title = (AtomicBlock)newBlock;
                            }
                            else
                            {
                                itemTitles.Add((AtomicBlock)newBlock);
                            }
                        }
                        else if (newBlock is FrameBlock)
                        {
                            items.Add((FrameBlock)newBlock);
                        }
                    }
                }
            }

            if ((title != null) && !String.IsNullOrWhiteSpace(title.Caption) && (itemTitles.Count > 0) && (items.Count > 0) && (itemTitles.Count == items.Count))
            {
                panorama       = new Panorama();
                panorama.Title = title.Caption;

                for (int i = 0; i < items.Count; i++)
                {
                    PanoramaItem item = new PanoramaItem();

                    item.Header  = !String.IsNullOrWhiteSpace(itemTitles[i].Caption) ? itemTitles[i].Caption : WaveConstant.UnknownText;
                    item.Content = items[i];

                    panorama.Items.Add(item);
                }

                if ((ContainerDefinition != null) && ContainerDefinition.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(ContainerDefinition.Background.Value);

                    if (bgRes.Brush != null)
                    {
                        panorama.Background = bgRes.Brush;
                    }
                }

                Children.Add(panorama);

                for (int i = 0; i < items.Count; i++)
                {
                    WaveChildren.Add(items[i]);
                }
            }
        }
Exemplo n.º 2
0
        protected override void SwitchToState(BlockState state)
        {
            if (state == currentState)
            {
                return;
            }

            if (((state == BlockState.Normal) && !hasNormalState) || ((state == BlockState.Focused) && !hasFocusedState) ||
                ((state == BlockState.CheckedNormal) && !hasCheckedNormalState) || ((state == BlockState.CheckedFocused) && !hasCheckedFocusedState))
            {
                return;
            }

            // save old state
            BlockState oldState = currentState;

            // set current state
            currentState = state;

            // clean-up
            WaveChildren.Clear();
            Children.Clear();

            // try to create new state
            AtomicBlockStateData stateData = Data[state];

            if (stateData != null)
            {
                // background
                if (stateData.ComponentBackground.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(stateData.ComponentBackground.Value);

                    if (bgRes.Brush != null)
                    {
                        Background = bgRes.Brush;
                    }
                }

                // foreground
                if (stateData.ComponentForeground.HasValue)
                {
                    PaintStyleResult fgRes = ResolvePaintStyle(stateData.ComponentForeground.Value);

                    if (fgRes.Brush != null)
                    {
                        Foreground = fgRes.Brush;
                    }
                }

                // margins and paddings
                Margin  = new Spacing(stateData.MarginLeft, stateData.MarginTop, stateData.MarginRight, stateData.MarginBottom);
                Padding = new Spacing(stateData.PaddingLeft, stateData.PaddingTop, stateData.PaddingRight, stateData.PaddingBottom);

                // setup layout
                TableLayoutTemplate table = stateData.LayoutTemplate as TableLayoutTemplate;

                if (table != null)
                {
                    // save this layout for layout passes
                    currentLayout = table;

                    // create slots
                    for (int i = 0; i < stateData.SlotInfo.Count; i++)
                    {
                        int          slotIndex = stateData.SlotInfo[i].SlotIndex ?? i;
                        RendererBase renderer  = null;

                        // find layout information for the slot
                        TableLayoutItemInfo slotLayout = null;

                        if ((table.LayoutItems != null) && (i < table.LayoutItems.Count))
                        {
                            slotLayout = table.LayoutItems[i];
                        }

                        // find display data for the slot
                        DisplayData dd = null;

                        if (Data.StaticDisplayData != null)
                        {
                            if (slotIndex < Data.StaticDisplayData.Count)
                            {
                                // static display data
                                dd = Data.StaticDisplayData[slotIndex];
                            }
                            else if (serverDisplayData != null)
                            {
                                // server display data (with modified index)
                                dd = serverDisplayData[slotIndex - Data.StaticDisplayData.Count];
                            }
                        }
                        else if (serverDisplayData != null)
                        {
                            // server display data
                            dd = serverDisplayData[slotIndex];
                        }

                        if ((dd != null) && (i < table.LayoutItems.Count))
                        {
                            renderer = Core.UIFactory.CreateRenderer(this, dd, stateData.SlotInfo[i], null, slotLayout);

                            if (renderer != null)
                            {
                                TableLayout.SetSlotPosition(
                                    renderer,
                                    new TableLayoutPosition()
                                {
                                    Column     = table.LayoutItems[i].SlotX,
                                    Row        = table.LayoutItems[i].SlotY,
                                    ColumnSpan = table.LayoutItems[i].SlotXEnd - table.LayoutItems[i].SlotX,
                                    RowSpan    = table.LayoutItems[i].SlotYEnd - table.LayoutItems[i].SlotY
                                });

                                renderer.HorizontalAlignment = HorizontalAlignment.Stretch;
                                renderer.VerticalAlignment   = VerticalAlignment.Stretch;

                                WaveChildren.Add(renderer);
                                Children.Add(renderer);
                            }
                        }
                    }
                }

                // fire required anchors
                switch (oldState)
                {
                case BlockState.Normal:
                {
                    switch (state)
                    {
                    case BlockState.Focused:
                        FireAction(Anchor.OnFocused);
                        break;

                    case BlockState.CheckedNormal:
                        FireAction(Anchor.OnChecked);
                        break;

                    case BlockState.CheckedFocused:
                        FireAction(Anchor.OnChecked);
                        FireAction(Anchor.OnFocused);
                        break;
                    }

                    break;
                }

                case BlockState.Focused:
                {
                    switch (state)
                    {
                    case BlockState.Normal:
                        FireAction(Anchor.OnUnfocused);
                        break;

                    case BlockState.CheckedNormal:
                        FireAction(Anchor.OnChecked);
                        FireAction(Anchor.OnUnfocused);
                        break;

                    case BlockState.CheckedFocused:
                        FireAction(Anchor.OnChecked);
                        break;
                    }

                    break;
                }

                case BlockState.CheckedNormal:
                {
                    switch (state)
                    {
                    case BlockState.Normal:
                        FireAction(Anchor.OnUnchecked);
                        break;

                    case BlockState.Focused:
                        FireAction(Anchor.OnUnchecked);
                        FireAction(Anchor.OnFocused);
                        break;

                    case BlockState.CheckedFocused:
                        FireAction(Anchor.OnFocused);
                        break;
                    }

                    break;
                }

                case BlockState.CheckedFocused:
                {
                    switch (state)
                    {
                    case BlockState.Normal:
                        FireAction(Anchor.OnUnchecked);
                        FireAction(Anchor.OnUnfocused);
                        break;

                    case BlockState.Focused:
                        FireAction(Anchor.OnUnchecked);
                        break;

                    case BlockState.CheckedNormal:
                        FireAction(Anchor.OnUnfocused);
                        break;
                    }

                    break;
                }
                }
            }
        }
Exemplo n.º 3
0
        public virtual void AddChildBlock(BlockBase childBlock)
        {
            WaveChildren.Add(childBlock);

            AddSynchronisedBlock(childBlock);
        }
Exemplo n.º 4
0
        private void UnpackContent()
        {
            // parse settings
            if (Data != null)
            {
                loadOnDemand = Data.RenderingHints[RenderingHintKey.OnDemand].Equals(WaveConstant.True, StringComparison.InvariantCultureIgnoreCase);
            }

            // creating children
            List <FieldList> children = Content.GetItems <FieldList>(NaviAgentFieldID.BlockData);

            AtomicBlock        title      = null;
            List <AtomicBlock> itemTitles = new List <AtomicBlock>();
            List <FrameBlock>  items      = new List <FrameBlock>();

            for (int i = 0; i < children.Count; i++)
            {
                int             childDefinitionID = children[i][MessageOutFieldID.DefinitionID].AsInteger() ?? 0;
                BlockDefinition definition        = Core.Definitions.Find(ParentNode.ApplicationID, childDefinitionID, true) as BlockDefinition;

                if (definition != null)
                {
                    if (definition is FrameDefinition)
                    {
                        items.Add(new FrameBlock(Host, ParentNode, this, definition as FrameDefinition, children[i], false, !loadOnDemand));
                    }
                    else
                    {
                        AtomicBlock newBlock = Core.UIFactory.CreateAndInitialiseBlock(Host, ParentNode, this, definition, children[i], false) as AtomicBlock;

                        if (newBlock != null)
                        {
                            if (definition.HintedType == UIHintedType.PivotTitle)
                            {
                                title = newBlock;
                            }
                            else
                            {
                                itemTitles.Add(newBlock);
                            }
                        }
                    }
                }
            }

            if ((title != null) && !String.IsNullOrWhiteSpace(title.Caption) && (itemTitles.Count > 0) && (items.Count > 0) && (itemTitles.Count == items.Count))
            {
                pivot                   = new Pivot();
                pivot.Title             = title.Caption;
                pivot.LoadingPivotItem += new EventHandler <PivotItemEventArgs>(pivot_LoadingPivotItem);

                for (int i = 0; i < items.Count; i++)
                {
                    PivotItem item = new PivotItem();

                    item.Header  = !String.IsNullOrWhiteSpace(itemTitles[i].Caption) ? itemTitles[i].Caption : WaveConstant.UnknownText;
                    item.Content = items[i];

                    pivot.Items.Add(item);
                }

                if ((ContainerDefinition != null) && ContainerDefinition.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(ContainerDefinition.Background.Value);

                    if (bgRes.Brush != null)
                    {
                        pivot.Background = bgRes.Brush;
                    }
                }

                Children.Add(pivot);

                for (int i = 0; i < items.Count; i++)
                {
                    WaveChildren.Add(items[i]);
                }
            }
        }
Exemplo n.º 5
0
        protected override void SwitchToState(BlockState state)
        {
            if (state == currentState)
            {
                return;
            }

            // clean-up
            WaveChildren.Clear();
            Children.Clear();

            // try to create new state
            SingleSlotBlockStateData stateData = Data[state];

            if (stateData != null)
            {
                // margins and paddings
                Margin  = new Spacing(stateData.MarginLeft, stateData.MarginTop, stateData.MarginRight, stateData.MarginBottom);
                Padding = new Spacing(stateData.PaddingLeft, stateData.PaddingTop, stateData.PaddingRight, stateData.PaddingBottom);

                // create slot
                slot = Core.UIFactory.CreateRenderer(this, displayData[stateData.SlotIndex], null, stateData.SlotStyle, null);

                if (slot != null)
                {
                    WaveChildren.Add(slot);
                    Children.Add(slot);
                }

                // fire required anchors
                switch (currentState)
                {
                case BlockState.Normal:
                {
                    switch (state)
                    {
                    case BlockState.Focused:
                        FireAction(Anchor.OnFocused);
                        break;

                    case BlockState.CheckedNormal:
                        FireAction(Anchor.OnChecked);
                        break;

                    case BlockState.CheckedFocused:
                        FireAction(Anchor.OnChecked);
                        FireAction(Anchor.OnFocused);
                        break;
                    }

                    break;
                }

                case BlockState.Focused:
                {
                    switch (state)
                    {
                    case BlockState.Normal:
                        FireAction(Anchor.OnUnfocused);
                        break;

                    case BlockState.CheckedNormal:
                        FireAction(Anchor.OnChecked);
                        FireAction(Anchor.OnUnfocused);
                        break;

                    case BlockState.CheckedFocused:
                        FireAction(Anchor.OnChecked);
                        break;
                    }

                    break;
                }

                case BlockState.CheckedNormal:
                {
                    switch (state)
                    {
                    case BlockState.Normal:
                        FireAction(Anchor.OnUnchecked);
                        break;

                    case BlockState.Focused:
                        FireAction(Anchor.OnUnchecked);
                        FireAction(Anchor.OnFocused);
                        break;

                    case BlockState.CheckedFocused:
                        FireAction(Anchor.OnFocused);
                        break;
                    }

                    break;
                }

                case BlockState.CheckedFocused:
                {
                    switch (state)
                    {
                    case BlockState.Normal:
                        FireAction(Anchor.OnUnchecked);
                        FireAction(Anchor.OnUnfocused);
                        break;

                    case BlockState.Focused:
                        FireAction(Anchor.OnUnchecked);
                        break;

                    case BlockState.CheckedNormal:
                        FireAction(Anchor.OnUnfocused);
                        break;
                    }

                    break;
                }
                }

                // and finally save current state
                currentState = state;
            }
        }