Ejemplo n.º 1
0
        private void UnpackDefinition()
        {
            if (Data != null)
            {
                if (Data.IsHorizontal)
                {
                    wrapper.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                    wrapper.VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled;
                }
                else
                {
                    wrapper.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                    wrapper.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
                }

                if (Data.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(Data.Background.Value);

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

                ////
            }
        }
Ejemplo n.º 2
0
        private void UnpackDefinition()
        {
            // extract colours
            if (Data != null)
            {
                AtomicBlockStateData stateData = Data[BlockState.Normal];

                if (stateData != null)
                {
                    if (stateData.ComponentForeground.HasValue)
                    {
                        PaintStyleResult res = ResolvePaintStyle(stateData.ComponentForeground.Value);

                        if ((res.Brush != null) && (res.Brush is SolidColorBrush))
                        {
                            ForegroundColour = ((SolidColorBrush)res.Brush).Color;
                        }
                    }

                    if (stateData.ComponentBackground.HasValue)
                    {
                        PaintStyleResult res = ResolvePaintStyle(stateData.ComponentBackground.Value);

                        if ((res.Brush != null) && (res.Brush is SolidColorBrush))
                        {
                            BackgroundColour = ((SolidColorBrush)res.Brush).Color;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void UnpackContent()
        {
            if ((Data != null) && Data.HasState(BlockState.Normal))
            {
                // visibility
                isVisible = !Data.RenderingHints[RenderingHintKey.Visibility].Equals(WaveConstant.False, StringComparison.InvariantCultureIgnoreCase);

                // opacity
                string opData = Data.RenderingHints[RenderingHintKey.Opacity];

                if (!String.IsNullOrEmpty(opData))
                {
                    double temp = 0;

                    if (Double.TryParse(opData, out temp))
                    {
                        opacity = temp;
                    }
                }

                // try to get colours
                AtomicBlockStateData state = Data[BlockState.Normal];

                if (state != null)
                {
                    if (state.ComponentBackground.HasValue && (state.ComponentBackground.Value.StyleType == PaletteEntryType.Colour))
                    {
                        PaintStyleResult res = ResolvePaintStyle(state.ComponentBackground.Value);

                        if ((res.Context == PaintStyleResult.Result.Colour) && (res.Brush is SolidColorBrush))
                        {
                            background = ((SolidColorBrush)res.Brush).Color;
                        }
                    }

                    if (state.ComponentForeground.HasValue && (state.ComponentForeground.Value.StyleType == PaletteEntryType.Colour))
                    {
                        PaintStyleResult res = ResolvePaintStyle(state.ComponentForeground.Value);

                        if ((res.Context == PaintStyleResult.Result.Colour) && (res.Brush is SolidColorBrush))
                        {
                            foreground = ((SolidColorBrush)res.Brush).Color;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void UnpackDefinition()
        {
            if (Data != null)
            {
                // applying definition
                if (Data.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(Data.Background.Value);

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

                //IMPLEMENT: rest of box layout definition
            }
        }
Ejemplo n.º 5
0
        public override void ApplyFormattingAndLayout(SlotData slotData, SlotStyleData slotStyleData, TableLayoutItemInfo layout)
        {
            base.ApplyFormattingAndLayout(slotData, slotStyleData, layout);

            //IMPLEMENT: the rest of the properties in SlotData, SlotStyleData, and TableLayoutItemInfo

            if (layout != null)
            {
                Margin  = new Spacing(layout.LeftMargin, layout.TopMargin, layout.RightMargin, layout.BottomMargin);
                Padding = new Spacing(layout.LeftPadding, layout.TopPadding, layout.RightPadding, layout.BottomPadding);
                Crop    = layout.CropStrategy;
            }

            if (slotData != null)
            {
                // background
                if (slotData.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(slotData.Background.Value, PaintStyleUse.Background);

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

            if (slotStyleData != null)
            {
                Crop = slotStyleData.Crop;

                // background
                if (slotStyleData.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(slotStyleData.Background.Value, PaintStyleUse.Background);

                    if (bgRes.Brush != null)
                    {
                        Background = bgRes.Brush;
                    }
                }
            }
        }
Ejemplo n.º 6
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]);
                }
            }
        }
Ejemplo n.º 7
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;
                }
                }
            }
        }
Ejemplo n.º 8
0
        public override void ApplyFormattingAndLayout(SlotData slotData, SlotStyleData slotStyleData, TableLayoutItemInfo layout)
        {
            base.ApplyFormattingAndLayout(slotData, slotStyleData, layout);

            Brush background = null;
            Brush foreground = null;
            short fontID     = -1;

            //IMPLEMENT: the rest of the properties in SlotData, SlotStyleData, and TableLayoutItemInfo

            if (layout != null)
            {
                // margins and paddings
                Margin  = new Spacing(layout.LeftMargin, layout.TopMargin, layout.RightMargin, layout.BottomMargin);
                Padding = new Spacing(layout.LeftPadding, layout.TopPadding, layout.RightPadding, layout.BottomPadding);

                // cropping
                Crop = layout.CropStrategy;
            }

            if (slotData != null)
            {
                // background
                if (slotData.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(slotData.Background.Value, PaintStyleUse.Background);

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

                // foreground
                if (slotData.Foreground.HasValue)
                {
                    PaintStyleResult fgRes = ResolvePaintStyle(slotData.Foreground.Value, PaintStyleUse.Foreground);

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

                // get font
                fontID = slotData.Font ?? -1;
            }

            if (slotStyleData != null)
            {
                // cropping
                Crop = slotStyleData.Crop;

                // background
                if (slotStyleData.Background.HasValue)
                {
                    PaintStyleResult bgRes = ResolvePaintStyle(slotStyleData.Background.Value, PaintStyleUse.Background);

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

                // foreground
                if (slotStyleData.Foreground.HasValue)
                {
                    PaintStyleResult fgRes = ResolvePaintStyle(slotStyleData.Foreground.Value, PaintStyleUse.Foreground);

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

                // get font
                fontID = slotStyleData.Font;
            }

            // use parent foreground if needed
            if (foreground == null)
            {
                foreground = Atomic.Foreground;
            }

            // apply brushes
            Background             = background;
            textControl.Foreground = foreground;

            // apply font
            if (fontID != -1)
            {
                FontReferencePaletteEntry fr = Atomic.FindCascadedPaletteItem(fontID) as FontReferencePaletteEntry;

                if (fr != null)
                {
                    FontDefinition fd = fr.Resolve(Atomic.ParentNode.ApplicationID);

                    if (fd != null)
                    {
                        fd.Apply(textControl);
                    }
                }
            }

            // apply cropping, alignment, tick
            if ((Crop & CropStrategy.Wrap) == CropStrategy.Wrap)
            {
                textControl.TextWrapping = TextWrapping.Wrap;

                if ((Crop & CropStrategy.Tick) == CropStrategy.Tick)
                {
                    textControl.TextTrimming = TextTrimming.WordEllipsis;
                }
                else
                {
                    textControl.TextTrimming = TextTrimming.None;
                }
            }
            else if ((Crop & CropStrategy.Tick) == CropStrategy.Tick)
            {
                textControl.TextWrapping = TextWrapping.NoWrap;
                textControl.TextTrimming = TextTrimming.WordEllipsis;
            }
            else
            {
                textControl.TextWrapping = TextWrapping.NoWrap;
                textControl.TextTrimming = TextTrimming.None;
            }

            // set horizontal alignment (vertical one is done in layout)
            if ((Crop & CropStrategy.AlignLeft) == CropStrategy.AlignLeft)
            {
                textControl.TextAlignment = TextAlignment.Left;
            }
            else if ((Crop & CropStrategy.AlignHCenter) == CropStrategy.AlignHCenter)
            {
                textControl.TextAlignment = TextAlignment.Center;
            }
            else if ((Crop & CropStrategy.AlignRight) == CropStrategy.AlignRight)
            {
                textControl.TextAlignment = TextAlignment.Right;
            }
        }
Ejemplo n.º 9
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]);
                }
            }
        }
Ejemplo n.º 10
0
        public ScrollingTextBlock(View hostView, Node parentNode, BlockBase parentBlock, BlockDefinition definition, FieldList content, bool isRoot)
            : base(hostView, parentNode, parentBlock, definition, content, isRoot)
        {
            Caption = String.Empty;

            // parse content
            if (Content != null)
            {
                DisplayDataCollection ddc = DisplayData.Parse(Content);

                if ((ddc != null) && (ddc.Count > 0) && (ddc[0].DisplayType == DisplayType.String))
                {
                    Caption = (string)ddc[0].Data;
                }
            }

            // creating controls
            panel             = new StackPanel();
            panel.Orientation = Orientation.Vertical;

            wrapper         = new ScrollViewer();
            wrapper.Content = panel;

            // apply definition
            Brush          fg = null;
            FontDefinition fd = null;

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

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

                // foreground
                if (Data.Foreground.HasValue)
                {
                    PaintStyleResult fgRes = ResolvePaintStyle(Data.Foreground.Value);

                    fg = fgRes.Brush;
                }

                // apply font
                if (Data.Font.HasValue && (Data.Font.Value != -1))
                {
                    FontReferencePaletteEntry fr = FindCascadedPaletteItem(Data.Font.Value) as FontReferencePaletteEntry;

                    if (fr != null)
                    {
                        fd = fr.Resolve(ParentNode.ApplicationID);
                    }
                }

                // padding for text
                panel.Margin = new Thickness(DefaultPadding);
            }

            // apply text
            string[] parts = Caption.Split('\n');

            foreach (string part in parts)
            {
                TextBlock paragraph = new TextBlock();

                if (fg != null)
                {
                    paragraph.Foreground = fg;
                }

                if (fd != null)
                {
                    fd.Apply(paragraph);
                }

                paragraph.TextWrapping = TextWrapping.Wrap;

                if (!String.IsNullOrEmpty(part))
                {
                    paragraph.Text = part;
                }
                else
                {
                    paragraph.Text = " ";
                }

                panel.Children.Add(paragraph);
            }

            // display text
            Children.Add(wrapper);
        }