public bool IsEqual(IGeneratorPageNavigation other, IGeneratorPage currentPage) { if (BeforeObject != other.BeforeObject) { return(false); } if (BeforeObjectEvent != other.BeforeObjectEvent) { return(false); } IGeneratorPage ThisPage = (GoToPage == GeneratorPage.CurrentPage) ? currentPage : GoToPage; IGeneratorPage OtherPage = (other.GoToPage == GeneratorPage.CurrentPage) ? currentPage : other.GoToPage; if (ThisPage != OtherPage) { return(false); } if (AfterObject != other.AfterObject) { return(false); } if (AfterObjectEvent != other.AfterObjectEvent) { return(false); } return(true); }
public IGeneratorPageNavigation CreateCopyForPage(IGeneratorPage currentPage, IGeneratorComponent source) { GeneratorPageNavigation Result = new GeneratorPageNavigation(); Result.BeforeObject = BeforeObject; Result.BeforeObjectEvent = BeforeObjectEvent; if (GoToPage == GeneratorPage.CurrentPage) { Result.GoToPage = currentPage; } else if (GoToPage != null) { Result.GoToPage = GoToPage; Result.IsExternal = IsExternal; Result.GoToObject = null; Result.GoToObjectProperty = null; } else { Result.GoToPage = null; Result.IsExternal = true; Result.GoToObject = GoToObject; Result.GoToObjectProperty = GoToObjectProperty; } Result.AfterObject = AfterObject; Result.AfterObjectEvent = AfterObjectEvent; Result.Source = source; return(Result); }
public string GetComponentValue(IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorResource resourceValue, IGeneratorObject objectValue, IGeneratorObjectProperty objectPropertyValue, IDeclarationSource key, bool isTwoWays) { if (resourceValue != null) { return($"{{StaticResource {resourceValue.XamlName}}}"); } else if (objectValue != null && objectPropertyValue != null) { string Mode = isTwoWays ? ", Mode=TwoWay" : ""; string ObjectBinding = GetObjectBinding(currentObject, objectValue, objectPropertyValue); if (key == null) { return($"{{Binding {ObjectBinding}{Mode}}}"); } else if (key.Name == GeneratorPage.CurrentPage.Name) { return($"{{Binding {ObjectBinding}{Mode}, Converter={{StaticResource convKeyToValue}}, ConverterParameter=page-{ParserDomain.ToKeyName(currentPage.Name)}}}"); } else { return($"{{Binding {ObjectBinding}{Mode}, Converter={{StaticResource convKeyToValue}}, ConverterParameter={key.Name}}}"); } } else { throw new InvalidOperationException(); } }
public string ClickEventName(IGeneratorPage currentPage) { if (GoTo.GoToPage == GeneratorPage.CurrentPage) { IGeneratorPageNavigation Copy = GoTo.CreateCopyForPage(currentPage, this); return(Copy.EventName); } else { return(GoTo.EventName); } }
protected string GetElementProperties(IGeneratorPage currentPage, IGeneratorObject currentObject) { string Result = ""; if (!string.IsNullOrEmpty(Margin)) { Result += $" Margin=\"{Margin}\""; } if (!string.IsNullOrEmpty(HorizontalAlignment)) { Result += $" HorizontalAlignment=\"{HorizontalAlignment}\""; } if (!string.IsNullOrEmpty(VerticalAlignment)) { Result += $" VerticalAlignment=\"{VerticalAlignment}\""; } if (!string.IsNullOrEmpty(Width)) { Result += $" Width=\"{Width}\""; } if (!string.IsNullOrEmpty(Height)) { Result += $" Height=\"{Height}\""; } if (DynamicController != null) { switch (DynamicController.Result) { case DynamicOperationResults.Boolean: Result += $" IsEnabled=\"{{Binding Dynamic.{DynamicController.CSharpName}}}\" IsEnabledChanged=\"OnIsEnabledChanged\""; break; default: throw new InvalidOperationException(); } } return(Result); }
protected string GetPanelProperties(IGeneratorPage currentPage, IGeneratorObject currentObject) { string Result = ""; if (!string.IsNullOrEmpty(MaxWidth)) { Result += $" MaxWidth=\"{MaxWidth}\""; } if (!string.IsNullOrEmpty(MaxHeight)) { Result += $" MaxHeight=\"{MaxHeight}\""; } if (!string.IsNullOrEmpty(Background)) { Result += $" Background=\"{Background}\""; } return(Result); }
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}\"/>"); } }
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}/>"); }
private void GenerateCSharp(IGeneratorDomain domain, string appNamespace, StreamWriter cSharpWriter) { cSharpWriter.WriteLine("using System.Collections.Generic;"); cSharpWriter.WriteLine("using Windows.UI.Xaml;"); cSharpWriter.WriteLine("using Windows.UI.Xaml.Controls;"); cSharpWriter.WriteLine("using Windows.UI.Xaml.Controls.Primitives;"); cSharpWriter.WriteLine(); cSharpWriter.WriteLine($"namespace {appNamespace}"); cSharpWriter.WriteLine("{"); cSharpWriter.WriteLine($" public partial class {XamlName} : Page, IPageBase"); cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine($" public {XamlName}()"); cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine(" InitializeComponent();"); cSharpWriter.WriteLine(" DataContext = this;"); if (Dynamic.HasProperties) { cSharpWriter.WriteLine(); cSharpWriter.WriteLine($" Dynamic = new {XamlName}Dynamic(this);"); } cSharpWriter.WriteLine(" }"); cSharpWriter.WriteLine(); cSharpWriter.WriteLine($" public PageNames ThisPage {{ get {{ return PageNames.{XamlName}; }} }}"); cSharpWriter.WriteLine(" public App GetApp { get { return (App)App.Current; } }"); string ObjectLine = null; foreach (IGeneratorObject Object in domain.Objects) { if (Object.IsGlobal) { if (ObjectLine == null) { cSharpWriter.WriteLine(); } ObjectLine = $" public I{Object.CSharpName} Get{Object.CSharpName} {{ get {{ return App.Get{Object.CSharpName}; }} }}"; cSharpWriter.WriteLine(ObjectLine); } } if (domain.Translation != null) { cSharpWriter.WriteLine(" public Translation GetTranslation { get { return App.GetTranslation; } }"); } if (Dynamic.HasProperties) { cSharpWriter.WriteLine($" public {XamlName}Dynamic Dynamic {{ get; private set; }}"); } List <Tuple <IGeneratorPageNavigation, IGeneratorObject, IGeneratorObjectPropertyBoolean> > GoToList = new List <Tuple <IGeneratorPageNavigation, IGeneratorObject, IGeneratorObjectPropertyBoolean> >(); Area.CollectGoTo(GoToList, this); foreach (Tuple <IGeneratorPageNavigation, IGeneratorObject, IGeneratorObjectPropertyBoolean> Item in GoToList) { IGeneratorPageNavigation GoTo = Item.Item1; IGeneratorObject ClosePopupObject = Item.Item2; IGeneratorObjectPropertyBoolean ClosePopupObjectProperty = Item.Item3; string GoToCall = GoTo.IsExternal ? "GoToExternal" : "GoTo"; cSharpWriter.WriteLine(); cSharpWriter.WriteLine($" public void {GoTo.EventName}(object sender, RoutedEventArgs e)"); cSharpWriter.WriteLine(" {"); if (GoTo.BeforeObject != null && GoTo.BeforeObjectEvent != null) { cSharpWriter.WriteLine(" string Content = (sender as Button).Content as string;"); if (GoTo.GoToPage == GeneratorPage.AnyPage) { cSharpWriter.WriteLine(" PageNames DestinationPageName;"); cSharpWriter.WriteLine(" IObjectBase SenderContext = (IObjectBase)(sender as Button).DataContext;"); if (GoTo.BeforeObject.IsGlobal) { cSharpWriter.WriteLine($" SenderContext.Get{GoTo.BeforeObject.CSharpName}.On_{GoTo.BeforeObjectEvent.CSharpName}(PageNames.{XamlName}, SenderContext, \"{GoTo.Source.Source.Name}\", Content, out DestinationPageName);"); } else { cSharpWriter.WriteLine($" (({GoTo.BeforeObject.CSharpName})SenderContext).On_{GoTo.BeforeObjectEvent.CSharpName}(PageNames.{XamlName}, SenderContext, \"{GoTo.Source.Source.Name}\", Content, out DestinationPageName);"); } cSharpWriter.WriteLine($" (App.Current as App).{GoToCall}(DestinationPageName);"); } else { if (GoTo.BeforeObject.IsGlobal) { cSharpWriter.WriteLine(" IObjectBase SenderContext = (IObjectBase)(sender as Button).DataContext;"); cSharpWriter.WriteLine($" SenderContext.Get{GoTo.BeforeObject.CSharpName}.On_{GoTo.BeforeObjectEvent.CSharpName}(PageNames.{XamlName}, \"{GoTo.Source.Source.Name}\", Content);"); } else { cSharpWriter.WriteLine($" {GoTo.BeforeObject.CSharpName} SenderContext = ({GoTo.BeforeObject.CSharpName})(sender as Button).DataContext;"); cSharpWriter.WriteLine($" SenderContext.On_{GoTo.BeforeObjectEvent.CSharpName}(PageNames.{XamlName}, \"{GoTo.Source.Source.Name}\", Content);"); } if (GoTo.GoToPage == GeneratorPage.PreviousPage) { cSharpWriter.WriteLine($" (App.Current as App).{GoToCall}(PageNames.PreviousPage);"); } else { cSharpWriter.WriteLine($" (App.Current as App).{GoToCall}(PageNames.{GoTo.GoToPage.XamlName});"); } } } else if (GoTo.GoToPage == GeneratorPage.PreviousPage) { cSharpWriter.WriteLine($" (App.Current as App).{GoToCall}(PageNames.PreviousPage);"); } else if (GoTo.GoToPage != null) { cSharpWriter.WriteLine($" (App.Current as App).{GoToCall}(PageNames.{GoTo.GoToPage.XamlName});"); } else { if (GoTo.GoToObject.IsGlobal) { cSharpWriter.WriteLine($" (App.Current as App).NavigateToExternal(Get{GoTo.GoToObject.CSharpName}.{GoTo.GoToObjectProperty.CSharpName});"); } else { cSharpWriter.WriteLine($" (App.Current as App).NavigateToExternal((({GoTo.GoToObject.CSharpName})(sender as Button).DataContext).{GoTo.GoToObjectProperty.CSharpName});"); } } if (ClosePopupObject != null && ClosePopupObjectProperty != null) { if (ClosePopupObject.IsGlobal) { cSharpWriter.WriteLine($" if (((IObjectBase)(sender as Button).DataContext).Get{ClosePopupObject.CSharpName}.{ClosePopupObjectProperty.CSharpName})"); } else { cSharpWriter.WriteLine($" if ((({ClosePopupObject.CSharpName})(sender as Button).DataContext).{ClosePopupObjectProperty.CSharpName})"); } cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine($" ClosePopups();"); if (ClosePopupObject.IsGlobal) { cSharpWriter.WriteLine($" ((IObjectBase)(sender as Button).DataContext).Get{ClosePopupObject.CSharpName}.OnPopupClosed_{ClosePopupObjectProperty.CSharpName}();"); } else { cSharpWriter.WriteLine($" (({ClosePopupObject.CSharpName})(sender as Button).DataContext).OnPopupClosed_{ClosePopupObjectProperty.CSharpName}();"); } cSharpWriter.WriteLine(" }"); } cSharpWriter.WriteLine(" }"); } if (Dynamic.HasProperties) { List <IGeneratorBindableComponent> BoundComponentList = new List <IGeneratorBindableComponent>(); Area.CollectBoundComponents(BoundComponentList, this); foreach (IGeneratorBindableComponent Component in BoundComponentList) { string ObjectName = Component.BoundObject.CSharpName; string ObjectPropertyName = Component.BoundObjectProperty.CSharpName; string HandlerName = GeneratorComponent.GetLoadedHandlerName(Component.BoundObject, Component.BoundObjectProperty); string HandlerArgumentTypeName = Component.HandlerArgumentTypeName; if (Component is IGeneratorComponentSelector AsSelector) { cSharpWriter.WriteLine(); cSharpWriter.WriteLine($" public void {HandlerName}(object sender, RoutedEventArgs e)"); cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine(" ListBox Ctrl = (ListBox)sender;"); cSharpWriter.WriteLine($" {ObjectName} Item = ({ObjectName})Ctrl.DataContext;"); cSharpWriter.WriteLine($" Item.NotifyPropertyChanged(nameof({ObjectName}.{ObjectPropertyName}));"); cSharpWriter.WriteLine(" }"); } else if (Component is IGeneratorComponentPasswordEdit AsPasswordEdit) { cSharpWriter.WriteLine(); cSharpWriter.WriteLine($" public void {HandlerName}(object sender, RoutedEventArgs e)"); cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine(" PasswordBox Ctrl = (PasswordBox)sender;"); cSharpWriter.WriteLine($" string BindingName = $\"{{nameof({ObjectName})}}.{{nameof({ObjectName}.{ObjectPropertyName})}}\";"); cSharpWriter.WriteLine(" GetApp.AddPasswordControl(BindingName, Ctrl);"); cSharpWriter.WriteLine(" }"); } } foreach (IGeneratorBindableComponent Component in BoundComponentList) { string ObjectName = Component.BoundObject.CSharpName; string ObjectPropertyName = Component.BoundObjectProperty.CSharpName; string HandlerName = GeneratorComponent.GetChangedHandlerName(Component.BoundObject, Component.BoundObjectProperty); string HandlerArgumentTypeName = Component.HandlerArgumentTypeName; cSharpWriter.WriteLine(); cSharpWriter.WriteLine($" public void {HandlerName}(object sender, {Component.HandlerArgumentTypeName} e)"); cSharpWriter.WriteLine(" {"); if (Component is IGeneratorComponentSelector AsSelector) { cSharpWriter.WriteLine(" ListBox Ctrl = (ListBox)sender;"); cSharpWriter.WriteLine($" {ObjectName} Item = ({ObjectName})Ctrl.DataContext;"); cSharpWriter.WriteLine($" if (Ctrl.SelectedIndex >= 0 && Item.{ObjectPropertyName} != Ctrl.SelectedIndex)"); cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine($" Item.{ObjectPropertyName} = Ctrl.SelectedIndex;"); cSharpWriter.WriteLine($" Item.NotifyPropertyChanged(nameof({ObjectName}.{ObjectPropertyName}));"); cSharpWriter.WriteLine(" }"); cSharpWriter.WriteLine(); } string Notification = $"Dynamic.OnPropertyChanged($\"{{nameof({ObjectName})}}.{{nameof({ObjectName}.{ObjectPropertyName})}}\")"; if (Component.PostponeChangedNotification) { cSharpWriter.WriteLine($" Dispatcher.BeginInvoke( () => {Notification} );"); } else { cSharpWriter.WriteLine($" {Notification};"); } cSharpWriter.WriteLine(" }"); } } Dictionary <IGeneratorPage, string> LinkedPageTable = new Dictionary <IGeneratorPage, string>(); foreach (KeyValuePair <ILayoutElement, IGeneratorLayoutElement> Entry in GeneratorLayoutElement.GeneratorLayoutElementMap) { if (Entry.Value is IGeneratorTextDecoration AsTextDecoration) { foreach (object LinkEntry in AsTextDecoration.LinkedPageList) { IGeneratorPage LinkedPage = (IGeneratorPage)LinkEntry; if (!LinkedPageTable.ContainsKey(LinkedPage)) { LinkedPageTable.Add(LinkedPage, GeneratorTextDecoration.ToEventHandlerName(LinkedPage)); } } } } foreach (KeyValuePair <IGeneratorPage, string> LinkEntry in LinkedPageTable) { cSharpWriter.WriteLine(); cSharpWriter.WriteLine($" private void {LinkEntry.Value}(object sender, RoutedEventArgs e)"); cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine($" (App.Current as App).GoTo(PageNames.{LinkEntry.Key.XamlName});"); cSharpWriter.WriteLine(" }"); } cSharpWriter.WriteLine(); cSharpWriter.WriteLine(" private void OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)"); cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine(" (App.Current as App).OnIsEnabledChanged(sender, e);"); cSharpWriter.WriteLine(" }"); cSharpWriter.WriteLine(); cSharpWriter.WriteLine(" private List<ToggleButton> ToggleList = new List<ToggleButton>();"); cSharpWriter.WriteLine(); cSharpWriter.WriteLine(" private void OnToggleLoaded(object sender, RoutedEventArgs e)"); cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine(" if ((sender is ToggleButton AsToggle) && !ToggleList.Contains(AsToggle))"); cSharpWriter.WriteLine(" ToggleList.Add(AsToggle);"); cSharpWriter.WriteLine(" }"); cSharpWriter.WriteLine(); cSharpWriter.WriteLine(" private void OnPointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)"); cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine(" ClosePopups();"); cSharpWriter.WriteLine(" }"); cSharpWriter.WriteLine(); cSharpWriter.WriteLine(" private void ClosePopups()"); cSharpWriter.WriteLine(" {"); cSharpWriter.WriteLine(" foreach (ToggleButton Toggle in ToggleList)"); cSharpWriter.WriteLine(" Toggle.IsChecked = false;"); cSharpWriter.WriteLine(" }"); cSharpWriter.WriteLine(" }"); cSharpWriter.WriteLine("}"); }
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}\"/>"); }
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>"); }
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>"); }
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}/>"); }
public void CollectBoundComponents(List <IGeneratorBindableComponent> boundComponentList, IGeneratorPage currentPage) { if (this == EmptyArea) { return; } foreach (IGeneratorComponent Component in Components) { if (Component is IGeneratorBindableComponent AsBindable) { bool IsFound = false; foreach (IGeneratorBindableComponent Item in boundComponentList) { if (Item.BoundObject == AsBindable.BoundObject && Item.BoundObjectProperty == AsBindable.BoundObjectProperty) { IsFound = true; break; } } if (!IsFound) { boundComponentList.Add(AsBindable); } } else if (Component is IGeneratorComponentPopup AsPopup) { AsPopup.Area.CollectBoundComponents(boundComponentList, currentPage); } else if (Component is IGeneratorComponentArea AsArea) { AsArea.Area.CollectBoundComponents(boundComponentList, currentPage); } else if (Component is IGeneratorComponentContainer AsContainer) { AsContainer.ItemNestedArea.CollectBoundComponents(boundComponentList, currentPage); } else if (Component is IGeneratorComponentContainerList AsContainerList) { AsContainerList.ItemNestedArea.CollectBoundComponents(boundComponentList, currentPage); } } }
public abstract 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);
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}/>"); }
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}/>"); }
public abstract void Generate(Dictionary <IGeneratorArea, IGeneratorLayout> areaLayouts, IList <IGeneratorPage> pageList, IGeneratorDesign design, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter, string visibilityBinding);
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}/>"); }
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}/>"); }
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>"); }
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>"); } }
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}/>"); } }
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}\"/>"); }
public void CollectGoTo(List <Tuple <IGeneratorPageNavigation, IGeneratorObject, IGeneratorObjectPropertyBoolean> > goToList, IGeneratorPage currentPage) { if (this == EmptyArea) { return; } foreach (IGeneratorComponent Component in Components) { if (Component is IGeneratorComponentButton AsButton) { bool IsIncluded = false; foreach (Tuple <IGeneratorPageNavigation, IGeneratorObject, IGeneratorObjectPropertyBoolean> Item in goToList) { if (Item.Item1.IsEqual(AsButton.GoTo, currentPage)) { IsIncluded = true; break; } } if (!IsIncluded) { IGeneratorPageNavigation Copy = AsButton.GoTo.CreateCopyForPage(currentPage, AsButton); IGeneratorObject ClosePopupObject = AsButton.ClosePopupObject; IGeneratorObjectPropertyBoolean ClosePopupObjectProperty = AsButton.ClosePopupObjectProperty; goToList.Add(new Tuple <IGeneratorPageNavigation, IGeneratorObject, IGeneratorObjectPropertyBoolean>(Copy, ClosePopupObject, ClosePopupObjectProperty)); } } else if (Component is IGeneratorComponentPopup AsPopup) { AsPopup.Area.CollectGoTo(goToList, currentPage); } else if (Component is IGeneratorComponentArea AsArea) { AsArea.Area.CollectGoTo(goToList, currentPage); } else if (Component is IGeneratorComponentContainer AsContainer) { AsContainer.ItemNestedArea.CollectGoTo(goToList, currentPage); } else if (Component is IGeneratorComponentContainerList AsContainerList) { AsContainerList.ItemNestedArea.CollectGoTo(goToList, currentPage); } } }
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}\"/>"); }
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); }
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) { bool IsHorizontalAlignmentStretch = (HorizontalAlignment == Windows.UI.Xaml.HorizontalAlignment.Stretch.ToString()); string AttachedProperties = GetAttachedProperties(); string ElementProperties = GetElementProperties(currentPage, currentObject); Component.Generate(design, Style, AttachedProperties, ElementProperties, TextWrapping, IsHorizontalAlignmentStretch, indentation, currentPage, currentObject, colorTheme, xamlWriter, visibilityBinding); }
public void Generate(IGeneratorArea area, Dictionary <IGeneratorArea, IGeneratorLayout> areaLayouts, IList <IGeneratorPage> pageList, IGeneratorDesign design, int indentation, IGeneratorPage currentPage, IGeneratorObject currentObject, IGeneratorColorTheme colorTheme, StreamWriter xamlWriter) { Content.Generate(areaLayouts, pageList, design, indentation, currentPage, currentObject, colorTheme, xamlWriter, ""); }
public static string ToEventHandlerName(IGeneratorPage page) { return($"OnLinkClick_{page.XamlName}"); }