コード例 #1
0
        public void Generate(StreamWriter xamlWriter, int indentation, IGeneratorColorTheme colorTheme)
        {
            string s          = GeneratorLayout.IndentationString(indentation);
            string Properties = $" Template=\"{{StaticResource {XamlName}}}\"";

            colorTheme.WriteXamlLine(xamlWriter, $"{s}<ContentControl{Properties}/>");
        }
コード例 #2
0
        public override void Generate(Dictionary <IGeneratorArea, IGeneratorLayout> areaLayouts, IList <IGeneratorPage> pageList, IGeneratorDesign design, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation          = GeneratorLayout.IndentationString(indentation);
            string AttachedProperties   = GetAttachedProperties();
            string StackPanelProperties = GetPanelProperties(currentPage, currentObject);
            string ElementProperties    = GetElementProperties(currentPage, currentObject);

            string PanelType;

            switch (Orientation)
            {
            case Orientation.Horizontal:
                PanelType = "WrapPanel";
                break;

            default:
            case Orientation.Vertical:
                PanelType = "StackPanel";
                break;
            }

            string AllProperties = $"{AttachedProperties}{visibilityBinding}{StackPanelProperties}{ElementProperties}";

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<{PanelType}{AllProperties}>");

            foreach (IGeneratorLayoutElement element in Items)
            {
                element.Generate(areaLayouts, pageList, design, indentation + 1, currentPage, currentObject, colorTheme, xamlWriter, "");
            }

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}</{PanelType}>");
        }
コード例 #3
0
        public override void Generate(Dictionary <IGeneratorArea, IGeneratorLayout> areaLayouts, IList <IGeneratorPage> pageList, IGeneratorDesign design, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation          = GeneratorLayout.IndentationString(indentation);
            string AttachedProperties   = GetAttachedProperties();
            string StatePanelProperties = GetPanelProperties(currentPage, currentObject);
            string ElementProperties    = GetElementProperties(currentPage, currentObject);

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<Grid{AttachedProperties}{visibilityBinding}{StatePanelProperties}{ElementProperties}>");

            List <string> Parameters = new List <string>();

            for (int i = 0; i < Items.Count; i++)
            {
                Parameters.Add(i.ToString());
            }

            IGeneratorObjectPropertyIndex IndexObjectProperty = Component.IndexObjectProperty;
            int Index = 0;

            foreach (IGeneratorLayoutElement Element in Items)
            {
                string IndexReference    = Component.GetObjectBinding(currentObject, Component.IndexObject, Component.IndexObjectProperty);
                string VisibilityBinding = $" Visibility=\"{{Binding {IndexReference}, Converter={{StaticResource convIndexToVisibility}}, ConverterParameter={Parameters[Index++]}}}\"";
                Element.Generate(areaLayouts, pageList, design, indentation + 1, currentPage, currentObject, colorTheme, xamlWriter, VisibilityBinding);
            }

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}</Grid>");
        }
コード例 #4
0
        public override void Generate(Dictionary <IGeneratorArea, IGeneratorLayout> areaLayouts, IList <IGeneratorPage> pageList, IGeneratorDesign design, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation        = GeneratorLayout.IndentationString(indentation);
            string AttachedProperties = GetAttachedProperties();
            string ElementProperties  = GetElementProperties(currentPage, currentObject);
            string BorderProperties   = GetPanelProperties(currentPage, currentObject);

            if (!string.IsNullOrEmpty(CornerRadius))
            {
                BorderProperties += $" CornerRadius=\"{CornerRadius}\"";
            }

            if (!string.IsNullOrEmpty(BorderBrush))
            {
                BorderProperties += $" BorderBrush=\"{BorderBrush}\"";
            }

            if (!string.IsNullOrEmpty(BorderThickness))
            {
                BorderProperties += $" BorderThickness=\"{BorderThickness}\"";
            }

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<Border{AttachedProperties}{visibilityBinding}{BorderProperties}{ElementProperties}>");

            foreach (IGeneratorLayoutElement element in Items)
            {
                element.Generate(areaLayouts, pageList, design, indentation + 1, currentPage, currentObject, colorTheme, xamlWriter, "");
            }

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}</Border>");
        }
コード例 #5
0
ファイル: GeneratorDesign.cs プロジェクト: dlebansais/Wrist
        public void Generate(IGeneratorDomain domain, StreamWriter xamlWriter, bool declareXmlns, int indentation, IGeneratorColorTheme colorTheme)
        {
            string s = GeneratorLayout.IndentationString(indentation);

            if (declareXmlns)
            {
                colorTheme.WriteXamlLine(xamlWriter, s + "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"");
                colorTheme.WriteXamlLine(xamlWriter, s + "                    xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">");
            }
            else
            {
                colorTheme.WriteXamlLine(xamlWriter, s + "<ResourceDictionary>");
            }

            indentation++;

            foreach (object Key in Root.Keys)
            {
                string StyleKey = KeyToString(Key);
                object Item     = Root[Key];
                string Content  = System.Windows.Markup.XamlWriter.Save(Item);
                Content = CleanupXaml(StyleKey, Content, indentation);
                colorTheme.WriteXamlLine(xamlWriter, Content);
            }

            colorTheme.WriteXamlLine(xamlWriter, s + "</ResourceDictionary>");
        }
コード例 #6
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation = GeneratorLayout.IndentationString(indentation);
            string Properties  = $" Style=\"{{StaticResource {GetStyleResourceKey(design, styleName)}}}\"";
            string Value       = GetComponentValue(currentPage, currentObject, null, IndexObject, IndexObjectProperty, null, false);

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<TextBlock{attachedProperties}{visibilityBinding} Text=\"{Value}\"{Properties}{elementProperties}/>");
        }
コード例 #7
0
        public static void Generate(IGeneratorArea area, string attachedProperties, string elementProperties, int indentation, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding, double width)
        {
            string s             = GeneratorLayout.IndentationString(indentation);
            string Properties    = $" Template=\"{{StaticResource {area.XamlName}}}\"";
            string WidthProperty = double.IsNaN(width) ? "" : $" HorizontalAlignment=\"Center\" Width=\"{width}\"";

            colorTheme.WriteXamlLine(xamlWriter, $"{s}<ContentControl{attachedProperties}{visibilityBinding}{Properties}{elementProperties}{WidthProperty}/>");
        }
コード例 #8
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation = GeneratorLayout.IndentationString(indentation);
            string Properties  = "";
            string Value       = GetComponentValue(currentPage, currentObject, HtmlResource, HtmlObject, HtmlObjectProperty, HtmlKey, false);

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<n:HtmlPresenter{attachedProperties}{visibilityBinding} Content=\"{Value}\"{Properties}{elementProperties}/>");
        }
コード例 #9
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation    = GeneratorLayout.IndentationString(indentation);
            string Properties     = "";
            string Value          = GetComponentValue(currentPage, currentObject, null, ItemObject, ItemObjectProperty, null, false);
            string ContentBinding = $" ItemsSource=\"{Value}\"";
            string AreaTemplate   = $" ItemTemplate=\"{{StaticResource {ItemNestedArea.XamlName}}}\"";

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<ItemsControl{attachedProperties}{visibilityBinding}{ContentBinding}{AreaTemplate}{Properties}{elementProperties}/>");
        }
コード例 #10
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation           = GeneratorLayout.IndentationString(indentation);
            string MaximumLengthProperty = ((TextObjectProperty != null && TextObjectProperty.MaximumLength > 0) ? $" MaxLength=\"{TextObjectProperty.MaximumLength}\"" : "");
            string Properties            = $" Style=\"{{StaticResource {GetStyleResourceKey(design, styleName)}}}\"{MaximumLengthProperty}";
            //string Value = GetComponentValue(currentPage, currentObject, null, TextObject, TextObjectProperty, null, true);
            string Events = currentPage.Dynamic.HasProperties ? $" Loaded=\"{LoadedEventName}\" PasswordChanged=\"{PasswordChangedEventName}\"" : "";

            //colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<PasswordBox x:Name=\"{ControlName}\"{attachedProperties}{visibilityBinding} Password=\"{Value}\"{ValueChangedEvent}{LoadedEvent}{Properties}{elementProperties}/>");
            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<PasswordBox x:Name=\"{ControlName}\"{attachedProperties}{visibilityBinding}{Events}{Properties}{elementProperties}/>");
        }
コード例 #11
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation      = GeneratorLayout.IndentationString(indentation);
            string Properties       = $" Style=\"{{StaticResource {GetStyleResourceKey(design, styleName)}}}\" GroupName=\"{GroupName}\"";
            string ContentValue     = GetComponentValue(currentPage, currentObject, ContentResource, ContentObject, ContentObjectProperty, ContentKey, false);
            string IndexValue       = GetObjectBinding(currentObject, IndexObject, IndexObjectProperty);
            string IsCheckedBinding = $"{{Binding {IndexValue}, Mode=TwoWay, Converter={{StaticResource convIndexToChecked}}, ConverterParameter={GroupIndex}}}";
            string CheckedEvent     = currentPage.Dynamic.HasProperties ? $" Checked=\"{GetChangedHandlerName(IndexObject, IndexObjectProperty)}\"" : "";

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<RadioButton{attachedProperties}{visibilityBinding}{Properties}{elementProperties} IsChecked=\"{IsCheckedBinding}\"{CheckedEvent} Content=\"{ContentValue}\"/>");
        }
コード例 #12
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation      = GeneratorLayout.IndentationString(indentation);
            string Properties       = $" Style=\"{{StaticResource {GetStyleResourceKey(design, styleName)}}}\"";
            string Content          = GetComponentValue(currentPage, currentObject, ContentResource, ContentObject, ContentObjectProperty, ContentKey, false);
            string IsCheckedBinding = GetComponentValue(currentPage, currentObject, null, CheckedObject, CheckedObjectProperty, null, true);
            string CheckedEvent     = currentPage.Dynamic.HasProperties ? $" Checked=\"{GetChangedHandlerName(CheckedObject, CheckedObjectProperty)}\"" : "";
            string UncheckedEvent   = currentPage.Dynamic.HasProperties ? $" Unchecked=\"{GetChangedHandlerName(CheckedObject, CheckedObjectProperty)}\"" : "";

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<CheckBox{attachedProperties}{visibilityBinding}{Properties}{elementProperties} IsChecked=\"{IsCheckedBinding}\"{CheckedEvent}{UncheckedEvent} Content=\"{Content}\"/>");
        }
コード例 #13
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation        = GeneratorLayout.IndentationString(indentation);
            string AlignmentProperty  = (isHorizontalAlignmentStretch ? $" TextAlignment=\"Justify\"" : "");
            string WrappingProperty   = ((textWrapping.HasValue && textWrapping.Value == TextWrapping.NoWrap) ? " TextWrapping=\"NoWrap\"" : " TextWrapping=\"Wrap\"");
            string DecorationProperty = (TextDecoration != null ? $" TextDecorations=\"{TextDecoration}\"" : "");
            string Properties         = $" Style=\"{{StaticResource {GetStyleResourceKey(design, styleName)}}}\"{AlignmentProperty}{WrappingProperty}{DecorationProperty}";
            string Value = GetComponentValue(currentPage, currentObject, TextResource, TextObject, TextObjectProperty, TextKey, false);

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<TextBlock{attachedProperties}{visibilityBinding} Text=\"{Value}\"{Properties}{elementProperties}/>");
        }
コード例 #14
0
        public override void Generate(Dictionary <IGeneratorArea, IGeneratorLayout> areaLayouts, IList <IGeneratorPage> pageList, IGeneratorDesign design, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation        = GeneratorLayout.IndentationString(indentation);
            string AttachedProperties = GetAttachedProperties();
            string WrappingProperty   = ((TextWrapping.HasValue && TextWrapping.Value == Windows.UI.Xaml.TextWrapping.NoWrap) ? " TextWrapping=\"NoWrap\"" : " TextWrapping=\"Wrap\"");
            string Properties         = $" Style=\"{{StaticResource {GetStyleResourceKey(design)}}}\"";
            string ElementProperties  = GetElementProperties(currentPage, currentObject);

            /*
             * Debug.Assert(TextToSpan("test") == "test");
             *
             * Debug.Assert(TextToSpan("<i/>") == "");
             * Debug.Assert(TextToSpan("<i></i>") == "");
             * Debug.Assert(TextToSpan("<i>test</i>") == "<Italic>test</Italic>");
             * Debug.Assert(TextToSpan("x<i>test</i>") == "x<Italic>test</Italic>");
             * Debug.Assert(TextToSpan("<i>test</i>x") == "<Italic>test</Italic>x");
             * Debug.Assert(TextToSpan("x<i>test</i>x") == "x<Italic>test</Italic>x");
             * Debug.Assert(TextToSpan("<i>test") == "<Italic>test</Italic>");
             * Debug.Assert(TextToSpan("x<i>test") == "x<Italic>test</Italic>");
             * Debug.Assert(TextToSpan("<i>test</i><i>test</i>") == "<Italic>test</Italic><Italic>test</Italic>");
             * Debug.Assert(TextToSpan("<i>test</i>x<i>test</i>") == "<Italic>test</Italic>x<Italic>test</Italic>");
             * Debug.Assert(TextToSpan("<i>test</i>x<i>test</i>x") == "<Italic>test</Italic>x<Italic>test</Italic>x");
             * Debug.Assert(TextToSpan("<i>test</i><i>test") == "<Italic>test</Italic><Italic>test</Italic>");
             * Debug.Assert(TextToSpan("<i>test</i>x<i>test") == "<Italic>test</Italic>x<Italic>test</Italic>");
             * Debug.Assert(TextToSpan("x<i>test</i><i>test") == "x<Italic>test</Italic><Italic>test</Italic>");
             * Debug.Assert(TextToSpan("x<i>test</i>x<i>test") == "x<Italic>test</Italic>x<Italic>test</Italic>");
             *
             * Debug.Assert(TextToSpan("<b>test</b>") == "<Bold>test</Bold>");
             * Debug.Assert(TextToSpan("<u>test</u>") == "<Underline>test</Underline>");
             * Debug.Assert(TextToSpan("<p/>test") == "<LineBreak/>test");
             * Debug.Assert(TextToSpan("<z>test</z>") == "<z>test</z>");
             *
             * Debug.Assert(TextToSpan("<font>test</font>") == "<Span>test</Span>");
             * Debug.Assert(TextToSpan("<font size=\"20\">test</font>") == "<Span FontSize=\"20\">test</Span>");
             * Debug.Assert(TextToSpan("<font color=\"Red\">test</font>") == "<Span Foreground=\"Red\">test</Span>");
             * Debug.Assert(TextToSpan("<font background=\"Red\">test</font>") == "<Span Background=\"Red\">test</Span>");
             * Debug.Assert(TextToSpan("<font face=\"Verdana\">test</font>") == "<Span FontFamily=\"Verdana\">test</Span>");
             * Debug.Assert(TextToSpan("<font face=\"Verdana\" size=\"20\" background=\"Red\" color=\"Red\">test</font>") == "<Span FontFamily=\"Verdana\" FontSize=\"20\" Background=\"Red\" Foreground=\"Red\">test</Span>");
             *
             * Debug.Assert(TextToSpan("<font size=\"20\">te<i>xx</i><b>st</b></font>") == "<Span FontSize=\"20\">te<Italic>xx</Italic><Bold>st</Bold></Span>");
             */

            string SpanText = TextToSpan(Text, pageList);

            if (SpanText == Text)
            {
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<TextBlock{AttachedProperties}{visibilityBinding} Text=\"{SpanText}\"{Properties}{ElementProperties}{WrappingProperty}/>");
            }
            else
            {
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<TextBlock{AttachedProperties}{visibilityBinding}{Properties}{ElementProperties}{WrappingProperty}>{SpanText}</TextBlock>");
            }
        }
コード例 #15
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation       = GeneratorLayout.IndentationString(indentation);
            string Properties        = $" Style=\"{{StaticResource {GetStyleResourceKey(design, styleName)}}}\"";
            string IndexValue        = GetComponentValue(currentPage, currentObject, null, IndexObject, IndexObjectProperty, null, false);
            string ItemsValue        = GetComponentValue(currentPage, currentObject, ItemsResource, ItemsObject, ItemsObjectProperty, null, false);
            string LoadedEvent       = currentPage.Dynamic.HasProperties ? $" Loaded=\"{GetLoadedHandlerName(IndexObject, IndexObjectProperty)}\"" : "";
            string ValueChangedEvent = currentPage.Dynamic.HasProperties ? $" SelectionChanged=\"{GetChangedHandlerName(IndexObject, IndexObjectProperty)}\"" : "";

            // SelectedIndex must be first, no clue why.
            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<p:ListBox x:Name=\"{ControlName}\"{attachedProperties}{visibilityBinding}{Properties}{elementProperties} ControlSelectedIndex=\"{IndexValue}\"{LoadedEvent}{ValueChangedEvent} ItemsSource=\"{ItemsValue}\"/>");
        }
コード例 #16
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            double LocalWidth  = double.IsNaN(Width) ? SourceResource.Width : Width;
            double LocalHeight = double.IsNaN(Height) ? SourceResource.Height : Height;

            string Indentation     = GeneratorLayout.IndentationString(indentation);
            string WidthProperty   = double.IsNaN(Width) ? "" : $" Width=\"{Width}\"";
            string HeightProperty  = double.IsNaN(Height) ? "" : $" Height=\"{Height}\"";
            string StretchProperty = (double.IsNaN(Width) && double.IsNaN(Height)) ? " Stretch=\"Uniform\"" : "";
            string Properties      = $" Style=\"{{StaticResource {GetStyleResourceKey(design, styleName)}}}\"{StretchProperty}{WidthProperty}{HeightProperty}";
            string Value           = GetComponentValue(currentPage, currentObject, SourceResource, null, null, null, false);

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<Image{attachedProperties}{visibilityBinding} Source=\"{Value}\"{Properties}{elementProperties}/>");
        }
コード例 #17
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation                 = GeneratorLayout.IndentationString(indentation);
            string MaximumLengthProperty       = ((TextObjectProperty != null && TextObjectProperty.MaximumLength > 0) ? $" MaxLength=\"{TextObjectProperty.MaximumLength}\"" : "");
            string AcceptsReturnProperty       = (AcceptsReturn ? " AcceptsReturn=\"True\"" : "");
            string AlignmentProperty           = (isHorizontalAlignmentStretch ? $" TextAlignment=\"Justify\"" : "");
            string WrappingProperty            = ((textWrapping.HasValue && textWrapping.Value == TextWrapping.Wrap) ? " TextWrapping=\"Wrap\"" : " TextWrapping=\"NoWrap\"");
            string DecorationProperty          = (TextDecoration != null ? $" TextDecorations=\"{TextDecoration}\"" : "");
            string HorizontalScrollBarProperty = (HorizontalScrollBarVisibility != null ? $" HorizontalScrollBarVisibility=\"{HorizontalScrollBarVisibility}\"" : "");
            string VerticalScrollBarProperty   = (VerticalScrollBarVisibility != null ? $" VerticalScrollBarVisibility=\"{VerticalScrollBarVisibility}\"" : "");
            string Properties        = $" Style=\"{{StaticResource {GetStyleResourceKey(design, styleName)}}}\"{MaximumLengthProperty}{AcceptsReturnProperty}{AlignmentProperty}{WrappingProperty}{DecorationProperty}{HorizontalScrollBarProperty}{VerticalScrollBarProperty}";
            string Value             = GetComponentValue(currentPage, currentObject, null, TextObject, TextObjectProperty, null, true);
            string ValueChangedEvent = currentPage.Dynamic.HasProperties ? $" TextChanged=\"{TextChangedEventName}\"" : "";

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<TextBox x:Name=\"{ControlName}\"{attachedProperties}{visibilityBinding} Text=\"{Value}\"{ValueChangedEvent}{Properties}{elementProperties}/>");
        }
コード例 #18
0
ファイル: GeneratorEmpty.cs プロジェクト: dlebansais/Wrist
        public override void Generate(Dictionary <IGeneratorArea, IGeneratorLayout> areaLayouts, IList <IGeneratorPage> pageList, IGeneratorDesign design, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation        = GeneratorLayout.IndentationString(indentation);
            string AttachedProperties = GetAttachedProperties();
            string ElementProperties  = GetElementProperties(currentPage, currentObject);

            if (Type == "Button")
            {
                string Properties = $" Style=\"{{StaticResource {GetButtonStyleResourceKey(design)}}}\"";
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<Button{AttachedProperties}{visibilityBinding}{Properties}{ElementProperties} Opacity=\"0\"/>");
            }
            else
            {
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<Grid{AttachedProperties}{visibilityBinding}{ElementProperties}/>");
            }
        }
コード例 #19
0
        public override void Generate(Dictionary <IGeneratorArea, IGeneratorLayout> areaLayouts, IList <IGeneratorPage> pageList, IGeneratorDesign design, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation         = GeneratorLayout.IndentationString(indentation);
            string AttachedProperties  = GetAttachedProperties();
            string ElementProperties   = GetElementProperties(currentPage, currentObject);
            string DockPanelProperties = GetPanelProperties(currentPage, currentObject);
            string AllProperties       = $"{AttachedProperties}{visibilityBinding}{DockPanelProperties}{ElementProperties}";

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<DockPanel{AllProperties}>");

            foreach (IGeneratorLayoutElement element in Items)
            {
                element.Generate(areaLayouts, pageList, design, indentation + 1, currentPage, currentObject, colorTheme, xamlWriter, "");
            }

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}</DockPanel>");
        }
コード例 #20
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation       = GeneratorLayout.IndentationString(indentation);
            string Properties        = $" Style=\"{{StaticResource {GetStyleResourceKey(design, styleName)}}}\"";
            string ClickEventHandler = $" Click=\"{ClickEventName(currentPage)}\"";
            string Value             = GetComponentValue(currentPage, currentObject, ContentResource, ContentObject, ContentObjectProperty, ContentKey, false);

            if (ContentResource != null)
            {
                string ImageValue = $"<Image Source=\"{Value}\"/>";
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<Button x:Name=\"{ControlName}\"{attachedProperties}{visibilityBinding}{Properties}{elementProperties}{ClickEventHandler}>");
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}    {ImageValue}");
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}</Button>");
            }
            else
            {
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<Button x:Name=\"{ControlName}\"{attachedProperties}{visibilityBinding}{Properties}{elementProperties}{ClickEventHandler} Content=\"{Value}\"/>");
            }
        }
コード例 #21
0
ファイル: GeneratorGrid.cs プロジェクト: dlebansais/Wrist
        public override void Generate(Dictionary <IGeneratorArea, IGeneratorLayout> areaLayouts, IList <IGeneratorPage> pageList, IGeneratorDesign design, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation        = GeneratorLayout.IndentationString(indentation);
            string AttachedProperties = GetAttachedProperties();
            string GridProperties     = GetPanelProperties(currentPage, currentObject);
            string ElementProperties  = GetElementProperties(currentPage, currentObject);
            string AllProperties      = $"{AttachedProperties}{visibilityBinding}{GridProperties}{ElementProperties}";

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<Grid{AllProperties}>");

            if (ColumnCount > 1)
            {
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}    <Grid.ColumnDefinitions>");

                for (int i = 0; i < ColumnCount; i++)
                {
                    string WidthProperty = (double.IsNaN(ColumnWidthArray[i]) ? " Width=\"Auto\"" : (ColumnWidthArray[i] > 0 ? $" Width=\"{ColumnWidthArray[i]}\"" : ""));
                    colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}        <ColumnDefinition{WidthProperty}/>");
                }

                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}    </Grid.ColumnDefinitions>");
            }

            if (RowCount > 1)
            {
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}    <Grid.RowDefinitions>");

                for (int i = 0; i < RowCount; i++)
                {
                    string HeightProperty = (double.IsNaN(RowHeightArray[i]) ? " Height=\"Auto\"" : (RowHeightArray[i] > 0 ? $" Height=\"{RowHeightArray[i]}\"" : ""));
                    colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}        <RowDefinition{HeightProperty}/>");
                }

                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}    </Grid.RowDefinitions>");
            }

            foreach (IGeneratorLayoutElement element in Items)
            {
                element.Generate(areaLayouts, pageList, design, indentation + 1, currentPage, currentObject, colorTheme, xamlWriter, "");
            }

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}</Grid>");
        }
コード例 #22
0
        public void GenerateResource(StreamWriter xamlWriter, IGeneratorColorTheme colorTheme)
        {
            string Indentation = GeneratorLayout.IndentationString(2);

            foreach (string Line in Lines)
            {
                string ModifiedLine;
                if (Line.StartsWith("<ControlTemplate"))
                {
                    ModifiedLine = $"{Indentation}<ControlTemplate x:Key=\"{XamlName}\" {Line.Substring(16)}";
                }
                else
                {
                    ModifiedLine = $"{Indentation}{Line}";
                }

                colorTheme.WriteXamlLine(xamlWriter, ModifiedLine);
            }
        }
コード例 #23
0
        public override void Generate(IGeneratorDesign design, string styleName, string attachedProperties, string elementProperties, TextWrapping?textWrapping, bool isHorizontalAlignmentStretch, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding)
        {
            string Indentation      = GeneratorLayout.IndentationString(indentation);
            string OpeningBinding   = $" IsOpen=\"{{Binding IsChecked, ElementName={ControlName}}}\"";
            string PanelProperties  = " HorizontalAlignment=\"Right\"";
            string ButtonProperties = $" HorizontalAlignment=\"Right\" Style=\"{{StaticResource {GetToggleButtonStyleResourceKey(design, styleName)}}}\"";
            string PopupProperties  = " HorizontalOffset=\"0\" VerticalOffset=\"0\"";
            string AreaProperties   = $" Template=\"{{StaticResource {Area.XamlName}}}\"";
            string ImageProperties  = $" Style=\"{{StaticResource {GetImageStyleResourceKey(design, styleName)}}}\"";
            string ImageSource      = $" Source=\"{GetComponentValue(currentPage, currentObject, SourceResource, null, null, null, false)}\"";
            string WidthProperty    = double.IsNaN(Width) ? "" : $" Width=\"{Width}\"";
            string HeightProperty   = double.IsNaN(Height) ? "" : $" Height=\"{Height}\"";

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}<StackPanel{attachedProperties}{visibilityBinding}{PanelProperties}{elementProperties}>");
            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}    <Grid>");
            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}        <ContentControl{AreaProperties} Height=\"0\" Opacity=\"0\"/>");
            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}        <ToggleButton x:Name=\"{ControlName}\"{ButtonProperties} Loaded=\"OnToggleLoaded\">");

            if (SourcePressedResource != null)
            {
                string ImageSourcePressed            = $" Source=\"{GetComponentValue(currentPage, currentObject, SourcePressedResource, null, null, null, false)}\"";
                string ImageVisibilityBinding        = $" Visibility=\"{{Binding IsChecked, ElementName={ControlName}, Converter={{StaticResource convIndexToVisibility}}, ConverterParameter=1}}\"";
                string ImagePressedVisibilityBinding = $" Visibility=\"{{Binding IsChecked, ElementName={ControlName}, Converter={{StaticResource convIndexToVisibility}}, ConverterParameter=0}}\"";
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}            <Grid>");
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}                <Image{ImageVisibilityBinding}{ImageProperties}{ImageSourcePressed}{WidthProperty}{HeightProperty}/>");
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}                <Image{ImagePressedVisibilityBinding}{ImageProperties}{ImageSource}{WidthProperty}{HeightProperty}/>");
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}            </Grid>");
            }
            else
            {
                colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}            <Image{ImageProperties}{ImageSource}{WidthProperty}{HeightProperty}/>");
            }

            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}        </ToggleButton>");
            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}    </Grid>");
            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}    <p:Popup{OpeningBinding}{PopupProperties}>");
            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}        <ContentControl{AreaProperties}/>");
            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}    </p:Popup>");
            colorTheme.WriteXamlLine(xamlWriter, $"{Indentation}</StackPanel>");
        }
コード例 #24
0
ファイル: GeneratorDesign.cs プロジェクト: dlebansais/Wrist
        private string CleanupXaml(string key, string xamlText, int indentation)
        {
            string Result = "";
            string s;

            xamlText = xamlText.Replace(" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"", "");
            xamlText = xamlText.Replace("<Style.Resources><ResourceDictionary /></Style.Resources>", "");

            List <string> TagList = new List <string>();

            int EndTagIndex = 0;
            int OldTagIndex = 0;

            while ((EndTagIndex = xamlText.IndexOf("><", EndTagIndex)) >= 0)
            {
                string Tag = xamlText.Substring(OldTagIndex, EndTagIndex - OldTagIndex + 1);
                TagList.Add(Tag);

                OldTagIndex = ++EndTagIndex;
            }

            TagList.Add(xamlText.Substring(OldTagIndex));

            bool IsFirstTag = true;

            foreach (string t in TagList)
            {
                string Tag;

                if (IsFirstTag)
                {
                    IsFirstTag = false;

                    int BeginOffset;
                    if ((BeginOffset = t.IndexOf(' ')) > 0)
                    {
                        Tag = t.Substring(0, BeginOffset) + " x:Key=\"" + key + "\"" + t.Substring(BeginOffset);
                    }
                    else if ((BeginOffset = t.IndexOf('>')) > 0)
                    {
                        Tag = t.Substring(0, BeginOffset) + " x:Key=\"" + key + "\"" + t.Substring(BeginOffset);
                    }
                    else
                    {
                        Tag = t;
                    }
                }
                else
                {
                    Tag = t;
                }

                if (Tag.StartsWith("</"))
                {
                    indentation--;
                    s       = GeneratorLayout.IndentationString(indentation);
                    Result += s + Tag + "\r\n";
                }

                else if (Tag.EndsWith("/>"))
                {
                    s       = GeneratorLayout.IndentationString(indentation);
                    Result += s + Tag + "\r\n";
                }

                else
                {
                    s       = GeneratorLayout.IndentationString(indentation);
                    Result += s + Tag + "\r\n";

                    if (!Tag.Contains("</"))
                    {
                        indentation++;
                    }
                }
            }

            return(Result);
        }
コード例 #25
0
ファイル: GeneratorPage.cs プロジェクト: dlebansais/Wrist
        private void GenerateXaml(IGeneratorDomain domain, string appNamespace, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter)
        {
            xamlWriter.WriteLine($"<Page x:Class=\"{appNamespace}.{XamlName}\"");
            xamlWriter.WriteLine("      xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"");
            xamlWriter.WriteLine("      xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"");
            xamlWriter.WriteLine("      xmlns:n=\"clr-namespace:NetTools\"");
            xamlWriter.WriteLine("      xmlns:p=\"clr-namespace:Presentation\"");
            xamlWriter.WriteLine("      xmlns:conv=\"clr-namespace:Converters\"");
            xamlWriter.WriteLine($"      xmlns:local=\"using:{appNamespace}\"");

            if (!string.IsNullOrEmpty(Tag))
            {
                xamlWriter.WriteLine($"      Tag=\"{Tag}\"");
            }

            xamlWriter.WriteLine("    >");
            xamlWriter.WriteLine("    <Page.Resources>");
            xamlWriter.WriteLine("        <conv:KeyToValueConverter x:Key=\"convKeyToValue\"/>");
            xamlWriter.WriteLine("        <conv:IndexToVisibilityConverter x:Key=\"convIndexToVisibility\"/>");
            xamlWriter.WriteLine("        <conv:IndexToCheckedConverter x:Key=\"convIndexToChecked\"/>");

            foreach (IGeneratorResource Resource in domain.Resources)
            {
                Resource.GenerateResourceLine(xamlWriter);
            }

            int    Indentation = 2;
            string s           = GeneratorLayout.IndentationString(Indentation);

            // Make sure areas used by other areas are first
            List <IGeneratorArea> Areas = new List <IGeneratorArea>();

            foreach (IGeneratorArea Area in domain.Areas)
            {
                if (Area.IsReferencedBy(this.Area))
                {
                    Areas.Add(Area);
                }
            }

            BubbleSort(Areas);

            foreach (IGeneratorArea Area in Areas)
            {
                if (Area.CurrentObject == null)
                {
                    xamlWriter.WriteLine($"{s}<ControlTemplate x:Key=\"{Area.XamlName}\">");
                }
                else
                {
                    xamlWriter.WriteLine($"{s}<DataTemplate x:Key=\"{Area.XamlName}\">");
                }

                IGeneratorLayout Layout = AreaLayouts[Area];
                Area.Generate(Layout, AreaLayouts, domain.Pages, Design, Indentation + 1, this, colorTheme, xamlWriter);

                if (Area.CurrentObject == null)
                {
                    xamlWriter.WriteLine($"{s}</ControlTemplate>");
                }
                else
                {
                    xamlWriter.WriteLine($"{s}</DataTemplate>");
                }
            }

            if (Background != null)
            {
                Background.GenerateResource(xamlWriter, colorTheme);
            }

            xamlWriter.WriteLine("    </Page.Resources>");

            if (IsScrollable)
            {
                string BackgroundColorProperty = $" Color=\"{BackgroundColor}\"";
                colorTheme.WriteXamlLine(xamlWriter, $"    <ScrollViewer>");
                colorTheme.WriteXamlLine(xamlWriter, "        <ScrollViewer.Background>");
                colorTheme.WriteXamlLine(xamlWriter, $"            <SolidColorBrush{BackgroundColorProperty}/>");
                colorTheme.WriteXamlLine(xamlWriter, "        </ScrollViewer.Background>");
                Indentation++;
            }

            s = GeneratorLayout.IndentationString(Indentation - 1);

            string PageHeight = double.IsNaN(Height) ? "" : $" Height=\"{Height}\"";

            xamlWriter.WriteLine($"{s}<Grid PointerPressed=\"OnPointerPressed\"{PageHeight}>");

            if (Background != null)
            {
                Background.Generate(xamlWriter, Indentation, colorTheme);
            }
            GeneratorComponentArea.Generate(Area, "", "", Indentation, colorTheme, xamlWriter, "", Width);

            xamlWriter.WriteLine($"{s}</Grid>");

            if (IsScrollable)
            {
                Indentation--;
                xamlWriter.WriteLine("    </ScrollViewer>");
            }

            xamlWriter.WriteLine("</Page>");
        }