private protected override void WriteHeaderClassStart(HeaderBuilder builder, IAnimatedVisualSourceInfo info, string inherits) { builder.Preamble.WriteLine($"{(info.Public ? "public " : string.Empty)}class {SourceClassName}"); builder.Preamble.Indent(); builder.Preamble.WriteLine($": public winrt::implements<{SourceClassName}, winrt::{inherits}>"); builder.Preamble.UnIndent(); }
private protected override void WriteHeaderClassStart(HeaderBuilder builder, IAnimatedVisualSourceInfo info, string inherits) { // NOTE: the CX class is always made public. This is necessary to allow CX // XAML projects to compile (the XAML compiler can't find the metadata for the // class if it isn't made public). builder.Preamble.WriteLine($"public ref class {SourceClassName} sealed"); builder.Preamble.Indent(); builder.Preamble.WriteLine($": public {inherits}"); builder.Preamble.UnIndent(); }
private protected override void WriteThemeHeader(HeaderBuilder builder) { // Add a field to hold the theme property set. builder.Private.WriteLine($"{Wuc}::{T.CompositionPropertySet} {SourceInfo.ThemePropertiesFieldName}{{ nullptr }};"); builder.Internal.WriteComment("Theme properties."); var hasColorProperty = false; // Add fields and proeprty declarations for each of the theme properties. foreach (var prop in SourceInfo.SourceMetadata.PropertyBindings) { hasColorProperty |= prop.ExposedType == PropertySetValueType.Color; if (SourceInfo.GenerateDependencyObject) { builder.Private.WriteLine($"static {WinUINamespace}::Xaml::DependencyProperty^ _{S.CamelCase(prop.BindingName)}Property;"); builder.Private.WriteLine($"static void On{prop.BindingName}Changed({WinUINamespace}::Xaml::DependencyObject^ d, {WinUINamespace}::Xaml::DependencyPropertyChangedEventArgs^ e);"); builder.Internal.WriteLine($"static {WinUINamespace}::Xaml::DependencyProperty^ {prop.BindingName}Property();"); builder.Internal.WriteLine(); } else { var exposedTypeName = QualifiedTypeName(prop.ExposedType); WriteInitializedField(builder.Private, exposedTypeName, $"_theme{prop.BindingName}", S.VariableInitialization($"c_theme{prop.BindingName}")); } builder.Internal.WriteLine($"property {QualifiedTypeName(prop.ExposedType)} {prop.BindingName}"); builder.Internal.OpenScope(); builder.Internal.WriteLine($"{QualifiedTypeName(prop.ExposedType)} get();"); builder.Internal.WriteLine($"void set ({QualifiedTypeName(prop.ExposedType)} value);"); builder.Internal.CloseScope(); builder.Internal.WriteLine(); } builder.Private.WriteLine(); builder.Private.WriteLine($"{Wuc}::{T.CompositionPropertySet} EnsureThemeProperties({Wuc}::{T.Compositor} compositor);"); builder.Private.WriteLine(); if (hasColorProperty) { var b = IsInterfaceCustom ? builder.Internal : builder.Private; b.WriteLine($"static Windows::Foundation::Numerics::float4 ColorAsVector4({WinUINamespace}::Color color);"); b.WriteLine(); } }
private protected override void WriteThemeHeader(HeaderBuilder builder) { // Add a field to hold the theme property set. builder.Private.WriteLine($"winrt::{Wuc}::{T.CompositionPropertySet} {SourceInfo.ThemePropertiesFieldName}{{ nullptr }};"); // Add fields for each of the theme properties. foreach (var prop in SourceInfo.SourceMetadata.PropertyBindings) { if (SourceInfo.GenerateDependencyObject) { builder.Private.WriteLine($"static {WinUINamespace}::Xaml::DependencyProperty^ _{prop.BindingName}Property;"); builder.Private.WriteLine($"static void On{prop.BindingName}Changed({WinUINamespace}::Xaml::DependencyObject^ d, {WinUINamespace}::Xaml::DependencyPropertyChangedEventArgs^ e);"); } else { var exposedTypeName = QualifiedTypeName(prop.ExposedType); var initialValue = prop.ExposedType switch { PropertySetValueType.Color => S.ColorArgs((WinCompData.Wui.Color)prop.DefaultValue), PropertySetValueType.Scalar => S.Float((float)prop.DefaultValue), PropertySetValueType.Vector2 => S.Vector2Args((Vector2)prop.DefaultValue), PropertySetValueType.Vector3 => S.Vector3Args((Vector3)prop.DefaultValue), PropertySetValueType.Vector4 => S.Vector4Args((Vector4)prop.DefaultValue), _ => throw new InvalidOperationException(), }; WriteInitializedField(builder.Private, exposedTypeName, $"_theme{prop.BindingName}", S.VariableInitialization(initialValue)); } } builder.Private.WriteLine(); builder.Private.WriteLine($"winrt::{Wuc}::{T.CompositionPropertySet} EnsureThemeProperties(winrt::{Wuc}::{T.Compositor} compositor);"); builder.Private.WriteLine(); // Write properties declarations for each themed property. foreach (var prop in SourceInfo.SourceMetadata.PropertyBindings) { builder.Internal.WriteLine($"{QualifiedTypeName(prop.ExposedType)} {prop.BindingName}();"); builder.Internal.WriteLine($"void {prop.BindingName}({QualifiedTypeName(prop.ExposedType)} value);"); } builder.Internal.WriteLine(); }