コード例 #1
0
ファイル: GeneratorPage.cs プロジェクト: dlebansais/Wrist
        public bool Connect(IGeneratorDomain domain)
        {
            bool IsConnected = false;

            if ((BasePage.QueryObject != null && BasePage.QueryObjectEvent != null) && (QueryObject == null || QueryObjectEvent == null))
            {
                IsConnected      = true;
                QueryObject      = GeneratorObject.GeneratorObjectMap[BasePage.QueryObject];
                QueryObjectEvent = GeneratorObjectEvent.GeneratorObjectEventMap[BasePage.QueryObjectEvent];
            }

            if (Area == null)
            {
                IsConnected = true;
                if (BasePage.Area != Parser.Area.EmptyArea)
                {
                    Area = GeneratorArea.GeneratorAreaMap[BasePage.Area];
                }
                else
                {
                    Area = Parser.GeneratorArea.EmptyArea;
                }
            }

            if (AreaLayouts.Count < BasePage.AreaLayouts.Count)
            {
                IsConnected = true;

                foreach (KeyValuePair <IArea, ILayout> Entry in BasePage.AreaLayouts)
                {
                    AreaLayouts.Add(GeneratorArea.GeneratorAreaMap[Entry.Key], GeneratorLayout.GeneratorLayoutMap[Entry.Value]);
                }

                foreach (KeyValuePair <IGeneratorArea, IGeneratorLayout> Entry in AreaLayouts)
                {
                    IGeneratorLayout Layout = Entry.Value;
                    IsConnected |= Layout.Connect(domain, Entry.Key);
                }
            }

            if (Design == null)
            {
                IsConnected = true;
                Design      = GeneratorDesign.GeneratorDesignMap[BasePage.Design];
            }

            if (Background == null && BasePage.Background != null)
            {
                IsConnected = true;
                Background  = GeneratorBackground.GeneratorBackgroundMap[BasePage.Background];
            }

            if (Dynamic == null)
            {
                IsConnected = true;
                Dynamic     = GeneratorDynamic.GeneratorDynamicMap[BasePage.Dynamic];
            }

            return(IsConnected);
        }
コード例 #2
0
ファイル: GeneratorArea.cs プロジェクト: dlebansais/Wrist
 public void Generate(IGeneratorLayout layout, Dictionary <IGeneratorArea, IGeneratorLayout> areaLayouts, IList <IGeneratorPage> pageList, IGeneratorDesign design, int indentation, IGeneratorPage currentPage, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter)
 {
     layout.Generate(this, areaLayouts, pageList, design, indentation, currentPage, CurrentObject, colorTheme, xamlWriter);
 }
コード例 #3
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>");
        }