├── LICENSE ├── ekUiGen ├── New EmptyKeys UI.zip ├── packages.config ├── App.config ├── SpriteFontTemplate.pdxfnt ├── Properties │ └── AssemblyInfo.cs ├── SpriteFontTemplate.xkfnt ├── SpriteFontTemplate.xml ├── EmptyKeys.UserInterface.targets └── ekUiGen.csproj ├── EmptyKeys.UserInterface.Designer ├── Effects │ ├── FakeShader.ps │ ├── CompileShader.bat │ ├── FakeShader.fx │ ├── CustomEffect.cs │ └── DirectionalBlurEffect.cs ├── Properties │ ├── Settings.settings │ ├── AssemblyInfo.cs │ ├── Settings.Designer.cs │ └── Resources.Designer.cs ├── Interactions │ ├── Action.cs │ ├── Behavior.cs │ ├── ActionCollection.cs │ ├── BehaviorCollection.cs │ ├── PlaySoundAction.cs │ ├── CallMethodAction.cs │ └── Interaction.cs ├── SoundSourceCollection.cs ├── GeneratedBindingsMode.cs ├── Charts │ ├── SeriesPointCollection.cs │ └── SeriesPoint.cs ├── ScrollViewerAction.cs ├── RoutedEvents.cs ├── ImageBrush.cs ├── EmptyKeys.UserInterface.Designer.csproj ├── SoundType.cs ├── ScrollViewerHelper.cs ├── Input │ ├── GamepadGesture.cs │ └── GamepadInput.cs ├── PasswordBox.cs ├── DragDrop.cs ├── DataGrid.cs ├── SoundManager.cs └── AnimatedImage.cs ├── README.md ├── UIGenerator ├── Properties │ └── AssemblyInfo.cs ├── Types │ ├── CheckBoxGeneratorType.cs │ ├── CustomUserControlGeneratorType.cs │ ├── Controls │ │ ├── RadialPanelGeneratorType.cs │ │ ├── GroupBoxGeneratorType.cs │ │ ├── TreeViewGeneratorType.cs │ │ ├── Primitives │ │ │ └── TabPanelGeneratorType.cs │ │ ├── CanvasGeneratorType.cs │ │ ├── DataGridTextColumnGeneratorType.cs │ │ ├── TreeViewItemGeneratorType.cs │ │ ├── DataGridCheckBoxColumnGeneratorType.cs │ │ ├── RadioButtonGeneratorType.cs │ │ ├── DockPanelGeneratorType.cs │ │ ├── DataGridTemplateColumnGeneratorType.cs │ │ ├── WrapPanelGeneratorType.cs │ │ ├── UniformGridGeneratorType.cs │ │ ├── HeaderedItemsControlGeneratorType.cs │ │ └── DataGridBoundColumnGeneratorType.cs │ ├── ThumbGeneratorType.cs │ ├── Shapes │ │ ├── EllipseGeneratorType.cs │ │ ├── RectangleGeneratorType.cs │ │ ├── LineGeneratorType.cs │ │ ├── ShapeGeneratorType.cs │ │ └── PathGeneratorType.cs │ ├── UserControlGeneratorType.cs │ ├── ListBoxGeneratorType.cs │ ├── PasswordBoxGeneratorType.cs │ ├── ProgressBarGeneratorType.cs │ ├── ComboBoxGeneratorType.cs │ ├── ScrollContentPresenterGeneratorType.cs │ ├── TabItemGeneratorType.cs │ ├── ListBoxItemGeneratorType.cs │ ├── TabControlGeneratorType.cs │ ├── StackPanelGeneratorType.cs │ ├── ComboBoxItemGeneratorType.cs │ ├── RepeatButtonGeneratorType.cs │ ├── SelectorGeneratorType.cs │ ├── ExpanderGeneratorType.cs │ ├── ScrollBarGeneratorType.cs │ ├── TextBoxGeneratorType.cs │ ├── SliderGeneratorType.cs │ ├── ToggleButtonGeneratorType.cs │ ├── CustomPasswordBoxGeneratorType.cs │ ├── AnimatedImageGeneratorType.cs │ ├── ImageGeneratorType.cs │ ├── RangeBaseGeneratorType.cs │ ├── ButtonGeneratorType.cs │ ├── ScrollViewerGeneratorType.cs │ ├── NumericTextBoxGeneratorType.cs │ ├── HeaderedContentControlGeneratorType.cs │ ├── TextBoxBaseGeneratorType.cs │ ├── PanelGeneratorType.cs │ └── Charts │ │ └── LineSeries2DGeneratorType.cs ├── RenderMode.cs ├── IGeneratorValue.cs ├── Values │ ├── PrimitiveGeneratorValue.cs │ ├── FontFamilyGeneratorValue.cs │ ├── BrushGeneratorValue.cs │ ├── BitmapImageGeneratorValue.cs │ ├── ResourceExtGeneratorValue.cs │ ├── ColorGeneratorValue.cs │ ├── FontWeightGeneratorValue.cs │ ├── LineGeometryGeneratorValue.cs │ ├── SoundSourceGeneratorValue.cs │ ├── Effects │ │ ├── CustomEffectGeneratorValue.cs │ │ └── DirectionalBlurEffectGeneratorValue.cs │ ├── EllipseGeometryGeneratorValue.cs │ ├── RectangleGeometryGeneratorValue.cs │ ├── ItemsPanelTemplateGeneratorValue.cs │ ├── ThicknessAnimationGeneratorValue.cs │ ├── DoubleAnimationGeneratorValue.cs │ ├── ThicknessGeneratorValue.cs │ ├── SolidColorBrushAnimGeneratorValue.cs │ └── DataTemplateGeneratorValue.cs ├── IGeneratorType.cs ├── EmptyKeys.UserInterface.Generator.csproj └── EffectAssets.cs ├── GlobalAssemblyInfo.cs └── EmptyKeys.UserInterface.Generator.sln /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmptyKeys/UI_Generator/HEAD/LICENSE -------------------------------------------------------------------------------- /ekUiGen/New EmptyKeys UI.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmptyKeys/UI_Generator/HEAD/ekUiGen/New EmptyKeys UI.zip -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Effects/FakeShader.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EmptyKeys/UI_Generator/HEAD/EmptyKeys.UserInterface.Designer/Effects/FakeShader.ps -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Effects/CompileShader.bat: -------------------------------------------------------------------------------- 1 | "C:\Program Files (x86)\Windows Kits\10\bin\x64\fxc.exe" /T ps_2_0 /E main /Fo "FakeShader.ps" "FakeShader.fx" 2 | -------------------------------------------------------------------------------- /ekUiGen/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ekUiGen/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UI_Generator 2 | ============ 3 | 4 | User Interface Generator for Empty Keys UI library. Generator takes XAML files and generates .cs files for each. It can generate UIRoot, UserControl or ResourceDictionary XAML files. 5 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Interactions/Action.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace EmptyKeys.UserInterface.Designer.Interactions 9 | { 10 | public class Action : DependencyObject 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Interactions/Behavior.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace EmptyKeys.UserInterface.Designer.Interactions 9 | { 10 | public class Behavior : DependencyObject 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ekUiGen/SpriteFontTemplate.pdxfnt: -------------------------------------------------------------------------------- 1 | !SpriteFont 2 | Id: {3} 3 | Tags: [] 4 | Source: 5 | FontName: {0} 6 | Size: {1} 7 | Style: {2} 8 | IsDynamic: false 9 | DefaultCharacter: '*' 10 | CharacterSet: 11 | CharacterRegions: 12 | - Start: ' ' 13 | End: "\x7F" 14 | AntiAlias: ClearType 15 | NoPremultiply: false 16 | Spacing: 0.0 17 | LineSpacing: 0.0 18 | UseKerning: true 19 | -------------------------------------------------------------------------------- /ekUiGen/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle("Empty Keys User Interface Generator Console")] 6 | [assembly: AssemblyDescription("")] 7 | [assembly: AssemblyProduct("ekUiGen")] 8 | [assembly: AssemblyCulture("")] 9 | 10 | [assembly: ComVisible(false)] 11 | [assembly: CLSCompliant(false)] -------------------------------------------------------------------------------- /UIGenerator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle("Empty Keys User Interface Generator")] 6 | [assembly: AssemblyDescription("Empty Keys User Interface Generator")] 7 | [assembly: AssemblyProduct("UIGenerator")] 8 | [assembly: AssemblyCulture("")] 9 | 10 | [assembly: ComVisible(false)] 11 | [assembly: CLSCompliant(false)] -------------------------------------------------------------------------------- /ekUiGen/SpriteFontTemplate.xkfnt: -------------------------------------------------------------------------------- 1 | !SpriteFont 2 | Id: {3} 3 | SerializedVersion: {5} 4 | Tags: [] 5 | FontSource: !SystemFontProvider 6 | FontName: {0} 7 | Style: {2} 8 | FontType: !OfflineRasterizedSpriteFontType 9 | Size: {1} 10 | CharacterSet: 11 | CharacterRegions: 12 | {4}: 13 | Start: ' ' 14 | End: "΃" 15 | AntiAlias: ClearType 16 | DefaultCharacter: '*' -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Interactions/ActionCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EmptyKeys.UserInterface.Designer.Interactions 8 | { 9 | public class ActionCollection : List 10 | { 11 | public ActionCollection() 12 | : base() 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Interactions/BehaviorCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EmptyKeys.UserInterface.Designer.Interactions 8 | { 9 | public class BehaviorCollection : List 10 | { 11 | public BehaviorCollection() 12 | : base() 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /GlobalAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | 4 | #if DEBUG 5 | [assembly: AssemblyConfiguration("Debug")] 6 | #else 7 | [assembly: AssemblyConfiguration("Release")] 8 | #endif 9 | 10 | [assembly: AssemblyCompany("Empty Keys")] 11 | [assembly: AssemblyCopyright("Copyright © 2016-2025 Empty Keys, Filip Dušek")] 12 | [assembly: AssemblyTrademark("Empty Keys ™")] 13 | 14 | [assembly: NeutralResourcesLanguage("en")] 15 | 16 | [assembly: AssemblyVersion("4.0.0.0")] 17 | [assembly: AssemblyFileVersion("4.0.0.0")] 18 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/SoundSourceCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EmptyKeys.UserInterface.Designer 8 | { 9 | /// 10 | /// Fake implementations for WPF designer 11 | /// 12 | public class SoundSourceCollection : List 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public SoundSourceCollection() 18 | : base() 19 | { 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/GeneratedBindingsMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EmptyKeys.UserInterface.Designer 8 | { 9 | /// 10 | /// Describes modes for binding generator 11 | /// 12 | public enum GeneratedBindingsMode 13 | { 14 | // Bindings are generated 15 | Generated, 16 | // Bindings are ignored and using reflection 17 | Reflection, 18 | // Bindings can use both, reflection and generated 19 | Mixed, 20 | // Bindings with custom type 21 | Manual 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Charts/SeriesPointCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EmptyKeys.UserInterface.Designer.Charts 8 | { 9 | /// 10 | /// Implements fake designer collection for SeriesPoints 11 | /// 12 | public class SeriesPointCollection : List 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public SeriesPointCollection() 18 | : base() 19 | { 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ekUiGen/SpriteFontTemplate.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {0} 6 | 7 | {1} 8 | 0 9 | true 10 | 11 | 12 | * 13 | 14 | 15 | 16 | ſ 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /UIGenerator/Types/CheckBoxGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Controls; 7 | 8 | namespace EmptyKeys.UserInterface.Generator.Types 9 | { 10 | /// 11 | /// Implements Check Box control generator 12 | /// 13 | public class CheckBoxGeneratorType : ToggleButtonGeneratorType 14 | { 15 | /// 16 | /// Gets the type of the xaml. 17 | /// 18 | /// 19 | /// The type of the xaml. 20 | /// 21 | public override Type XamlType 22 | { 23 | get 24 | { 25 | return typeof(CheckBox); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ekUiGen/EmptyKeys.UserInterface.targets: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | $(ProjectDir)UI\Views 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /UIGenerator/RenderMode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EmptyKeys.UserInterface.Generator 8 | { 9 | /// 10 | /// Render modes 11 | /// 12 | public enum RenderMode 13 | { 14 | /// 15 | /// Synapse Gaming Sunburn engine 16 | /// 17 | SunBurn, 18 | 19 | /// 20 | /// MonoGame 21 | /// 22 | MonoGame, 23 | 24 | /// 25 | /// FNA 26 | /// 27 | FNA, 28 | 29 | /// 30 | /// Cocos Sharp 31 | /// 32 | CocosSharp, 33 | 34 | /// 35 | /// Xenko engine 36 | /// 37 | Xenko 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | using System.Windows; 5 | 6 | [assembly: AssemblyTitle("EmptyKeys.UserInterface.Designer")] 7 | [assembly: AssemblyDescription("Empty Keys UI WPF Designer library")] 8 | [assembly: AssemblyProduct("EmptyKeys.UserInterface.Designer")] 9 | [assembly: AssemblyCulture("")] 10 | 11 | [assembly: ComVisible(false)] 12 | [assembly: CLSCompliant(false)] 13 | 14 | [assembly:ThemeInfo( 15 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 16 | //(used if a resource is not found in the page, 17 | // or application resource dictionaries) 18 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 19 | //(used if a resource is not found in the page, 20 | // app, or any theme specific resource dictionaries) 21 | )] -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Interactions/PlaySoundAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace EmptyKeys.UserInterface.Designer.Interactions 9 | { 10 | public class PlaySoundAction : Action 11 | { 12 | /// 13 | /// The source property 14 | /// 15 | public static readonly DependencyProperty SourceProperty = 16 | DependencyProperty.Register("Source", typeof(SoundSource), typeof(PlaySoundAction), 17 | new FrameworkPropertyMetadata(null)); 18 | 19 | /// 20 | /// Gets or sets the source. 21 | /// 22 | /// 23 | /// The source. 24 | /// 25 | public SoundSource Source 26 | { 27 | get { return (SoundSource)GetValue(SourceProperty); } 28 | set { SetValue(SourceProperty, value); } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/ScrollViewerAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EmptyKeys.UserInterface.Designer 8 | { 9 | /// 10 | /// Describes actions for Scroll Viewer 11 | /// 12 | public enum ScrollViewerAction 13 | { 14 | /// 15 | /// The none 16 | /// 17 | None, 18 | 19 | /// 20 | /// The scroll to bottom 21 | /// 22 | ScrollToBottom, 23 | 24 | /// 25 | /// The scroll to top 26 | /// 27 | ScrollToTop, 28 | 29 | /// 30 | /// The scroll to left 31 | /// 32 | ScrollToLeft, 33 | 34 | /// 35 | /// The scroll to right 36 | /// 37 | ScrollToRight, 38 | 39 | /// 40 | /// The scroll to point 41 | /// 42 | ScrollToPoint 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Effects/FakeShader.fx: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // 3 | // Fake shader 4 | // 5 | //-------------------------------------------------------------------------------------- 6 | 7 | //----------------------------------------------------------------------------------------- 8 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 9 | //----------------------------------------------------------------------------------------- 10 | 11 | //-------------------------------------------------------------------------------------- 12 | // Sampler Inputs (Brushes, including ImplicitInput) 13 | //-------------------------------------------------------------------------------------- 14 | 15 | sampler2D implicitInputSampler : register(S0); 16 | 17 | //-------------------------------------------------------------------------------------- 18 | // Pixel Shader 19 | //-------------------------------------------------------------------------------------- 20 | 21 | float4 main(float2 uv : TEXCOORD) : COLOR 22 | { 23 | float4 color = tex2D(implicitInputSampler, uv); 24 | return color; 25 | } -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EmptyKeys.UserInterface.Designer.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/RoutedEvents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace EmptyKeys.UserInterface.Designer 9 | { 10 | public class RoutedEvents : UIElement 11 | { 12 | /// 13 | /// The visible event 14 | /// 15 | public static readonly RoutedEvent VisibleEvent; 16 | 17 | /// 18 | /// The hidden event 19 | /// 20 | public static readonly RoutedEvent HiddenEvent; 21 | 22 | /// 23 | /// The collapsed event 24 | /// 25 | public static readonly RoutedEvent CollapsedEvent; 26 | 27 | static RoutedEvents() 28 | { 29 | VisibleEvent = EventManager.RegisterRoutedEvent("Visible", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(RoutedEvents)); 30 | HiddenEvent = EventManager.RegisterRoutedEvent("Hidden", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(RoutedEvents)); 31 | CollapsedEvent = EventManager.RegisterRoutedEvent("Collapsed", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(RoutedEvents)); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /UIGenerator/Types/CustomUserControlGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EmptyKeys.UserInterface.Generator.Types 8 | { 9 | /// 10 | /// Implements fake generator for custom User Controls (in data templates for MVVM support) 11 | /// 12 | public class CustomUserControlGeneratorType : ContentControlGeneratorType 13 | { 14 | /// 15 | /// Gets the type of the xaml. 16 | /// 17 | /// 18 | /// The type of the xaml. 19 | /// 20 | public override Type XamlType 21 | { 22 | get 23 | { 24 | return this.GetType(); 25 | } 26 | } 27 | 28 | /// 29 | /// Gets the children. 30 | /// 31 | /// source 32 | /// 33 | public override System.Collections.IEnumerable GetChildren(System.Windows.DependencyObject source) 34 | { 35 | // we don't have to generate children, because custom user control is already generated 36 | return null; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /UIGenerator/IGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace EmptyKeys.UserInterface.Generator 10 | { 11 | /// 12 | /// Describes generator value interface 13 | /// 14 | public interface IGeneratorValue 15 | { 16 | /// 17 | /// Gets the type of the value. 18 | /// 19 | /// 20 | /// The type of the value. 21 | /// 22 | Type ValueType 23 | { 24 | get; 25 | } 26 | 27 | /// 28 | /// Generates code for value 29 | /// 30 | /// The parent class. 31 | /// The method. 32 | /// The value. 33 | /// Name of the base. 34 | /// The dictionary. 35 | /// 36 | CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/ImageBrush.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Media; 8 | 9 | namespace EmptyKeys.UserInterface.Designer 10 | { 11 | /// 12 | /// Implements fake designer class for Image Brush 13 | /// 14 | public static class ImageBrush 15 | { 16 | /// 17 | /// The color overlay property 18 | /// 19 | public static readonly DependencyProperty ColorOverlayProperty = 20 | DependencyProperty.RegisterAttached("ColorOverlay", typeof(Color), typeof(ImageBrush), 21 | new FrameworkPropertyMetadata(Color.FromArgb(255,255,255,255))); 22 | 23 | /// 24 | /// Gets the color overlay. 25 | /// 26 | /// The object. 27 | /// 28 | public static Color GetColorOverlay(DependencyObject obj) 29 | { 30 | return (Color)obj.GetValue(ColorOverlayProperty); 31 | } 32 | 33 | /// 34 | /// Sets the color overlay. 35 | /// 36 | /// The object. 37 | /// The value. 38 | public static void SetColorOverlay(DependencyObject obj, Color value) 39 | { 40 | obj.SetValue(ColorOverlayProperty, value); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/RadialPanelGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using EmptyKeys.UserInterface.Designer; 2 | using System; 3 | using System.CodeDom; 4 | using System.Windows; 5 | 6 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 7 | { 8 | /// 9 | /// Implements generator for Radial Panel 10 | /// 11 | /// 12 | public class RadialPanelGeneratorType : PanelGeneratorType 13 | { 14 | /// 15 | /// Gets the type of the xaml. 16 | /// 17 | /// 18 | /// The type of the xaml. 19 | /// 20 | public override Type XamlType 21 | { 22 | get { return typeof(RadialPanel); } 23 | } 24 | 25 | /// 26 | /// Generates the specified initialize method. 27 | /// 28 | /// The dependency object 29 | /// Type of the class. 30 | /// The initialize method. 31 | /// if set to true [generate field]. 32 | /// 33 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 34 | { 35 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 36 | 37 | return fieldReference; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /UIGenerator/Values/PrimitiveGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace EmptyKeys.UserInterface.Generator.Values 10 | { 11 | /// 12 | /// Implements generator for all primitive types 13 | /// 14 | /// 15 | public class PrimitiveGeneratorValue : IGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(T); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code for value 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | return new CodePrimitiveExpression(value); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/EmptyKeys.UserInterface.Designer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0-windows 4 | Library 5 | SAK 6 | SAK 7 | SAK 8 | SAK 9 | false 10 | true 11 | true 12 | AppStore;Debug;Release;Testing 13 | 14 | 15 | bin\x64\Debug\ 16 | MinimumRecommendedRules.ruleset 17 | 18 | 19 | bin\x64\Release\ 20 | MinimumRecommendedRules.ruleset 21 | 22 | 23 | 24 | Properties\GlobalAssemblyInfo.cs 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/GroupBoxGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 11 | { 12 | /// 13 | /// Implements Group Box control generator 14 | /// 15 | public class GroupBoxGeneratorType : HeaderedContentControlGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(GroupBox); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code 33 | /// 34 | /// The dependence object 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 42 | return fieldReference; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /UIGenerator/Types/ThumbGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls.Primitives; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types 11 | { 12 | /// 13 | /// Implements UI generator for Thumb WPF control 14 | /// 15 | public class ThumbGeneratorType : ControlGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(Thumb); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates the specified source. 33 | /// 34 | /// The source. 35 | /// Type of the class. 36 | /// The method. 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 42 | 43 | return fieldReference; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /UIGenerator/Values/FontFamilyGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements generator for Font Family value 14 | /// 15 | public class FontFamilyGeneratorValue : IGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(FontFamily); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code for value 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | FontFamily fontFamily = value as FontFamily; 43 | return CodeComHelper.GenerateFontFamilyExpression(fontFamily); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /UIGenerator/Types/Shapes/EllipseGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Shapes; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Shapes 11 | { 12 | /// 13 | /// Implements Ellipse shape type generator 14 | /// 15 | public class EllipseGeneratorType : ShapeGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get { return typeof(Ellipse); } 26 | } 27 | 28 | /// 29 | /// Generates control fields 30 | /// 31 | /// The source. 32 | /// Type of the class. 33 | /// The initialize method. 34 | /// if set to true [generate field]. 35 | /// 36 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 37 | { 38 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 39 | 40 | Ellipse ellipse = source as Ellipse; 41 | 42 | return fieldReference; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/TreeViewGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 11 | { 12 | /// 13 | /// Implements Tree View control generator 14 | /// 15 | public class TreeViewGeneratorType : ItemsControlGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(TreeView); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code 33 | /// 34 | /// The dependence object 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 42 | TreeView treeView = source as TreeView; 43 | return fieldReference; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /UIGenerator/Values/BrushGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements generator for all brushes 14 | /// 15 | /// 16 | public class BrushGeneratorValue : IGeneratorValue 17 | { 18 | /// 19 | /// Gets the type of the value. 20 | /// 21 | /// 22 | /// The type of the value. 23 | /// 24 | public Type ValueType 25 | { 26 | get 27 | { 28 | return typeof(T); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates the specified parent class. 34 | /// 35 | /// The parent class. 36 | /// The method. 37 | /// The value. 38 | /// Name of the base. 39 | /// The dictionary. 40 | /// 41 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 42 | { 43 | string brushVarName = baseName + "_b"; 44 | return CodeComHelper.GenerateBrushInstance(method, value as Brush, brushVarName); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/Primitives/TabPanelGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls.Primitives; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Controls.Primitives 11 | { 12 | /// 13 | /// Implements generator for TabPanel 14 | /// 15 | public class TabPanelGeneratorType : PanelGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get { return typeof(TabPanel); } 26 | } 27 | 28 | /// 29 | /// Generates the specified initialize method. 30 | /// 31 | /// The dependency object 32 | /// Type of the class. 33 | /// The initialize method. 34 | /// if set to true [generate field]. 35 | /// 36 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 37 | { 38 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 39 | 40 | TabPanel tabPanel = source as TabPanel; 41 | 42 | return fieldReference; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/CanvasGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Media; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 13 | { 14 | /// 15 | /// Implements Canvas control generator 16 | /// 17 | public class CanvasGeneratorType : PanelGeneratorType 18 | { 19 | /// 20 | /// Gets the type of the xaml. 21 | /// 22 | /// 23 | /// The type of the xaml. 24 | /// 25 | public override Type XamlType 26 | { 27 | get { return typeof(Canvas); } 28 | } 29 | 30 | /// 31 | /// Generates the specified initialize method. 32 | /// 33 | /// The dependency object 34 | /// Type of the class. 35 | /// The initialize method. 36 | /// if set to true [generate field]. 37 | /// 38 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 39 | { 40 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 41 | Canvas canvas = source as Canvas; 42 | return fieldReference; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/SoundType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EmptyKeys.UserInterface.Designer 8 | { 9 | /// 10 | /// Sound Types for UI 11 | /// 12 | public enum SoundType 13 | { 14 | /// 15 | /// 16 | /// 17 | None, 18 | 19 | /// 20 | /// The buttons click 21 | /// 22 | ButtonsClick, 23 | 24 | /// 25 | /// The buttons hover sound 26 | /// 27 | ButtonsHover, 28 | 29 | /// 30 | /// The ListBox move 31 | /// 32 | ListBoxMove, 33 | 34 | /// 35 | /// The ListBox select 36 | /// 37 | ListBoxSelect, 38 | 39 | /// 40 | /// The text box key press 41 | /// 42 | TextBoxKeyPress, 43 | 44 | /// 45 | /// The tab control move 46 | /// 47 | TabControlMove, 48 | 49 | /// 50 | /// The tab control select 51 | /// 52 | TabControlSelect, 53 | 54 | /// 55 | /// The CheckBox hover 56 | /// 57 | CheckBoxHover, 58 | 59 | /// 60 | /// The RadioButton hover 61 | /// 62 | RadioButtonHover, 63 | 64 | /// 65 | /// Sound type when focus is changed 66 | /// 67 | FocusChanged 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /UIGenerator/Values/BitmapImageGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media.Imaging; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements generator for Bitmap Image 14 | /// 15 | public class BitmapImageGeneratorValue : IGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(BitmapImage); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code for value 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | string bitmapVarName = baseName + "_bm"; 43 | 44 | BitmapImage bitmap = value as BitmapImage; 45 | return CodeComHelper.GenerateBitmapImageValue(method, bitmap.UriSource, bitmapVarName); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /UIGenerator/Types/UserControlGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types 11 | { 12 | /// 13 | /// Implements User Control generator 14 | /// 15 | public class UserControlGeneratorType : ContentControlGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(UserControl); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates control fields 33 | /// 34 | /// The source. 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 40 | { 41 | CodeExpression fieldReference = new CodeThisReferenceExpression(); 42 | 43 | CodeComHelper.GenerateTemplateStyleField(classType, initMethod, fieldReference, source, FrameworkElement.StyleProperty); 44 | 45 | return fieldReference; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/DataGridTextColumnGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 11 | { 12 | /// 13 | /// Implements generator for text column 14 | /// 15 | public class DataGridTextColumnGeneratorType : DataGridBoundColumnGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(DataGridTextColumn); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates control fields 33 | /// 34 | /// The source. 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 42 | 43 | DataGridTextColumn column = source as DataGridTextColumn; 44 | 45 | return fieldReference; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/TreeViewItemGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 11 | { 12 | /// 13 | /// Implements Tree View Item generator 14 | /// 15 | public class TreeViewItemGeneratorType : HeaderedItemsControlGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(TreeViewItem); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code 33 | /// 34 | /// The dependence object 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 42 | 43 | TreeViewItem item = source as TreeViewItem; 44 | CodeComHelper.GenerateField(method, fieldReference, item, TreeViewItem.IsSelectedProperty); 45 | 46 | return fieldReference; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /UIGenerator/Values/ResourceExtGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements generator for DynamicResourceExtension 14 | /// 15 | public class ResourceExtGeneratorValue : IGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(DynamicResourceExtension); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates the specified parent class. 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | DynamicResourceExtension dynamicResource = value as DynamicResourceExtension; 43 | return new CodeObjectCreateExpression("ResourceReferenceExpression", new CodePrimitiveExpression(dynamicResource.ResourceKey)); 44 | } 45 | } 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/DataGridCheckBoxColumnGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 11 | { 12 | /// 13 | /// Implements generator for boolean column with check box 14 | /// 15 | public class DataGridCheckBoxColumnGeneratorType : DataGridBoundColumnGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(DataGridCheckBoxColumn); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates control fields 33 | /// 34 | /// The source. 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 42 | 43 | DataGridCheckBoxColumn column = source as DataGridCheckBoxColumn; 44 | 45 | return fieldReference; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /UIGenerator/Types/ListBoxGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Controls.Primitives; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements List Box control generator 15 | /// 16 | public class ListBoxGeneratorType : SelectorGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(ListBox); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates code 34 | /// 35 | /// The dependence object 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | ListBox listBox = source as ListBox; 45 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, ListBox.SelectionModeProperty); 46 | 47 | return fieldReference; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/ScrollViewerHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace EmptyKeys.UserInterface.Designer 9 | { 10 | /// 11 | /// Implements Scroll Viewer helper with custom attached property, this is fake designer class 12 | /// 13 | public static class ScrollViewerHelper 14 | { 15 | private static Type typeOfThis = typeof(ScrollViewerHelper); 16 | 17 | /// 18 | /// Gets the action. 19 | /// 20 | /// The object. 21 | /// 22 | public static ScrollViewerAction GetAction(DependencyObject obj) 23 | { 24 | return (ScrollViewerAction)obj.GetValue(ActionProperty); 25 | } 26 | 27 | /// 28 | /// Sets the action. 29 | /// 30 | /// The object. 31 | /// The value. 32 | public static void SetAction(DependencyObject obj, ScrollViewerAction value) 33 | { 34 | obj.SetValue(ActionProperty, value); 35 | } 36 | 37 | /// 38 | /// The action property 39 | /// 40 | public static readonly DependencyProperty ActionProperty = 41 | DependencyProperty.RegisterAttached("Action", typeof(ScrollViewerAction), typeOfThis, 42 | new FrameworkPropertyMetadata(ScrollViewerAction.None, FrameworkPropertyMetadataOptions.None, new PropertyChangedCallback(OnActionChanged))); 43 | 44 | private static void OnActionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 45 | { 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /UIGenerator/Types/PasswordBoxGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types 11 | { 12 | /// 13 | /// Implements Password Box control generator 14 | /// 15 | public class PasswordBoxGeneratorType : TextBoxGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(PasswordBox); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code 33 | /// 34 | /// The dependence object 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 42 | 43 | PasswordBox passBox = source as PasswordBox; 44 | CodeComHelper.GenerateField(initMethod, fieldReference, source, PasswordBox.PasswordCharProperty); 45 | 46 | return fieldReference; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /UIGenerator/Types/ProgressBarGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types 11 | { 12 | /// 13 | /// Implements Progress Bar control generator 14 | /// 15 | public class ProgressBarGeneratorType : RangeBaseGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(ProgressBar); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates the specified source. 33 | /// 34 | /// The source. 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 42 | 43 | ProgressBar bar = source as ProgressBar; 44 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, bar, ProgressBar.OrientationProperty); 45 | 46 | return fieldReference; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Effects/CustomEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Media.Effects; 7 | 8 | namespace EmptyKeys.UserInterface.Designer.Effects 9 | { 10 | /// 11 | /// Implements empty class for custom effect shader - fake class for designer 12 | /// 13 | /// 14 | public class CustomEffect : ShaderEffect 15 | { 16 | /// 17 | /// The effect asset property 18 | /// 19 | public static readonly DependencyProperty EffectAssetProperty = 20 | DependencyProperty.Register("EffectAsset", typeof(string), typeof(CustomEffect), 21 | new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.None)); 22 | 23 | /// 24 | /// Gets or sets the effect asset. 25 | /// 26 | /// 27 | /// The effect asset. 28 | /// 29 | public string EffectAsset 30 | { 31 | get { return (string)GetValue(EffectAssetProperty); } 32 | set { SetValue(EffectAssetProperty, value); } 33 | } 34 | 35 | /// 36 | /// Initializes a new instance of the class. 37 | /// 38 | public CustomEffect() : base() 39 | { 40 | var pixelShader = new PixelShader(); 41 | var fileUri = new Uri("pack://application:,,,/EmptyKeys.UserInterface.Designer;component/Effects/FakeShader.ps", UriKind.RelativeOrAbsolute); 42 | pixelShader.UriSource = fileUri; 43 | PixelShader = pixelShader; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /UIGenerator/Types/ComboBoxGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Controls.Primitives; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements Combo Box control generator 15 | /// 16 | public class ComboBoxGeneratorType : SelectorGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(ComboBox); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates control fields 34 | /// 35 | /// The dependence object 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | ComboBox combo = source as ComboBox; 45 | CodeComHelper.GenerateFieldDoubleToFloat(initMethod, fieldReference, source, ComboBox.MaxDropDownHeightProperty); 46 | 47 | return fieldReference; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /UIGenerator/Types/ScrollContentPresenterGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements Scroll Content Presenter generator 15 | /// 16 | public class ScrollContentPresenterGeneratorType : ContentPresenterGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(ScrollContentPresenter); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates control fields 34 | /// 35 | /// The source. 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// if set to true [generate field]. 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | CodeComHelper.GenerateField(initMethod, fieldReference, source, ScrollViewer.CanContentScrollProperty); 45 | 46 | return fieldReference; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /UIGenerator/Types/TabItemGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Controls.Primitives; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types 13 | { 14 | /// 15 | /// Implements Tab Item control generator 16 | /// 17 | public class TabItemGeneratorType : HeaderedContentControlGeneratorType 18 | { 19 | /// 20 | /// Gets the type of the xaml. 21 | /// 22 | /// 23 | /// The type of the xaml. 24 | /// 25 | public override Type XamlType 26 | { 27 | get 28 | { 29 | return typeof(TabItem); 30 | } 31 | } 32 | 33 | /// 34 | /// Generates code 35 | /// 36 | /// The dependence object 37 | /// Type of the class. 38 | /// The initialize method. 39 | /// 40 | /// 41 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 42 | { 43 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 44 | 45 | TabItem item = source as TabItem; 46 | CodeComHelper.GenerateField(method, fieldReference, source, Selector.IsSelectedProperty); 47 | 48 | return fieldReference; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/RadioButtonGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 11 | { 12 | /// 13 | /// Implements Radio Button control generator 14 | /// 15 | public class RadioButtonGeneratorType : ToggleButtonGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(RadioButton); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code 33 | /// 34 | /// The dependence object 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 42 | 43 | RadioButton radio = source as RadioButton; 44 | CodeComHelper.GenerateField(initMethod, fieldReference, source, RadioButton.GroupNameProperty); 45 | 46 | return fieldReference; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/DockPanelGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Media; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 13 | { 14 | /// 15 | /// Implements DockPanel control generator 16 | /// 17 | public class DockPanelGeneratorType : PanelGeneratorType 18 | { 19 | /// 20 | /// Gets the type of the xaml. 21 | /// 22 | /// 23 | /// The type of the xaml. 24 | /// 25 | public override Type XamlType 26 | { 27 | get { return typeof(DockPanel); } 28 | } 29 | 30 | /// 31 | /// Generates the specified initialize method. 32 | /// 33 | /// The dependency object 34 | /// Type of the class. 35 | /// The initialize method. 36 | /// if set to true [generate field]. 37 | /// 38 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 39 | { 40 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 41 | DockPanel dockPanel = source as DockPanel; 42 | CodeComHelper.GenerateField(initMethod, fieldReference, source, DockPanel.LastChildFillProperty); 43 | return fieldReference; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /UIGenerator/Types/ListBoxItemGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Controls.Primitives; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types 13 | { 14 | /// 15 | /// Implements List Box Item control generator 16 | /// 17 | public class ListBoxItemGeneratorType : ContentControlGeneratorType 18 | { 19 | /// 20 | /// Gets the type of the xaml. 21 | /// 22 | /// 23 | /// The type of the xaml. 24 | /// 25 | public override Type XamlType 26 | { 27 | get 28 | { 29 | return typeof(ListBoxItem); 30 | } 31 | } 32 | 33 | /// 34 | /// Generates code 35 | /// 36 | /// The dependence object 37 | /// Type of the class. 38 | /// The initialize method. 39 | /// 40 | /// 41 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 42 | { 43 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 44 | 45 | ListBoxItem item = source as ListBoxItem; 46 | CodeComHelper.GenerateField(method, fieldReference, source, Selector.IsSelectedProperty); 47 | 48 | return fieldReference; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /UIGenerator/Types/TabControlGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Controls.Primitives; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements Tab Control generator 15 | /// 16 | public class TabControlGeneratorType : SelectorGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(TabControl); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates code 34 | /// 35 | /// The dependence object 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// if set to true [generate field]. 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | TabControl tabControl = source as TabControl; 45 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, TabControl.TabStripPlacementProperty); 46 | 47 | return fieldReference; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /UIGenerator/Types/StackPanelGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Media; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types 13 | { 14 | /// 15 | /// Implements Stack Panel control generator 16 | /// 17 | public class StackPanelGeneratorType : PanelGeneratorType 18 | { 19 | /// 20 | /// Gets the type of the xaml. 21 | /// 22 | /// 23 | /// The type of the xaml. 24 | /// 25 | public override Type XamlType 26 | { 27 | get { return typeof(StackPanel); } 28 | } 29 | 30 | /// 31 | /// Generates the specified initialize method. 32 | /// 33 | /// The dependency object 34 | /// Type of the class. 35 | /// The initialize method. 36 | /// if set to true [generate field]. 37 | /// 38 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 39 | { 40 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 41 | 42 | StackPanel stackPanel = source as StackPanel; 43 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, StackPanel.OrientationProperty); 44 | 45 | return fieldReference; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Input/GamepadGesture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Input; 7 | 8 | namespace EmptyKeys.UserInterface.Designer.Input 9 | { 10 | /// 11 | /// Implements fake Gamepad Gesture for XAML designer 12 | /// 13 | public class GamepadGesture : InputGesture 14 | { 15 | /// 16 | /// Gets the game pad input. 17 | /// 18 | /// 19 | /// The game pad input. 20 | /// 21 | public GamepadInput GamepadInput 22 | { 23 | get; 24 | internal set; 25 | } 26 | 27 | /// 28 | /// Initializes a new instance of the class. 29 | /// 30 | /// The game pad input. 31 | public GamepadGesture(GamepadInput gamepadInput) 32 | { 33 | GamepadInput = gamepadInput; 34 | } 35 | 36 | /// 37 | /// When overridden in a derived class, determines whether the specified matches the input associated with the specified object. 38 | /// 39 | /// The target of the command. 40 | /// The input event data to compare this gesture to. 41 | /// 42 | /// true if the gesture matches the input; otherwise, false. 43 | /// 44 | public override bool Matches(object targetElement, InputEventArgs inputEventArgs) 45 | { 46 | return true; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /UIGenerator/Types/Shapes/RectangleGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Shapes; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Shapes 11 | { 12 | /// 13 | /// Implements Rectangle shape type generator 14 | /// 15 | public class RectangleGeneratorType : ShapeGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get { return typeof(Rectangle); } 26 | } 27 | 28 | /// 29 | /// Generates control fields 30 | /// 31 | /// The source. 32 | /// Type of the class. 33 | /// The initialize method. 34 | /// if set to true [generate field]. 35 | /// 36 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 37 | { 38 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 39 | 40 | Rectangle rect = source as Rectangle; 41 | 42 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, source, Rectangle.RadiusXProperty); 43 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, source, Rectangle.RadiusYProperty); 44 | 45 | return fieldReference; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /UIGenerator/Types/ComboBoxItemGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Collections.ObjectModel; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Controls.Primitives; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types 13 | { 14 | /// 15 | /// Implements Combo Box Item control generator 16 | /// 17 | public class ComboBoxItemGeneratorType : ListBoxItemGeneratorType 18 | { 19 | /// 20 | /// Gets the type of the xaml. 21 | /// 22 | /// 23 | /// The type of the xaml. 24 | /// 25 | public override Type XamlType 26 | { 27 | get 28 | { 29 | return typeof(ComboBoxItem); 30 | } 31 | } 32 | 33 | /// 34 | /// Generates control fields 35 | /// 36 | /// The source. 37 | /// Type of the class. 38 | /// The method. 39 | /// if set to true [generate field]. 40 | /// 41 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 42 | { 43 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 44 | 45 | ComboBoxItem item = source as ComboBoxItem; 46 | CodeComHelper.GenerateField(method, fieldReference, source, ComboBoxItem.IsHighlightedProperty); 47 | 48 | return fieldReference; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /UIGenerator/Types/RepeatButtonGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Controls.Primitives; 10 | using System.Windows.Data; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types 13 | { 14 | /// 15 | /// Implements Repeat Button control generator 16 | /// 17 | public class RepeatButtonGeneratorType : ButtonGeneratorType 18 | { 19 | /// 20 | /// Gets the type of the xaml. 21 | /// 22 | /// 23 | /// The type of the xaml. 24 | /// 25 | public override Type XamlType 26 | { 27 | get 28 | { 29 | return typeof(RepeatButton); 30 | } 31 | } 32 | 33 | /// 34 | /// Generates code 35 | /// 36 | /// The dependence object 37 | /// Type of the class. 38 | /// The initialize method. 39 | /// 40 | /// 41 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 42 | { 43 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 44 | CodeComHelper.GenerateField(initMethod, fieldReference, source, RepeatButton.DelayProperty); 45 | CodeComHelper.GenerateField(initMethod, fieldReference, source, RepeatButton.IntervalProperty); 46 | 47 | return fieldReference; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /UIGenerator/Types/SelectorGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Controls.Primitives; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements Selector control generator 15 | /// 16 | public class SelectorGeneratorType : ItemsControlGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(Selector); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates code 34 | /// 35 | /// The dependence object 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// if set to true [generate field]. 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | Selector selector = source as Selector; 45 | CodeComHelper.GenerateField(initMethod, fieldReference, source, Selector.SelectedIndexProperty); 46 | 47 | // TODO selected item 48 | 49 | return fieldReference; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/DataGridTemplateColumnGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 11 | { 12 | /// 13 | /// Implements generator for Data Grid Template Column 14 | /// 15 | public class DataGridTemplateColumnGeneratorType : DataGridColumnGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(DataGridTemplateColumn); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates control fields 33 | /// 34 | /// The source. 35 | /// Type of the class. 36 | /// 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 42 | DataGridTemplateColumn column = source as DataGridTemplateColumn; 43 | 44 | CodeComHelper.GenerateTemplateStyleField(classType, method, fieldReference, source, DataGridTemplateColumn.CellTemplateProperty, ColumnName + "_ct"); 45 | 46 | return fieldReference; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /UIGenerator/Types/ExpanderGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements Expander control generator 15 | /// 16 | public class ExpanderGeneratorType : HeaderedContentControlGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(Expander); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates code 34 | /// 35 | /// The dependence object 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | Expander expander = source as Expander; 45 | CodeComHelper.GenerateField(initMethod, fieldReference, source, Expander.IsExpandedProperty); 46 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, Expander.ExpandDirectionProperty); 47 | 48 | return fieldReference; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /UIGenerator/Types/ScrollBarGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Controls.Primitives; 10 | using System.Windows.Media; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types 13 | { 14 | /// 15 | /// Implements Scroll Bar control generator 16 | /// 17 | public class ScrollBarGeneratorType : RangeBaseGeneratorType 18 | { 19 | /// 20 | /// Gets the type of the xaml. 21 | /// 22 | /// 23 | /// The type of the xaml. 24 | /// 25 | public override Type XamlType 26 | { 27 | get 28 | { 29 | return typeof(ScrollBar); 30 | } 31 | } 32 | 33 | /// 34 | /// Generates control fields 35 | /// 36 | /// The source. 37 | /// Type of the class. 38 | /// The initialize method. 39 | /// if set to true [generate field]. 40 | /// 41 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 42 | { 43 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 44 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, ScrollBar.OrientationProperty); 45 | CodeComHelper.GenerateFieldDoubleToFloat(initMethod, fieldReference, source, ScrollBar.ViewportSizeProperty); 46 | return fieldReference; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /UIGenerator/Types/TextBoxGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Controls.Primitives; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements Text Box control generator 15 | /// 16 | public class TextBoxGeneratorType : TextBoxBaseGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(TextBox); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates code 34 | /// 35 | /// The dependence object 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// if set to true [generate field]. 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | TextBox textBox = source as TextBox; 45 | CodeComHelper.GenerateField(initMethod, fieldReference, source, TextBox.TextProperty); 46 | CodeComHelper.GenerateField(initMethod, fieldReference, source, TextBox.MaxLengthProperty); 47 | 48 | return fieldReference; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /UIGenerator/Types/SliderGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types 11 | { 12 | /// 13 | /// Implements Slider UI Generator 14 | /// 15 | public class SliderGeneratorType : RangeBaseGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(Slider); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates the specified source. 33 | /// 34 | /// The source. 35 | /// Type of the class. 36 | /// The method. 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 42 | 43 | CodeComHelper.GenerateEnumField(method, fieldReference, source, Slider.OrientationProperty); 44 | CodeComHelper.GenerateField(method, fieldReference, source, Slider.IsSnapToTickEnabledProperty); 45 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, source, Slider.TickFrequencyProperty); 46 | 47 | return fieldReference; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /UIGenerator/IGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | 10 | namespace EmptyKeys.UserInterface.Generator 11 | { 12 | /// 13 | /// Describes Generator Type interface 14 | /// 15 | public interface IGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | Type XamlType 24 | { 25 | get; 26 | } 27 | 28 | /// 29 | /// Gets the children. 30 | /// 31 | /// The dependency object 32 | /// 33 | IEnumerable GetChildren(DependencyObject source); 34 | 35 | /// 36 | /// Generates the specified source. 37 | /// 38 | /// The source. 39 | /// Type of the class. 40 | /// The method. 41 | /// if set to true [generate field]. 42 | /// 43 | CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField); 44 | 45 | /// 46 | /// Adds the child. 47 | /// 48 | /// The parent. 49 | /// The child. 50 | /// The initialize method. 51 | /// The index. 52 | void AddChild(CodeExpression parent, CodeExpression child, CodeMemberMethod method, int index); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /UIGenerator/Types/ToggleButtonGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls.Primitives; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types 11 | { 12 | /// 13 | /// Implements Toggle Button control generator 14 | /// 15 | public class ToggleButtonGeneratorType : ButtonGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(ToggleButton); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code 33 | /// 34 | /// The dependence object 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 42 | 43 | ToggleButton toggle = source as ToggleButton; 44 | CodeComHelper.GenerateField(initMethod, fieldReference, source, ToggleButton.IsCheckedProperty); 45 | CodeComHelper.GenerateField(initMethod, fieldReference, source, ToggleButton.IsThreeStateProperty); 46 | 47 | return fieldReference; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /UIGenerator/Values/ColorGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements value generator for Color type 14 | /// 15 | public class ColorGeneratorValue : IGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(Color); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code for value 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | Color color = (Color)value; 43 | CodeObjectCreateExpression colorExpr = new CodeObjectCreateExpression( 44 | "ColorW", 45 | new CodePrimitiveExpression(color.R), 46 | new CodePrimitiveExpression(color.G), 47 | new CodePrimitiveExpression(color.B), 48 | new CodePrimitiveExpression(color.A)); 49 | 50 | return colorExpr; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /UIGenerator/Types/CustomPasswordBoxGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using EmptyKeys.UserInterface.Designer; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types 11 | { 12 | /// 13 | /// Implements Custom Password Box control generator with binding support for Password property 14 | /// 15 | public class CustomPasswordBoxGeneratorType : TextBoxGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get 26 | { 27 | return typeof(PasswordBox); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code 33 | /// 34 | /// The dependence object 35 | /// Type of the class. 36 | /// The initialize method. 37 | /// if set to true [generate field]. 38 | /// 39 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 40 | { 41 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 42 | 43 | PasswordBox passBox = source as PasswordBox; 44 | CodeComHelper.GenerateField(initMethod, fieldReference, source, PasswordBox.PasswordCharProperty); 45 | CodeComHelper.GenerateField(initMethod, fieldReference, source, PasswordBox.PasswordProperty); 46 | 47 | return fieldReference; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /UIGenerator/Types/Shapes/LineGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Shapes; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Shapes 11 | { 12 | /// 13 | /// Implements Type Generator for Line shape 14 | /// 15 | public class LineGeneratorType : ShapeGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get { return typeof(Line); } 26 | } 27 | 28 | /// 29 | /// Generates control fields 30 | /// 31 | /// The source. 32 | /// Type of the class. 33 | /// The initialize method. 34 | /// if set to true [generate field]. 35 | /// 36 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 37 | { 38 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 39 | 40 | Line line = source as Line; 41 | 42 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, line, Line.X1Property); 43 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, line, Line.X2Property); 44 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, line, Line.Y1Property); 45 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, line, Line.Y2Property); 46 | 47 | return fieldReference; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /UIGenerator/EmptyKeys.UserInterface.Generator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0-windows 4 | Library 5 | SAK 6 | SAK 7 | SAK 8 | SAK 9 | false 10 | true 11 | true 12 | AppStore;Debug;Release;Testing 13 | 14 | 15 | true 16 | 17 | 18 | true 19 | 20 | 21 | 22 | bin\x64\Debug\ 23 | MinimumRecommendedRules.ruleset 24 | 25 | 26 | bin\x64\Release\ 27 | bin\Release\EmptyKeys.UserInterface.Generator.XML 28 | true 29 | MinimumRecommendedRules.ruleset 30 | 31 | 32 | 33 | Properties\GlobalAssemblyInfo.cs 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/WrapPanelGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 11 | { 12 | /// 13 | /// Implements generator for WrapPanel control 14 | /// 15 | public class WrapPanelGeneratorType : PanelGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get { return typeof(WrapPanel); } 26 | } 27 | 28 | /// 29 | /// Generates the specified initialize method. 30 | /// 31 | /// The dependency object 32 | /// Type of the class. 33 | /// The initialize method. 34 | /// if set to true [generate field]. 35 | /// 36 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 37 | { 38 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 39 | 40 | WrapPanel wrapPanel = source as WrapPanel; 41 | CodeComHelper.GenerateFieldDoubleToFloat(initMethod, fieldReference, source, WrapPanel.ItemHeightProperty); 42 | CodeComHelper.GenerateFieldDoubleToFloat(initMethod, fieldReference, source, WrapPanel.ItemWidthProperty); 43 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, WrapPanel.OrientationProperty); 44 | 45 | return fieldReference; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /UIGenerator/Types/Shapes/ShapeGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | using System.Windows.Shapes; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types.Shapes 12 | { 13 | /// 14 | /// Implements Shape type generator 15 | /// 16 | public class ShapeGeneratorType : ElementGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get { return typeof(Shape); } 27 | } 28 | 29 | /// 30 | /// Generates control fields 31 | /// 32 | /// The source. 33 | /// Type of the class. 34 | /// The initialize method. 35 | /// if set to true [generate field]. 36 | /// 37 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 38 | { 39 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 40 | 41 | Shape shape = source as Shape; 42 | 43 | CodeComHelper.GenerateEnumField(method, fieldReference, source, Shape.StretchProperty); 44 | CodeComHelper.GenerateBrushField(method, fieldReference, source, Shape.FillProperty); 45 | CodeComHelper.GenerateBrushField(method, fieldReference, source, Shape.StrokeProperty); 46 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, source, Shape.StrokeThicknessProperty); 47 | 48 | return fieldReference; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /UIGenerator/Types/Shapes/PathGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Shapes; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Shapes 11 | { 12 | /// 13 | /// Implements Path shape type generator 14 | /// 15 | public class PathGeneratorType : ShapeGeneratorType 16 | { 17 | /// 18 | /// Gets the type of the xaml. 19 | /// 20 | /// 21 | /// The type of the xaml. 22 | /// 23 | public override Type XamlType 24 | { 25 | get { return typeof(Path); } 26 | } 27 | 28 | /// 29 | /// Generates control fields 30 | /// 31 | /// The source. 32 | /// Type of the class. 33 | /// The initialize method. 34 | /// if set to true [generate field]. 35 | /// 36 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 37 | { 38 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 39 | 40 | Path path = source as Path; 41 | 42 | if (CodeComHelper.IsValidForFieldGenerator(source.ReadLocalValue(Path.DataProperty))) 43 | { 44 | CodeExpression dataValueExpression = CodeComHelper.GetValueExpression(classType, method, path.Data, path.Name + "_G"); 45 | method.Statements.Add( 46 | new CodeAssignStatement( 47 | new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(path.Name), "Data"), 48 | dataValueExpression)); 49 | } 50 | 51 | return fieldReference; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/UniformGridGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls.Primitives; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 11 | { 12 | /// 13 | /// Implements generator for Uniform Grid control 14 | /// 15 | /// 16 | public class UniformGridGeneratorType : PanelGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get { return typeof(UniformGrid); } 27 | } 28 | 29 | /// 30 | /// Generates the specified initialize method. 31 | /// 32 | /// The dependency object 33 | /// Type of the class. 34 | /// The initialize method. 35 | /// if set to true [generate field]. 36 | /// 37 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 38 | { 39 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 40 | 41 | UniformGrid uniGrid = source as UniformGrid; 42 | CodeComHelper.GenerateField(initMethod, fieldReference, source, UniformGrid.FirstColumnProperty); 43 | CodeComHelper.GenerateField(initMethod, fieldReference, source, UniformGrid.RowsProperty); 44 | CodeComHelper.GenerateField(initMethod, fieldReference, source, UniformGrid.ColumnsProperty); 45 | 46 | return fieldReference; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /UIGenerator/Types/AnimatedImageGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using EmptyKeys.UserInterface.Designer; 14 | 15 | namespace EmptyKeys.UserInterface.Generator.Types 16 | { 17 | /// 18 | /// Implements Image control generator 19 | /// 20 | public class AnimatedImageGeneratorType : ImageGeneratorType 21 | { 22 | /// 23 | /// Gets the type of the xaml. 24 | /// 25 | /// 26 | /// The type of the xaml. 27 | /// 28 | public override Type XamlType 29 | { 30 | get 31 | { 32 | return typeof(AnimatedImage); 33 | } 34 | } 35 | 36 | /// 37 | /// Generates control fields 38 | /// 39 | /// The source. 40 | /// Type of the class. 41 | /// The initialize method. 42 | /// if set to true [generate field]. 43 | /// 44 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 45 | { 46 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 47 | 48 | CodeComHelper.GenerateField(method, fieldReference, source, AnimatedImage.FrameWidthProperty); 49 | CodeComHelper.GenerateField(method, fieldReference, source, AnimatedImage.FrameHeightProperty); 50 | CodeComHelper.GenerateField(method, fieldReference, source, AnimatedImage.FramesPerSecondProperty); 51 | 52 | return fieldReference; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Input/GamepadInput.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace EmptyKeys.UserInterface.Designer.Input 3 | { 4 | /// 5 | /// Enumeration of all types of game pad input 6 | /// 7 | public enum GamepadInput 8 | { 9 | /// 10 | /// The none 11 | /// 12 | None, 13 | 14 | /// 15 | /// A button 16 | /// 17 | AButton, 18 | 19 | /// 20 | /// The b button 21 | /// 22 | BButton, 23 | 24 | /// 25 | /// The c button 26 | /// 27 | CButton, 28 | 29 | /// 30 | /// The d button 31 | /// 32 | DButton, 33 | 34 | /// 35 | /// The left shoulder button 36 | /// 37 | LeftShoulderButton, 38 | 39 | /// 40 | /// The right shoulder button 41 | /// 42 | RightShoulderButton, 43 | 44 | /// 45 | /// The left stick button 46 | /// 47 | LeftStickButton, 48 | 49 | /// 50 | /// The right stick button 51 | /// 52 | RightStickButton, 53 | 54 | /// 55 | /// The select button 56 | /// 57 | SelectButton, 58 | 59 | /// 60 | /// The start button 61 | /// 62 | StartButton, 63 | 64 | /// 65 | /// The d pad 66 | /// 67 | DPad, 68 | 69 | /// 70 | /// The left thumb stick 71 | /// 72 | LeftThumbStick, 73 | 74 | /// 75 | /// The right thumb stick 76 | /// 77 | RightThumbStick, 78 | 79 | /// 80 | /// The right trigger 81 | /// 82 | RightTrigger, 83 | 84 | /// 85 | /// The left trigger 86 | /// 87 | LeftTrigger 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /UIGenerator/Values/FontWeightGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace EmptyKeys.UserInterface.Generator.Values 10 | { 11 | /// 12 | /// Implements generator for Font Weight value 13 | /// 14 | public class FontWeightGeneratorValue : IGeneratorValue 15 | { 16 | /// 17 | /// Gets the type of the value. 18 | /// 19 | /// 20 | /// The type of the value. 21 | /// 22 | public Type ValueType 23 | { 24 | get 25 | { 26 | return typeof(FontWeight); 27 | } 28 | } 29 | 30 | /// 31 | /// Generates code for value 32 | /// 33 | /// The parent class. 34 | /// The method. 35 | /// The value. 36 | /// Name of the base. 37 | /// The dictionary. 38 | /// 39 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 40 | { 41 | CodeExpression valueExpression = null; 42 | if (value != null) 43 | { 44 | FontWeight fontWeight = (FontWeight)value; 45 | CodeTypeReferenceExpression typeReference = new CodeTypeReferenceExpression("FontStyle"); 46 | if (fontWeight == FontWeights.Normal) 47 | { 48 | valueExpression = new CodeFieldReferenceExpression(typeReference, "Regular"); 49 | } 50 | else 51 | { 52 | valueExpression = new CodeFieldReferenceExpression(typeReference, fontWeight.ToString()); 53 | } 54 | } 55 | 56 | return valueExpression; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /UIGenerator/Types/ImageGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | 14 | namespace EmptyKeys.UserInterface.Generator.Types 15 | { 16 | /// 17 | /// Implements Image control generator 18 | /// 19 | public class ImageGeneratorType : ElementGeneratorType 20 | { 21 | /// 22 | /// Gets the type of the xaml. 23 | /// 24 | /// 25 | /// The type of the xaml. 26 | /// 27 | public override Type XamlType 28 | { 29 | get 30 | { 31 | return typeof(Image); 32 | } 33 | } 34 | 35 | /// 36 | /// Generates control fields 37 | /// 38 | /// The source. 39 | /// Type of the class. 40 | /// The initialize method. 41 | /// if set to true [generate field]. 42 | /// 43 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 44 | { 45 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 46 | 47 | Image image = source as Image; 48 | 49 | BitmapImage bitmap = image.Source as BitmapImage; 50 | if (bitmap != null) 51 | { 52 | CodeComHelper.GenerateBitmapImageField(method, fieldReference, source, bitmap.UriSource, image.Name + "_bm", Image.SourceProperty); 53 | } 54 | 55 | CodeComHelper.GenerateEnumField(method, fieldReference, source, Image.StretchProperty); 56 | return fieldReference; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /UIGenerator/Values/LineGeometryGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements value generator for Line Geometry 14 | /// 15 | public class LineGeometryGeneratorValue : IGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(LineGeometry); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code for value 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | CodeExpression valueExpression = null; 43 | if (value != null) 44 | { 45 | var geometryVariable = new CodeVariableDeclarationStatement("LineGeometry", baseName, new CodeObjectCreateExpression("LineGeometry")); 46 | method.Statements.Add(geometryVariable); 47 | valueExpression = new CodeVariableReferenceExpression(baseName); 48 | 49 | LineGeometry line = value as LineGeometry; 50 | CodeComHelper.GeneratePointField(method, valueExpression, line, LineGeometry.StartPointProperty); 51 | CodeComHelper.GeneratePointField(method, valueExpression, line, LineGeometry.EndPointProperty); 52 | } 53 | 54 | return valueExpression; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /UIGenerator/Values/SoundSourceGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using EmptyKeys.UserInterface.Designer; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Values 12 | { 13 | /// 14 | /// Implements generator for Sound Source Collection value 15 | /// 16 | public class SoundSourceGeneratorValue : IGeneratorValue 17 | { 18 | /// 19 | /// Gets the type of the value. 20 | /// 21 | /// 22 | /// The type of the value. 23 | /// 24 | public Type ValueType 25 | { 26 | get 27 | { 28 | return typeof(SoundSourceCollection); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates code for value 34 | /// 35 | /// The parent class. 36 | /// The method. 37 | /// The value. 38 | /// Name of the base. 39 | /// The dictionary. 40 | /// 41 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 42 | { 43 | return GetSoundSourceCollectionValueExpression(method, value, baseName); 44 | } 45 | 46 | private static CodeExpression GetSoundSourceCollectionValueExpression(CodeMemberMethod method, object value, string baseName) 47 | { 48 | string collVar = baseName + "_sounds"; 49 | CodeVariableDeclarationStatement collection = 50 | new CodeVariableDeclarationStatement("var", collVar, new CodeObjectCreateExpression("SoundSourceCollection")); 51 | method.Statements.Add(collection); 52 | CodeComHelper.GenerateSoundSources(method, value as SoundSourceCollection, collVar); 53 | return new CodeVariableReferenceExpression(collVar); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /UIGenerator/Types/RangeBaseGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Controls.Primitives; 10 | using System.Windows.Media; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types 13 | { 14 | /// 15 | /// Implements Range Base generator 16 | /// 17 | public class RangeBaseGeneratorType : ControlGeneratorType 18 | { 19 | /// 20 | /// Gets the type of the xaml. 21 | /// 22 | /// 23 | /// The type of the xaml. 24 | /// 25 | public override Type XamlType 26 | { 27 | get 28 | { 29 | return typeof(RangeBase); 30 | } 31 | } 32 | 33 | /// 34 | /// Generates control fields 35 | /// 36 | /// The source. 37 | /// Type of the class. 38 | /// The initialize method. 39 | /// if set to true [generate field]. 40 | /// 41 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 42 | { 43 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 44 | RangeBase rangeBase = source as RangeBase; 45 | 46 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, source, RangeBase.MinimumProperty); 47 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, source, RangeBase.MaximumProperty); 48 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, source, RangeBase.ValueProperty); 49 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, source, RangeBase.SmallChangeProperty); 50 | CodeComHelper.GenerateFieldDoubleToFloat(method, fieldReference, source, RangeBase.LargeChangeProperty); 51 | return fieldReference; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Interactions/CallMethodAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace EmptyKeys.UserInterface.Designer.Interactions 9 | { 10 | public class CallMethodAction : Action 11 | { 12 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] 13 | public static readonly DependencyProperty MethodNameProperty = DependencyProperty.Register( 14 | "MethodName", 15 | typeof(string), 16 | typeof(CallMethodAction), 17 | new FrameworkPropertyMetadata(null)); 18 | 19 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] 20 | public static readonly DependencyProperty TargetObjectProperty = DependencyProperty.Register( 21 | "TargetObject", 22 | typeof(object), 23 | typeof(CallMethodAction), 24 | new FrameworkPropertyMetadata(null)); 25 | 26 | /// 27 | /// Gets or sets the name of the method to invoke. This is a dependency property. 28 | /// 29 | /// 30 | /// The name of the method. 31 | /// 32 | public string MethodName 33 | { 34 | get 35 | { 36 | return (string)GetValue(CallMethodAction.MethodNameProperty); 37 | } 38 | 39 | set 40 | { 41 | SetValue(CallMethodAction.MethodNameProperty, value); 42 | } 43 | } 44 | 45 | /// 46 | /// Gets or sets the object that exposes the method of interest. This is a dependency property. 47 | /// 48 | /// 49 | /// The target object. 50 | /// 51 | public object TargetObject 52 | { 53 | get 54 | { 55 | return GetValue(CallMethodAction.TargetObjectProperty); 56 | } 57 | 58 | set 59 | { 60 | SetValue(CallMethodAction.TargetObjectProperty, value); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/PasswordBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | 9 | namespace EmptyKeys.UserInterface.Designer 10 | { 11 | public class PasswordBox : TextBox 12 | { 13 | private static readonly Type typeOfThis = typeof(PasswordBox); 14 | 15 | /// 16 | /// The password character property 17 | /// 18 | public static readonly DependencyProperty PasswordCharProperty = 19 | DependencyProperty.Register("PasswordChar", typeof(char), typeOfThis, 20 | new FrameworkPropertyMetadata('*', FrameworkPropertyMetadataOptions.None, new PropertyChangedCallback(OnPasswordCharChanged))); 21 | 22 | private static void OnPasswordCharChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 23 | { 24 | } 25 | 26 | /// 27 | /// Gets or sets the password character. 28 | /// 29 | /// 30 | /// The password character. 31 | /// 32 | public char PasswordChar 33 | { 34 | get { return (char)GetValue(PasswordCharProperty); } 35 | set { SetValue(PasswordCharProperty, value); } 36 | } 37 | 38 | /// 39 | /// The password property 40 | /// 41 | public static readonly DependencyProperty PasswordProperty = 42 | DependencyProperty.Register("Password", typeof(string), typeOfThis, 43 | new FrameworkPropertyMetadata(string.Empty)); 44 | 45 | /// 46 | /// Gets or sets the password. 47 | /// 48 | /// 49 | /// The password. 50 | /// 51 | public string Password 52 | { 53 | get { return (string)GetValue(PasswordProperty); } 54 | set { SetValue(PasswordProperty, value); } 55 | } 56 | 57 | /// 58 | /// Initializes a new instance of the class. 59 | /// 60 | public PasswordBox() 61 | : base() 62 | { 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /UIGenerator/Types/ButtonGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Controls.Primitives; 6 | using System.Windows.Input; 7 | 8 | namespace EmptyKeys.UserInterface.Generator.Types 9 | { 10 | /// 11 | /// Implements Button control generator 12 | /// 13 | public class ButtonGeneratorType : ContentControlGeneratorType 14 | { 15 | /// 16 | /// Gets the type of the xaml. 17 | /// 18 | /// 19 | /// The type of the xaml. 20 | /// 21 | public override Type XamlType 22 | { 23 | get 24 | { 25 | return typeof(Button); 26 | } 27 | } 28 | 29 | /// 30 | /// Generates control fields 31 | /// 32 | /// The source. 33 | /// Type of the class. 34 | /// The initialize method. 35 | /// if set to true [generate field]. 36 | /// 37 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 38 | { 39 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 40 | ButtonBase buttonBase = source as ButtonBase; 41 | 42 | RoutedCommand command = buttonBase.Command as RoutedCommand; 43 | if (command != null && !string.IsNullOrEmpty(command.Name) && command.OwnerType != null) 44 | { 45 | initMethod.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(fieldReference, "Command"), 46 | new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(command.OwnerType.Name), command.Name + "Command"))); 47 | } 48 | 49 | CodeComHelper.GenerateField(initMethod, fieldReference, source, ButtonBase.CommandParameterProperty); 50 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, ButtonBase.ClickModeProperty); 51 | return fieldReference; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /UIGenerator/EffectAssets.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace EmptyKeys.UserInterface.Generator 9 | { 10 | /// 11 | /// Implements Effect Assets store 12 | /// 13 | public sealed class EffectAssets 14 | { 15 | private static EffectAssets singleton = new EffectAssets(); 16 | 17 | /// 18 | /// Gets the instance. 19 | /// 20 | /// 21 | /// The instance. 22 | /// 23 | public static EffectAssets Instance 24 | { 25 | get 26 | { 27 | return singleton; 28 | } 29 | } 30 | 31 | private List effectAssets = new List(); 32 | 33 | /// 34 | /// Prevents a default instance of the class from being created. 35 | /// 36 | private EffectAssets() 37 | { 38 | } 39 | 40 | /// 41 | /// Adds the effect. 42 | /// 43 | /// Name of the asset. 44 | public void AddEffect(string assetName) 45 | { 46 | if (!effectAssets.Contains(assetName)) 47 | { 48 | effectAssets.Add(assetName); 49 | } 50 | } 51 | 52 | /// 53 | /// Generates the manager code. 54 | /// 55 | /// The method. 56 | public void GenerateManagerCode(CodeMemberMethod method) 57 | { 58 | foreach (var asset in effectAssets) 59 | { 60 | method.Statements.Add(new CodeMethodInvokeExpression( 61 | new CodeFieldReferenceExpression( 62 | new CodeTypeReferenceExpression("EffectManager"), "Instance"), 63 | "AddEffect", 64 | new CodePrimitiveExpression(asset))); 65 | } 66 | } 67 | 68 | /// 69 | /// Clears the assets. 70 | /// 71 | public void ClearAssets() 72 | { 73 | effectAssets.Clear(); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Charts/SeriesPoint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | 7 | namespace EmptyKeys.UserInterface.Designer.Charts 8 | { 9 | /// 10 | /// Implements single chart point - fake designer class 11 | /// 12 | public class SeriesPoint : DependencyObject 13 | { 14 | private static readonly Type typeOfThis = typeof(SeriesPoint); 15 | private static DependencyObjectType dependencyType; 16 | 17 | /// 18 | /// The argument property 19 | /// 20 | public static readonly DependencyProperty ArgumentProperty = 21 | DependencyProperty.Register("Argument", typeof(float), typeOfThis, 22 | new FrameworkPropertyMetadata(float.NaN)); 23 | 24 | /// 25 | /// Gets or sets the argument. 26 | /// 27 | /// 28 | /// The argument. 29 | /// 30 | public float Argument 31 | { 32 | get { return (float)GetValue(ArgumentProperty); } 33 | set { SetValue(ArgumentProperty, value); } 34 | } 35 | 36 | /// 37 | /// The value property 38 | /// 39 | public static readonly DependencyProperty ValueProperty = 40 | DependencyProperty.Register("Value", typeof(float), typeOfThis, 41 | new FrameworkPropertyMetadata(float.NaN)); 42 | 43 | /// 44 | /// Gets or sets the value. 45 | /// 46 | /// 47 | /// The value. 48 | /// 49 | public float Value 50 | { 51 | get { return (float)GetValue(ValueProperty); } 52 | set { SetValue(ValueProperty, value); } 53 | } 54 | 55 | /// 56 | /// Initializes the class. 57 | /// 58 | static SeriesPoint() 59 | { 60 | dependencyType = DependencyObjectType.FromSystemType(typeOfThis); 61 | } 62 | 63 | /// 64 | /// Initializes a new instance of the class. 65 | /// 66 | public SeriesPoint() 67 | : base() 68 | { 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /UIGenerator/Types/ScrollViewerGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Controls.Primitives; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements Scroll Viewer control generator 15 | /// 16 | public class ScrollViewerGeneratorType : ContentControlGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(ScrollViewer); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates code 34 | /// 35 | /// The dependence object 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | ScrollViewer scrollViewer = source as ScrollViewer; 45 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, ScrollViewer.HorizontalScrollBarVisibilityProperty); 46 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, ScrollViewer.VerticalScrollBarVisibilityProperty); 47 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, ScrollViewer.PanningModeProperty); 48 | CodeComHelper.GenerateFieldDoubleToFloat(initMethod, fieldReference, source, ScrollViewer.PanningRatioProperty); 49 | CodeComHelper.GenerateFieldDoubleToFloat(initMethod, fieldReference, source, ScrollViewer.PanningDecelerationProperty); 50 | 51 | return fieldReference; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Generator.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmptyKeys.UserInterface.Designer", "EmptyKeys.UserInterface.Designer\EmptyKeys.UserInterface.Designer.csproj", "{6EC689B2-36F9-415D-A130-F67DE6C7E8BC}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ekUiGen", "ekUiGen\ekUiGen.csproj", "{32640266-DF2B-43A6-A9E0-04769E8531BA}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmptyKeys.UserInterface.Generator", "UIGenerator\EmptyKeys.UserInterface.Generator.csproj", "{5F1A3948-5E4A-4F47-847B-BB178E3AD50E}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2B55748F-E795-4B5F-B7C6-60D642BA572E}" 13 | ProjectSection(SolutionItems) = preProject 14 | GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs 15 | LICENSE = LICENSE 16 | README.md = README.md 17 | EndProjectSection 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|Any CPU = Debug|Any CPU 22 | Release|Any CPU = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {6EC689B2-36F9-415D-A130-F67DE6C7E8BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {6EC689B2-36F9-415D-A130-F67DE6C7E8BC}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {6EC689B2-36F9-415D-A130-F67DE6C7E8BC}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {6EC689B2-36F9-415D-A130-F67DE6C7E8BC}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {32640266-DF2B-43A6-A9E0-04769E8531BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 30 | {32640266-DF2B-43A6-A9E0-04769E8531BA}.Debug|Any CPU.Build.0 = Debug|Any CPU 31 | {32640266-DF2B-43A6-A9E0-04769E8531BA}.Release|Any CPU.ActiveCfg = Release|Any CPU 32 | {32640266-DF2B-43A6-A9E0-04769E8531BA}.Release|Any CPU.Build.0 = Release|Any CPU 33 | {5F1A3948-5E4A-4F47-847B-BB178E3AD50E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 34 | {5F1A3948-5E4A-4F47-847B-BB178E3AD50E}.Debug|Any CPU.Build.0 = Debug|Any CPU 35 | {5F1A3948-5E4A-4F47-847B-BB178E3AD50E}.Release|Any CPU.ActiveCfg = Release|Any CPU 36 | {5F1A3948-5E4A-4F47-847B-BB178E3AD50E}.Release|Any CPU.Build.0 = Release|Any CPU 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /UIGenerator/Values/Effects/CustomEffectGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using EmptyKeys.UserInterface.Designer.Effects; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values.Effects 11 | { 12 | /// 13 | /// Implements value generator for Custom Effect 14 | /// 15 | /// 16 | public class CustomEffectGeneratorValue : IGeneratorValue 17 | { 18 | /// 19 | /// Gets the type of the value. 20 | /// 21 | /// 22 | /// The type of the value. 23 | /// 24 | public Type ValueType 25 | { 26 | get 27 | { 28 | return typeof(CustomEffect); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates the specified parent class. 34 | /// 35 | /// The parent class. 36 | /// The method. 37 | /// The value. 38 | /// Name of the base. 39 | /// The dictionary. 40 | /// 41 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 42 | { 43 | CodeExpression valueExpression = null; 44 | if (value != null) 45 | { 46 | string variableName = baseName + "_cef"; 47 | var variable = new CodeVariableDeclarationStatement("CustomEffect", variableName, new CodeObjectCreateExpression("CustomEffect")); 48 | method.Statements.Add(variable); 49 | valueExpression = new CodeVariableReferenceExpression(variableName); 50 | 51 | CustomEffect effect = value as CustomEffect; 52 | CodeComHelper.GenerateField(method, valueExpression, effect, CustomEffect.EffectAssetProperty); 53 | 54 | EffectAssets.Instance.AddEffect(effect.EffectAsset); 55 | } 56 | 57 | return valueExpression; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /UIGenerator/Values/EllipseGeometryGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements Ellipse Geometry value generator 14 | /// 15 | public class EllipseGeometryGeneratorValue : IGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(EllipseGeometry); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code for value 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | CodeExpression valueExpression = null; 43 | if (value != null) 44 | { 45 | var geometryVariable = new CodeVariableDeclarationStatement("EllipseGeometry", baseName, new CodeObjectCreateExpression("EllipseGeometry")); 46 | method.Statements.Add(geometryVariable); 47 | valueExpression = new CodeVariableReferenceExpression(baseName); 48 | 49 | EllipseGeometry ellipse = value as EllipseGeometry; 50 | CodeComHelper.GenerateFieldDoubleToFloat(method, valueExpression, ellipse, EllipseGeometry.RadiusXProperty); 51 | CodeComHelper.GenerateFieldDoubleToFloat(method, valueExpression, ellipse, EllipseGeometry.RadiusYProperty); 52 | CodeComHelper.GeneratePointField(method, valueExpression, ellipse, EllipseGeometry.CenterProperty); 53 | } 54 | 55 | return valueExpression; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /UIGenerator/Values/RectangleGeometryGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements Rectangle Geometry value generator 14 | /// 15 | public class RectangleGeometryGeneratorValue : IGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(RectangleGeometry); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code for value 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | CodeExpression valueExpression = null; 43 | if (value != null) 44 | { 45 | var geometryVariable = new CodeVariableDeclarationStatement("RectangleGeometry", baseName, new CodeObjectCreateExpression("RectangleGeometry")); 46 | method.Statements.Add(geometryVariable); 47 | valueExpression = new CodeVariableReferenceExpression(baseName); 48 | 49 | RectangleGeometry rect = value as RectangleGeometry; 50 | CodeComHelper.GenerateFieldDoubleToFloat(method, valueExpression, rect, RectangleGeometry.RadiusXProperty); 51 | CodeComHelper.GenerateFieldDoubleToFloat(method, valueExpression, rect, RectangleGeometry.RadiusYProperty); 52 | CodeComHelper.GenerateRectangleField(method, valueExpression, rect, RectangleGeometry.RectProperty); 53 | } 54 | 55 | return valueExpression; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /UIGenerator/Types/NumericTextBoxGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Globalization; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using EmptyKeys.UserInterface.Designer; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements type generator for Numeric Text Box control 15 | /// 16 | public class NumericTextBoxGeneratorType : TextBoxGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(NumericTextBox); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates code 34 | /// 35 | /// The dependence object 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// if set to true [generate field]. 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | NumericTextBox numeric = source as NumericTextBox; 45 | CodeComHelper.GenerateField(initMethod, fieldReference, source, NumericTextBox.ValueProperty); 46 | CodeComHelper.GenerateField(initMethod, fieldReference, source, NumericTextBox.MinimumProperty); 47 | CodeComHelper.GenerateField(initMethod, fieldReference, source, NumericTextBox.MaximumProperty); 48 | CodeComHelper.GenerateField(initMethod, fieldReference, source, NumericTextBox.IncrementProperty); 49 | CodeComHelper.GenerateField(initMethod, fieldReference, source, NumericTextBox.ValueFormatProperty); 50 | CodeComHelper.GenerateFlagEnumField(initMethod, fieldReference, source, NumericTextBox.ValueStyleProperty); 51 | 52 | return fieldReference; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /UIGenerator/Values/ItemsPanelTemplateGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements generator for Items Panel Template 14 | /// 15 | public class ItemsPanelTemplateGeneratorValue : IGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(ItemsPanelTemplate); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code for value 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | return GetItemsPanelTemplateValueExpression(parentClass, method, value, baseName); 43 | } 44 | 45 | private static CodeExpression GetItemsPanelTemplateValueExpression(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName) 46 | { 47 | ItemsPanelTemplate template = value as ItemsPanelTemplate; 48 | DependencyObject content = template.LoadContent(); 49 | string variableName = baseName + "_ipt"; 50 | string creator = CodeComHelper.GenerateTemplate(parentClass, method, content, variableName); 51 | CodeVariableDeclarationStatement templateVar = new CodeVariableDeclarationStatement( 52 | "ControlTemplate", variableName, 53 | new CodeObjectCreateExpression("ControlTemplate", new CodeSnippetExpression(creator))); 54 | method.Statements.Add(templateVar); 55 | return new CodeVariableReferenceExpression(variableName); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /UIGenerator/Values/ThicknessAnimationGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media.Animation; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements generator for ThicknessAnimation 14 | /// 15 | public class ThicknessAnimationGeneratorValue : TimelineGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public override Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(ThicknessAnimation); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code for value 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public override CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | CodeExpression baseValue = base.Generate(parentClass, method, value, baseName, dictionary); 43 | ThicknessAnimation animation = value as ThicknessAnimation; 44 | CodeComHelper.GenerateThicknessField(method, baseValue, animation, ThicknessAnimation.FromProperty); 45 | CodeComHelper.GenerateThicknessField(method, baseValue, animation, ThicknessAnimation.ToProperty); 46 | CodeComHelper.GenerateThicknessField(method, baseValue, animation, ThicknessAnimation.ByProperty); 47 | CodeComHelper.GenerateField(method, baseValue, animation, ThicknessAnimation.IsAdditiveProperty); 48 | 49 | if (animation.EasingFunction != null) 50 | { 51 | EasingFunctionBase easingFunc = animation.EasingFunction as EasingFunctionBase; 52 | CodeComHelper.GenerateEasingFunction(method, baseValue, baseName, easingFunc); 53 | } 54 | 55 | return baseValue; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Effects/DirectionalBlurEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Media.Effects; 7 | 8 | namespace EmptyKeys.UserInterface.Designer.Effects 9 | { 10 | /// 11 | /// Implements Directional Blur effect 12 | /// 13 | public class DirectionalBlurEffect : ShaderEffect 14 | { 15 | private static Type typeOfThis = typeof(DirectionalBlurEffect); 16 | 17 | /// 18 | /// The angle property 19 | /// 20 | public static readonly DependencyProperty AngleProperty = 21 | DependencyProperty.Register("Angle", typeof(float), typeOfThis, 22 | new FrameworkPropertyMetadata(0f, FrameworkPropertyMetadataOptions.AffectsRender)); 23 | 24 | /// 25 | /// Gets or sets the angle. 26 | /// 27 | /// 28 | /// The angle. 29 | /// 30 | public float Angle 31 | { 32 | get { return (float)GetValue(AngleProperty); } 33 | set { SetValue(AngleProperty, value); } 34 | } 35 | 36 | /// 37 | /// The blur amount property 38 | /// 39 | public static readonly DependencyProperty BlurAmountProperty = 40 | DependencyProperty.Register("BlurAmount", typeof(float), typeOfThis, 41 | new FrameworkPropertyMetadata(0f, FrameworkPropertyMetadataOptions.AffectsRender)); 42 | 43 | /// 44 | /// Gets or sets the blur amount. 45 | /// 46 | /// 47 | /// The blur amount. 48 | /// 49 | public float BlurAmount 50 | { 51 | get { return (float)GetValue(BlurAmountProperty); } 52 | set { SetValue(BlurAmountProperty, value); } 53 | } 54 | 55 | /// 56 | /// Initializes a new instance of the class. 57 | /// 58 | public DirectionalBlurEffect() : base() 59 | { 60 | var pixelShader = new PixelShader(); 61 | var fileUri = new Uri("pack://application:,,,/EmptyKeys.UserInterface.Designer;component/Effects/FakeShader.ps", UriKind.RelativeOrAbsolute); 62 | pixelShader.UriSource = fileUri; 63 | PixelShader = pixelShader; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /UIGenerator/Values/DoubleAnimationGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media.Animation; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values 11 | { 12 | /// 13 | /// Implements value generator for DoubleAnimation type 14 | /// 15 | public class DoubleAnimationGeneratorValue : TimelineGeneratorValue 16 | { 17 | /// 18 | /// Gets the type of the value. 19 | /// 20 | /// 21 | /// The type of the value. 22 | /// 23 | public override Type ValueType 24 | { 25 | get 26 | { 27 | return typeof(DoubleAnimation); 28 | } 29 | } 30 | 31 | /// 32 | /// Generates code for value 33 | /// 34 | /// The parent class. 35 | /// The method. 36 | /// The value. 37 | /// Name of the base. 38 | /// The dictionary. 39 | /// 40 | public override CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 41 | { 42 | CodeExpression baseValue = base.Generate(parentClass, method, value, baseName, dictionary); 43 | DoubleAnimation animation = value as DoubleAnimation; 44 | CodeComHelper.GenerateFieldDoubleToFloat(method, baseValue, animation, DoubleAnimation.FromProperty); 45 | CodeComHelper.GenerateFieldDoubleToFloat(method, baseValue, animation, DoubleAnimation.ToProperty); 46 | CodeComHelper.GenerateFieldDoubleToFloat(method, baseValue, animation, DoubleAnimation.ByProperty); 47 | CodeComHelper.GenerateField(method, baseValue, animation, DoubleAnimation.IsAdditiveProperty); 48 | 49 | if (animation.EasingFunction != null) 50 | { 51 | EasingFunctionBase easingFunc = animation.EasingFunction as EasingFunctionBase; 52 | CodeComHelper.GenerateEasingFunction(method, baseValue, baseName, easingFunc); 53 | } 54 | 55 | return baseValue; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /UIGenerator/Values/ThicknessGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace EmptyKeys.UserInterface.Generator.Values 10 | { 11 | /// 12 | /// Implements generator for Thickness value 13 | /// 14 | public class ThicknessGeneratorValue : IGeneratorValue 15 | { 16 | /// 17 | /// Gets the type of the value. 18 | /// 19 | /// 20 | /// The type of the value. 21 | /// 22 | public Type ValueType 23 | { 24 | get 25 | { 26 | return typeof(Thickness); 27 | } 28 | } 29 | 30 | /// 31 | /// Generates code for value 32 | /// 33 | /// The parent class. 34 | /// The method. 35 | /// The value. 36 | /// Name of the base. 37 | /// The dictionary. 38 | /// 39 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 40 | { 41 | CodeExpression valueExpression = null; 42 | if (value != null) 43 | { 44 | Thickness thickness = (Thickness)value; 45 | 46 | if (thickness.Left == thickness.Top && thickness.Top == thickness.Right && thickness.Right == thickness.Bottom) 47 | { 48 | valueExpression = new CodeObjectCreateExpression("Thickness", new CodePrimitiveExpression((float)thickness.Left)); 49 | } 50 | else 51 | { 52 | valueExpression = new CodeObjectCreateExpression( 53 | "Thickness", 54 | new CodePrimitiveExpression((float)thickness.Left), 55 | new CodePrimitiveExpression((float)thickness.Top), 56 | new CodePrimitiveExpression((float)thickness.Right), 57 | new CodePrimitiveExpression((float)thickness.Bottom)); 58 | } 59 | } 60 | 61 | return valueExpression; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /UIGenerator/Values/Effects/DirectionalBlurEffectGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using EmptyKeys.UserInterface.Designer.Effects; 9 | 10 | namespace EmptyKeys.UserInterface.Generator.Values.Effects 11 | { 12 | /// 13 | /// Implements value generator for Directional Blur Effect 14 | /// 15 | /// 16 | public class DirectionalBlurEffectGeneratorValue : IGeneratorValue 17 | { 18 | /// 19 | /// Gets the type of the value. 20 | /// 21 | /// 22 | /// The type of the value. 23 | /// 24 | public Type ValueType 25 | { 26 | get 27 | { 28 | return typeof(DirectionalBlurEffect); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates the specified parent class. 34 | /// 35 | /// The parent class. 36 | /// The method. 37 | /// The value. 38 | /// Name of the base. 39 | /// The dictionary. 40 | /// 41 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 42 | { 43 | CodeExpression valueExpression = null; 44 | if (value != null) 45 | { 46 | string variableName = baseName + "_dbef"; 47 | var variable = new CodeVariableDeclarationStatement("DirectionalBlurEffect", variableName, new CodeObjectCreateExpression("DirectionalBlurEffect")); 48 | method.Statements.Add(variable); 49 | valueExpression = new CodeVariableReferenceExpression(variableName); 50 | 51 | DirectionalBlurEffect effect = value as DirectionalBlurEffect; 52 | CodeComHelper.GenerateField(method, valueExpression, effect, DirectionalBlurEffect.AngleProperty); 53 | CodeComHelper.GenerateField(method, valueExpression, effect, DirectionalBlurEffect.BlurAmountProperty); 54 | } 55 | 56 | return valueExpression; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/HeaderedItemsControlGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements Headered Items Control generator 15 | /// 16 | public class HeaderedItemsControlGeneratorType : ItemsControlGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(HeaderedItemsControl); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates control fields 34 | /// 35 | /// The source. 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// if set to true [generate field]. 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | HeaderedItemsControl control = source as HeaderedItemsControl; 45 | 46 | UIElement header = control.Header as UIElement; 47 | if (header != null) 48 | { 49 | TypeGenerator headerGenerator = new TypeGenerator(); 50 | CodeExpression headerExpr = headerGenerator.ProcessGenerators(header, classType, initMethod, false); 51 | 52 | initMethod.Statements.Add(new CodeAssignStatement( 53 | new CodeFieldReferenceExpression(fieldReference, "Header"), headerExpr)); 54 | } 55 | else if (control.Header != null) 56 | { 57 | CodeComHelper.GenerateField(initMethod, fieldReference, source, HeaderedContentControl.HeaderProperty); 58 | // TODO content can be another class, so this will not work 59 | } 60 | 61 | return fieldReference; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /UIGenerator/Types/HeaderedContentControlGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements Headered Content Control generator 15 | /// 16 | public class HeaderedContentControlGeneratorType : ContentControlGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(HeaderedContentControl); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates control fields 34 | /// 35 | /// The source. 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// if set to true [generate field]. 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | HeaderedContentControl control = source as HeaderedContentControl; 45 | 46 | UIElement header = control.Header as UIElement; 47 | if (header != null) 48 | { 49 | TypeGenerator headerGenerator = new TypeGenerator(); 50 | CodeExpression headerExpr = headerGenerator.ProcessGenerators(header, classType, initMethod, false); 51 | 52 | initMethod.Statements.Add(new CodeAssignStatement( 53 | new CodeFieldReferenceExpression(fieldReference, "Header"), headerExpr)); 54 | 55 | } 56 | else if (control.Header != null) 57 | { 58 | CodeComHelper.GenerateField(initMethod, fieldReference, source, HeaderedContentControl.HeaderProperty); 59 | // TODO content can be another class, so this will not work 60 | } 61 | 62 | return fieldReference; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /UIGenerator/Values/SolidColorBrushAnimGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Media.Animation; 9 | using EmptyKeys.UserInterface.Designer; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Values 12 | { 13 | /// 14 | /// Implements generator for SolidColorBrushAnimation 15 | /// 16 | public class SolidColorBrushAnimGeneratorValue : TimelineGeneratorValue 17 | { 18 | /// 19 | /// Gets the type of the value. 20 | /// 21 | /// 22 | /// The type of the value. 23 | /// 24 | public override Type ValueType 25 | { 26 | get 27 | { 28 | return typeof(SolidColorBrushAnimation); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates code for value 34 | /// 35 | /// The parent class. 36 | /// The method. 37 | /// The value. 38 | /// Name of the base. 39 | /// The dictionary. 40 | /// 41 | public override CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 42 | { 43 | CodeExpression baseValue = base.Generate(parentClass, method, value, baseName, dictionary); 44 | SolidColorBrushAnimation animation = value as SolidColorBrushAnimation; 45 | CodeComHelper.GenerateColorField(method, baseValue, animation, SolidColorBrushAnimation.FromProperty); 46 | CodeComHelper.GenerateColorField(method, baseValue, animation, SolidColorBrushAnimation.ToProperty); 47 | CodeComHelper.GenerateColorField(method, baseValue, animation, SolidColorBrushAnimation.ByProperty); 48 | CodeComHelper.GenerateField(method, baseValue, animation, SolidColorBrushAnimation.IsAdditiveProperty); 49 | 50 | if (animation.EasingFunction != null) 51 | { 52 | EasingFunctionBase easingFunc = animation.EasingFunction as EasingFunctionBase; 53 | CodeComHelper.GenerateEasingFunction(method, baseValue, baseName, easingFunc); 54 | } 55 | 56 | return baseValue; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/DragDrop.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace EmptyKeys.UserInterface.Designer 9 | { 10 | public sealed class DragDrop 11 | { 12 | private static Type typeOfThis = typeof(DragDrop); 13 | 14 | /// 15 | /// The is drag source property 16 | /// 17 | public static readonly DependencyProperty IsDragSourceProperty = 18 | DependencyProperty.RegisterAttached("IsDragSource", typeof(bool), typeOfThis, 19 | new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.None)); 20 | 21 | /// 22 | /// Gets the is drag source. 23 | /// 24 | /// The target. 25 | /// 26 | public static bool GetIsDragSource(UIElement target) 27 | { 28 | return (bool)target.GetValue(IsDragSourceProperty); 29 | } 30 | 31 | /// 32 | /// Sets the is drag source. 33 | /// 34 | /// The target. 35 | /// if set to true [value]. 36 | public static void SetIsDragSource(UIElement target, bool value) 37 | { 38 | target.SetValue(IsDragSourceProperty, value); 39 | } 40 | 41 | /// 42 | /// The is drop target property 43 | /// 44 | public static readonly DependencyProperty IsDropTargetProperty = 45 | DependencyProperty.RegisterAttached("IsDropTarget", typeof(bool), typeOfThis, 46 | new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.None)); 47 | 48 | /// 49 | /// Gets the is drop target. 50 | /// 51 | /// The target. 52 | /// 53 | public static bool GetIsDropTarget(UIElement target) 54 | { 55 | return (bool)target.GetValue(IsDropTargetProperty); 56 | } 57 | 58 | /// 59 | /// Sets the is drop target. 60 | /// 61 | /// The target. 62 | /// if set to true [value]. 63 | public static void SetIsDropTarget(UIElement target, bool value) 64 | { 65 | target.SetValue(IsDropTargetProperty, value); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /UIGenerator/Types/Controls/DataGridBoundColumnGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using EmptyKeys.UserInterface.Designer; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types.Controls 13 | { 14 | /// 15 | /// Implements generator for Data Grind bound column 16 | /// 17 | public class DataGridBoundColumnGeneratorType : DataGridColumnGeneratorType 18 | { 19 | /// 20 | /// Gets the type of the xaml. 21 | /// 22 | /// 23 | /// The type of the xaml. 24 | /// 25 | public override Type XamlType 26 | { 27 | get 28 | { 29 | return typeof(DataGridBoundColumn); 30 | } 31 | } 32 | 33 | /// 34 | /// Generates control fields 35 | /// 36 | /// The source. 37 | /// Type of the class. 38 | /// The initialize method. 39 | /// if set to true [generate field]. 40 | /// 41 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 42 | { 43 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 44 | 45 | DataGridBoundColumn column = source as DataGridBoundColumn; 46 | CodeComHelper.GenerateTemplateStyleField(classType, initMethod, fieldReference, source, DataGridBoundColumn.ElementStyleProperty, ColumnName + "_e"); 47 | 48 | Binding commandBindingExpr = column.Binding as Binding; 49 | if (commandBindingExpr != null) 50 | { 51 | GeneratedBindingsMode generatedMode = (GeneratedBindingsMode)source.GetValue(GeneratedBindings.ModeProperty); 52 | CodeVariableReferenceExpression bindingVar = CodeComHelper.GenerateBinding(initMethod, commandBindingExpr, ColumnName + "_b", generatedMode); 53 | 54 | var statement = new CodeAssignStatement(new CodeFieldReferenceExpression(fieldReference, "Binding"), bindingVar); 55 | initMethod.Statements.Add(statement); 56 | } 57 | 58 | return fieldReference; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /ekUiGen/ekUiGen.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0-windows 4 | Exe 5 | EmptyKeys.UserInterface.Generator 6 | SAK 7 | SAK 8 | SAK 9 | SAK 10 | false 11 | true 12 | true 13 | AppStore;Debug;Release;Testing 14 | 15 | 16 | ..\..\!Release\EmptyKeysUI\Generator\ 17 | false 18 | 19 | 20 | bin\x64\Debug\ 21 | MinimumRecommendedRules.ruleset 22 | 23 | 24 | ..\..\!Release\EmptyKeysUI\Generator\ 25 | false 26 | MinimumRecommendedRules.ruleset 27 | 28 | 29 | 30 | Properties\GlobalAssemblyInfo.cs 31 | 32 | 33 | 34 | 35 | PreserveNewest 36 | 37 | 38 | PreserveNewest 39 | 40 | 41 | PreserveNewest 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Always 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /UIGenerator/Values/DataTemplateGeneratorValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace EmptyKeys.UserInterface.Generator.Values 10 | { 11 | /// 12 | /// Implements generator for Data Template 13 | /// 14 | public class DataTemplateGeneratorValue : IGeneratorValue 15 | { 16 | /// 17 | /// Gets the type of the value. 18 | /// 19 | /// 20 | /// The type of the value. 21 | /// 22 | public Type ValueType 23 | { 24 | get 25 | { 26 | return typeof(DataTemplate); 27 | } 28 | } 29 | 30 | /// 31 | /// Generates code for value 32 | /// 33 | /// The parent class. 34 | /// The method. 35 | /// The value. 36 | /// Name of the base. 37 | /// The dictionary. 38 | /// 39 | public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null) 40 | { 41 | return GetDataTemplateValueExpression(parentClass, method, value, baseName); 42 | } 43 | 44 | private static CodeExpression GetDataTemplateValueExpression(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName) 45 | { 46 | DataTemplate dataTemplate = value as DataTemplate; 47 | Type dataType = dataTemplate.DataType as Type; 48 | DependencyObject content = dataTemplate.LoadContent(); 49 | string variableName = baseName + "_dt"; 50 | Type oldDataType = BindingGenerator.Instance.ActiveDataType; 51 | BindingGenerator.Instance.ActiveDataType = dataType; 52 | string creator = CodeComHelper.GenerateTemplate(parentClass, method, content, variableName); 53 | BindingGenerator.Instance.ActiveDataType = oldDataType; 54 | 55 | if (dataType != null) 56 | { 57 | return new CodeObjectCreateExpression("DataTemplate", new CodeTypeOfExpression(dataType.FullName), new CodeSnippetExpression(creator)); 58 | } 59 | 60 | return new CodeObjectCreateExpression("DataTemplate", new CodeSnippetExpression(creator)); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/DataGrid.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Input; 9 | 10 | namespace EmptyKeys.UserInterface.Designer 11 | { 12 | /// 13 | /// Fake designer helper class for DataGrid 14 | /// 15 | public static class DataGrid 16 | { 17 | /// 18 | /// Gets the sorting command. 19 | /// 20 | /// The object. 21 | /// 22 | public static ICommand GetSortingCommand(DependencyObject obj) 23 | { 24 | return (ICommand)obj.GetValue(SortingCommandProperty); 25 | } 26 | 27 | /// 28 | /// Sets the sorting command. 29 | /// 30 | /// The object. 31 | /// The value. 32 | public static void SetSortingCommand(DependencyObject obj, ICommand value) 33 | { 34 | obj.SetValue(SortingCommandProperty, value); 35 | } 36 | 37 | /// 38 | /// The sorting command property 39 | /// 40 | public static readonly DependencyProperty SortingCommandProperty = 41 | DependencyProperty.RegisterAttached("SortingCommand", typeof(ICommand), typeof(DataGrid), 42 | new FrameworkPropertyMetadata(null)); 43 | 44 | /// 45 | /// The virtualized cache maximum rows property 46 | /// 47 | public static readonly DependencyProperty VirtualizedCacheMaxRowsProperty = 48 | DependencyProperty.RegisterAttached("VirtualizedCacheMaxRows", typeof(int), typeof(DataGrid), 49 | new FrameworkPropertyMetadata(50)); 50 | 51 | /// 52 | /// Gets the virtualized cache maximum rows. 53 | /// 54 | /// The object. 55 | /// 56 | public static int GetVirtualizedCacheMaxRows(DependencyObject obj) 57 | { 58 | return (int)obj.GetValue(VirtualizedCacheMaxRowsProperty); 59 | } 60 | 61 | /// 62 | /// Sets the virtualized cache maximum rows. 63 | /// 64 | /// The object. 65 | /// The value. 66 | public static void SetVirtualizedCacheMaxRows(DependencyObject obj, int value) 67 | { 68 | obj.SetValue(VirtualizedCacheMaxRowsProperty, value); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /UIGenerator/Types/TextBoxBaseGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Controls.Primitives; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types 12 | { 13 | /// 14 | /// Implements Text Box base generator 15 | /// 16 | public class TextBoxBaseGeneratorType : ControlGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(TextBoxBase); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates control fields 34 | /// 35 | /// The source. 36 | /// Type of the class. 37 | /// The initialize method. 38 | /// if set to true [generate field]. 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 43 | 44 | TextBoxBase textBoxBase = source as TextBoxBase; 45 | CodeComHelper.GenerateField(initMethod, fieldReference, source, TextBoxBase.IsReadOnlyProperty); 46 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, TextBoxBase.HorizontalScrollBarVisibilityProperty); 47 | CodeComHelper.GenerateEnumField(initMethod, fieldReference, source, TextBoxBase.VerticalScrollBarVisibilityProperty); 48 | CodeComHelper.GenerateBrushField(initMethod, fieldReference, source, TextBoxBase.CaretBrushProperty); 49 | CodeComHelper.GenerateBrushField(initMethod, fieldReference, source, TextBoxBase.SelectionBrushProperty); 50 | CodeComHelper.GenerateFieldDoubleToFloat(initMethod, fieldReference, source, TextBoxBase.SelectionOpacityProperty); 51 | CodeComHelper.GenerateField(initMethod, fieldReference, source, TextBoxBase.IsUndoEnabledProperty); 52 | CodeComHelper.GenerateField(initMethod, fieldReference, source, TextBoxBase.UndoLimitProperty); 53 | 54 | return fieldReference; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/SoundManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace EmptyKeys.UserInterface.Designer 9 | { 10 | public class SoundManager 11 | { 12 | /// 13 | /// The sounds property 14 | /// 15 | public static readonly DependencyProperty SoundsProperty = 16 | DependencyProperty.RegisterAttached("Sounds", typeof(SoundSourceCollection), typeof(SoundManager), 17 | new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits)); 18 | 19 | /// 20 | /// Gets the sounds. 21 | /// 22 | /// The object. 23 | /// 24 | public static SoundSourceCollection GetSounds(DependencyObject obj) 25 | { 26 | var collection = (SoundSourceCollection)obj.GetValue(SoundsProperty); 27 | if (collection == null) 28 | { 29 | collection = new SoundSourceCollection(); 30 | obj.SetValue(SoundsProperty, collection); 31 | } 32 | 33 | return collection; 34 | } 35 | 36 | /// 37 | /// Sets the sounds. 38 | /// 39 | /// The object. 40 | /// The value. 41 | public static void SetSounds(DependencyObject obj, SoundSourceCollection value) 42 | { 43 | obj.SetValue(SoundsProperty, value); 44 | } 45 | 46 | /// 47 | /// The is sound enabled property 48 | /// 49 | public static readonly DependencyProperty IsSoundEnabledProperty = 50 | DependencyProperty.RegisterAttached("IsSoundEnabled", typeof(bool), typeof(SoundManager), 51 | new FrameworkPropertyMetadata(true)); 52 | 53 | /// 54 | /// Gets the is sound enabled. 55 | /// 56 | /// The object. 57 | /// 58 | public static bool GetIsSoundEnabled(DependencyObject obj) 59 | { 60 | return (bool)obj.GetValue(IsSoundEnabledProperty); 61 | } 62 | 63 | /// 64 | /// Sets the is sound enabled. 65 | /// 66 | /// The object. 67 | /// if set to true [value]. 68 | public static void SetIsSoundEnabled(DependencyObject obj, bool value) 69 | { 70 | obj.SetValue(IsSoundEnabledProperty, value); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Interactions/Interaction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace EmptyKeys.UserInterface.Designer.Interactions 9 | { 10 | public sealed class Interaction 11 | { 12 | private Interaction() 13 | { 14 | } 15 | 16 | /// 17 | /// Gets or sets the associated with a specified object. 18 | /// 19 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] 20 | internal static readonly DependencyProperty BehaviorsProperty = DependencyProperty.RegisterAttached( 21 | "InternalBehaviors", 22 | typeof(BehaviorCollection), 23 | typeof(Interaction)); 24 | 25 | /// 26 | /// Gets the associated with a specified object. 27 | /// 28 | /// The from which to retrieve the . 29 | /// 30 | /// A containing the behaviors associated with the specified object. 31 | /// 32 | /// obj 33 | internal static BehaviorCollection GetInternalBehaviors(DependencyObject obj) 34 | { 35 | if (obj == null) 36 | { 37 | throw new ArgumentNullException("obj"); 38 | } 39 | 40 | BehaviorCollection behaviorCollection = (BehaviorCollection)obj.GetValue(Interaction.BehaviorsProperty); 41 | if (behaviorCollection == null) 42 | { 43 | behaviorCollection = new BehaviorCollection(); 44 | obj.SetValue(Interaction.BehaviorsProperty, behaviorCollection); 45 | } 46 | 47 | return behaviorCollection; 48 | } 49 | 50 | /// 51 | /// Gets the associated with a specified object. 52 | /// 53 | /// The from which to retrieve the . 54 | /// 55 | /// A containing the behaviors associated with the specified object. 56 | /// 57 | public static BehaviorCollection GetBehaviors(DependencyObject obj) 58 | { 59 | return Interaction.GetInternalBehaviors(obj); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /UIGenerator/Types/PanelGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Media; 11 | 12 | namespace EmptyKeys.UserInterface.Generator.Types 13 | { 14 | /// 15 | /// Implements Panel control generator 16 | /// 17 | public class PanelGeneratorType : ElementGeneratorType 18 | { 19 | 20 | /// 21 | /// Gets the children. 22 | /// 23 | /// The dependency object 24 | /// 25 | public override IEnumerable GetChildren(DependencyObject source) 26 | { 27 | Panel panel = source as Panel; 28 | if (!panel.IsItemsHost) 29 | { 30 | return panel.Children; 31 | } 32 | else 33 | { 34 | return null; 35 | } 36 | } 37 | 38 | /// 39 | /// Generates control fields 40 | /// 41 | /// The source. 42 | /// Type of the class. 43 | /// The initialize method. 44 | /// if set to true [generate field]. 45 | /// 46 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod initMethod, bool generateField) 47 | { 48 | CodeExpression fieldReference = base.Generate(source, classType, initMethod, generateField); 49 | 50 | Panel panel = source as Panel; 51 | CodeComHelper.GenerateBrushField(initMethod, fieldReference, source, Panel.BackgroundProperty); 52 | CodeComHelper.GenerateField(initMethod, fieldReference, source, Panel.IsItemsHostProperty); 53 | 54 | return fieldReference; 55 | } 56 | 57 | /// 58 | /// Adds the child. 59 | /// 60 | /// The parent. 61 | /// The child. 62 | /// The initialize method. 63 | /// The index. 64 | public override void AddChild(CodeExpression parent, CodeExpression child, CodeMemberMethod initMethod, int index) 65 | { 66 | initMethod.Statements.Insert(index, new CodeExpressionStatement(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(parent, "Children"), "Add", child))); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /UIGenerator/Types/Charts/LineSeries2DGeneratorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.CodeDom; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using EmptyKeys.UserInterface.Designer.Charts; 10 | 11 | namespace EmptyKeys.UserInterface.Generator.Types.Charts 12 | { 13 | /// 14 | /// Implements LineSeries2D generator 15 | /// 16 | public class LineSeries2DGeneratorType : ControlGeneratorType 17 | { 18 | /// 19 | /// Gets the type of the xaml. 20 | /// 21 | /// 22 | /// The type of the xaml. 23 | /// 24 | public override Type XamlType 25 | { 26 | get 27 | { 28 | return typeof(LineSeries2D); 29 | } 30 | } 31 | 32 | /// 33 | /// Generates the specified source. 34 | /// 35 | /// The source. 36 | /// Type of the class. 37 | /// The method. 38 | /// if set to true [generate field]. 39 | /// 40 | public override CodeExpression Generate(DependencyObject source, CodeTypeDeclaration classType, CodeMemberMethod method, bool generateField) 41 | { 42 | CodeExpression fieldReference = base.Generate(source, classType, method, generateField); 43 | 44 | LineSeries2D series = source as LineSeries2D; 45 | CodeComHelper.GenerateField(method, fieldReference, source, LineSeries2D.LineThicknessProperty); 46 | 47 | return fieldReference; 48 | } 49 | 50 | /// 51 | /// Gets the children. 52 | /// 53 | /// The dependency object 54 | /// 55 | public override IEnumerable GetChildren(DependencyObject source) 56 | { 57 | LineSeries2D series = source as LineSeries2D; 58 | return series.Points; 59 | } 60 | 61 | /// 62 | /// Adds the child. 63 | /// 64 | /// The parent. 65 | /// The child. 66 | /// The initialize method. 67 | /// The index. 68 | public override void AddChild(CodeExpression parent, CodeExpression child, CodeMemberMethod initMethod, int index) 69 | { 70 | initMethod.Statements.Insert(index, new CodeExpressionStatement(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(parent, "Points"), "Add", child))); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EmptyKeys.UserInterface.Designer.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EmptyKeys.UserInterface.Designer.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /EmptyKeys.UserInterface.Designer/AnimatedImage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | 9 | namespace EmptyKeys.UserInterface.Designer 10 | { 11 | public class AnimatedImage : Image 12 | { 13 | private static readonly Type typeOfThis = typeof(AnimatedImage); 14 | private static DependencyObjectType dependencyType; 15 | 16 | /// 17 | /// The frame width property 18 | /// 19 | public static readonly DependencyProperty FrameWidthProperty = 20 | DependencyProperty.Register("FrameWidth", typeof(int), typeOfThis, 21 | new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsMeasure)); 22 | 23 | /// 24 | /// Gets or sets the width of one frame in image atlas 25 | /// 26 | /// 27 | /// The width of the frame. 28 | /// 29 | public int FrameWidth 30 | { 31 | get { return (int)GetValue(FrameWidthProperty); } 32 | set { SetValue(FrameWidthProperty, value); } 33 | } 34 | 35 | /// 36 | /// The frame height property 37 | /// 38 | public static readonly DependencyProperty FrameHeightProperty = 39 | DependencyProperty.Register("FrameHeight", typeof(int), typeOfThis, 40 | new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsMeasure)); 41 | 42 | /// 43 | /// Gets or sets the height of the frame. 44 | /// 45 | /// 46 | /// The height of the frame. 47 | /// 48 | public int FrameHeight 49 | { 50 | get { return (int)GetValue(FrameHeightProperty); } 51 | set { SetValue(FrameHeightProperty, value); } 52 | } 53 | 54 | /// 55 | /// The frames per second property 56 | /// 57 | public static readonly DependencyProperty FramesPerSecondProperty = 58 | DependencyProperty.Register("FramesPerSecond", typeof(int), typeOfThis, 59 | new FrameworkPropertyMetadata(60)); 60 | 61 | /// 62 | /// Gets or sets the frames per second. 63 | /// 64 | /// 65 | /// The frames per second. 66 | /// 67 | public int FramesPerSecond 68 | { 69 | get { return (int)GetValue(FramesPerSecondProperty); } 70 | set { SetValue(FramesPerSecondProperty, value); } 71 | } 72 | 73 | static AnimatedImage() 74 | { 75 | dependencyType = DependencyObjectType.FromSystemType(typeOfThis); 76 | } 77 | 78 | /// 79 | /// Initializes a new instance of the class. 80 | /// 81 | public AnimatedImage() 82 | : base() 83 | { 84 | } 85 | } 86 | } 87 | --------------------------------------------------------------------------------