コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ButtonBar"/> class.
 /// </summary>
 public ButtonBar()
 {
     TabStop = true;
     Padding = new Padding(3, 3, 3, 3);
     SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     SetStyle(ControlStyles.UserPaint, true);
     SetStyle(ControlStyles.DoubleBuffer, true);
     SetStyle(ControlStyles.ResizeRedraw, true);
     SetStyle(ControlStyles.Selectable, true);
     SetStyle(ControlStyles.SupportsTransparentBackColor, true);
     BackColor        = Color.Transparent;
     items            = new GenericCollection <BarItem>();
     items.Inserted  += OnItemsInserted;
     items.Removed   += OnItemsRemoved;
     items.Changed   += OnItemsChanged;
     items.Inserting += OnItemsInserting;
     items.Changing  += OnItemsChanging;
     items.Removing  += OnItemsRemoving;
     items.Clearing  += OnItemsClearing;
     toolTip          = new ToolTip();
     appearance       = new Appearance();
     appearance.AppearanceChanged += OnAppearanceChanged;
     currentAppearance             = new Appearance();
     themeProperty = new ThemeProperty();
     themeProperty.ThemeChanged += OnAppearanceChanged;
     showScroll  = false;
     useMnemonic = true;
     showBorders = true;
     Height      = 200;
     InitializeDefaultScheme();
     SetThemeDefaults();
 }
コード例 #2
0
        private static object ConvertValue(ThemeProperty property)
        {
            switch (property.Value)
            {
            case ThemeBitmap bitmap:
                return(new ThemeBitmapViewModel(bitmap));

            case Color color:
                return(color.ToWpfColor());

            case HIGHCONTRASTCOLOR hcc:
                return(new HighContrastColor(hcc));

            case IMAGEPROPERTIES[] images:
                return(new SimplifiedImageGroup(images));

            case HCIMAGEPROPERTIES[] images:
                return(new HighContrastSimplifiedImageGroup(images));
            }

            if (property.Value != null && property.Value.GetType().IsEnum)
            {
                return($"{property.Value} [{(int)property.Value}]");
            }

            return(property.Value);
        }
コード例 #3
0
        static ThemeManager()
        {
            ThemeProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(OnThemeChanged));

            _actualThemeChangedEventArgs = new RoutedEventArgs(ActualThemeChangedEvent);

            if (DesignMode.DesignModeEnabled)
            {
                _ = GetDefaultThemeDictionary(LightKey);
                _ = GetDefaultThemeDictionary(DarkKey);
            }
        }
コード例 #4
0
        private string CreateCss(ThemeProperty x)
        {
            var vpnl = x.ValuePropName.Split <string>(",").ToList();

            if (vpnl.Count() > 1)
            {
                var vpnls = vpnl.Select(z => string.Format("{0}:{1}!important", z, string.Format(x.ValueTemplate, x.ValueString))).JoinToString(";\r\n");
                return(string.Format("{0} {{{1}}}", x.ClassName, vpnls
                                     ));
            }
            return(string.Format("{0} {{{1}:{2}!important;}}", x.ClassName, x.ValuePropName,
                                 string.Format(x.ValueTemplate, x.ValueString)));
        }
コード例 #5
0
ファイル: ThemeManager.cs プロジェクト: vasiliyph/ModernWpf
        static ThemeManager()
        {
            ThemeProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(OnThemeChanged));

            _actualThemeChangedEventArgs = new RoutedEventArgs(ActualThemeChangedEvent);
            MenuDropAlignmentHelper.EnsureStandardPopupAlignment();

            if (DesignMode.DesignModeEnabled)
            {
                _ = GetDefaultThemeDictionary(LightKey);
                _ = GetDefaultThemeDictionary(DarkKey);
                _ = GetDefaultThemeDictionary(HighContrastKey);
            }
        }
 public MonthCalander()
 {
     InitMonthContextMenu();
     Location     = new Point(0, 0);
     selectedDate = DateTime.Now;
     Size         = new Size(ControlWidth, (BottomLabelsPos.Y + BottomLabelHeight) + 5);
     SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     SetStyle(ControlStyles.DoubleBuffer, true);
     SetStyle(ControlStyles.UserPaint, true);
     SetStyle(ControlStyles.Selectable, true);
     themeProperty = new ThemeProperty();
     appearance    = new MonthCalanderAppearance();
     appearance.AppearanceChanged += OnAppearanceChanged;
     themeProperty.ThemeChanged   += OnAppearanceChanged;
     CreateMemoryBitmap();
     SetDefaults();
     SetThemeDefaults();
 }
コード例 #7
0
 set => this.SetValue(ThemeProperty, value);
コード例 #8
0
 set => SetValue(ThemeProperty, value);
コード例 #9
0
        protected override void AfterLoadInternal(Stack<ObjectModel> objectModels)
        {
            base.AfterLoadInternal(objectModels);

            MarkupObjectModel mom = (objectModels.Pop() as MarkupObjectModel);
            ThemeObjectModel themes = (objectModels.Pop() as ThemeObjectModel);

            MarkupTagElement tagThemes = (mom.FindElement("AwesomeControls", "Theming", "Themes") as MarkupTagElement);
            if (tagThemes != null)
            {
                foreach (MarkupElement elTheme in tagThemes.Elements)
                {
                    MarkupTagElement tagTheme = (elTheme as MarkupTagElement);
                    if (tagTheme == null) continue;

                    MarkupAttribute attThemeID = tagTheme.Attributes["ID"];
                    if (attThemeID == null) continue;

                    Theme theme = new Theme();

                    UniversalEditor.Accessors.FileAccessor fa = (this.Accessor as UniversalEditor.Accessors.FileAccessor);
                    if (fa != null) theme.BasePath = System.IO.Path.GetDirectoryName(fa.FileName);

                    theme.ID = new Guid(attThemeID.Value);

                    MarkupAttribute attInheritsThemeID = tagTheme.Attributes["InheritsThemeID"];
                    if (attInheritsThemeID != null) theme.InheritsThemeID = new Guid(attInheritsThemeID.Value);

                    MarkupTagElement tagInformation = (tagTheme.Elements["Information"] as MarkupTagElement);
                    if (tagInformation != null)
                    {
                        MarkupTagElement tagInformationTitle = (tagInformation.Elements["Title"] as MarkupTagElement);
                        if (tagInformationTitle != null) theme.Title = tagInformationTitle.Value;
                    }

                    MarkupTagElement tagMetrics = (tagTheme.Elements["Metrics"] as MarkupTagElement);
                    if (tagMetrics != null)
                    {
                        foreach (MarkupElement elMetric in tagMetrics.Elements)
                        {
                            MarkupTagElement tagMetric = (elMetric as MarkupTagElement);
                            if (tagMetric == null) continue;

                            MarkupAttribute attMetricName = tagMetric.Attributes["Name"];
                            if (attMetricName == null) continue;

                            switch (tagMetric.FullName.ToLower())
                            {
                                case "paddingmetric":
                                {
                                    PaddingMetric metric = new PaddingMetric();
                                    metric.Name = attMetricName.Value;

                                    MarkupAttribute attMetricLeft = tagMetric.Attributes["Left"];
                                    if (attMetricLeft != null) metric.Left = Single.Parse(attMetricLeft.Value);
                                    MarkupAttribute attMetricTop = tagMetric.Attributes["Top"];
                                    if (attMetricTop != null) metric.Top = Single.Parse(attMetricTop.Value);
                                    MarkupAttribute attMetricBottom = tagMetric.Attributes["Bottom"];
                                    if (attMetricBottom != null) metric.Bottom = Single.Parse(attMetricBottom.Value);
                                    MarkupAttribute attMetricRight = tagMetric.Attributes["Right"];
                                    if (attMetricRight != null) metric.Right = Single.Parse(attMetricRight.Value);

                                    theme.Metrics.Add(metric);
                                    break;
                                }
                            }
                        }
                    }

                    MarkupTagElement tagColors = (tagTheme.Elements["Colors"] as MarkupTagElement);
                    if (tagColors != null)
                    {
                        foreach (MarkupElement elColor in tagColors.Elements)
                        {
                            MarkupTagElement tagColor = (elColor as MarkupTagElement);
                            if (tagColor == null) continue;
                            if (tagColor.FullName != "Color") continue;

                            MarkupAttribute attColorID = tagColor.Attributes["ID"];
                            MarkupAttribute attColorName = tagColor.Attributes["Name"];

                            if (attColorID == null && attColorName == null) continue;

                            MarkupAttribute attColorValue = tagColor.Attributes["Value"];
                            if (attColorValue == null) continue;

                            ThemeColor color = new ThemeColor();
                            if (attColorID != null) color.ID = new Guid(attColorID.Value);
                            if (attColorName != null) color.Name = attColorName.Value;
                            if (attColorValue != null) color.Value = attColorValue.Value;

                            theme.Colors.Add(color);
                        }
                    }

                    MarkupTagElement tagFonts = (tagTheme.Elements["Fonts"] as MarkupTagElement);
                    if (tagFonts != null)
                    {
                        foreach (MarkupElement elFont in tagFonts.Elements)
                        {
                            MarkupTagElement tagFont = (elFont as MarkupTagElement);
                            if (tagFont == null) continue;
                            if (tagFont.FullName != "Font") continue;

                            MarkupAttribute attFontName = tagFont.Attributes["Name"];
                            if (attFontName == null) continue;

                            MarkupAttribute attFontValue = tagFont.Attributes["Value"];
                            if (attFontValue == null) continue;

                            ThemeFont font = new ThemeFont();
                            font.Name = attFontName.Value;
                            font.Value = attFontValue.Value;

                            theme.Fonts.Add(font);
                        }
                    }

                    MarkupTagElement tagStockImages = (tagTheme.Elements["StockImages"] as MarkupTagElement);
                    if (tagStockImages != null)
                    {
                        foreach (MarkupElement elStockImage in tagStockImages.Elements)
                        {
                            MarkupTagElement tagStockImage = (elStockImage as MarkupTagElement);
                            if (tagStockImage == null) continue;
                            if (tagStockImage.FullName != "StockImage") continue;

                            MarkupAttribute attStockImageName = tagStockImage.Attributes["Name"];
                            if (attStockImageName == null) continue;

                            MarkupAttribute attStockImageFileName = tagStockImage.Attributes["FileName"];
                            if (attStockImageFileName == null) continue;

                            ThemeStockImage stockImage = new ThemeStockImage();
                            stockImage.Name = attStockImageName.Value;
                            stockImage.ImageFileName = attStockImageFileName.Value;

                            theme.StockImages.Add(stockImage);
                        }
                    }

                    MarkupTagElement tagProperties = (tagTheme.Elements["Properties"] as MarkupTagElement);
                    if (tagProperties != null)
                    {
                        foreach (MarkupElement elProperty in tagProperties.Elements)
                        {
                            MarkupTagElement tagProperty = (elProperty as MarkupTagElement);
                            if (tagProperty == null) continue;
                            if (tagProperty.FullName != "Property") continue;

                            MarkupAttribute attName = tagProperty.Attributes["Name"];
                            if (attName == null) continue;

                            ThemeProperty property = new ThemeProperty();
                            property.Name = attName.Value;

                            MarkupAttribute attValue = tagProperty.Attributes["Value"];
                            if (attValue != null) property.Value = attValue.Value;

                            theme.Properties.Add(property);
                        }
                    }

                    MarkupTagElement tagComponents = (tagTheme.Elements["Components"] as MarkupTagElement);
                    if (tagComponents != null)
                    {
                        foreach (MarkupElement elComponent in tagComponents.Elements)
                        {
                            MarkupTagElement tagComponent = (elComponent as MarkupTagElement);
                            if (tagComponent == null) continue;
                            if (tagComponent.FullName != "Component") continue;

                            MarkupAttribute attComponentID = tagComponent.Attributes["ID"];
                            if (attComponentID == null) continue;

                            ThemeComponent component = new ThemeComponent();
                            component.ID = new Guid(attComponentID.Value);

                            MarkupAttribute attInheritsComponentID = tagComponent.Attributes["InheritsComponentID"];
                            if (attInheritsComponentID != null) component.InheritsComponentID = new Guid(attInheritsComponentID.Value);

                            MarkupTagElement tagComponentStates = (tagComponent.Elements["States"] as MarkupTagElement);
                            if (tagComponentStates != null)
                            {
                                // if States is specified, only apply to specific states
                                foreach (MarkupElement elState in tagComponentStates.Elements)
                                {
                                    MarkupTagElement tagState = (elState as MarkupTagElement);
                                    if (tagState == null) continue;
                                    if (tagState.FullName != "State") continue;

                                    MarkupAttribute attStateID = tagState.Attributes["ID"];
                                    if (attStateID == null) continue;

                                    ThemeComponentState state = new ThemeComponentState();
                                    state.ID = new Guid(attStateID.Value);

                                    MarkupAttribute attStateName = tagState.Attributes["Name"];
                                    if (attStateName != null) state.Name = attStateName.Value;

                                    component.States.Add(state);
                                }
                            }

                            MarkupTagElement tagRenderings = (tagComponent.Elements["Renderings"] as MarkupTagElement);
                            if (tagRenderings != null)
                            {
                                foreach (MarkupElement elRendering in tagRenderings.Elements)
                                {
                                    MarkupTagElement tagRendering = (elRendering as MarkupTagElement);
                                    if (tagRendering == null) continue;
                                    if (tagRendering.FullName != "Rendering") continue;

                                    MarkupTagElement tagRenderingActions = (tagRendering.Elements["Actions"] as MarkupTagElement);
                                    if (tagRenderingActions == null) continue;

                                    Rendering rendering = new Rendering();
                                    foreach (MarkupElement elRenderingAction in tagRenderingActions.Elements)
                                    {
                                        MarkupTagElement tagRenderingAction = (elRenderingAction as MarkupTagElement);
                                        if (tagRenderingAction == null) continue;

                                        switch (tagRenderingAction.FullName)
                                        {
                                            case "Rectangle":
                                            {
                                                MarkupAttribute attX = tagRenderingAction.Attributes["X"];
                                                MarkupAttribute attY = tagRenderingAction.Attributes["Y"];
                                                MarkupAttribute attWidth = tagRenderingAction.Attributes["Width"];
                                                MarkupAttribute attHeight = tagRenderingAction.Attributes["Height"];

                                                RectangleRenderingAction item = new RectangleRenderingAction();
                                                item.X = RenderingExpression.Parse(attX.Value);
                                                item.Y = RenderingExpression.Parse(attY.Value);
                                                item.Width = RenderingExpression.Parse(attWidth.Value);
                                                item.Height = RenderingExpression.Parse(attHeight.Value);

                                                item.Outline = OutlineFromTag(tagRenderingAction.Elements["Outline"] as MarkupTagElement);
                                                item.Fill = FillFromTag(tagRenderingAction.Elements["Fill"] as MarkupTagElement);

                                                rendering.Actions.Add(item);
                                                break;
                                            }
                                            case "Line":
                                            {
                                                LineRenderingAction item = new LineRenderingAction();

                                                MarkupAttribute attX1 = tagRenderingAction.Attributes["X1"];
                                                if (attX1 != null)
                                                {
                                                    item.X1 = RenderingExpression.Parse(attX1.Value);
                                                }
                                                MarkupAttribute attX2 = tagRenderingAction.Attributes["X2"];
                                                if (attX2 != null)
                                                {
                                                    item.X2 = RenderingExpression.Parse(attX2.Value);
                                                }
                                                MarkupAttribute attY1 = tagRenderingAction.Attributes["Y1"];
                                                if (attY1 != null)
                                                {
                                                    item.Y1 = RenderingExpression.Parse(attY1.Value);
                                                }
                                                MarkupAttribute attY2 = tagRenderingAction.Attributes["Y2"];
                                                if (attY2 != null)
                                                {
                                                    item.Y2 = RenderingExpression.Parse(attY2.Value);
                                                }

                                                item.Outline = OutlineFromTag(tagRenderingAction.Elements["Outline"] as MarkupTagElement);

                                                rendering.Actions.Add(item);
                                                break;
                                            }
                                            case "Text":
                                            {
                                                MarkupAttribute attX = tagRenderingAction.Attributes["X"];
                                                MarkupAttribute attY = tagRenderingAction.Attributes["Y"];
                                                MarkupAttribute attWidth = tagRenderingAction.Attributes["Width"];
                                                MarkupAttribute attHeight = tagRenderingAction.Attributes["Height"];

                                                if (attX == null || attY == null) continue;

                                                MarkupAttribute attHorizontalAlignment = tagRenderingAction.Attributes["HorizontalAlignment"];
                                                MarkupAttribute attVerticalAlignment = tagRenderingAction.Attributes["VerticalAlignment"];

                                                TextRenderingAction item = new TextRenderingAction();
                                                item.X = RenderingExpression.Parse(attX.Value);
                                                item.Y = RenderingExpression.Parse(attY.Value);

                                                if (attWidth != null) item.Width = RenderingExpression.Parse(attWidth.Value);
                                                if (attWidth != null) item.Height = RenderingExpression.Parse(attHeight.Value);

                                                if (attHorizontalAlignment != null)
                                                {
                                                    switch (attHorizontalAlignment.Value.ToLower())
                                                    {
                                                        case "center":
                                                        {
                                                            item.HorizontalAlignment = HorizontalAlignment.Center;
                                                            break;
                                                        }
                                                        case "justify":
                                                        {
                                                            item.HorizontalAlignment = HorizontalAlignment.Justify;
                                                            break;
                                                        }
                                                        case "left":
                                                        {
                                                            item.HorizontalAlignment = HorizontalAlignment.Left;
                                                            break;
                                                        }
                                                        case "right":
                                                        {
                                                            item.HorizontalAlignment = HorizontalAlignment.Right;
                                                            break;
                                                        }
                                                    }
                                                }

                                                if (attVerticalAlignment != null)
                                                {
                                                    switch (attVerticalAlignment.Value.ToLower())
                                                    {
                                                        case "bottom":
                                                        {
                                                            item.VerticalAlignment = VerticalAlignment.Bottom;
                                                            break;
                                                        }
                                                        case "middle":
                                                        {
                                                            item.VerticalAlignment = VerticalAlignment.Middle;
                                                            break;
                                                        }
                                                        case "top":
                                                        {
                                                            item.VerticalAlignment = VerticalAlignment.Top;
                                                            break;
                                                        }
                                                    }
                                                }

                                                MarkupAttribute attColor = tagRenderingAction.Attributes["Color"];
                                                if (attColor != null) item.Color = attColor.Value;

                                                MarkupAttribute attFont = tagRenderingAction.Attributes["Font"];
                                                if (attFont != null) item.Font = attFont.Value;

                                                MarkupAttribute attValue = tagRenderingAction.Attributes["Value"];
                                                if (attValue != null) item.Value = attValue.Value;

                                                rendering.Actions.Add(item);
                                                break;
                                            }
                                        }
                                    }

                                    MarkupTagElement tagRenderingStates = (tagRendering.Elements["States"] as MarkupTagElement);
                                    if (tagRenderingStates != null)
                                    {
                                        // if States is specified, only apply to specific states
                                        foreach (MarkupElement elState in tagRenderingStates.Elements)
                                        {
                                            MarkupTagElement tagState = (elState as MarkupTagElement);
                                            if (tagState == null) continue;
                                            if (tagState.FullName != "State") continue;

                                            MarkupAttribute attStateID = tagState.Attributes["ID"];
                                            if (attStateID == null) continue;

                                            ThemeComponentStateReference state = new ThemeComponentStateReference();
                                            state.StateID = new Guid(attStateID.Value);
                                            rendering.States.Add(state);
                                        }
                                    }

                                    component.Renderings.Add(rendering);
                                }
                            }

                            theme.Components.Add(component);
                        }
                    }
                    themes.Themes.Add(theme);
                }
            }
        }
コード例 #10
0
        public override void AddDefaultProperty(TMT propertyId, TMT primitiveType, object value)
        {
            var property = new ThemeProperty(State, -1, -1, propertyId, primitiveType, PropertyOrigin.Default, value);

            properties.Add(new OwnedThemePropertyViewModel(property));
        }
コード例 #11
0
        protected override void AfterLoadInternal(Stack <ObjectModel> objectModels)
        {
            base.AfterLoadInternal(objectModels);

            MarkupObjectModel mom    = (objectModels.Pop() as MarkupObjectModel);
            ThemeObjectModel  themes = (objectModels.Pop() as ThemeObjectModel);

            MarkupTagElement tagThemes = (mom.FindElement("AwesomeControls", "Theming", "Themes") as MarkupTagElement);

            if (tagThemes != null)
            {
                foreach (MarkupElement elTheme in tagThemes.Elements)
                {
                    MarkupTagElement tagTheme = (elTheme as MarkupTagElement);
                    if (tagTheme == null)
                    {
                        continue;
                    }

                    MarkupAttribute attThemeID = tagTheme.Attributes["ID"];
                    if (attThemeID == null)
                    {
                        continue;
                    }

                    Theme theme = new Theme();

                    UniversalEditor.Accessors.FileAccessor fa = (this.Accessor as UniversalEditor.Accessors.FileAccessor);
                    if (fa != null)
                    {
                        theme.BasePath = System.IO.Path.GetDirectoryName(fa.FileName);
                    }

                    theme.ID = new Guid(attThemeID.Value);

                    MarkupAttribute attInheritsThemeID = tagTheme.Attributes["InheritsThemeID"];
                    if (attInheritsThemeID != null)
                    {
                        theme.InheritsThemeID = new Guid(attInheritsThemeID.Value);
                    }

                    MarkupTagElement tagInformation = (tagTheme.Elements["Information"] as MarkupTagElement);
                    if (tagInformation != null)
                    {
                        MarkupTagElement tagInformationTitle = (tagInformation.Elements["Title"] as MarkupTagElement);
                        if (tagInformationTitle != null)
                        {
                            theme.Title = tagInformationTitle.Value;
                        }
                    }

                    MarkupTagElement tagMetrics = (tagTheme.Elements["Metrics"] as MarkupTagElement);
                    if (tagMetrics != null)
                    {
                        foreach (MarkupElement elMetric in tagMetrics.Elements)
                        {
                            MarkupTagElement tagMetric = (elMetric as MarkupTagElement);
                            if (tagMetric == null)
                            {
                                continue;
                            }

                            MarkupAttribute attMetricName = tagMetric.Attributes["Name"];
                            if (attMetricName == null)
                            {
                                continue;
                            }

                            switch (tagMetric.FullName.ToLower())
                            {
                            case "paddingmetric":
                            {
                                PaddingMetric metric = new PaddingMetric();
                                metric.Name = attMetricName.Value;

                                MarkupAttribute attMetricLeft = tagMetric.Attributes["Left"];
                                if (attMetricLeft != null)
                                {
                                    metric.Left = Single.Parse(attMetricLeft.Value);
                                }
                                MarkupAttribute attMetricTop = tagMetric.Attributes["Top"];
                                if (attMetricTop != null)
                                {
                                    metric.Top = Single.Parse(attMetricTop.Value);
                                }
                                MarkupAttribute attMetricBottom = tagMetric.Attributes["Bottom"];
                                if (attMetricBottom != null)
                                {
                                    metric.Bottom = Single.Parse(attMetricBottom.Value);
                                }
                                MarkupAttribute attMetricRight = tagMetric.Attributes["Right"];
                                if (attMetricRight != null)
                                {
                                    metric.Right = Single.Parse(attMetricRight.Value);
                                }

                                theme.Metrics.Add(metric);
                                break;
                            }
                            }
                        }
                    }

                    MarkupTagElement tagColors = (tagTheme.Elements["Colors"] as MarkupTagElement);
                    if (tagColors != null)
                    {
                        foreach (MarkupElement elColor in tagColors.Elements)
                        {
                            MarkupTagElement tagColor = (elColor as MarkupTagElement);
                            if (tagColor == null)
                            {
                                continue;
                            }
                            if (tagColor.FullName != "Color")
                            {
                                continue;
                            }

                            MarkupAttribute attColorID   = tagColor.Attributes["ID"];
                            MarkupAttribute attColorName = tagColor.Attributes["Name"];

                            if (attColorID == null && attColorName == null)
                            {
                                continue;
                            }

                            MarkupAttribute attColorValue = tagColor.Attributes["Value"];
                            if (attColorValue == null)
                            {
                                continue;
                            }

                            ThemeColor color = new ThemeColor();
                            if (attColorID != null)
                            {
                                color.ID = new Guid(attColorID.Value);
                            }
                            if (attColorName != null)
                            {
                                color.Name = attColorName.Value;
                            }
                            if (attColorValue != null)
                            {
                                color.Value = attColorValue.Value;
                            }

                            theme.Colors.Add(color);
                        }
                    }

                    MarkupTagElement tagFonts = (tagTheme.Elements["Fonts"] as MarkupTagElement);
                    if (tagFonts != null)
                    {
                        foreach (MarkupElement elFont in tagFonts.Elements)
                        {
                            MarkupTagElement tagFont = (elFont as MarkupTagElement);
                            if (tagFont == null)
                            {
                                continue;
                            }
                            if (tagFont.FullName != "Font")
                            {
                                continue;
                            }

                            MarkupAttribute attFontName = tagFont.Attributes["Name"];
                            if (attFontName == null)
                            {
                                continue;
                            }

                            MarkupAttribute attFontValue = tagFont.Attributes["Value"];
                            if (attFontValue == null)
                            {
                                continue;
                            }

                            ThemeFont font = new ThemeFont();
                            font.Name  = attFontName.Value;
                            font.Value = attFontValue.Value;

                            theme.Fonts.Add(font);
                        }
                    }

                    MarkupTagElement tagStockImages = (tagTheme.Elements["StockImages"] as MarkupTagElement);
                    if (tagStockImages != null)
                    {
                        foreach (MarkupElement elStockImage in tagStockImages.Elements)
                        {
                            MarkupTagElement tagStockImage = (elStockImage as MarkupTagElement);
                            if (tagStockImage == null)
                            {
                                continue;
                            }
                            if (tagStockImage.FullName != "StockImage")
                            {
                                continue;
                            }

                            MarkupAttribute attStockImageName = tagStockImage.Attributes["Name"];
                            if (attStockImageName == null)
                            {
                                continue;
                            }

                            MarkupAttribute attStockImageFileName = tagStockImage.Attributes["FileName"];
                            if (attStockImageFileName == null)
                            {
                                continue;
                            }

                            ThemeStockImage stockImage = new ThemeStockImage();
                            stockImage.Name          = attStockImageName.Value;
                            stockImage.ImageFileName = attStockImageFileName.Value;

                            theme.StockImages.Add(stockImage);
                        }
                    }

                    MarkupTagElement tagProperties = (tagTheme.Elements["Properties"] as MarkupTagElement);
                    if (tagProperties != null)
                    {
                        foreach (MarkupElement elProperty in tagProperties.Elements)
                        {
                            MarkupTagElement tagProperty = (elProperty as MarkupTagElement);
                            if (tagProperty == null)
                            {
                                continue;
                            }
                            if (tagProperty.FullName != "Property")
                            {
                                continue;
                            }

                            MarkupAttribute attName = tagProperty.Attributes["Name"];
                            if (attName == null)
                            {
                                continue;
                            }

                            ThemeProperty property = new ThemeProperty();
                            property.Name = attName.Value;

                            MarkupAttribute attValue = tagProperty.Attributes["Value"];
                            if (attValue != null)
                            {
                                property.Value = attValue.Value;
                            }

                            theme.Properties.Add(property);
                        }
                    }

                    MarkupTagElement tagComponents = (tagTheme.Elements["Components"] as MarkupTagElement);
                    if (tagComponents != null)
                    {
                        foreach (MarkupElement elComponent in tagComponents.Elements)
                        {
                            MarkupTagElement tagComponent = (elComponent as MarkupTagElement);
                            if (tagComponent == null)
                            {
                                continue;
                            }
                            if (tagComponent.FullName != "Component")
                            {
                                continue;
                            }

                            MarkupAttribute attComponentID = tagComponent.Attributes["ID"];
                            if (attComponentID == null)
                            {
                                continue;
                            }

                            ThemeComponent component = new ThemeComponent();
                            component.ID = new Guid(attComponentID.Value);

                            MarkupAttribute attInheritsComponentID = tagComponent.Attributes["InheritsComponentID"];
                            if (attInheritsComponentID != null)
                            {
                                component.InheritsComponentID = new Guid(attInheritsComponentID.Value);
                            }

                            MarkupTagElement tagComponentStates = (tagComponent.Elements["States"] as MarkupTagElement);
                            if (tagComponentStates != null)
                            {
                                // if States is specified, only apply to specific states
                                foreach (MarkupElement elState in tagComponentStates.Elements)
                                {
                                    MarkupTagElement tagState = (elState as MarkupTagElement);
                                    if (tagState == null)
                                    {
                                        continue;
                                    }
                                    if (tagState.FullName != "State")
                                    {
                                        continue;
                                    }

                                    MarkupAttribute attStateID = tagState.Attributes["ID"];
                                    if (attStateID == null)
                                    {
                                        continue;
                                    }

                                    ThemeComponentState state = new ThemeComponentState();
                                    state.ID = new Guid(attStateID.Value);

                                    MarkupAttribute attStateName = tagState.Attributes["Name"];
                                    if (attStateName != null)
                                    {
                                        state.Name = attStateName.Value;
                                    }

                                    component.States.Add(state);
                                }
                            }

                            MarkupTagElement tagRenderings = (tagComponent.Elements["Renderings"] as MarkupTagElement);
                            if (tagRenderings != null)
                            {
                                foreach (MarkupElement elRendering in tagRenderings.Elements)
                                {
                                    MarkupTagElement tagRendering = (elRendering as MarkupTagElement);
                                    if (tagRendering == null)
                                    {
                                        continue;
                                    }
                                    if (tagRendering.FullName != "Rendering")
                                    {
                                        continue;
                                    }

                                    MarkupTagElement tagRenderingActions = (tagRendering.Elements["Actions"] as MarkupTagElement);
                                    if (tagRenderingActions == null)
                                    {
                                        continue;
                                    }

                                    Rendering rendering = new Rendering();
                                    foreach (MarkupElement elRenderingAction in tagRenderingActions.Elements)
                                    {
                                        MarkupTagElement tagRenderingAction = (elRenderingAction as MarkupTagElement);
                                        if (tagRenderingAction == null)
                                        {
                                            continue;
                                        }

                                        switch (tagRenderingAction.FullName)
                                        {
                                        case "Rectangle":
                                        {
                                            MarkupAttribute attX      = tagRenderingAction.Attributes["X"];
                                            MarkupAttribute attY      = tagRenderingAction.Attributes["Y"];
                                            MarkupAttribute attWidth  = tagRenderingAction.Attributes["Width"];
                                            MarkupAttribute attHeight = tagRenderingAction.Attributes["Height"];

                                            RectangleRenderingAction item = new RectangleRenderingAction();
                                            item.X      = RenderingExpression.Parse(attX.Value);
                                            item.Y      = RenderingExpression.Parse(attY.Value);
                                            item.Width  = RenderingExpression.Parse(attWidth.Value);
                                            item.Height = RenderingExpression.Parse(attHeight.Value);

                                            item.Outline = OutlineFromTag(tagRenderingAction.Elements["Outline"] as MarkupTagElement);
                                            item.Fill    = FillFromTag(tagRenderingAction.Elements["Fill"] as MarkupTagElement);

                                            rendering.Actions.Add(item);
                                            break;
                                        }

                                        case "Line":
                                        {
                                            LineRenderingAction item = new LineRenderingAction();

                                            MarkupAttribute attX1 = tagRenderingAction.Attributes["X1"];
                                            if (attX1 != null)
                                            {
                                                item.X1 = RenderingExpression.Parse(attX1.Value);
                                            }
                                            MarkupAttribute attX2 = tagRenderingAction.Attributes["X2"];
                                            if (attX2 != null)
                                            {
                                                item.X2 = RenderingExpression.Parse(attX2.Value);
                                            }
                                            MarkupAttribute attY1 = tagRenderingAction.Attributes["Y1"];
                                            if (attY1 != null)
                                            {
                                                item.Y1 = RenderingExpression.Parse(attY1.Value);
                                            }
                                            MarkupAttribute attY2 = tagRenderingAction.Attributes["Y2"];
                                            if (attY2 != null)
                                            {
                                                item.Y2 = RenderingExpression.Parse(attY2.Value);
                                            }

                                            item.Outline = OutlineFromTag(tagRenderingAction.Elements["Outline"] as MarkupTagElement);

                                            rendering.Actions.Add(item);
                                            break;
                                        }

                                        case "Text":
                                        {
                                            MarkupAttribute attX      = tagRenderingAction.Attributes["X"];
                                            MarkupAttribute attY      = tagRenderingAction.Attributes["Y"];
                                            MarkupAttribute attWidth  = tagRenderingAction.Attributes["Width"];
                                            MarkupAttribute attHeight = tagRenderingAction.Attributes["Height"];

                                            if (attX == null || attY == null)
                                            {
                                                continue;
                                            }

                                            MarkupAttribute attHorizontalAlignment = tagRenderingAction.Attributes["HorizontalAlignment"];
                                            MarkupAttribute attVerticalAlignment   = tagRenderingAction.Attributes["VerticalAlignment"];

                                            TextRenderingAction item = new TextRenderingAction();
                                            item.X = RenderingExpression.Parse(attX.Value);
                                            item.Y = RenderingExpression.Parse(attY.Value);

                                            if (attWidth != null)
                                            {
                                                item.Width = RenderingExpression.Parse(attWidth.Value);
                                            }
                                            if (attWidth != null)
                                            {
                                                item.Height = RenderingExpression.Parse(attHeight.Value);
                                            }

                                            if (attHorizontalAlignment != null)
                                            {
                                                switch (attHorizontalAlignment.Value.ToLower())
                                                {
                                                case "center":
                                                {
                                                    item.HorizontalAlignment = HorizontalAlignment.Center;
                                                    break;
                                                }

                                                case "justify":
                                                {
                                                    item.HorizontalAlignment = HorizontalAlignment.Justify;
                                                    break;
                                                }

                                                case "left":
                                                {
                                                    item.HorizontalAlignment = HorizontalAlignment.Left;
                                                    break;
                                                }

                                                case "right":
                                                {
                                                    item.HorizontalAlignment = HorizontalAlignment.Right;
                                                    break;
                                                }
                                                }
                                            }

                                            if (attVerticalAlignment != null)
                                            {
                                                switch (attVerticalAlignment.Value.ToLower())
                                                {
                                                case "bottom":
                                                {
                                                    item.VerticalAlignment = VerticalAlignment.Bottom;
                                                    break;
                                                }

                                                case "middle":
                                                {
                                                    item.VerticalAlignment = VerticalAlignment.Middle;
                                                    break;
                                                }

                                                case "top":
                                                {
                                                    item.VerticalAlignment = VerticalAlignment.Top;
                                                    break;
                                                }
                                                }
                                            }

                                            MarkupAttribute attColor = tagRenderingAction.Attributes["Color"];
                                            if (attColor != null)
                                            {
                                                item.Color = attColor.Value;
                                            }

                                            MarkupAttribute attFont = tagRenderingAction.Attributes["Font"];
                                            if (attFont != null)
                                            {
                                                item.Font = attFont.Value;
                                            }

                                            MarkupAttribute attValue = tagRenderingAction.Attributes["Value"];
                                            if (attValue != null)
                                            {
                                                item.Value = attValue.Value;
                                            }

                                            rendering.Actions.Add(item);
                                            break;
                                        }
                                        }
                                    }

                                    MarkupTagElement tagRenderingStates = (tagRendering.Elements["States"] as MarkupTagElement);
                                    if (tagRenderingStates != null)
                                    {
                                        // if States is specified, only apply to specific states
                                        foreach (MarkupElement elState in tagRenderingStates.Elements)
                                        {
                                            MarkupTagElement tagState = (elState as MarkupTagElement);
                                            if (tagState == null)
                                            {
                                                continue;
                                            }
                                            if (tagState.FullName != "State")
                                            {
                                                continue;
                                            }

                                            MarkupAttribute attStateID = tagState.Attributes["ID"];
                                            if (attStateID == null)
                                            {
                                                continue;
                                            }

                                            ThemeComponentStateReference state = new ThemeComponentStateReference();
                                            state.StateID = new Guid(attStateID.Value);
                                            rendering.States.Add(state);
                                        }
                                    }

                                    component.Renderings.Add(rendering);
                                }
                            }

                            theme.Components.Add(component);
                        }
                    }
                    themes.Themes.Add(theme);
                }
            }
        }
コード例 #12
0
 /// <summary>
 /// Indicates wether <see cref="ThemeProperty"/> needs to be serialized by designer or not.
 /// </summary>
 /// <returns>true if designer needs to serialize</returns>
 protected bool ShouldSerializeThemeProperty()
 {
     return(ThemeProperty.DefaultChanged());
 }
コード例 #13
0
 /// <summary>
 /// Resets Theme Property to Default Value.
 /// </summary>
 protected void ResetThemeProperty()
 {
     ThemeProperty.Reset();
 }
コード例 #14
0
    public void Read(TProtocol iprot)
    {
        iprot.IncrementRecursionDepth();
        try
        {
            TField field;
            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }
                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.Struct)
                    {
                        StickerProperty = new StickerProperty();
                        StickerProperty.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 3:
                    if (field.Type == TType.Struct)
                    {
                        SticonProperty = new SticonProperty();
                        SticonProperty.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.Struct)
                    {
                        ThemeProperty = new ThemeProperty();
                        ThemeProperty.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                default:
                    TProtocolUtil.Skip(iprot, field.Type);
                    break;
                }
                iprot.ReadFieldEnd();
            }
            iprot.ReadStructEnd();
        }
        finally
        {
            iprot.DecrementRecursionDepth();
        }
    }
コード例 #15
0
 public OwnedThemePropertyViewModel(ThemeProperty property)
 {
     this.property = property;
     Value         = ConvertValue(property);
 }