├── .gitattributes ├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── ComicDesigner.Controls ├── ColorPicker │ ├── ColorPicker.xaml │ ├── ColorPicker.xaml.cs │ ├── ColorSpace.cs │ └── HSV.cs ├── ComicDesigner.Controls.csproj ├── FontPicker │ └── FontPicker.cs ├── Properties │ └── AssemblyInfo.cs ├── Themes │ └── Generic.xaml └── packages.config ├── ComicDesigner ├── App.xaml ├── App.xaml.cs ├── Assets │ ├── Logo.scale-100.png │ ├── Logo.scale-140.png │ ├── Logo.scale-180.png │ ├── Logo.scale-80.png │ ├── SmallLogo.scale-100.png │ ├── SplashScreen.scale-100.png │ └── StoreLogo.scale-100.png ├── BundleArtifacts │ └── neutral.txt ├── ComicDesigner.csproj ├── ComicDesigner_TemporaryKey.pfx ├── DesignSurfaceCommandHandler.cs ├── EditingContext.cs ├── IDesignCommandHandler.cs ├── IEditingContext.cs ├── Images │ ├── Mario.png │ └── UI │ │ ├── BringToFront.png │ │ ├── SendToBack.png │ │ └── Undo.png ├── InitializationBootstrapper.cs ├── ItemToUserControlConverter.cs ├── MainPage.xaml ├── MainPage.xaml.cs ├── MainViewModel.cs ├── Model │ ├── Bubble.cs │ ├── CanvasItemViewModel.cs │ ├── Color.cs │ ├── Document.cs │ ├── Frame.cs │ ├── Mario.cs │ ├── Model.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Shape.cs │ ├── app.config │ └── packages.config ├── Package.appxmanifest ├── Properties │ └── AssemblyInfo.cs ├── PropertiesControl.xaml ├── PropertiesControl.xaml.cs ├── PropertyPages │ ├── BubbleViewModel.cs │ ├── ColorToModelColorConverter.cs │ ├── EqualsConverter.cs │ ├── FontFamilyToFontNameConverter.cs │ ├── FrameControl.xaml │ ├── FrameControl.xaml.cs │ ├── FrameViewModel.cs │ ├── ModelColorToSolidColorBrushConverter.cs │ ├── SpeechBubbleControl.xaml │ └── SpeechBubbleControl.xaml.cs ├── Themes │ └── Generic.xaml ├── ToolbarControl.xaml ├── ToolbarControl.xaml.cs ├── ToolbarViewModel.cs ├── Tooling │ ├── ITool.cs │ ├── IToolProvider.cs │ ├── ToolKeyToImageSourceConverter.cs │ ├── ToolProvider.cs │ └── Tools │ │ ├── FrameTool.cs │ │ ├── Icons │ │ ├── Frame.png │ │ ├── Mario.png │ │ └── SpeechBubble.png │ │ ├── MarioTool.cs │ │ └── SpeechBubbleTool.cs ├── UIUtils │ ├── IRelayCommand.cs │ ├── RelayCommand.cs │ ├── SetterValueBindingHelper.cs │ ├── SizeChange.cs │ └── TypedTemplateSelector.cs ├── VectorGraphics │ ├── GeometryData.xaml │ ├── IconControl.cs │ └── StringToPathGeometryConverter.cs ├── ViewModelLocator.cs └── packages.config ├── Glass ├── Glass.Basics │ ├── Attributes │ │ ├── LocalizableString.cs │ │ ├── LocalizedCategoryAttribute.cs │ │ └── LocalizedDescriptionAttribute.cs │ ├── Behaviors │ │ ├── DragDrop │ │ │ ├── ChildrenRetriever.cs │ │ │ ├── DragDropBehavior.cs │ │ │ └── DropModes.cs │ │ ├── KeepFocusOnErrorBehavior.cs │ │ ├── RubberBand │ │ │ ├── ListBoxSelectionBehavior.cs │ │ │ ├── RubberBandAdorner.cs │ │ │ ├── RubberBandBehavior.cs │ │ │ ├── RubberBandSelectionBehavior.cs │ │ │ └── SelectionMode.cs │ │ └── SelectionChangeSupervisingBehavior.cs │ ├── BindingHelper.cs │ ├── Borders.cs │ ├── Collections │ │ └── ObservableCollectionSynchronizer.cs │ ├── Controls │ │ ├── BindableGrid │ │ │ ├── BindableGrid.cs │ │ │ ├── BoundGridColumnDefinitionCollection.cs │ │ │ └── BoundGridRowDefinitionCollection.cs │ │ ├── DottedGrid.cs │ │ ├── EditableTextBlock │ │ │ └── EditableTextBlock.cs │ │ └── FontFamilyPicker │ │ │ └── FontFamilyPicker.cs │ ├── Converters │ │ ├── Designer │ │ │ ├── Bool2VisibilityConverter.cs │ │ │ ├── ColorToSolidColorBrushValueConverter.cs │ │ │ ├── IsGreaterThanConverter.cs │ │ │ ├── NegConverter.cs │ │ │ ├── PercentageConverter.cs │ │ │ ├── ValueConverterGroup.cs │ │ │ └── Visibility2BoolConverter.cs │ │ ├── FlaggedEnumConverter.cs │ │ ├── ImageSourceToImageConverter.cs │ │ ├── InvertBoolConverter.cs │ │ ├── IsDifferentConverter.cs │ │ ├── IsEqualConverter.cs │ │ ├── IsGreaterThanConverter.cs │ │ ├── IsLessThanConverter.cs │ │ ├── IsMatchConverter.cs │ │ ├── MenuIconConverter.cs │ │ ├── ObjectTypeConverter.cs │ │ ├── ValueConverterGroup.cs │ │ └── VisibilityConverter.cs │ ├── Core │ │ └── EventArgs.cs │ ├── Extensions │ │ ├── BitmapSourceExtensions.cs │ │ ├── PanelExtensions.cs │ │ ├── UIElementExtensions.cs │ │ └── VisualExtensions.cs │ ├── Glass.Basics.Wpf.csproj │ ├── ISelectable.cs │ ├── Localization │ │ ├── Strings.Designer.cs │ │ ├── Strings.es-ES.Designer.cs │ │ ├── Strings.es-ES.resx │ │ └── Strings.resx │ ├── Presentation │ │ ├── ControlAdorner.cs │ │ ├── ItemsControlExtensions.cs │ │ └── Rubberband │ │ │ ├── RectEventHandler.cs │ │ │ ├── RubberBandAdorner.cs │ │ │ ├── RubberBandAttacher.cs │ │ │ ├── RubberbandAutoSelectionBehavior.cs │ │ │ ├── RubberbandBehavior.cs │ │ │ └── RubberbandSelectionBehavior.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── RoutedEventHelper.cs │ ├── RoutedEventTrigger.cs │ ├── Styles │ │ ├── CloseButton.cs │ │ ├── MaximizeButton.cs │ │ ├── MinimizeButton.cs │ │ ├── SystemButton.cs │ │ ├── Themes │ │ │ ├── Blue.xaml │ │ │ └── Brushes.xaml │ │ ├── WPFBasics.Styles.csproj │ │ └── app.config │ ├── Themes │ │ └── Generic.xaml │ ├── VisualTreeUtils.cs │ ├── app.config │ └── packages.config ├── Glass.Design.Pcl │ ├── Annotations │ │ ├── AspMvcActionAttribute.cs │ │ ├── AspMvcActionSelectorAttribute.cs │ │ ├── AspMvcAreaAttribute.cs │ │ ├── AspMvcAreaMasterLocationFormatAttribute.cs │ │ ├── AspMvcAreaPartialViewLocationFormatAttribute.cs │ │ ├── AspMvcAreaViewLocationFormatAttribute.cs │ │ ├── AspMvcControllerAttribute.cs │ │ ├── AspMvcDisplayTemplateAttribute.cs │ │ ├── AspMvcEditorTemplateAttribute.cs │ │ ├── AspMvcMasterAttribute.cs │ │ ├── AspMvcMasterLocationFormatAttribute.cs │ │ ├── AspMvcModelTypeAttribute.cs │ │ ├── AspMvcPartialViewAttribute.cs │ │ ├── AspMvcPartialViewLocationFormatAttribute.cs │ │ ├── AspMvcSupressViewErrorAttribute.cs │ │ ├── AspMvcTemplateAttribute.cs │ │ ├── AspMvcViewAttribute.cs │ │ ├── AspMvcViewLocationFormatAttribute.cs │ │ ├── BaseTypeRequiredAttribute.cs │ │ ├── CanBeNullAttribute.cs │ │ ├── CannotApplyEqualityOperatorAttribute.cs │ │ ├── ContractAnnotationAttribute.cs │ │ ├── HtmlAttributeValueAttribute.cs │ │ ├── HtmlElementAttributesAttribute.cs │ │ ├── ImplicitUseKindFlags.cs │ │ ├── ImplicitUseTargetFlags.cs │ │ ├── InstantHandleAttribute.cs │ │ ├── InvokerParameterNameAttribute.cs │ │ ├── LocalizationRequiredAttribute.cs │ │ ├── MeansImplicitUseAttribute.cs │ │ ├── NotNullAttribute.cs │ │ ├── NotifyPropertyChangedInvocatorAttribute.cs │ │ ├── PathReferenceAttribute.cs │ │ ├── PublicAPIAttribute.cs │ │ ├── PureAttribute.cs │ │ ├── RazorSectionAttribute.cs │ │ ├── StringFormatMethodAttribute.cs │ │ └── UsedImplicitlyAttribute.cs │ ├── Canvas │ │ ├── Aligner.cs │ │ ├── CanvasItem.cs │ │ ├── CanvasItemCollection.cs │ │ ├── CanvasItemRelocator.cs │ │ ├── CanvasItemResizeInfo.cs │ │ ├── CanvasItemSelection.cs │ │ ├── CanvasModelItem.cs │ │ ├── CanvasVisualItem.cs │ │ ├── ChildrenPositioning.cs │ │ ├── ICanvasItem.cs │ │ └── ICanvasItemContainer.cs │ ├── ChildrenExpandableCanvasItem.cs │ ├── Core │ │ ├── CoordinatePart.cs │ │ ├── HorizontalAlignment.cs │ │ ├── ICoordinate.cs │ │ ├── ICoreTypesFactory.cs │ │ ├── IInputProvider.cs │ │ ├── IPoint.cs │ │ ├── IRect.cs │ │ ├── ISize.cs │ │ ├── IUIElementFactory.cs │ │ ├── IVector.cs │ │ ├── Point.cs │ │ ├── Range.cs │ │ ├── Rect.cs │ │ ├── ServiceLocator.cs │ │ ├── Size.cs │ │ └── VerticalAlignment.cs │ ├── DesignSurface │ │ ├── CanvasSelectorExtensions.cs │ │ ├── DesignAidsProvider.cs │ │ ├── GroupCommandArgs.cs │ │ ├── ICanvasSelector.cs │ │ ├── IDesignSurface.cs │ │ ├── IDesignerItem.cs │ │ ├── IMultiSelector.cs │ │ ├── INamed.cs │ │ ├── IPositionable.cs │ │ ├── IResizeThumb.cs │ │ ├── ISizable.cs │ │ ├── PlaneOperation.cs │ │ ├── SizeChangeEventArgs.cs │ │ └── VisualAids │ │ │ ├── Drag │ │ │ ├── DragOperation.cs │ │ │ └── DragOperationHost.cs │ │ │ ├── Resize │ │ │ ├── AspectRatioKeeper.cs │ │ │ ├── ResizeOperation.cs │ │ │ └── UIResizeOperationHandleConnector.cs │ │ │ ├── Selection │ │ │ ├── SelectionHandler.cs │ │ │ └── SelectionMode.cs │ │ │ └── Snapping │ │ │ ├── CanvasItemSnappingEngine.cs │ │ │ ├── Edge.cs │ │ │ ├── EdgeSnappingEngine.cs │ │ │ ├── GridSnappingEngine.cs │ │ │ ├── ICanvasItemSnappingEngine.cs │ │ │ ├── IEdgeSnappingEngine.cs │ │ │ ├── ISnappingEngine.cs │ │ │ ├── NoEffectsCanvasItemSnappingEngine.cs │ │ │ ├── NoEffectsSnappingEngine.cs │ │ │ ├── Orientation.cs │ │ │ └── SnappingEngine.cs │ ├── Extensions.cs │ ├── Geometrics.cs │ ├── Glass.Design.Pcl.csproj │ ├── MathOperations.cs │ ├── PlatformAbstraction │ │ ├── FingerManipulationEventArgs.cs │ │ ├── FingerManipulationEventHandler.cs │ │ ├── IAdorner.cs │ │ ├── IControl.cs │ │ ├── IFrameworkElement.cs │ │ ├── IUIElement.cs │ │ ├── IUserInputReceiver.cs │ │ ├── PointingManipulationEventArgs.cs │ │ └── PointingManipulationEventHandler.cs │ ├── PointCollection.cs │ ├── Primitives │ │ └── EnumerableExtensions.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ProportionalResizer.cs │ ├── app.config │ └── packages.config ├── Glass.Design.Tests │ ├── CanvasItemGroupTest.cs │ ├── ExtensionsTest.cs │ ├── Glass.Design.Tests.csproj │ ├── LayeredSelectionTest.cs │ ├── MathTests.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ResizeTests.cs │ ├── SnappingTest.cs │ ├── app.config │ └── packages.config ├── Glass.Design.WinRT │ ├── CanvasItemControl.cs │ ├── Core │ │ ├── PointExtensions.cs │ │ └── Vector.cs │ ├── DesignSurface │ │ ├── DesignSurface.cs │ │ ├── DesignSurfaceBase.cs │ │ └── VisualAids │ │ │ ├── Drag │ │ │ └── MovingControl.cs │ │ │ ├── Resize │ │ │ └── ResizeControl.cs │ │ │ ├── Selection │ │ │ ├── Adorner.cs │ │ │ ├── CanvasItemAdorner.cs │ │ │ └── SelectionAdorner.cs │ │ │ └── Snapping │ │ │ ├── CanvasItemAdorner.cs │ │ │ └── EdgeAdorner.cs │ ├── Glass.Design.WinRT.csproj │ ├── InputDeviceEventHandler.cs │ ├── InputDeviceEventHandlerArgs.cs │ ├── PlatformSpecific │ │ ├── ControlAdapter.cs │ │ ├── FrameworkElementAdapter.cs │ │ ├── UIElementAdapter.cs │ │ ├── WinRTInputProvider.cs │ │ └── WinRTUIElementFactory.cs │ ├── Properties │ │ ├── Annotations.cs │ │ └── AssemblyInfo.cs │ ├── Themes │ │ └── Generic.xaml │ ├── VisualExtensions.cs │ ├── WrappingAdorner.cs │ └── packages.config ├── Glass.Design.Wpf │ ├── Converters │ │ └── IThumbCursorConverter.cs │ ├── Core │ │ └── PointExtensions.cs │ ├── DesignSurface │ │ ├── DesignSurface.cs │ │ ├── DesignSurfaceBase.cs │ │ ├── DesignSurfaceCommandHandler.cs │ │ ├── DesignSurfaceCommands.cs │ │ └── VisualAids │ │ │ ├── Drag │ │ │ └── MovingControl.cs │ │ │ ├── Resize │ │ │ └── ResizeControl.cs │ │ │ ├── Selection │ │ │ ├── CanvasItemAdorner.cs │ │ │ └── SelectionAdorner.cs │ │ │ └── Snapping │ │ │ └── EdgeAdorner.cs │ ├── DesignSurfaceItem.cs │ ├── Glass.Design.Wpf.csproj │ ├── PlatformSpecific │ │ ├── ControlAdapter.cs │ │ ├── FrameworkElementAdapter.cs │ │ ├── NetCoreInputProvider.cs │ │ ├── NetCoreUIElementFactory.cs │ │ └── UIElementAdapter.cs │ ├── Properties │ │ ├── Annotations.cs │ │ └── AssemblyInfo.cs │ ├── Themes │ │ └── Generic.xaml │ ├── Viewing │ │ └── ViewingSurface.cs │ ├── WindowsSizeCursorsThumbCursorConverter.cs │ ├── WrappingAdorner.cs │ ├── app.config │ └── packages.config └── Glass.Design │ ├── Annotations │ └── Annotations.cs │ ├── CanvasItem │ ├── CanvasItem.cs │ ├── CanvasItemExtensions.cs │ ├── CanvasItemGroup.cs │ ├── CanvasItemResizeInfo.cs │ └── ICanvasItem.cs │ ├── ChildrenExpandableCanvasItem.cs │ ├── Converters │ └── IThumbCursorConverter.cs │ ├── DesignSurface │ ├── DesignOperation.cs │ ├── IDesignSurface.cs │ ├── IDesignerItem.cs │ ├── IMultiSelector.cs │ ├── IPositionable.cs │ ├── IResizeThumb.cs │ ├── ISizable.cs │ └── VisualAids │ │ ├── Drag │ │ ├── DragOperation.cs │ │ └── DragOperationHost.cs │ │ ├── Resize │ │ └── AspectRatioKeeper.cs │ │ ├── Selection │ │ ├── SelectionHandler.cs │ │ └── SelectionMode.cs │ │ └── Snapping │ │ ├── CanvasItemSnappingEngine.cs │ │ ├── EdgeSnappingEngine.cs │ │ ├── GridSnappingEngine.cs │ │ ├── ICanvasItemSnappingEngine.cs │ │ ├── ISnappingEngine.cs │ │ ├── NoEffectsCanvasItemSnappingEngine.cs │ │ └── NoEffectsSnappingEngine.cs │ ├── DragOperation.cs │ ├── Extensions.cs │ ├── Geometrics.cs │ ├── Glass.Design.csproj │ ├── MathOperations.cs │ ├── PointCollection.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── ProportionalResizer.cs │ └── Selection │ └── LayeredSelection.cs ├── README.md ├── SampleModel.Serialization ├── EllipseDto.cs ├── GroupDto.cs ├── LinkDto.cs ├── MarioDto.cs ├── ModelDto.cs ├── ObjectDto.cs ├── Properties │ └── AssemblyInfo.cs ├── RectangleDto.cs ├── SampleModel.Serialization.csproj ├── ShapeDto.cs ├── SonicDto.cs ├── XmlModelSerializer.cs ├── app.config └── packages.config ├── SampleModel ├── CanvasDocument.cs ├── CanvasItemViewModel.cs ├── CanvasRectangle.cs ├── Color.cs ├── Ellipse.cs ├── Group.cs ├── Label.cs ├── Link.cs ├── Mario.cs ├── Properties │ └── AssemblyInfo.cs ├── SampleModel.csproj ├── Shape.cs ├── Sonic.cs ├── app.config └── packages.config ├── SampleModelNoPCL ├── CanvasRectangle.cs ├── Color.cs ├── Mario.cs ├── Properties │ └── AssemblyInfo.cs └── SampleModel.csproj ├── VisualDesigner.sln └── WPFTestApp ├── App.config ├── App.xaml ├── App.xaml.cs ├── DockingPart.xaml ├── DockingPart.xaml.cs ├── Images ├── Group.png ├── Link.png ├── Mario.png └── Sonic.png ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── MainWindowViewModel.cs ├── ModelColorToSolidColorBrushConverter.cs ├── MyOperationFormatter.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── WPFTestApp.csproj └── packages.config /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/.nuget/NuGet.exe -------------------------------------------------------------------------------- /ComicDesigner.Controls/ColorPicker/HSV.cs: -------------------------------------------------------------------------------- 1 | namespace ComicDesigner.Controls.ColorPicker 2 | { 3 | public struct HSV 4 | { 5 | public float Hue; 6 | public float Saturation; 7 | public float Value; 8 | 9 | public HSV(float hue, float saturation, float value) 10 | { 11 | Hue = hue; 12 | Saturation = saturation; 13 | Value = value; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ComicDesigner.Controls/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ComicDesigner.Controls")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ComicDesigner.Controls")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /ComicDesigner.Controls/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 24 | 25 | -------------------------------------------------------------------------------- /ComicDesigner.Controls/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ComicDesigner/App.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ComicDesigner/Assets/Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Assets/Logo.scale-100.png -------------------------------------------------------------------------------- /ComicDesigner/Assets/Logo.scale-140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Assets/Logo.scale-140.png -------------------------------------------------------------------------------- /ComicDesigner/Assets/Logo.scale-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Assets/Logo.scale-180.png -------------------------------------------------------------------------------- /ComicDesigner/Assets/Logo.scale-80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Assets/Logo.scale-80.png -------------------------------------------------------------------------------- /ComicDesigner/Assets/SmallLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Assets/SmallLogo.scale-100.png -------------------------------------------------------------------------------- /ComicDesigner/Assets/SplashScreen.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Assets/SplashScreen.scale-100.png -------------------------------------------------------------------------------- /ComicDesigner/Assets/StoreLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Assets/StoreLogo.scale-100.png -------------------------------------------------------------------------------- /ComicDesigner/BundleArtifacts/neutral.txt: -------------------------------------------------------------------------------- 1 | MainPackage=C:\src\VisualDesigner\ComicDesigner\bin\Debug\ComicDesigner_1.0.0.0_Bundle\ComicDesigner_1.0.0.0_AnyCPU_Debug.appx 2 | SymbolPackage=C:\src\VisualDesigner\ComicDesigner\AppPackages\ComicDesigner_1.0.0.0_Debug_Test\ComicDesigner_1.0.0.0_AnyCPU_Debug.appxsym 3 | ResourcePack=C:\src\VisualDesigner\ComicDesigner\bin\Debug\ComicDesigner_1.0.0.0_Bundle\ComicDesigner_1.0.0.0_scale-140.appx 4 | ResourcePack=C:\src\VisualDesigner\ComicDesigner\bin\Debug\ComicDesigner_1.0.0.0_Bundle\ComicDesigner_1.0.0.0_scale-180.appx 5 | -------------------------------------------------------------------------------- /ComicDesigner/ComicDesigner_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/ComicDesigner_TemporaryKey.pfx -------------------------------------------------------------------------------- /ComicDesigner/EditingContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Glass.Design.Pcl.Annotations; 3 | using Glass.Design.Pcl.Canvas; 4 | using Model; 5 | using StyleMVVM.DependencyInjection; 6 | 7 | namespace ComicDesigner 8 | { 9 | [Singleton] 10 | [Export(typeof(IEditingContext))] 11 | public class EditingContext : IEditingContext 12 | { 13 | [ImportConstructor] 14 | public EditingContext() 15 | { 16 | SelectedItems = new CanvasItemCollection(); 17 | } 18 | [NotNull] 19 | public Document Document { get; set; } 20 | 21 | public double SurfaceWidth { get; set; } 22 | public double SurfaceHeight { get; set; } 23 | public CanvasItemCollection SelectedItems { get; set; } 24 | } 25 | } -------------------------------------------------------------------------------- /ComicDesigner/IDesignCommandHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Input; 2 | using ComicDesigner.UIUtils; 3 | 4 | namespace ComicDesigner 5 | { 6 | 7 | public interface IDesignCommandHandler 8 | { 9 | IEditingContext EditingContext { get; } 10 | RelayCommand UndoCommand { get; } 11 | RelayCommand RedoCommand { get; } 12 | RelayCommand LoadItemsCommand { get; } 13 | RelayCommand SendToBackCommand { get; } 14 | RelayCommand BringToFrontCommand { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /ComicDesigner/IEditingContext.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Glass.Design.Pcl.Canvas; 3 | using Model; 4 | 5 | namespace ComicDesigner 6 | { 7 | public interface IEditingContext 8 | { 9 | Document Document { get; set; } 10 | double SurfaceWidth { get; set; } 11 | double SurfaceHeight { get; set; } 12 | CanvasItemCollection SelectedItems { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /ComicDesigner/Images/Mario.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Images/Mario.png -------------------------------------------------------------------------------- /ComicDesigner/Images/UI/BringToFront.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Images/UI/BringToFront.png -------------------------------------------------------------------------------- /ComicDesigner/Images/UI/SendToBack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Images/UI/SendToBack.png -------------------------------------------------------------------------------- /ComicDesigner/Images/UI/Undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Images/UI/Undo.png -------------------------------------------------------------------------------- /ComicDesigner/ItemToUserControlConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI.Xaml.Controls; 3 | using Windows.UI.Xaml.Data; 4 | using ComicDesigner.PropertyPages; 5 | using Model; 6 | 7 | namespace ComicDesigner 8 | { 9 | public class ItemToUserControlConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, string language) 12 | { 13 | if (value is Bubble) 14 | { 15 | return new SpeechBubbleControl(); 16 | } 17 | if (value is Model.Frame) 18 | { 19 | return new FrameControl(); 20 | } 21 | 22 | return new ContentControl(); 23 | } 24 | 25 | public object ConvertBack(object value, Type targetType, object parameter, string language) 26 | { 27 | throw new NotSupportedException(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /ComicDesigner/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml.Controls; 2 | 3 | // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 4 | 5 | namespace ComicDesigner 6 | { 7 | /// 8 | /// An empty page that can be used on its own or navigated to within a Frame. 9 | /// 10 | public sealed partial class MainPage : Page 11 | { 12 | public MainPage() 13 | { 14 | this.InitializeComponent(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ComicDesigner/Model/Bubble.cs: -------------------------------------------------------------------------------- 1 | using PostSharp.Patterns.Model; 2 | 3 | namespace Model 4 | { 5 | public class Bubble : Shape 6 | { 7 | public string Text { get; set; } 8 | 9 | public Color TextColor { get; set; } 10 | 11 | public double FontSize { get; set; } 12 | public string FontName { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /ComicDesigner/Model/CanvasItemViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using Glass.Design.Pcl.Canvas; 3 | 4 | namespace Model 5 | { 6 | public class CanvasItemViewModel : CanvasModelItem 7 | { 8 | private static int nextId; 9 | private readonly int id = Interlocked.Increment(ref nextId); 10 | 11 | public CanvasItemViewModel() 12 | { 13 | this.Name = this.GetType().Name + id; 14 | } 15 | 16 | public string Name { get; set; } 17 | 18 | public override string ToString() 19 | { 20 | // For better debugging. 21 | return string.Format("{0} #{5}, Left={1}, Top={2}, Width={3}, Height={4}", this.GetType().Name, this.Left, 22 | this.Top, this.Width, this.Height, this.id); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /ComicDesigner/Model/Color.cs: -------------------------------------------------------------------------------- 1 | namespace Model 2 | { 3 | public struct Color 4 | { 5 | private readonly byte r; 6 | private readonly byte g; 7 | private readonly byte b; 8 | private readonly byte a; 9 | 10 | public Color(byte alpha, byte r, byte g, byte b) 11 | { 12 | this.a = alpha; 13 | this.r = r; 14 | this.g = g; 15 | this.b = b; 16 | } 17 | 18 | public Color(byte r, byte g, byte b) : this(255, r, g, b) 19 | { 20 | 21 | } 22 | 23 | public byte R 24 | { 25 | get { return r; } 26 | } 27 | 28 | public byte G 29 | { 30 | get { return g; } 31 | 32 | } 33 | 34 | public byte B 35 | { 36 | get { return b; } 37 | } 38 | 39 | public byte A 40 | { 41 | get { return a; } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /ComicDesigner/Model/Document.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Canvas; 2 | using PostSharp.Patterns.Model; 3 | using PostSharp.Patterns.Recording; 4 | 5 | namespace Model 6 | { 7 | [Recordable] 8 | public class Document : ICanvasItemContainer 9 | { 10 | public Document() 11 | { 12 | this.Children = new CanvasItemCollection(); 13 | } 14 | 15 | [Child] 16 | public CanvasItemCollection Children { get; set; } 17 | 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /ComicDesigner/Model/Frame.cs: -------------------------------------------------------------------------------- 1 | using PostSharp.Patterns.Model; 2 | 3 | namespace Model 4 | { 5 | public class Frame : Shape 6 | { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ComicDesigner/Model/Mario.cs: -------------------------------------------------------------------------------- 1 | namespace Model 2 | { 3 | public class Mario : CanvasItemViewModel 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /ComicDesigner/Model/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Model")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Model")] 14 | [assembly: AssemblyCopyright("Copyright © 2014")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: NeutralResourcesLanguage("en")] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | -------------------------------------------------------------------------------- /ComicDesigner/Model/Shape.cs: -------------------------------------------------------------------------------- 1 | using PostSharp.Patterns.Model; 2 | 3 | namespace Model 4 | { 5 | public class Shape : CanvasItemViewModel 6 | { 7 | public Color Background { get; set; } 8 | public Color Stroke { get; set; } 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ComicDesigner/Model/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ComicDesigner/Model/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ComicDesigner/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | ComicDesigner 6 | JoséManuel 7 | Assets\StoreLogo.png 8 | 9 | 10 | 6.3.0 11 | 6.3.0 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ComicDesigner/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("ComicDesigner")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("ComicDesigner")] 12 | [assembly: AssemblyCopyright("Copyright © 2014")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Version information for an assembly consists of the following four values: 17 | // 18 | // Major Version 19 | // Minor Version 20 | // Build Number 21 | // Revision 22 | // 23 | // You can specify all the values or you can default the Build and Revision Numbers 24 | // by using the '*' as shown below: 25 | // [assembly: AssemblyVersion("1.0.*")] 26 | [assembly: AssemblyVersion("1.0.0.0")] 27 | [assembly: AssemblyFileVersion("1.0.0.0")] 28 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /ComicDesigner/PropertiesControl.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /ComicDesigner/PropertiesControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI.Xaml; 3 | using Glass.Design.Pcl.Canvas; 4 | 5 | namespace ComicDesigner 6 | { 7 | public sealed partial class PropertiesControl 8 | { 9 | public PropertiesControl() 10 | { 11 | this.InitializeComponent(); 12 | } 13 | 14 | #region SelectedItem 15 | public static readonly DependencyProperty SelectedItemProperty = 16 | DependencyProperty.Register("SelectedItem", typeof(object), typeof(PropertiesControl), 17 | new PropertyMetadata(null, PropertyChangedCallback)); 18 | 19 | private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) 20 | { 21 | 22 | } 23 | 24 | public bool SelectedItem 25 | { 26 | get { return (bool)GetValue(SelectedItemProperty); } 27 | set { SetValue(SelectedItemProperty, value); } 28 | } 29 | 30 | #endregion 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ComicDesigner/PropertyPages/ColorToModelColorConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI; 3 | using Windows.UI.Xaml.Data; 4 | 5 | namespace ComicDesigner.PropertyPages 6 | { 7 | public class ColorToModelColorConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, string culture) 10 | { 11 | if (value != null) 12 | { 13 | var modelColor = (Model.Color) value; 14 | var color = Color.FromArgb(modelColor.A, modelColor.R, modelColor.G, modelColor.B); 15 | return color; 16 | } 17 | else 18 | { 19 | return new Color(); 20 | } 21 | } 22 | 23 | public object ConvertBack(object value, Type targetType, object parameter, string culture) 24 | { 25 | var color = (Color) value; 26 | var modelColor = new Model.Color(color.A, color.R, color.G, color.B); 27 | return modelColor; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /ComicDesigner/PropertyPages/EqualsConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI.Xaml.Data; 3 | 4 | namespace ComicDesigner.PropertyPages 5 | { 6 | public class EqualsConverter : IValueConverter 7 | { 8 | public object Convert(object value, Type targetType, object parameter, string language) 9 | { 10 | return Equals(value, parameter); 11 | } 12 | 13 | public object ConvertBack(object value, Type targetType, object parameter, string language) 14 | { 15 | throw new NotSupportedException(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /ComicDesigner/PropertyPages/FontFamilyToFontNameConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI.Xaml.Data; 3 | using Windows.UI.Xaml.Media; 4 | 5 | namespace ComicDesigner.PropertyPages 6 | { 7 | public class FontFamilyToFontNameConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, string language) 10 | { 11 | var fontName = value as string; 12 | if (!string.IsNullOrEmpty( fontName )) 13 | { 14 | return new FontFamily(fontName); 15 | } 16 | 17 | return null; 18 | } 19 | 20 | public object ConvertBack(object value, Type targetType, object parameter, string language) 21 | { 22 | 23 | 24 | var fontFamily = value as FontFamily; 25 | if (fontFamily != null) 26 | { 27 | return fontFamily.Source; 28 | } 29 | 30 | return null; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /ComicDesigner/PropertyPages/FrameControl.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace ComicDesigner.PropertyPages 2 | { 3 | public sealed partial class FrameControl 4 | { 5 | public FrameControl() 6 | { 7 | this.InitializeComponent(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /ComicDesigner/PropertyPages/ModelColorToSolidColorBrushConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Windows.UI; 3 | using Windows.UI.Xaml.Data; 4 | using Windows.UI.Xaml.Media; 5 | using AutoMapper; 6 | 7 | namespace ComicDesigner.PropertyPages 8 | { 9 | public class ModelColorToSolidColorBrushConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, string culture) 12 | { 13 | if (value != null) 14 | { 15 | 16 | var modelColor = (Model.Color)value; 17 | var color = Color.FromArgb(modelColor.A, modelColor.R, modelColor.G, modelColor.B); 18 | var solidColorBrush = new SolidColorBrush(color); 19 | return solidColorBrush; 20 | } 21 | return new SolidColorBrush(); 22 | } 23 | 24 | public object ConvertBack(object value, Type targetType, object parameter, string culture) 25 | { 26 | var solidColorBrush = (SolidColorBrush)value; 27 | var colorFromBrush = solidColorBrush.Color; 28 | var color = new Model.Color(colorFromBrush.A, colorFromBrush.R, colorFromBrush.G, colorFromBrush.B); 29 | return color; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /ComicDesigner/PropertyPages/SpeechBubbleControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml.Controls; 2 | 3 | // The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 4 | 5 | namespace ComicDesigner.PropertyPages 6 | { 7 | public sealed partial class SpeechBubbleControl 8 | { 9 | public SpeechBubbleControl() 10 | { 11 | this.InitializeComponent(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ComicDesigner/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ComicDesigner/ToolbarControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml.Controls; 2 | 3 | // The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 4 | 5 | namespace ComicDesigner 6 | { 7 | public sealed partial class ToolbarControl : UserControl 8 | { 9 | public ToolbarControl() 10 | { 11 | this.InitializeComponent(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ComicDesigner/Tooling/ITool.cs: -------------------------------------------------------------------------------- 1 | using Model; 2 | using PostSharp.Patterns.Recording; 3 | 4 | namespace ComicDesigner.Tooling 5 | { 6 | public interface ITool 7 | { 8 | string Name { get; set; } 9 | string IconKey { get; set; } 10 | CanvasItemViewModel CreateItem(IEditingContext editingContext); 11 | } 12 | 13 | public abstract class Tool : ITool 14 | { 15 | public string Name { get; set; } 16 | public abstract CanvasItemViewModel CreateItem(); 17 | 18 | public string IconKey { get; set; } 19 | public CanvasItemViewModel CreateItem(IEditingContext editingContext) 20 | { 21 | 22 | var items = editingContext.Document.Children; 23 | var canvasItemViewModel = CreateItem(); 24 | 25 | if ( this.InsertOrder == InsertOrder.ToEnd ) 26 | { 27 | items.Add( canvasItemViewModel ); 28 | } 29 | else 30 | { 31 | items.Insert( 0, canvasItemViewModel ); 32 | } 33 | 34 | return canvasItemViewModel; 35 | 36 | } 37 | 38 | public InsertOrder InsertOrder { get; set; } 39 | } 40 | 41 | public enum InsertOrder 42 | { 43 | ToEnd = 0, 44 | ToBeginning, 45 | } 46 | } -------------------------------------------------------------------------------- /ComicDesigner/Tooling/IToolProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace ComicDesigner.Tooling 4 | { 5 | public interface IToolProvider 6 | { 7 | IEnumerable Tools { get; } 8 | } 9 | } -------------------------------------------------------------------------------- /ComicDesigner/Tooling/ToolKeyToImageSourceConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Windows.UI.Xaml.Data; 8 | using Windows.UI.Xaml.Media.Imaging; 9 | 10 | namespace ComicDesigner.Tooling 11 | { 12 | public class ToolKeyToImageSourceConverter : IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, string language) 15 | { 16 | Debug.Assert(value is string); 17 | 18 | var iconKey = (string) value; 19 | var path = @"Tooling/Tools/Icons/"; 20 | var uriString = string.Format("ms-appx:/{0}{1}.png", path, iconKey); 21 | 22 | var uriSource = new Uri(uriString); 23 | var bitmapImage = new BitmapImage(uriSource); 24 | 25 | return bitmapImage; 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, string language) 29 | { 30 | throw new NotSupportedException(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ComicDesigner/Tooling/ToolProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using StyleMVVM.DependencyInjection; 3 | 4 | namespace ComicDesigner.Tooling 5 | { 6 | [Export(typeof(IToolProvider))] 7 | public partial class ToolProvider : IToolProvider 8 | { 9 | private IEnumerable tools; 10 | 11 | [ImportConstructor] 12 | public ToolProvider(IEnumerable tools) 13 | { 14 | this.tools = tools; 15 | } 16 | 17 | public IEnumerable Tools 18 | { 19 | get { return tools; } 20 | private set { tools = value; } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /ComicDesigner/Tooling/Tools/FrameTool.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.WinRT.Annotations; 2 | using Model; 3 | using StyleMVVM.DependencyInjection; 4 | 5 | namespace ComicDesigner.Tooling.Tools 6 | { 7 | [Export(typeof(ITool)), UsedImplicitly] 8 | public class FrameTool : Tool 9 | { 10 | public FrameTool() 11 | { 12 | Name = "Panel"; 13 | IconKey = "Frame"; 14 | InsertOrder = InsertOrder.ToBeginning; 15 | } 16 | 17 | public override CanvasItemViewModel CreateItem() 18 | { 19 | return new Frame 20 | { 21 | Width = 400, 22 | Height = 300, 23 | Background = new Color(255, 255, 255, 255), 24 | Stroke = new Color(255, 0, 0, 0), 25 | }; 26 | } 27 | 28 | } 29 | } -------------------------------------------------------------------------------- /ComicDesigner/Tooling/Tools/Icons/Frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Tooling/Tools/Icons/Frame.png -------------------------------------------------------------------------------- /ComicDesigner/Tooling/Tools/Icons/Mario.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Tooling/Tools/Icons/Mario.png -------------------------------------------------------------------------------- /ComicDesigner/Tooling/Tools/Icons/SpeechBubble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/ComicDesigner/Tooling/Tools/Icons/SpeechBubble.png -------------------------------------------------------------------------------- /ComicDesigner/Tooling/Tools/MarioTool.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.WinRT.Annotations; 2 | using Model; 3 | using StyleMVVM.DependencyInjection; 4 | 5 | namespace ComicDesigner.Tooling.Tools 6 | { 7 | [Export(typeof(ITool)), UsedImplicitly] 8 | public class MarioTool : Tool 9 | { 10 | public MarioTool() 11 | { 12 | Name = "Mario"; 13 | IconKey = "Mario"; 14 | } 15 | 16 | public override CanvasItemViewModel CreateItem() 17 | { 18 | return new Mario 19 | { 20 | Width = 170, 21 | Height = 200, 22 | }; 23 | } 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /ComicDesigner/Tooling/Tools/SpeechBubbleTool.cs: -------------------------------------------------------------------------------- 1 | using Model; 2 | using StyleMVVM.DependencyInjection; 3 | 4 | namespace ComicDesigner.Tooling.Tools 5 | { 6 | [Export(typeof(ITool))] 7 | public class SpeechBubbleTool : Tool 8 | { 9 | public SpeechBubbleTool() 10 | { 11 | Name = "Speech Bubble"; 12 | IconKey = "SpeechBubble"; 13 | } 14 | public override CanvasItemViewModel CreateItem() 15 | { 16 | return new Bubble 17 | { 18 | Width = 300, 19 | Height = 200, 20 | Background = new Color(255, 0, 200, 255), 21 | Text = "Sample Text", 22 | TextColor = new Color(255, 0, 0, 0), 23 | FontSize = 16D, 24 | }; 25 | 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /ComicDesigner/UIUtils/IRelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Input; 2 | 3 | namespace ComicDesigner.UIUtils 4 | { 5 | /// 6 | /// Support for commanding. 7 | /// 8 | public interface IRelayCommand : ICommand 9 | { 10 | /// 11 | /// Raises the can execute changed. 12 | /// 13 | void RaiseCanExecuteChanged(); 14 | 15 | /// 16 | /// Determines whether this instance can execute the specified parameter. 17 | /// 18 | /// The parameter. 19 | /// 20 | /// true if this instance can execute the specified parameter; otherwise, false. 21 | /// 22 | bool CanExecute(object parameter); 23 | 24 | /// 25 | /// Executes the specified parameter. 26 | /// 27 | /// The parameter. 28 | void Execute(object parameter); 29 | } 30 | } -------------------------------------------------------------------------------- /ComicDesigner/VectorGraphics/GeometryData.xaml: -------------------------------------------------------------------------------- 1 |  4 | m 224.32087 128.13493 c -247.927978 0 -449.12498 121.87533 -449.125 272.0625 0 81.53177 59.36924 154.68267 153.250002 204.56247 -54.924282 55.883 -133.816862 95.5734 -224.062502 108.75 17.35052 1.2706 35.03385 1.9688 53.03125 1.9688 112.44665 -10e-5 213.749102 -25.6431 284.812502 -66.5938 55.68145 14.9965 117.261228 23.4063 182.093748 23.4063 247.92798 0 449.15627 -121.9067 449.15625 -272.09377 0 -150.18714 -201.22825 -272.06249 -449.15625 -272.0625 z 5 | 6 | -------------------------------------------------------------------------------- /ComicDesigner/ViewModelLocator.cs: -------------------------------------------------------------------------------- 1 | using StyleMVVM; 2 | using StyleMVVM.DependencyInjection; 3 | 4 | namespace ComicDesigner 5 | { 6 | public class ViewModelLocator 7 | { 8 | public ViewModelLocator() 9 | { 10 | ToolbarViewModel = Bootstrapper.Instance.Container.Locate(); 11 | } 12 | public ToolbarViewModel ToolbarViewModel { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /ComicDesigner/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Glass/Glass.Basics/Attributes/LocalizedCategoryAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace Glass.Basics.Wpf.Attributes 5 | { 6 | [AttributeUsage(AttributeTargets.All)] 7 | public sealed class LocalizedCategoryAttribute : CategoryAttribute 8 | { 9 | private Type resourceType; 10 | private readonly LocalizableString category = new LocalizableString("Category"); 11 | 12 | protected override string GetLocalizedString(string value) 13 | { 14 | return category.GetLocalizableValue(); 15 | } 16 | 17 | public string Name 18 | { 19 | get { return category.Value; } 20 | set 21 | { 22 | if (category.Value == value) 23 | return; 24 | category.Value = value; 25 | } 26 | } 27 | 28 | public Type ResourceType 29 | { 30 | get { return resourceType; } 31 | set 32 | { 33 | if (resourceType == value) 34 | return; 35 | 36 | resourceType = value; 37 | category.ResourceType = value; 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Attributes/LocalizedDescriptionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace Glass.Basics.Wpf.Attributes 5 | { 6 | [AttributeUsage(AttributeTargets.All)] 7 | public sealed class LocalizedDescriptionAttribute : DescriptionAttribute 8 | { 9 | private Type resourceType; 10 | private readonly LocalizableString description = new LocalizableString("Description"); 11 | 12 | public string Name 13 | { 14 | get { return description.Value; } 15 | set 16 | { 17 | if (description.Value == value) 18 | return; 19 | description.Value=value; 20 | } 21 | } 22 | 23 | public override string Description 24 | { 25 | get { return description.GetLocalizableValue(); } 26 | } 27 | 28 | public Type ResourceType { 29 | get { return resourceType; } 30 | set 31 | { 32 | if (resourceType == value) 33 | return; 34 | 35 | resourceType = value; 36 | description.ResourceType = value; 37 | } 38 | } 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Behaviors/DragDrop/ChildrenRetriever.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using Glass.Basics.Wpf.Extensions; 6 | 7 | namespace Glass.Basics.Wpf.Behaviors.DragDrop 8 | { 9 | public static class ChildrenRetriever 10 | { 11 | public static IEnumerable GetChildrenFromPanel(Panel panel) 12 | { 13 | return panel.Children.Cast(); 14 | } 15 | 16 | public static IEnumerable GetChildrenFromItemsControl(ItemsControl itemsControl) 17 | { 18 | var items = itemsControl.Items.Cast(); 19 | var itemContainers = items.Select(o => (UIElement)itemsControl.ItemContainerGenerator.ContainerFromItem(o)); 20 | return itemContainers; 21 | } 22 | 23 | public static UIElement GetChildAt(IEnumerable children, Point point) 24 | { 25 | var child = children.FirstOrDefault(element => element.GetRectRelativeToParent().Contains(point)); 26 | return child; 27 | } 28 | 29 | public static UIElement GetChildAt(UIElementCollection children, Point point) 30 | { 31 | return GetChildAt(children.Cast(), point); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Behaviors/DragDrop/DropModes.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Basics.Wpf.Behaviors.DragDrop 2 | { 3 | public enum DropModes 4 | { 5 | DropOntoSelf, 6 | DropOntoChildren, 7 | } 8 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Behaviors/RubberBand/ListBoxSelectionBehavior.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | 6 | namespace Glass.Basics.Wpf.Behaviors.RubberBand 7 | { 8 | public class ListBoxSelectionBehavior : RubberBandSelectionBehavior 9 | { 10 | protected override void SetSelectedState(DependencyObject container, bool value) 11 | { 12 | var item = (ListBoxItem) container; 13 | item.IsSelected = value; 14 | } 15 | 16 | protected override bool GetSelectedState(DependencyObject container) 17 | { 18 | var item = (ListBoxItem)container; 19 | return item.IsSelected; 20 | } 21 | 22 | protected override void SaveSelectionState() 23 | { 24 | var selection = new List(AssociatedObject.SelectedItems.Cast()); 25 | SelectedItemsBackup = new HashSet(selection); 26 | } 27 | 28 | protected override void Unselect(IEnumerable containers) 29 | { 30 | AssociatedObject.SelectedItems.Clear(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Behaviors/RubberBand/SelectionMode.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Basics.Wpf.Behaviors.RubberBand 2 | { 3 | public enum SelectionMode 4 | { 5 | Direct, 6 | Add, 7 | Invert, 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/BindingHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Reflection; 4 | using System.Windows; 5 | using System.Windows.Data; 6 | using System.Windows.Media; 7 | 8 | namespace Glass.Basics.Wpf 9 | { 10 | public static class BindingHelper 11 | { 12 | public static void UpdateSourcesOfAllBindings(this DependencyObject o) 13 | { 14 | //Immediate Properties 15 | var propertiesAll = new List(); 16 | var currentLevel = o.GetType(); 17 | while (currentLevel != typeof(object)) 18 | { 19 | propertiesAll.AddRange(currentLevel.GetFields()); 20 | currentLevel = currentLevel.BaseType; 21 | } 22 | var propertiesDp = propertiesAll.Where(x => x.FieldType == typeof(DependencyProperty)); 23 | foreach (var property in propertiesDp) 24 | { 25 | var dependencyProperty = property.GetValue(o) as DependencyProperty; 26 | var ex = BindingOperations.GetBindingExpression(o, dependencyProperty); 27 | if (ex != null) 28 | { 29 | ex.UpdateSource(); 30 | } 31 | } 32 | 33 | //Children 34 | var childrenCount = VisualTreeHelper.GetChildrenCount(o); 35 | for (var i = 0; i < childrenCount; i++) 36 | { 37 | var child = VisualTreeHelper.GetChild(o, i); 38 | child.UpdateSourcesOfAllBindings(); 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Borders.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Basics.Wpf 2 | { 3 | public struct Borders 4 | { 5 | private bool left; 6 | private bool top; 7 | private bool right; 8 | private bool bottom; 9 | 10 | public Borders(bool uniformValue) 11 | { 12 | left = uniformValue; 13 | top = uniformValue; 14 | right = uniformValue; 15 | bottom = uniformValue; 16 | } 17 | 18 | public bool Left 19 | { 20 | get { return left; } 21 | set { left = value; } 22 | } 23 | 24 | public bool Top 25 | { 26 | get { return top; } 27 | set { top = value; } 28 | } 29 | 30 | public bool Right 31 | { 32 | get { return right; } 33 | set { right = value; } 34 | } 35 | 36 | public bool Bottom 37 | { 38 | get { return bottom; } 39 | set { bottom = value; } 40 | } 41 | 42 | public static Borders All 43 | { 44 | get 45 | { 46 | return new Borders(true); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Glass/Glass.Basics/Controls/BindableGrid/BoundGridColumnDefinitionCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | using System.Windows.Controls; 3 | 4 | namespace Glass.Basics.Wpf.Controls.BindableGrid 5 | { 6 | public class BoundGridColumnDefinitionCollection : ObservableCollection 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Controls/BindableGrid/BoundGridRowDefinitionCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | using System.Windows.Controls; 3 | 4 | namespace Glass.Basics.Wpf.Controls.BindableGrid 5 | { 6 | public class BoundGridRowDefinitionCollection : ObservableCollection 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/Designer/Bool2VisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Glass.Basics.Wpf.Converters.Designer 7 | { 8 | [ValueConversion(typeof(bool), typeof(Visibility))] 9 | public class Bool2VisibilityConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | var converted = (bool)value; 14 | return converted ? Visibility.Visible : Visibility.Collapsed; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | var converted = (Visibility)value; 20 | return converted == Visibility.Visible; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/Designer/ColorToSolidColorBrushValueConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | 6 | namespace Glass.Basics.Wpf.Converters.Designer 7 | { 8 | public class ColorToSolidColorBrushValueConverter : IValueConverter 9 | { 10 | 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | if (null == value) 14 | { 15 | return null; 16 | } 17 | // For a more sophisticated converter, check also the targetType and react accordingly.. 18 | if (value is Color) 19 | { 20 | var color = (Color)value; 21 | return new SolidColorBrush(color); 22 | } 23 | // You can support here more source types if you wish 24 | // For the example I throw an exception 25 | 26 | var type = value.GetType(); 27 | throw new InvalidOperationException("Unsupported type [" + type.Name + "]"); 28 | } 29 | 30 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 31 | { 32 | // If necessary, here you can convert back. Check if which brush it is (if its one), 33 | // get its Color-value and return it. 34 | 35 | throw new NotImplementedException(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/Designer/NegConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Glass.Basics.Wpf.Converters.Designer 6 | { 7 | [ValueConversion(typeof(bool), typeof(bool))] 8 | public class NegConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | return !((bool) value); 13 | } 14 | 15 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 16 | { 17 | return !((bool)value); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/Designer/PercentageConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Glass.Basics.Wpf.Converters.Designer 6 | { 7 | public class PercentageConverter : IValueConverter 8 | { 9 | private const double Epsilon = 0.1; 10 | 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | return (double) value; 14 | } 15 | 16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | var s = value as string; 19 | if (s != null) 20 | { 21 | var @string = s; 22 | var percentFormatted = false; 23 | if (@string.Contains("%")) 24 | { 25 | @string = @string.Replace("%", string.Empty); 26 | percentFormatted = true; 27 | } 28 | 29 | double convertedValue; 30 | 31 | var success = double.TryParse(@string, out convertedValue); 32 | 33 | if (success) 34 | { 35 | if (Math.Abs(convertedValue - 0) < Epsilon) 36 | { 37 | return 0; 38 | } 39 | 40 | return percentFormatted ? convertedValue / 100 : convertedValue; 41 | } 42 | return 0; 43 | } 44 | 45 | return Binding.DoNothing; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/Designer/Visibility2BoolConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Glass.Basics.Wpf.Converters.Designer 7 | { 8 | [ValueConversion(typeof(Visibility), typeof(bool))] 9 | public class Visibility2BoolConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | var converted = (Visibility)value; 14 | return converted == Visibility.Visible; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | var converted = (bool)value; 20 | return converted ? Visibility.Visible : Visibility.Collapsed; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/ImageSourceToImageConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Controls; 4 | using System.Windows.Data; 5 | using System.Windows.Media; 6 | 7 | namespace Glass.Basics.Wpf.Converters 8 | { 9 | [ValueConversion(typeof(ImageSource), typeof(Image))] 10 | public class ImageSourceToImageConverter : IValueConverter 11 | { 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | return new Image {Source = (ImageSource) value}; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/InvertBoolConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Glass.Basics.Wpf.Converters 6 | { 7 | /// 8 | /// WPF/Silverlight ValueConverter : Return inverted boolean (=Value) 9 | /// 10 | #if !SILVERLIGHT 11 | [ValueConversion(typeof(bool), typeof(bool))] 12 | #endif 13 | public class InvertBoolConverter : IValueConverter 14 | { 15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 16 | { 17 | return !(bool)value; 18 | } 19 | 20 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 21 | { 22 | throw new NotSupportedException(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/IsDifferentConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Glass.Basics.Wpf.Converters 6 | { 7 | /// 8 | /// WPF/Silverlight ValueConverter : return true if Value differs from Parameter 9 | /// 10 | public class IsDifferentConverter : IValueConverter 11 | { 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | return !((bool)new IsEqualConverter().Convert(value, targetType, parameter, culture)); 15 | } 16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | throw new NotSupportedException(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/IsEqualConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Glass.Basics.Wpf.Converters 6 | { 7 | /// 8 | /// WPF/Silverlight ValueConverter : return true if Value equals Parameter 9 | /// 10 | public class IsEqualConverter : IValueConverter 11 | { 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | 15 | if (targetType != typeof(bool) && targetType != typeof(bool?)) 16 | { 17 | throw new ArgumentException("Target must be a boolean"); 18 | } 19 | 20 | if (value == null) 21 | { 22 | return (parameter == null); 23 | } 24 | 25 | if (value is String) 26 | { 27 | return value.ToString().Equals(parameter.ToString()); 28 | } 29 | 30 | return value.Equals(parameter); 31 | } 32 | 33 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 34 | { 35 | throw new NotSupportedException(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/IsGreaterThanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Glass.Basics.Wpf.Converters 6 | { 7 | /// 8 | /// WPF/Silverlight ValueConverter : return true if Value is greater than Parameter 9 | /// 10 | public class IsGreaterThanConverter : IValueConverter 11 | { 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | if (targetType != typeof(bool)) 15 | { 16 | throw new ArgumentException("Target must be a boolean"); 17 | } 18 | 19 | if ((value == null) || (parameter == null)) 20 | { 21 | return false; 22 | } 23 | 24 | double convertedValue; 25 | if (!double.TryParse(value.ToString(), out convertedValue)) 26 | { 27 | throw new InvalidOperationException("The Value can not be converted to a Double"); 28 | } 29 | 30 | double convertedParameter; 31 | if (!double.TryParse(parameter.ToString(), out convertedParameter)) 32 | { 33 | throw new InvalidOperationException("The Parameter can not be converted to a Double"); 34 | } 35 | 36 | return convertedValue > convertedParameter; 37 | } 38 | 39 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 40 | { 41 | return new NotSupportedException(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/IsLessThanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Glass.Basics.Wpf.Converters 6 | { 7 | /// 8 | /// WPF/Silverlight ValueConverter : return true if Value is less than Parameter 9 | /// 10 | public class IsLessThanConverter : IValueConverter 11 | { 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | if (targetType != typeof(bool)) 15 | { 16 | throw new ArgumentException("Target must be a boolean"); 17 | } 18 | 19 | if ((value == null) || (parameter == null)) 20 | { 21 | return false; 22 | } 23 | 24 | double convertedValue; 25 | if (!double.TryParse(value.ToString(), out convertedValue)) 26 | { 27 | throw new InvalidOperationException("The Value can not be converted to a Double"); 28 | } 29 | 30 | double convertedParameter; 31 | if (!double.TryParse(parameter.ToString(), out convertedParameter)) 32 | { 33 | throw new InvalidOperationException("The Parameter can not be converted to a Double"); 34 | } 35 | 36 | return convertedValue < convertedParameter; 37 | } 38 | 39 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 40 | { 41 | return new NotSupportedException(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/IsMatchConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Text.RegularExpressions; 4 | using System.Windows.Data; 5 | 6 | namespace Glass.Basics.Wpf.Converters 7 | { 8 | /// 9 | /// WPF/Silverlight ValueConverter : does Value match the regular expression (=Parameter) ? 10 | /// 11 | #if !SILVERLIGHT 12 | [ValueConversion(typeof(string), typeof(bool), ParameterType = typeof(string))] 13 | #endif 14 | // ReSharper disable UnusedMember.Global 15 | public class IsMatchConverter : IValueConverter 16 | // ReSharper restore UnusedMember.Global 17 | { 18 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | if ((value == null) || (parameter == null)) 21 | { 22 | return false; 23 | } 24 | 25 | var regex = new Regex((string)parameter); 26 | return regex.IsMatch((string)value); 27 | } 28 | 29 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 30 | { 31 | throw new NotSupportedException(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/ObjectTypeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Glass.Basics.Wpf.Converters 6 | { 7 | public class ObjectTypeConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (value == null) 12 | return Binding.DoNothing; 13 | 14 | return value.GetType(); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Converters/VisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Glass.Basics.Wpf.Converters 7 | { 8 | 9 | /// 10 | /// WPF/Silverlight ValueConverter : Convert boolean to XAML Visibility 11 | /// 12 | #if !SILVERLIGHT 13 | [ValueConversion(typeof(bool), typeof(Visibility))] 14 | #endif 15 | public class VisibilityConverter : IValueConverter 16 | { 17 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | return (value != null && (bool)value) ? Visibility.Visible : Visibility.Collapsed; 20 | } 21 | 22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 23 | { 24 | var visibility = (Visibility)value; 25 | return (visibility == Visibility.Visible); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Core/EventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Basics.Wpf.Core 4 | { 5 | public class EventArgs : EventArgs 6 | { 7 | // Property variable 8 | private readonly T data; 9 | 10 | // Constructor 11 | public EventArgs(T data) 12 | { 13 | this.data = data; 14 | } 15 | 16 | // Property for EventArgs argument 17 | public T Data 18 | { 19 | get { return data; } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Extensions/BitmapSourceExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Windows.Media; 3 | using System.Windows.Media.Imaging; 4 | 5 | namespace Glass.Basics.Wpf.Extensions 6 | { 7 | public static class BitmapSourceExtensions 8 | { 9 | public static byte[] ToArray(this BitmapSource source) 10 | { 11 | byte[] data; 12 | using (var ms = new MemoryStream()) 13 | { 14 | var encoder = new PngBitmapEncoder(); 15 | encoder.Frames.Add(BitmapFrame.Create(source)); 16 | encoder.Save(ms); 17 | data = ms.ToArray(); 18 | } 19 | 20 | return data; 21 | } 22 | 23 | public static ImageSource FromArray(byte[] bytes) 24 | { 25 | using (var memoryStream = new MemoryStream(bytes)) 26 | { 27 | var decoder = new PngBitmapDecoder(memoryStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad); 28 | BitmapSource bitmapFrame = decoder.Frames[0]; 29 | return bitmapFrame; 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Extensions/PanelExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Media; 5 | 6 | namespace Glass.Basics.Wpf.Extensions 7 | { 8 | public static class PanelExtensions 9 | { 10 | public static List GetChildrenWithBounds(this Panel panel, Rect rect) 11 | { 12 | var list = new List(); 13 | 14 | foreach (Visual child in panel.Children) 15 | { 16 | var itemBounds = VisualTreeHelper.GetDescendantBounds(child); 17 | 18 | if (!itemBounds.IsEmpty) 19 | { 20 | var containerOffset = VisualTreeHelper.GetOffset(child); 21 | 22 | itemBounds.Offset(containerOffset); 23 | 24 | if (rect.Contains(itemBounds)) 25 | list.Add(child); 26 | } 27 | } 28 | return list; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Extensions/VisualExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/Glass/Glass.Basics/Extensions/VisualExtensions.cs -------------------------------------------------------------------------------- /Glass/Glass.Basics/ISelectable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Glass.Basics.Wpf.Core; 3 | 4 | namespace Glass.Basics.Wpf 5 | { 6 | public interface ISelectable 7 | { 8 | bool IsSelected { get; set; } 9 | event EventHandler> IsSelectedChanged; 10 | } 11 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Localization/Strings.es-ES.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/Glass/Glass.Basics/Localization/Strings.es-ES.Designer.cs -------------------------------------------------------------------------------- /Glass/Glass.Basics/Presentation/ItemsControlExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Glass.Basics.Wpf.Presentation 5 | { 6 | public static class ItemsControlExtensions 7 | { 8 | public static DependencyObject GetContainer(this ItemsControl itemsControl, object item) 9 | { 10 | return itemsControl.IsItemItsOwnContainer(item) 11 | ? (DependencyObject) item 12 | : itemsControl.ItemContainerGenerator.ContainerFromItem(item); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Presentation/Rubberband/RectEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Glass.Basics.Wpf.Presentation.Rubberband 4 | { 5 | public delegate void RectEventHandler(object sender, Rect rect); 6 | } -------------------------------------------------------------------------------- /Glass/Glass.Basics/Styles/CloseButton.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Windows; 3 | using System.Windows.Controls.Primitives; 4 | 5 | namespace Glass.Basics.Wpf.Styles 6 | { 7 | public class CloseButton : ToggleButton 8 | { 9 | static CloseButton() 10 | { 11 | DefaultStyleKeyProperty.OverrideMetadata(typeof(CloseButton), new FrameworkPropertyMetadata(typeof(CloseButton))); 12 | } 13 | 14 | protected override void OnClick() 15 | { 16 | var window = Window.GetWindow(this); 17 | Debug.Assert(window != null, "window != null"); 18 | window.Close(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Glass/Glass.Basics/Styles/MaximizeButton.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Glass.Basics.Wpf.Styles 5 | { 6 | 7 | public class MaximizeButton : CheckBox 8 | { 9 | static MaximizeButton() 10 | { 11 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MaximizeButton), new FrameworkPropertyMetadata(typeof(MaximizeButton))); 12 | } 13 | 14 | protected override void OnClick() 15 | { 16 | //base.OnClick(); 17 | var window = Window.GetWindow(this); 18 | 19 | //window.WindowState = WindowState.Minimized; 20 | if (IsChecked.HasValue) { 21 | 22 | if (IsChecked.Value) 23 | SystemCommands.RestoreWindow(window); 24 | else 25 | SystemCommands.MaximizeWindow(window); 26 | 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Glass/Glass.Basics/Styles/SystemButton.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Input; 5 | 6 | namespace Glass.Basics.Wpf.Styles 7 | { 8 | 9 | public class SystemButton : Button 10 | { 11 | 12 | static SystemButton() 13 | { 14 | DefaultStyleKeyProperty.OverrideMetadata(typeof(SystemButton), new FrameworkPropertyMetadata(typeof(SystemButton))); 15 | } 16 | 17 | protected override void OnMouseDown(MouseButtonEventArgs e) 18 | { 19 | //base.OnMouseDown(e); 20 | var window = Window.GetWindow(this); 21 | if (e.ClickCount == 1) 22 | { 23 | if (e.ChangedButton == MouseButton.Left) 24 | { 25 | var positionRelativeToWindow = new Point(VisualOffset.X, VisualOffset.Y); 26 | positionRelativeToWindow.Offset(0, ActualHeight); 27 | var screenPosition = PointToScreen(positionRelativeToWindow); 28 | SystemCommands.ShowSystemMenu(window, screenPosition); 29 | } 30 | 31 | } 32 | if (e.ClickCount == 2 && e.ChangedButton == MouseButton.Left) 33 | { 34 | Debug.Assert(window != null, "window != null"); 35 | window.Close(); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Glass/Glass.Basics/Styles/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Glass/Glass.Basics/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Glass/Glass.Basics/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcActionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 7 | /// is an MVC action. If applied to a method, the MVC action name is calculated 8 | /// implicitly from the context. Use this attribute for custom wrappers similar to 9 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String) 10 | /// 11 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 12 | public sealed class AspMvcActionAttribute : Attribute 13 | { 14 | public AspMvcActionAttribute() { } 15 | public AspMvcActionAttribute([NotNull] string anonymousProperty) 16 | { 17 | AnonymousProperty = anonymousProperty; 18 | } 19 | 20 | [NotNull] 21 | public string AnonymousProperty { get; private set; } 22 | } 23 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcActionSelectorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. When applied to a parameter of an attribute, 7 | /// indicates that this parameter is an MVC action name 8 | /// 9 | /// 10 | /// [ActionName("Foo")] 11 | /// public ActionResult Login(string returnUrl) { 12 | /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK 13 | /// return RedirectToAction("Bar"); // Error: Cannot resolve action 14 | /// } 15 | /// 16 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] 17 | public sealed class AspMvcActionSelectorAttribute : Attribute { } 18 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcAreaAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String) 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AspMvcAreaAttribute : PathReferenceAttribute 12 | { 13 | public AspMvcAreaAttribute() { } 14 | public AspMvcAreaAttribute([NotNull] string anonymousProperty) 15 | { 16 | AnonymousProperty = anonymousProperty; 17 | } 18 | 19 | [NotNull] 20 | public string AnonymousProperty { get; private set; } 21 | } 22 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcAreaMasterLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcAreaMasterLocationFormatAttribute(string format) { } 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcAreaPartialViewLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcAreaPartialViewLocationFormatAttribute(string format) { } 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcAreaViewLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcAreaViewLocationFormatAttribute(string format) { } 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcControllerAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that 7 | /// the parameter is an MVC controller. If applied to a method, 8 | /// the MVC controller name is calculated implicitly from the context. 9 | /// Use this attribute for custom wrappers similar to 10 | /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String) 11 | /// 12 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 13 | public sealed class AspMvcControllerAttribute : Attribute 14 | { 15 | public AspMvcControllerAttribute() { } 16 | public AspMvcControllerAttribute([NotNull] string anonymousProperty) 17 | { 18 | AnonymousProperty = anonymousProperty; 19 | } 20 | 21 | [NotNull] 22 | public string AnonymousProperty { get; private set; } 23 | } 24 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcDisplayTemplateAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String) 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AspMvcDisplayTemplateAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcEditorTemplateAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String) 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AspMvcEditorTemplateAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcMasterAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.Web.Mvc.Controller.View(String, String) 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AspMvcMasterAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcMasterLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public sealed class AspMvcMasterLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcMasterLocationFormatAttribute(string format) { } 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcModelTypeAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.Web.Mvc.Controller.View(String, ObjectDto) 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AspMvcModelTypeAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcPartialViewAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that 7 | /// the parameter is an MVC partial view. If applied to a method, 8 | /// the MVC partial view name is calculated implicitly from the context. 9 | /// Use this attribute for custom wrappers similar to 10 | /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String) 11 | /// 12 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 13 | public sealed class AspMvcPartialViewAttribute : PathReferenceAttribute { } 14 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcPartialViewLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcPartialViewLocationFormatAttribute(string format) { } 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcSupressViewErrorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Allows disabling all inspections 7 | /// for MVC views within a class or a method. 8 | /// 9 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] 10 | public sealed class AspMvcSupressViewErrorAttribute : Attribute { } 11 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcTemplateAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String) 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public sealed class AspMvcTemplateAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcViewAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter 7 | /// is an MVC view. If applied to a method, the MVC view name is calculated implicitly 8 | /// from the context. Use this attribute for custom wrappers similar to 9 | /// System.Web.Mvc.Controller.View(ObjectDto) 10 | /// 11 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] 12 | public sealed class AspMvcViewAttribute : PathReferenceAttribute { } 13 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/AspMvcViewLocationFormatAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] 6 | public sealed class AspMvcViewLocationFormatAttribute : Attribute 7 | { 8 | public AspMvcViewLocationFormatAttribute(string format) { } 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/BaseTypeRequiredAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// When applied to a target attribute, specifies a requirement for any type marked 7 | /// with the target attribute to implement or inherit specific type or types. 8 | /// 9 | /// 10 | /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement 11 | /// public class ComponentAttribute : Attribute { } 12 | /// [Component] // ComponentAttribute requires implementing IComponent interface 13 | /// public class MyComponent : IComponent { } 14 | /// 15 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] 16 | [BaseTypeRequired(typeof(Attribute))] 17 | public sealed class BaseTypeRequiredAttribute : Attribute 18 | { 19 | public BaseTypeRequiredAttribute([NotNull] Type baseType) 20 | { 21 | BaseType = baseType; 22 | } 23 | 24 | [NotNull] 25 | public Type BaseType { get; private set; } 26 | } 27 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/CanBeNullAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #pragma warning disable 1591 4 | // ReSharper disable UnusedMember.Global 5 | // ReSharper disable UnusedParameter.Local 6 | // ReSharper disable MemberCanBePrivate.Global 7 | // ReSharper disable UnusedAutoPropertyAccessor.Global 8 | // ReSharper disable IntroduceOptionalParameters.Global 9 | // ReSharper disable MemberCanBeProtected.Global 10 | // ReSharper disable InconsistentNaming 11 | namespace Glass.Design.Pcl.Annotations 12 | { 13 | /// 14 | /// Indicates that the value of the marked element could be null sometimes, 15 | /// so the check for null is necessary before its usage 16 | /// 17 | /// 18 | /// [CanBeNull] public object Test() { return null; } 19 | /// public void UseTest() { 20 | /// var p = Test(); 21 | /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' 22 | /// } 23 | /// 24 | [AttributeUsage( 25 | AttributeTargets.Method | AttributeTargets.Parameter | 26 | AttributeTargets.Property | AttributeTargets.Delegate | 27 | AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 28 | public sealed class CanBeNullAttribute : Attribute { } 29 | 30 | // ASP.NET MVC attributes 31 | 32 | // Razor attributes 33 | } 34 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/CannotApplyEqualityOperatorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Indicates that the value of the marked type (or its derivatives) 7 | /// cannot be compared using '==' or '!=' operators and Equals() 8 | /// should be used instead. However, using '==' or '!=' for comparison 9 | /// with null is always permitted. 10 | /// 11 | /// 12 | /// [CannotApplyEqualityOperator] 13 | /// class NoEquality { } 14 | /// class UsesNoEquality { 15 | /// public void Test() { 16 | /// var ca1 = new NoEquality(); 17 | /// var ca2 = new NoEquality(); 18 | /// if (ca1 != null) { // OK 19 | /// bool condition = ca1 == ca2; // Warning 20 | /// } 21 | /// } 22 | /// } 23 | /// 24 | [AttributeUsage( 25 | AttributeTargets.Interface | AttributeTargets.Class | 26 | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)] 27 | public sealed class CannotApplyEqualityOperatorAttribute : Attribute { } 28 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/HtmlAttributeValueAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | [AttributeUsage( 6 | AttributeTargets.Parameter | AttributeTargets.Field | 7 | AttributeTargets.Property, Inherited = true)] 8 | public sealed class HtmlAttributeValueAttribute : Attribute 9 | { 10 | public HtmlAttributeValueAttribute([NotNull] string name) 11 | { 12 | Name = name; 13 | } 14 | 15 | [NotNull] 16 | public string Name { get; private set; } 17 | } 18 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/HtmlElementAttributesAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | [AttributeUsage( 6 | AttributeTargets.Parameter | AttributeTargets.Property | 7 | AttributeTargets.Field, Inherited = true)] 8 | public sealed class HtmlElementAttributesAttribute : Attribute 9 | { 10 | public HtmlElementAttributesAttribute() { } 11 | public HtmlElementAttributesAttribute([NotNull] string name) 12 | { 13 | Name = name; 14 | } 15 | 16 | [NotNull] 17 | public string Name { get; private set; } 18 | } 19 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/ImplicitUseKindFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | [Flags] 6 | public enum ImplicitUseKindFlags 7 | { 8 | Default = Access | Assign | InstantiatedWithFixedConstructorSignature, 9 | /// Only entity marked with attribute considered used 10 | Access = 1, 11 | /// Indicates implicit assignment to a member 12 | Assign = 2, 13 | /// 14 | /// Indicates implicit instantiation of a type with fixed constructor signature. 15 | /// That means any unused constructor parameters won't be reported as such. 16 | /// 17 | InstantiatedWithFixedConstructorSignature = 4, 18 | /// Indicates implicit instantiation of a type 19 | InstantiatedNoFixedConstructorSignature = 8, 20 | } 21 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/ImplicitUseTargetFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Specify what is considered used implicitly 7 | /// when marked with 8 | /// or 9 | /// 10 | [Flags] 11 | public enum ImplicitUseTargetFlags 12 | { 13 | Default = Itself, 14 | Itself = 1, 15 | /// Members of entity marked with attribute are considered used 16 | Members = 2, 17 | /// Entity marked with attribute and all its members considered used 18 | WithMembers = Itself | Members 19 | } 20 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/InstantHandleAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Tells code analysis engine if the parameter is completely handled 7 | /// when the invoked method is on stack. If the parameter is a delegate, 8 | /// indicates that delegate is executed while the method is executed. 9 | /// If the parameter is an enumerable, indicates that it is enumerated 10 | /// while the method is executed 11 | /// 12 | [AttributeUsage(AttributeTargets.Parameter, Inherited = true)] 13 | public sealed class InstantHandleAttribute : Attribute { } 14 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/InvokerParameterNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Indicates that the function argument should be string literal and match one 7 | /// of the parameters of the caller function. For example, ReSharper annotates 8 | /// the parameter of 9 | /// 10 | /// 11 | /// public void Foo(string param) { 12 | /// if (param == null) 13 | /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol 14 | /// } 15 | /// 16 | [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] 17 | public sealed class InvokerParameterNameAttribute : Attribute { } 18 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/LocalizationRequiredAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Indicates that marked element should be localized or not 7 | /// 8 | /// 9 | /// [LocalizationRequiredAttribute(true)] 10 | /// public class Foo { 11 | /// private string str = "my string"; // Warning: Localizable string 12 | /// } 13 | /// 14 | [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)] 15 | public sealed class LocalizationRequiredAttribute : Attribute 16 | { 17 | public LocalizationRequiredAttribute() : this(true) { } 18 | public LocalizationRequiredAttribute(bool required) 19 | { 20 | Required = required; 21 | } 22 | 23 | public bool Required { get; private set; } 24 | } 25 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/MeansImplicitUseAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Should be used on attributes and causes ReSharper 7 | /// to not mark symbols marked with such attributes as unused 8 | /// (as well as by other usage inspections) 9 | /// 10 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] 11 | public sealed class MeansImplicitUseAttribute : Attribute 12 | { 13 | public MeansImplicitUseAttribute() 14 | : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } 15 | 16 | public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) 17 | : this(useKindFlags, ImplicitUseTargetFlags.Default) { } 18 | 19 | public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) 20 | : this(ImplicitUseKindFlags.Default, targetFlags) { } 21 | 22 | public MeansImplicitUseAttribute( 23 | ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) 24 | { 25 | UseKindFlags = useKindFlags; 26 | TargetFlags = targetFlags; 27 | } 28 | 29 | [UsedImplicitly] 30 | public ImplicitUseKindFlags UseKindFlags { get; private set; } 31 | [UsedImplicitly] 32 | public ImplicitUseTargetFlags TargetFlags { get; private set; } 33 | } 34 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/NotNullAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Indicates that the value of the marked element could never be null 7 | /// 8 | /// 9 | /// [NotNull] public object Foo() { 10 | /// return null; // Warning: Possible 'null' assignment 11 | /// } 12 | /// 13 | [AttributeUsage( 14 | AttributeTargets.Method | AttributeTargets.Parameter | 15 | AttributeTargets.Property | AttributeTargets.Delegate | 16 | AttributeTargets.Field, AllowMultiple = false, Inherited = true)] 17 | public sealed class NotNullAttribute : Attribute { } 18 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/PathReferenceAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Indicates that a parameter is a path to a file or a folder 7 | /// within a web project. Path can be relative or absolute, 8 | /// starting from web root (~) 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter)] 11 | public class PathReferenceAttribute : Attribute 12 | { 13 | public PathReferenceAttribute() { } 14 | public PathReferenceAttribute([PathReference] string basePath) 15 | { 16 | BasePath = basePath; 17 | } 18 | 19 | [NotNull] 20 | public string BasePath { get; private set; } 21 | } 22 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/PublicAPIAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// This attribute is intended to mark publicly available API 7 | /// which should not be removed and so is treated as used 8 | /// 9 | [MeansImplicitUse] 10 | public sealed class PublicAPIAttribute : Attribute 11 | { 12 | public PublicAPIAttribute() { } 13 | public PublicAPIAttribute([NotNull] string comment) 14 | { 15 | Comment = comment; 16 | } 17 | 18 | [NotNull] 19 | public string Comment { get; private set; } 20 | } 21 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/PureAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Indicates that a method does not make any observable state changes. 7 | /// The same as System.Diagnostics.Contracts.PureAttribute 8 | /// 9 | /// 10 | /// [Pure] private int Multiply(int x, int y) { return x * y; } 11 | /// public void Foo() { 12 | /// const int a = 2, b = 2; 13 | /// Multiply(a, b); // Waring: Return value of pure method is not used 14 | /// } 15 | /// 16 | [AttributeUsage(AttributeTargets.Method, Inherited = true)] 17 | public sealed class PureAttribute : Attribute { } 18 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/RazorSectionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Razor attribute. Indicates that a parameter or a method is a Razor section. 7 | /// Use this attribute for custom wrappers similar to 8 | /// System.Web.WebPages.WebPageBase.RenderSection(String) 9 | /// 10 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, Inherited = true)] 11 | public sealed class RazorSectionAttribute : Attribute { } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/StringFormatMethodAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Indicates that the marked method builds string by format pattern and (optional) arguments. 7 | /// Parameter, which contains format string, should be given in constructor. The format string 8 | /// should be in -like form 9 | /// 10 | /// 11 | /// [StringFormatMethod("message")] 12 | /// public void ShowError(string message, params object[] args) { /* do something */ } 13 | /// public void Foo() { 14 | /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string 15 | /// } 16 | /// 17 | [AttributeUsage( 18 | AttributeTargets.Constructor | AttributeTargets.Method, 19 | AllowMultiple = false, Inherited = true)] 20 | public sealed class StringFormatMethodAttribute : Attribute 21 | { 22 | /// 23 | /// Specifies which parameter of an annotated method should be treated as format-string 24 | /// 25 | public StringFormatMethodAttribute(string formatParameterName) 26 | { 27 | FormatParameterName = formatParameterName; 28 | } 29 | 30 | public string FormatParameterName { get; private set; } 31 | } 32 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Annotations/UsedImplicitlyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Annotations 4 | { 5 | /// 6 | /// Indicates that the marked symbol is used implicitly 7 | /// (e.g. via reflection, in external library), so this symbol 8 | /// will not be marked as unused (as well as by other usage inspections) 9 | /// 10 | [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)] 11 | public sealed class UsedImplicitlyAttribute : Attribute 12 | { 13 | public UsedImplicitlyAttribute() 14 | : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } 15 | 16 | public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) 17 | : this(useKindFlags, ImplicitUseTargetFlags.Default) { } 18 | 19 | public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) 20 | : this(ImplicitUseKindFlags.Default, targetFlags) { } 21 | 22 | public UsedImplicitlyAttribute( 23 | ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) 24 | { 25 | UseKindFlags = useKindFlags; 26 | TargetFlags = targetFlags; 27 | } 28 | 29 | public ImplicitUseKindFlags UseKindFlags { get; private set; } 30 | public ImplicitUseTargetFlags TargetFlags { get; private set; } 31 | } 32 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Canvas/CanvasItemCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using PostSharp.Patterns.Collections; 3 | 4 | namespace Glass.Design.Pcl.Canvas 5 | { 6 | public class CanvasItemCollection : AdvisableCollection 7 | { 8 | public CanvasItemCollection() 9 | { 10 | } 11 | 12 | public CanvasItemCollection(IEnumerable collection) : base(collection) 13 | { 14 | } 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Canvas/CanvasItemRelocator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Glass.Design.Pcl.Core; 4 | 5 | namespace Glass.Design.Pcl.Canvas 6 | { 7 | public static class CanvasItemRelocator 8 | { 9 | public static void Reparent(this IEnumerable items, ICanvasItem destination) 10 | { 11 | 12 | var rect = Extensions.GetBoundsFromChildren(items); 13 | 14 | var toRemove = items.ToList(); 15 | 16 | destination.SetBounds(rect); 17 | 18 | 19 | foreach (var canvasItem in toRemove) 20 | { 21 | var parent = canvasItem.Parent; 22 | parent.Children.Remove(canvasItem); 23 | } 24 | 25 | foreach (var canvasItem in items) 26 | { 27 | destination.Children.Add(canvasItem); 28 | canvasItem.Offset(rect.Location.Negative()); 29 | } 30 | 31 | } 32 | 33 | public static void RemoveAndPromoteChildren(this ICanvasItem canvasItem) 34 | { 35 | var newParent = canvasItem.Parent; 36 | 37 | var children = canvasItem.Children.ToList(); 38 | IPoint location = canvasItem.GetPosition(); 39 | 40 | foreach (var child in children) 41 | { 42 | child.Offset(location); 43 | canvasItem.Children.Remove(child); 44 | newParent.Children.Add(child); 45 | } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Canvas/CanvasItemResizeInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Canvas 2 | { 3 | internal struct CanvasItemResizeInfo 4 | { 5 | private readonly double positionDelta; 6 | private readonly double sizeDelta; 7 | 8 | public CanvasItemResizeInfo(double positionDelta, double sizeDelta) 9 | { 10 | this.positionDelta = positionDelta; 11 | this.sizeDelta = sizeDelta; 12 | } 13 | 14 | public double PositionDelta 15 | { 16 | get { return this.positionDelta; } 17 | } 18 | 19 | public double SizeDelta 20 | { 21 | get { return this.sizeDelta; } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Canvas/CanvasItemSelection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace Glass.Design.Pcl.Canvas 5 | { 6 | public class CanvasItemSelection : ChildrenExpandableCanvasItem 7 | { 8 | private readonly string name; 9 | 10 | public CanvasItemSelection(IEnumerable children) : base(children) 11 | { 12 | this.ChildrenPositioning = ChildrenPositioning.Absolute; 13 | 14 | if ( !children.Any() ) 15 | { 16 | this.name = "empty selection"; 17 | } 18 | else if ( children.Count() == 1 ) 19 | { 20 | this.name = string.Join( ", ", children.Select( item => item.GetName() ) ); 21 | } 22 | 23 | } 24 | 25 | 26 | public override string GetName() 27 | { 28 | return this.name; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Canvas/CanvasModelItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using PostSharp.Patterns.Model; 4 | using PostSharp.Patterns.Recording; 5 | 6 | namespace Glass.Design.Pcl.Canvas 7 | { 8 | [Recordable(ProvideMethodContext = true)] 9 | public class CanvasModelItem : CanvasItem 10 | { 11 | [Child] 12 | private readonly CanvasItemCollection items = new CanvasItemCollection(); 13 | 14 | [Parent] 15 | private ICanvasItemContainer parent; 16 | 17 | 18 | public CanvasModelItem() 19 | { 20 | // We have to set these members here, and not in the parent class, otherwise 21 | // the parent class constructor would call the advices on these properties 22 | // before the aspects have been initialized. 23 | this.Width = 1; 24 | this.Height = 1; 25 | } 26 | 27 | public override CanvasItemCollection Children 28 | { 29 | get { return this.items; } 30 | set { throw new NotSupportedException(); } 31 | } 32 | 33 | public override double Left { get; set; } 34 | public override double Top { get; set; } 35 | public override double Width { get; set; } 36 | public override double Height { get; set; } 37 | 38 | public override ICanvasItemContainer Parent 39 | { 40 | get { return this.parent; } 41 | } 42 | 43 | public override string GetName() 44 | { 45 | return this.GetType().Name; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Canvas/CanvasVisualItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.Canvas 4 | { 5 | public abstract class CanvasVisualItem : CanvasItem 6 | { 7 | private readonly CanvasItemCollection children; 8 | 9 | protected CanvasVisualItem() 10 | { 11 | this.children = new CanvasItemCollection(); 12 | this.Width = 1; 13 | this.Height = 1; 14 | } 15 | 16 | public override CanvasItemCollection Children 17 | { 18 | get { return this.children; } 19 | set { throw new System.NotImplementedException(); } 20 | } 21 | 22 | public override double Left { get; set; } 23 | public override double Top { get; set; } 24 | public override double Width { get; set; } 25 | public override double Height { get; set; } 26 | 27 | public override ICanvasItemContainer Parent 28 | { 29 | get { throw new NotSupportedException(); } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Canvas/ChildrenPositioning.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Canvas 2 | { 3 | internal enum ChildrenPositioning 4 | { 5 | Relative, 6 | Absolute 7 | } 8 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Canvas/ICanvasItem.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.DesignSurface; 2 | 3 | namespace Glass.Design.Pcl.Canvas 4 | { 5 | public interface ICanvasItem : ICanvasItemContainer, IPositionable, ISizable, INamed 6 | { 7 | double Right { get; } 8 | double Bottom { get; } 9 | 10 | ICanvasItemContainer Parent { get; } 11 | } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Canvas/ICanvasItemContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Canvas 2 | { 3 | public interface ICanvasItemContainer 4 | { 5 | CanvasItemCollection Children { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/CoordinatePart.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public enum CoordinatePart 4 | { 5 | None, 6 | Left, 7 | Right, 8 | Top, 9 | Bottom, 10 | Width, 11 | Height 12 | } 13 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/HorizontalAlignment.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public enum HorizontalAlignment 4 | { 5 | Left, 6 | Center, 7 | Right, 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/ICoordinate.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public interface ICoordinate 4 | { 5 | double GetCoordinate(CoordinatePart part); 6 | void SetCoordinate(CoordinatePart part, double value); 7 | } 8 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/ICoreTypesFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public interface ICoreTypesFactory 4 | { 5 | IPoint CreatePoint(double x, double y); 6 | 7 | // ReSharper disable once TooManyArguments 8 | IRect CreateRect(double left, double top, double width, double height); 9 | ISize CreateSize(double width, double height); 10 | IVector CreateVector(double x, double y); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/IInputProvider.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.PlatformAbstraction; 2 | 3 | namespace Glass.Design.Pcl.Core 4 | { 5 | public interface IInputProvider 6 | { 7 | Point GetMousePositionRelativeTo(IUserInputReceiver inputReceiver); 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/IPoint.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public interface IPoint 4 | { 5 | 6 | double X { get; set; } 7 | 8 | double Y { get; set; } 9 | 10 | void Offset(double offsetX, double offsetY); 11 | } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/IRect.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public interface IRect : ICoordinate 4 | { 5 | double Left { get; } 6 | double Top { get; } 7 | double Width { get; set; } 8 | double Height { get; set; } 9 | ISize Size { get; } 10 | IPoint Location { get; } 11 | double X { get; set; } 12 | double Y { get; set; } 13 | double Right { get; } 14 | double Bottom { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/ISize.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public interface ISize 4 | { 5 | double Width { get; set; } 6 | double Height { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/IUIElementFactory.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Canvas; 2 | using Glass.Design.Pcl.DesignSurface; 3 | using Glass.Design.Pcl.DesignSurface.VisualAids.Snapping; 4 | using Glass.Design.Pcl.PlatformAbstraction; 5 | 6 | namespace Glass.Design.Pcl.Core 7 | { 8 | public interface IUIElementFactory 9 | { 10 | IControl CreateResizeControl(CanvasItem itemToResize, IUserInputReceiver parent, IEdgeSnappingEngine snappingEngine); 11 | IControl CreateMovingControl(); 12 | IAdorner CreateWrappingAdorner(IUIElement adornerElement, IControl chrome, ICanvasItem canvasItem); 13 | IAdorner CreateEdgeAdorner(IUIElement adornedElement, ICanvasItem item, Edge edge); 14 | IAdorner CreateSelectionAdorner(IDesignSurface designSurface, ICanvasItem canvasItem); 15 | } 16 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/IVector.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public interface IVector 4 | { 5 | 6 | double X { get; set; } 7 | 8 | 9 | double Y { get; set; } 10 | 11 | 12 | double Length { get; } 13 | 14 | 15 | double LengthSquared { get; } 16 | 17 | 18 | bool Equals(IVector vector1, IVector vector2); 19 | 20 | 21 | bool Equals(object o); 22 | 23 | 24 | bool Equals(IVector value); 25 | 26 | 27 | int GetHashCode(); 28 | 29 | 30 | void Normalize(); 31 | 32 | 33 | double CrossProduct(IVector vector1, IVector vector2); 34 | 35 | 36 | double AngleBetween(IVector vector1, IVector vector2); 37 | 38 | 39 | void Negate(); 40 | 41 | 42 | 43 | IVector Multiply(IVector vector, double scalar); 44 | 45 | 46 | IVector Multiply(double scalar, IVector vector); 47 | 48 | 49 | IVector Divide(IVector vector, double scalar); 50 | 51 | 52 | double Multiply(IVector vector1, IVector vector2); 53 | 54 | 55 | double Determinant(IVector vector1, IVector vector2); 56 | } 57 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/Range.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public class Range 4 | { 5 | public Range(double segmentStart, double segmentEnd) 6 | { 7 | SegmentStart = segmentStart; 8 | SegmentEnd = segmentEnd; 9 | } 10 | 11 | public double SegmentStart { get; set; } 12 | public double SegmentEnd { get; set; } 13 | 14 | protected bool Equals(Range other) 15 | { 16 | return SegmentStart.Equals(other.SegmentStart) && SegmentEnd.Equals(other.SegmentEnd); 17 | } 18 | 19 | public override bool Equals(object obj) 20 | { 21 | if (ReferenceEquals(null, obj)) return false; 22 | if (ReferenceEquals(this, obj)) return true; 23 | if (obj.GetType() != this.GetType()) return false; 24 | return Equals((Range) obj); 25 | } 26 | 27 | public override int GetHashCode() 28 | { 29 | unchecked 30 | { 31 | return (SegmentStart.GetHashCode()*397) ^ SegmentEnd.GetHashCode(); 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/ServiceLocator.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Annotations; 2 | 3 | namespace Glass.Design.Pcl.Core 4 | { 5 | public static class ServiceLocator 6 | { 7 | public static ICoreTypesFactory CoreTypesFactory { get; set; } 8 | public static IInputProvider InputProvider { get; set; } 9 | public static IUIElementFactory UIElementFactory { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/Size.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public struct Size : ISize 4 | { 5 | public Size(double width, double height) : this() 6 | { 7 | Width = width; 8 | Height = height; 9 | } 10 | 11 | public double Width { get; set; } 12 | public double Height { get; set; } 13 | 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Core/VerticalAlignment.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.Core 2 | { 3 | public enum VerticalAlignment 4 | { 5 | Top, 6 | Center, 7 | Bottom, 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/CanvasSelectorExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using Glass.Design.Pcl.Canvas; 4 | 5 | namespace Glass.Design.Pcl.DesignSurface 6 | { 7 | public static class CanvasSelectorExtensions 8 | { 9 | public static IEnumerable GetSelectedCanvasItems(this IMultiSelector canvasSelector) 10 | { 11 | return canvasSelector.SelectedItems.Cast(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/GroupCommandArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Glass.Design.Pcl.Canvas; 3 | 4 | namespace Glass.Design.Pcl.DesignSurface 5 | { 6 | public class GroupCommandArgs 7 | { 8 | public Func CreateHostingItem { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/ICanvasSelector.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | 3 | namespace Glass.Design.Pcl.DesignSurface 4 | { 5 | public interface ICanvasSelector 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/IDesignSurface.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Input; 2 | using Glass.Design.Pcl.Canvas; 3 | using Glass.Design.Pcl.PlatformAbstraction; 4 | 5 | namespace Glass.Design.Pcl.DesignSurface 6 | { 7 | public interface IDesignSurface : IMultiSelector, IUIElement 8 | { 9 | ICommand GroupCommand { get; } 10 | ICanvasItemContainer CanvasDocument { get; } 11 | } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/IDesignerItem.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Canvas; 2 | 3 | namespace Glass.Design.Pcl.DesignSurface 4 | { 5 | public interface IDesignerItem : ICanvasItem 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/IMultiSelector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace Glass.Design.Pcl.DesignSurface 6 | { 7 | public interface IMultiSelector 8 | { 9 | IList SelectedItems { get; } 10 | event EventHandler ItemSpecified; 11 | event EventHandler SelectionCleared; 12 | void UnselectAll(); 13 | } 14 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/INamed.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace Glass.Design.Pcl.DesignSurface 4 | { 5 | public interface INamed 6 | { 7 | string GetName(); 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/IPositionable.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using Glass.Design.Pcl.Core; 3 | 4 | namespace Glass.Design.Pcl.DesignSurface 5 | { 6 | public interface IPositionable : INotifyPropertyChanged, ICoordinate 7 | { 8 | double Left { get; set; } 9 | double Top { get; set; } 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/IResizeThumb.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Canvas; 2 | 3 | namespace Glass.Design.Pcl.DesignSurface 4 | { 5 | public interface IResizeThumb : ICanvasItem 6 | { 7 | ICanvasItem CanvasItem { get; set; } 8 | void DeltaMove(double horizontalChange, double verticalChange); 9 | 10 | bool AllowVerticalResize { get; set; } 11 | bool AllowHorizontalResize { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/ISizable.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using Glass.Design.Pcl.Core; 3 | 4 | namespace Glass.Design.Pcl.DesignSurface 5 | { 6 | public interface ISizable : INotifyPropertyChanged, ICoordinate 7 | { 8 | double Width { get; set; } 9 | double Height { get; set; } 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/PlaneOperation.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.DesignSurface 2 | { 3 | public enum PlaneOperation 4 | { 5 | Move, 6 | Resize, 7 | } 8 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/SizeChangeEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl.DesignSurface 4 | { 5 | public class SizeChangeEventArgs : EventArgs 6 | { 7 | public SizeChangeEventArgs() 8 | { 9 | } 10 | 11 | public SizeChangeEventArgs(double oldValue, double newValue) 12 | { 13 | OldValue = oldValue; 14 | NewValue = newValue; 15 | } 16 | 17 | public double OldValue { get; set; } 18 | public double NewValue { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/VisualAids/Resize/AspectRatioKeeper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace Glass.Design.Pcl.DesignSurface.VisualAids.Resize 5 | { 6 | public class AspectRatioKeeper : IDisposable 7 | { 8 | 9 | public AspectRatioKeeper(ISizable sizable) 10 | { 11 | Sizable = sizable; 12 | Sizable.PropertyChanged += SizableOnPropertyChanged; 13 | Aspect = Sizable.Width / Sizable.Height; 14 | } 15 | 16 | private void SizableOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) 17 | { 18 | switch (propertyChangedEventArgs.PropertyName) 19 | { 20 | case "Height": 21 | { 22 | var newHeight = Sizable.Height; 23 | var newWidth = newHeight/Aspect; 24 | Sizable.Width = newWidth; 25 | break; 26 | } 27 | 28 | case "Width": 29 | { 30 | var newWidth = Sizable.Width; 31 | var newHeight = newWidth/Aspect; 32 | Sizable.Height = newHeight; 33 | break; 34 | } 35 | } 36 | } 37 | 38 | public ISizable Sizable { get; private set; } 39 | 40 | 41 | public double Aspect { get; private set; } 42 | public void Dispose() 43 | { 44 | Sizable.PropertyChanged -= SizableOnPropertyChanged; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/VisualAids/Selection/SelectionMode.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.DesignSurface.VisualAids.Selection 2 | { 3 | public enum SelectionMode 4 | { 5 | Direct, 6 | Invert, 7 | Add, 8 | Subtract 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/VisualAids/Snapping/Edge.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Core; 2 | 3 | namespace Glass.Design.Pcl.DesignSurface.VisualAids.Snapping 4 | { 5 | public class Edge 6 | { 7 | public Edge(double axisDistance, Range range, Orientation orientation) 8 | { 9 | this.Range = range; 10 | AxisDistance = axisDistance; 11 | 12 | Orientation = orientation; 13 | } 14 | 15 | public double AxisDistance { get; set; } 16 | 17 | 18 | public Orientation Orientation { get; set; } 19 | 20 | public Range Range { get; private set; } 21 | 22 | public Edge(Range range, Orientation orientation, double axisDistance) 23 | { 24 | Range = range; 25 | Orientation = orientation; 26 | AxisDistance = axisDistance; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/VisualAids/Snapping/GridSnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Core; 2 | 3 | namespace Glass.Design.Pcl.DesignSurface.VisualAids.Snapping 4 | { 5 | public class GridSnappingEngine : SnappingEngine 6 | { 7 | public ISize GridSize { get; set; } 8 | 9 | public GridSnappingEngine(ISize gridSize, double threshold) 10 | : base(threshold) 11 | { 12 | GridSize = gridSize; 13 | } 14 | 15 | public override double SnapHorizontal(double pointToSnap) 16 | { 17 | var nearestGridX = MathOperations.NearestMultiple(pointToSnap, GridSize.Width); 18 | var x = MathOperations.Snap(pointToSnap, nearestGridX, Threshold); 19 | 20 | return x; 21 | } 22 | 23 | public override double SnapVertical(double value) 24 | { 25 | return SnapHorizontal(value); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/VisualAids/Snapping/ICanvasItemSnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Glass.Design.Pcl.Canvas; 3 | 4 | namespace Glass.Design.Pcl.DesignSurface.VisualAids.Snapping 5 | { 6 | public interface ICanvasItemSnappingEngine : IEdgeSnappingEngine 7 | { 8 | IEnumerable Magnets { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/VisualAids/Snapping/IEdgeSnappingEngine.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.DesignSurface.VisualAids.Snapping 2 | { 3 | public interface IEdgeSnappingEngine : ISnappingEngine 4 | { 5 | void ClearSnappedEdges(); 6 | } 7 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/VisualAids/Snapping/ISnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Canvas; 2 | using Glass.Design.Pcl.Core; 3 | 4 | namespace Glass.Design.Pcl.DesignSurface.VisualAids.Snapping 5 | { 6 | public interface ISnappingEngine 7 | { 8 | double SnapHorizontal(double value); 9 | double SnapVertical(double value); 10 | double Threshold { get; set; } 11 | ICanvasItem Snappable { get; set; } 12 | void SetSourceRectForResize(IRect originalRect); 13 | void SetSourceRectForDrag(IRect originalRect); 14 | } 15 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/VisualAids/Snapping/NoEffectsCanvasItemSnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Glass.Design.Pcl.Canvas; 3 | 4 | namespace Glass.Design.Pcl.DesignSurface.VisualAids.Snapping 5 | { 6 | public class NoEffectsCanvasItemSnappingEngine : NoEffectsSnappingEngine, ICanvasItemSnappingEngine 7 | { 8 | public IEnumerable Magnets { get; set; } 9 | public ICanvasItem Snappable { get; set; } 10 | public void ClearSnappedEdges() 11 | { 12 | 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/VisualAids/Snapping/NoEffectsSnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Canvas; 2 | using Glass.Design.Pcl.Core; 3 | 4 | namespace Glass.Design.Pcl.DesignSurface.VisualAids.Snapping 5 | { 6 | public class NoEffectsSnappingEngine : ISnappingEngine 7 | { 8 | public double SnapHorizontal(double value) 9 | { 10 | return value; 11 | } 12 | 13 | public double SnapVertical(double value) 14 | { 15 | return value; 16 | } 17 | 18 | public bool ShouldSnap(Edge edge, double value) 19 | { 20 | return false; 21 | } 22 | 23 | public double Threshold { get; set; } 24 | public ICanvasItem Snappable { get; set; } 25 | public void SetSourceRectForResize(IRect originalRect) 26 | { 27 | 28 | } 29 | 30 | public void SetSourceRectForDrag(IRect originalRect) 31 | { 32 | 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/DesignSurface/VisualAids/Snapping/Orientation.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.DesignSurface.VisualAids.Snapping 2 | { 3 | public enum Orientation 4 | { 5 | Horizontal = 0, 6 | Vertical, 7 | } 8 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/MathOperations.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.Pcl 4 | { 5 | public static class MathOperations 6 | { 7 | public static double NearestMultiple(double number, double multipleBase) 8 | { 9 | var division = Math.Round(number / multipleBase); 10 | return division * multipleBase; 11 | } 12 | 13 | public static double Snap(double input, double attraction, double maxDistance) 14 | { 15 | var distance = Math.Abs(input - attraction); 16 | return distance >= maxDistance ? input : attraction; 17 | } 18 | 19 | public static int SquareRounding(double value, double total, int levels) 20 | { 21 | var hotSpot = value / total * levels; 22 | var roundedHotSpot = Math.Round(hotSpot); 23 | 24 | return (int)roundedHotSpot; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/PlatformAbstraction/FingerManipulationEventArgs.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Core; 2 | 3 | namespace Glass.Design.Pcl.PlatformAbstraction 4 | { 5 | public class FingerManipulationEventArgs 6 | { 7 | public Point Point { get; set; } 8 | public bool Handled { get; set; } 9 | 10 | public object Pointer { get; set; } 11 | 12 | public Point GetPosition(IUserInputReceiver relativeTo) 13 | { 14 | return ServiceLocator.InputProvider.GetMousePositionRelativeTo(relativeTo); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/PlatformAbstraction/FingerManipulationEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.PlatformAbstraction 2 | { 3 | public delegate void FingerManipulationEventHandler(object sender, FingerManipulationEventArgs args); 4 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/PlatformAbstraction/IAdorner.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.PlatformAbstraction 2 | { 3 | public interface IAdorner: IUIElement 4 | { 5 | IUIElement AdornedElement { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/PlatformAbstraction/IControl.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.PlatformAbstraction 2 | { 3 | public interface IControl : IFrameworkElement 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/PlatformAbstraction/IFrameworkElement.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.DesignSurface; 2 | 3 | namespace Glass.Design.Pcl.PlatformAbstraction 4 | { 5 | public interface IFrameworkElement : IUIElement, ISizable 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/PlatformAbstraction/IUIElement.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Canvas; 2 | using Glass.Design.Pcl.DesignSurface; 3 | 4 | namespace Glass.Design.Pcl.PlatformAbstraction 5 | { 6 | public interface IUIElement : IUserInputReceiver, IPositionable, ICanvasItemContainer 7 | { 8 | void AddAdorner(IAdorner adorner); 9 | void RemoveAdorner(IAdorner adorner); 10 | bool IsVisible { get; set; } 11 | bool IsHitTestVisible { get; set; } 12 | object GetCoreInstance(); 13 | } 14 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/PlatformAbstraction/IUserInputReceiver.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.PlatformAbstraction 2 | { 3 | public interface IUserInputReceiver 4 | { 5 | event FingerManipulationEventHandler FingerDown; 6 | event FingerManipulationEventHandler FingerMove; 7 | event FingerManipulationEventHandler FingerUp; 8 | void CaptureInput(object pointer); 9 | void ReleaseInput(object pointer); 10 | } 11 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/PlatformAbstraction/PointingManipulationEventArgs.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Core; 2 | 3 | namespace Glass.Design.Pcl.PlatformAbstraction 4 | { 5 | public class PointingManipulationEventArgs 6 | { 7 | public IPoint Point { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/PlatformAbstraction/PointingManipulationEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.Pcl.PlatformAbstraction 2 | { 3 | public delegate void PointingManipulationEventHandler(object sender, PointingManipulationEventArgs args); 4 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/PointCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | using Glass.Design.Pcl.Core; 3 | 4 | namespace Glass.Design.Pcl 5 | { 6 | public class PointCollection : Collection 7 | { 8 | public void Offset(double x, double y) 9 | { 10 | for (var index = 0; index < Items.Count; index++) 11 | { 12 | var point = Items[index]; 13 | point.Offset(x, y); 14 | Items[index] = point; 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Primitives/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Glass.Design.Pcl.Primitives 4 | { 5 | public static class EnumerableExtensions 6 | { 7 | public static void SynchronizeListTo(this ICollection current, ICollection toAchieve) 8 | { 9 | var toAdd = new List(); 10 | var toRemove = new List(); 11 | 12 | 13 | foreach (var itemInCurrent in current) 14 | { 15 | if (!toAchieve.Contains(itemInCurrent)) 16 | { 17 | toRemove.Add(itemInCurrent); 18 | } 19 | } 20 | 21 | foreach (var snappedEdge in toAchieve) 22 | { 23 | if (!current.Contains(snappedEdge)) 24 | { 25 | toAdd.Add(snappedEdge); 26 | } 27 | } 28 | 29 | foreach (var itemToRemove in toRemove) 30 | { 31 | current.Remove(itemToRemove); 32 | } 33 | 34 | foreach (var itemToAdd in toAdd) 35 | { 36 | current.Add(itemToAdd); 37 | } 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Design.Interfaces")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Design.Interfaces")] 12 | [assembly: AssemblyCopyright("Copyright © 2013")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | [assembly: NeutralResourcesLanguage("en")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Pcl/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Tests/ExtensionsTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace UnitTestProject1 4 | { 5 | [TestClass] 6 | public class ExtensionsTest 7 | { 8 | 9 | 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Tests/LayeredSelectionTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Glass.Design.Selection; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | 5 | namespace UnitTestProject1 6 | { 7 | [TestClass] 8 | public class LayeredSelectionTest 9 | { 10 | [TestMethod] 11 | public void AddItem() 12 | { 13 | var selectionGrouper = new LayeredSelection(); 14 | 15 | var item = "Hola"; 16 | 17 | selectionGrouper.Add(item, 0); 18 | Assert.AreEqual(true, selectionGrouper.Contains(item)); 19 | } 20 | 21 | [TestMethod] 22 | public void CreateSelection() 23 | { 24 | var selectionGrouper = new LayeredSelection(); 25 | 26 | var item1 = "Hola"; 27 | var item2 = "Hola2"; 28 | 29 | selectionGrouper.Add(item1, 4); 30 | selectionGrouper.Add(item2, 6); 31 | 32 | var selection = selectionGrouper.GetEffectiveSelection(); 33 | Assert.AreEqual(1, selection.Count); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("UnitTestProject1")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("UnitTestProject1")] 12 | [assembly: AssemblyCopyright("Copyright © 2013")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("52c98705-8408-41f5-afb9-01243d8e45b4")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Tests/ResizeTests.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Canvas; 2 | using Glass.Design.Pcl.DesignSurface.VisualAids.Resize; 3 | using Glass.Design.Pcl.DesignSurface.VisualAids.Snapping; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | using Point = Glass.Design.Pcl.Core.Point; 6 | 7 | namespace UnitTestProject1 8 | { 9 | [TestClass] 10 | public class ResizeTests 11 | { 12 | [TestMethod] 13 | public void IncreaseWidthTopRight() 14 | { 15 | var canvasItem = new CanvasModelItem 16 | { 17 | Width = 30, 18 | Height = 30, 19 | Left = 10, 20 | Top = 20, 21 | }; 22 | 23 | var hookPoint = new Point(40, 20); 24 | var newPoint = new Point(50, 20); 25 | 26 | var resizeOperation = new ResizeOperation(canvasItem, newPoint , new NoEffectsCanvasItemSnappingEngine()); 27 | resizeOperation.UpdateHandlePosition(newPoint); 28 | Assert.AreEqual(40D, canvasItem.Width); 29 | } 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Tests/SnappingTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Glass.Design.Pcl.Canvas; 3 | using Glass.Design.Pcl.DesignSurface.VisualAids.Snapping; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace UnitTestProject1 7 | { 8 | 9 | [TestClass] 10 | public class SnappingTest 11 | { 12 | 13 | [TestMethod] 14 | public void MyTestMethod() 15 | { 16 | var snappingEngine = new CanvasItemSnappingEngine(8); 17 | var canvasItems = new List 18 | { 19 | new CanvasModelItem 20 | { 21 | Left = 10, 22 | Top = 10, 23 | Height = 20, 24 | Width = 20, 25 | }, 26 | new CanvasModelItem 27 | { 28 | Left = 33, 29 | Top = 10, 30 | Height = 20, 31 | Width = 20, 32 | } 33 | }; 34 | 35 | 36 | snappingEngine.Magnets = canvasItems; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Tests/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/Core/PointExtensions.cs: -------------------------------------------------------------------------------- 1 | using Windows.Foundation; 2 | 3 | namespace Glass.Design.WinRT.Core 4 | { 5 | public static class PointExtensions 6 | { 7 | public static Point Swap(this Point point) 8 | { 9 | return new Point(point.Y, point.X); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/Core/Vector.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.WinRT.Core 2 | { 3 | public struct Vector 4 | { 5 | private readonly double x; 6 | private readonly double y; 7 | 8 | public Vector(double x, double y) 9 | { 10 | this.x = x; 11 | this.y = y; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/DesignSurface/VisualAids/Selection/CanvasItemAdorner.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.Canvas; 2 | using Glass.Design.Pcl.PlatformAbstraction; 3 | 4 | namespace Glass.Design.WinRT.DesignSurface.VisualAids.Selection 5 | { 6 | public abstract class CanvasItemAdorner : Adorner 7 | { 8 | private ICanvasItem canvasItem; 9 | 10 | public CanvasItemAdorner(IUIElement adornedElement, ICanvasItem canvasItem) 11 | : base(adornedElement) 12 | { 13 | CanvasItem = canvasItem; 14 | } 15 | 16 | protected ICanvasItem CanvasItem 17 | { 18 | get { return canvasItem; } 19 | set 20 | { 21 | canvasItem = value; 22 | this.Left = canvasItem.Left; 23 | this.Top = canvasItem.Top; 24 | this.Width = canvasItem.Width; 25 | this.Height = canvasItem.Height; 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/DesignSurface/VisualAids/Selection/SelectionAdorner.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI; 2 | using Windows.UI.Xaml.Media; 3 | using Windows.UI.Xaml.Shapes; 4 | using Glass.Design.Pcl.Canvas; 5 | using Glass.Design.Pcl.PlatformAbstraction; 6 | 7 | namespace Glass.Design.WinRT.DesignSurface.VisualAids.Selection 8 | { 9 | public class SelectionAdorner : CanvasItemAdorner 10 | { 11 | public SelectionAdorner(IUIElement adornedElement, ICanvasItem canvasItem) 12 | : base(adornedElement, canvasItem) 13 | { 14 | 15 | } 16 | 17 | public override object GetCoreInstance() 18 | { 19 | var rectangle = new Rectangle 20 | { 21 | Fill = new SolidColorBrush(Colors.Red), 22 | Opacity = 0.5, 23 | Width = CanvasItem.Width, 24 | Height = CanvasItem.Height, 25 | }; 26 | 27 | return rectangle; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/InputDeviceEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.WinRT 2 | { 3 | public delegate void InputDeviceEventHandler(object sender, InputDeviceEventHandlerArgs args); 4 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/InputDeviceEventHandlerArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Glass.Design.Pcl.Core; 3 | using Glass.Design.Pcl.PlatformAbstraction; 4 | 5 | namespace Glass.Design.WinRT 6 | { 7 | public class InputDeviceEventHandlerArgs 8 | { 9 | public bool Handled { get; set; } 10 | 11 | public Point GetPoint(IUIElement frameOfReference) 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/PlatformSpecific/ControlAdapter.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using Windows.UI.Xaml.Controls; 3 | using Glass.Design.Pcl.Canvas; 4 | using Glass.Design.Pcl.Core; 5 | using Glass.Design.Pcl.PlatformAbstraction; 6 | 7 | namespace Glass.Design.WinRT.PlatformSpecific 8 | { 9 | public class ControlAdapter : FrameworkElementAdapter, IControl 10 | { 11 | public ControlAdapter(Control control) 12 | : base(control) 13 | { 14 | 15 | } 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/PlatformSpecific/FrameworkElementAdapter.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml; 2 | using Glass.Design.Pcl.PlatformAbstraction; 3 | 4 | namespace Glass.Design.WinRT.PlatformSpecific 5 | { 6 | public class FrameworkElementAdapter : UIElementAdapter, IFrameworkElement 7 | { 8 | protected FrameworkElementAdapter(UIElement uiElement) : base(uiElement) 9 | { 10 | } 11 | 12 | public double Width 13 | { 14 | get { return ((FrameworkElement)UIElement).Width; } 15 | set { ((FrameworkElement)UIElement).Width = value; } 16 | } 17 | 18 | public double Height 19 | { 20 | get { return ((FrameworkElement)UIElement).Height; } 21 | set { ((FrameworkElement)UIElement).Height = value; } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/PlatformSpecific/WinRTInputProvider.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml; 2 | using Windows.UI.Xaml.Input; 3 | using AutoMapper; 4 | using Glass.Design.Pcl.Core; 5 | using Glass.Design.Pcl.PlatformAbstraction; 6 | using FoundationPoint = Windows.Foundation.Point; 7 | 8 | namespace Glass.Design.WinRT.PlatformSpecific 9 | { 10 | public class WinRTInputProvider : IInputProvider 11 | { 12 | public Point GetMousePositionRelativeTo(IUserInputReceiver inputReceiver) 13 | { 14 | 15 | var receiver = (UIElement) inputReceiver; 16 | var position = receiver 17 | .TransformToVisual(Window.Current.Content) 18 | .TransformPoint(new FoundationPoint()); 19 | 20 | var finalPosition = new FoundationPoint( 21 | position.X + Window.Current.CoreWindow.PointerPosition.X, 22 | position.Y + Window.Current.CoreWindow.PointerPosition.Y 23 | ); 24 | 25 | return Mapper.Map(finalPosition); 26 | } 27 | } 28 | 29 | 30 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Glass.Design.WinRT")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Glass.Design.WinRT")] 12 | [assembly: AssemblyCopyright("Copyright © 2014")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Version information for an assembly consists of the following four values: 17 | // 18 | // Major Version 19 | // Minor Version 20 | // Build Number 21 | // Revision 22 | // 23 | // You can specify all the values or you can default the Build and Revision Numbers 24 | // by using the '*' as shown below: 25 | // [assembly: AssemblyVersion("1.0.*")] 26 | [assembly: AssemblyVersion("1.0.0.0")] 27 | [assembly: AssemblyFileVersion("1.0.0.0")] 28 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/VisualExtensions.cs: -------------------------------------------------------------------------------- 1 | using Windows.UI.Xaml; 2 | using AutoMapper; 3 | using Glass.Design.Pcl.Core; 4 | 5 | using FoundationPoint = Windows.Foundation.Point; 6 | 7 | namespace Glass.Design.WinRT 8 | { 9 | static public class VisualExtensions 10 | { 11 | public static Rect GetRectRelativeToParent(this UIElement parent, UIElement child) 12 | { 13 | var transform = parent.TransformToVisual(child); 14 | var point = transform.TransformPoint(new FoundationPoint()); 15 | return new Rect(Mapper.Map(point), Mapper.Map(child.RenderSize)); 16 | } 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.WinRT/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Wpf/Converters/IThumbCursorConverter.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Input; 2 | using Glass.Design.Pcl.Core; 3 | 4 | namespace Glass.Design.Wpf.Converters 5 | { 6 | public interface IThumbCursorConverter 7 | { 8 | Cursor GetCursor(IRect handleRect, IRect parentRect); 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Wpf/Core/PointExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Glass.Design.Wpf.Core 4 | { 5 | public static class PointExtensions 6 | { 7 | public static Point Swap(this Point point) 8 | { 9 | return new Point(point.Y, point.X); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Wpf/DesignSurface/DesignSurfaceBase.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | using Glass.Design.Pcl.PlatformAbstraction; 3 | 4 | namespace Glass.Design.Wpf.DesignSurface 5 | { 6 | public abstract class DesignSurfaceBase : ListBox, IUserInputReceiver 7 | { 8 | public event FingerManipulationEventHandler FingerDown; 9 | 10 | public event FingerManipulationEventHandler FingerMove; 11 | 12 | public event FingerManipulationEventHandler FingerUp; 13 | 14 | 15 | protected virtual void OnFingerDown(FingerManipulationEventArgs args) 16 | { 17 | var handler = FingerDown; 18 | if (handler != null) handler(this, args); 19 | } 20 | 21 | protected virtual void OnFingerMove(FingerManipulationEventArgs args) 22 | { 23 | var handler = FingerMove; 24 | if (handler != null) handler(this, args); 25 | } 26 | 27 | protected virtual void OnFingerUp(FingerManipulationEventArgs args) 28 | { 29 | var handler = FingerUp; 30 | if (handler != null) handler(this, args); 31 | } 32 | 33 | public void CaptureInput(object pointer) 34 | { 35 | //CapturePointer(new Pointer()); 36 | } 37 | 38 | public void ReleaseInput(object pointer) 39 | { 40 | //ReleasePointerCaptures(); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Wpf/PlatformSpecific/ControlAdapter.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.PlatformAbstraction; 2 | using System.Windows.Controls; 3 | 4 | namespace Glass.Design.Wpf.PlatformSpecific 5 | { 6 | public class ControlAdapter : FrameworkElementAdapter, IControl 7 | { 8 | public ControlAdapter(Control control) 9 | : base(control) 10 | { 11 | 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Wpf/PlatformSpecific/FrameworkElementAdapter.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using Glass.Design.Pcl.PlatformAbstraction; 4 | 5 | namespace Glass.Design.Wpf.PlatformSpecific 6 | { 7 | public class FrameworkElementAdapter : UIElementAdapter, IFrameworkElement 8 | { 9 | public FrameworkElementAdapter(UIElement uiElement) : base(uiElement) 10 | { 11 | } 12 | 13 | public double Width 14 | { 15 | get { return ((FrameworkElement)UIElement).Width; } 16 | set { ((FrameworkElement)UIElement).Width = value; } 17 | } 18 | 19 | public double Height 20 | { 21 | get { return ((FrameworkElement)UIElement).Height; } 22 | set { ((FrameworkElement)UIElement).Height = value; } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Wpf/PlatformSpecific/NetCoreInputProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Input; 3 | using AutoMapper; 4 | using Glass.Design.Pcl.Core; 5 | using Glass.Design.Pcl.PlatformAbstraction; 6 | using Point = Glass.Design.Pcl.Core.Point; 7 | 8 | namespace Glass.Design.Wpf.PlatformSpecific 9 | { 10 | public class NetCoreInputProvider : IInputProvider 11 | { 12 | public Point GetMousePositionRelativeTo(IUserInputReceiver inputReceiver) 13 | { 14 | var mousePositionRelativeTo = Mouse.GetPosition((IInputElement)inputReceiver); 15 | var pclPoint = Mapper.Map(mousePositionRelativeTo); 16 | return pclPoint; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Wpf/Viewing/ViewingSurface.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Glass.Design.Wpf.Viewing 5 | { 6 | public class ViewingSurface : ItemsControl 7 | { 8 | static ViewingSurface() 9 | { 10 | DefaultStyleKeyProperty.OverrideMetadata(typeof(ViewingSurface), new FrameworkPropertyMetadata(typeof(ViewingSurface))); 11 | } 12 | 13 | protected override bool IsItemItsOwnContainerOverride(object item) 14 | { 15 | return item is DesignSurfaceItem; 16 | } 17 | 18 | protected override DependencyObject GetContainerForItemOverride() 19 | { 20 | return new DesignSurfaceItem(); 21 | } 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /Glass/Glass.Design.Wpf/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Glass/Glass.Design.Wpf/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Glass/Glass.Design/CanvasItem/CanvasItemExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using Glass.Design.DesignSurface; 3 | 4 | namespace Glass.Design.CanvasItem 5 | { 6 | public static class CanvasItemExtensions 7 | { 8 | public static Point GetLocation(this IPositionable positionable) 9 | { 10 | return new Point(positionable.Left, positionable.Top); 11 | } 12 | 13 | public static Point GetSize(this ISizable sizable) 14 | { 15 | return new Point(sizable.Width, sizable.Height); 16 | } 17 | 18 | public static void SetSize(this ISizable sizable, Size size) 19 | { 20 | sizable.Width = size.Width; 21 | sizable.Height = size.Height; 22 | } 23 | 24 | public static void SetLocation(this IPositionable positionable, Point location) 25 | { 26 | positionable.Left = location.X; 27 | positionable.Top = location.Y; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/CanvasItem/CanvasItemGroup.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Glass.Design.CanvasItem 4 | { 5 | public class CanvasItemGroup : ChildrenExpandableCanvasItem 6 | { 7 | public CanvasItemGroup(IEnumerable children) : base(children) 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/CanvasItem/CanvasItemResizeInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.CanvasItem 2 | { 3 | internal struct CanvasItemResizeInfo 4 | { 5 | private readonly double positionDelta; 6 | private readonly double sizeDelta; 7 | 8 | public CanvasItemResizeInfo(double positionDelta, double sizeDelta) 9 | { 10 | this.positionDelta = positionDelta; 11 | this.sizeDelta = sizeDelta; 12 | } 13 | 14 | public double PositionDelta 15 | { 16 | get { return positionDelta; } 17 | } 18 | 19 | public double SizeDelta 20 | { 21 | get { return sizeDelta; } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/CanvasItem/ICanvasItem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | using Glass.Design.DesignSurface; 3 | 4 | namespace Glass.Design.CanvasItem 5 | { 6 | public interface ICanvasItem : IPositionable, ISizable 7 | { 8 | ObservableCollection Children { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/Converters/IThumbCursorConverter.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Input; 3 | 4 | namespace Glass.Design.Converters 5 | { 6 | public interface IThumbCursorConverter 7 | { 8 | Cursor GetCursor(Rect handleRect, Rect parentRect); 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/DesignOperation.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.DesignSurface 2 | { 3 | public enum DesignOperation 4 | { 5 | Move, 6 | Resize, 7 | } 8 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/IDesignSurface.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using Glass.Design.CanvasItem; 4 | 5 | namespace Glass.Design.DesignSurface 6 | { 7 | public interface IDesignSurface 8 | { 9 | IEnumerable CanvasItems { get; } 10 | } 11 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/IDesignerItem.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.CanvasItem; 2 | 3 | namespace Glass.Design.DesignSurface 4 | { 5 | public interface IDesignerItem : ICanvasItem 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/IMultiSelector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace Glass.Design.DesignSurface 5 | { 6 | public interface IMultiSelector 7 | { 8 | IList SelectedItems { get; } 9 | event EventHandler ItemSpecified; 10 | event EventHandler NoneSpecified; 11 | void UnselectAll(); 12 | } 13 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/IPositionable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.DesignSurface 4 | { 5 | public interface IPositionable 6 | { 7 | double Left { get; set; } 8 | double Top { get; set; } 9 | 10 | event EventHandler LeftChanged; 11 | event EventHandler TopChanged; 12 | } 13 | 14 | public class LocationChangedEventArgs 15 | { 16 | public LocationChangedEventArgs() 17 | { 18 | 19 | } 20 | public LocationChangedEventArgs(double oldValue, double newValue) 21 | { 22 | OldValue = oldValue; 23 | NewValue = newValue; 24 | } 25 | 26 | public double OldValue { get; set; } 27 | public double NewValue { get; set; } 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/IResizeThumb.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.CanvasItem; 2 | 3 | namespace Glass.Design.DesignSurface 4 | { 5 | public interface IResizeThumb : ICanvasItem 6 | { 7 | ICanvasItem CanvasItem { get; set; } 8 | void DeltaMove(double horizontalChange, double verticalChange); 9 | 10 | bool AllowVerticalResize { get; set; } 11 | bool AllowHorizontalResize { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/ISizable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.DesignSurface 4 | { 5 | public interface ISizable 6 | { 7 | double Width { get; set; } 8 | double Height { get; set; } 9 | 10 | event EventHandler HeightChanged; 11 | event EventHandler WidthChanged; 12 | } 13 | 14 | public class SizeChangeEventArgs : EventArgs 15 | { 16 | public SizeChangeEventArgs() 17 | { 18 | } 19 | 20 | public SizeChangeEventArgs(double oldValue, double newValue) 21 | { 22 | OldValue = oldValue; 23 | NewValue = newValue; 24 | } 25 | 26 | public double OldValue { get; set; } 27 | public double NewValue { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/VisualAids/Drag/DragOperation.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using Glass.Design.Annotations; 3 | using Glass.Design.CanvasItem; 4 | using Glass.Design.DesignSurface.VisualAids.Snapping; 5 | 6 | namespace Glass.Design.DesignSurface.VisualAids.Drag 7 | { 8 | public class DragOperation 9 | { 10 | private ICanvasItem Child { get; set; } 11 | private Point StartingPoint { get; set; } 12 | 13 | [NotNull] 14 | public ISnappingEngine SnappingEngine { get; set; } 15 | 16 | public DragOperation(ICanvasItem child, Point startingPoint) 17 | { 18 | Child = child; 19 | 20 | StartingPoint = startingPoint; 21 | ChildStartingPoint = child.GetLocation(); 22 | } 23 | 24 | public Point ChildStartingPoint { get; set; } 25 | 26 | public void NotifyNewPosition(Point newPoint) 27 | { 28 | var delta = newPoint - StartingPoint; 29 | var newChildLocation = ChildStartingPoint + delta; 30 | 31 | var resultingLocation = SnappingEngine.SnapPoint(newChildLocation); 32 | 33 | Child.SetLocation(resultingLocation); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/VisualAids/Resize/AspectRatioKeeper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design.DesignSurface.VisualAids.Resize 4 | { 5 | public class AspectRatioKeeper : IDisposable 6 | { 7 | 8 | public AspectRatioKeeper(ISizable sizable) 9 | { 10 | Sizable = sizable; 11 | Sizable.WidthChanged += SizableOnWidthChanged; 12 | Sizable.HeightChanged += SizableOnHeightChanged; 13 | Aspect = Sizable.Width / Sizable.Height; 14 | } 15 | 16 | public ISizable Sizable { get; private set; } 17 | 18 | private void SizableOnHeightChanged(object sender, EventArgs eventArgs) 19 | { 20 | var newHeight = Sizable.Height; 21 | var newWidth = newHeight / Aspect; 22 | Sizable.Width = newWidth; 23 | } 24 | 25 | private void SizableOnWidthChanged(object sender, EventArgs eventArgs) 26 | { 27 | var newWidth = Sizable.Width; 28 | var newHeight = newWidth / Aspect; 29 | Sizable.Height = newHeight; 30 | } 31 | 32 | public double Aspect { get; private set; } 33 | public void Dispose() 34 | { 35 | Sizable.WidthChanged -= SizableOnWidthChanged; 36 | Sizable.HeightChanged -= SizableOnHeightChanged; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/VisualAids/Selection/SelectionMode.cs: -------------------------------------------------------------------------------- 1 | namespace Glass.Design.DesignSurface.VisualAids.Selection 2 | { 3 | public enum SelectionMode 4 | { 5 | Direct, 6 | Invert, 7 | Add, 8 | Subtract 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/VisualAids/Snapping/CanvasItemSnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Glass.Design.CanvasItem; 3 | 4 | namespace Glass.Design.DesignSurface.VisualAids.Snapping 5 | { 6 | public class CanvasItemSnappingEngine : EdgeSnappingEngine, ICanvasItemSnappingEngine 7 | { 8 | public CanvasItemSnappingEngine() 9 | { 10 | 11 | } 12 | 13 | private IEnumerable items; 14 | 15 | public IEnumerable Items 16 | { 17 | get { return items; } 18 | set 19 | { 20 | items = value; 21 | GenerateEdges(); 22 | } 23 | } 24 | 25 | private void GenerateEdges() 26 | { 27 | HorizontalEdges.Clear(); 28 | VerticalEdges.Clear(); 29 | 30 | foreach (var canvasItem in Items) 31 | { 32 | HorizontalEdges.Add(canvasItem.Left); 33 | HorizontalEdges.Add(canvasItem.Left + canvasItem.Width); 34 | VerticalEdges.Add(canvasItem.Left); 35 | VerticalEdges.Add(canvasItem.Top + canvasItem.Height); 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/VisualAids/Snapping/GridSnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Glass.Design.DesignSurface.VisualAids.Snapping 4 | { 5 | public class GridSnappingEngine : ISnappingEngine 6 | { 7 | public Size GridSize { get; set; } 8 | public Vector Power { get; set; } 9 | 10 | public GridSnappingEngine(Size gridSize, Vector power) 11 | { 12 | GridSize = gridSize; 13 | Power = power; 14 | } 15 | 16 | public Point SnapPoint(Point pointToSnap) 17 | { 18 | var scopeX = (Power.X * GridSize.Width) /2; 19 | var scopeY = (Power.Y * GridSize.Height) / 2; 20 | 21 | var nearestGridX = MathOperations.NearestMultiple(pointToSnap.X, GridSize.Width); 22 | var x = MathOperations.Snap(pointToSnap.X, nearestGridX, scopeX); 23 | 24 | var nearestGridY = MathOperations.NearestMultiple(pointToSnap.Y, GridSize.Height); 25 | var y = MathOperations.Snap(pointToSnap.Y, nearestGridY, scopeY); 26 | 27 | return new Point(x, y); 28 | 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/VisualAids/Snapping/ICanvasItemSnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | using Glass.Design.CanvasItem; 4 | 5 | namespace Glass.Design.DesignSurface.VisualAids.Snapping 6 | { 7 | public interface ICanvasItemSnappingEngine : ISnappingEngine 8 | { 9 | IEnumerable Items { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/VisualAids/Snapping/ISnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Glass.Design.DesignSurface.VisualAids.Snapping 4 | { 5 | public interface ISnappingEngine 6 | { 7 | Point SnapPoint(Point pointToSnap); 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/VisualAids/Snapping/NoEffectsCanvasItemSnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Glass.Design.CanvasItem; 3 | 4 | namespace Glass.Design.DesignSurface.VisualAids.Snapping 5 | { 6 | class NoEffectsCanvasItemSnappingEngine : NoEffectsSnappingEngine, ICanvasItemSnappingEngine 7 | { 8 | public IEnumerable Items { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DesignSurface/VisualAids/Snapping/NoEffectsSnappingEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Glass.Design.DesignSurface.VisualAids.Snapping 4 | { 5 | class NoEffectsSnappingEngine : ISnappingEngine 6 | { 7 | public Point SnapPoint(Point pointToSnap) 8 | { 9 | return pointToSnap; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/DragOperation.cs: -------------------------------------------------------------------------------- 1 | using Design.Interfaces; 2 | 3 | namespace Glass.Design 4 | { 5 | public class DragOperation 6 | { 7 | public ICanvasItem CanvasItem { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | using Glass.Design.CanvasItem; 4 | 5 | namespace Glass.Design 6 | { 7 | public static class Extensions 8 | { 9 | 10 | 11 | public static void SwapCoordinates(this IEnumerable items) 12 | { 13 | foreach (var canvasItem in items) 14 | { 15 | canvasItem.SwapCoordinates(); 16 | } 17 | } 18 | 19 | public static void SwapCoordinates(this ICanvasItem item) 20 | { 21 | var left = item.Left; 22 | var top = item.Top; 23 | Swap(ref left, ref top); 24 | var width = item.Width; 25 | var height = item.Height; 26 | Swap(ref width, ref height); 27 | 28 | item.Left = left; 29 | item.Top = top; 30 | item.Width = width; 31 | item.Height = height; 32 | } 33 | 34 | private static void Swap(ref T a, ref T b) 35 | { 36 | var temp = a; 37 | a = b; 38 | b = temp; 39 | } 40 | 41 | public static Rect ToRect(this ICanvasItem item) 42 | { 43 | return new Rect(item.Left, item.Top, item.Width, item.Height); 44 | } 45 | 46 | public static Point DiscretizeUsingAverage(this Rect item) 47 | { 48 | return new Point(item.Left + item.Width / 2, item.Top + item.Height / 2); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/MathOperations.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Glass.Design 4 | { 5 | public static class MathOperations 6 | { 7 | public static double NearestMultiple(double number, double multipleBase) 8 | { 9 | var division = Math.Round(number / multipleBase); 10 | return division * multipleBase; 11 | } 12 | 13 | public static double Snap(double input, double attraction, double maxDistance) 14 | { 15 | var distance = Math.Abs(input - attraction); 16 | return distance >= maxDistance ? input : attraction; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/PointCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | using System.Windows; 3 | 4 | namespace Glass.Design 5 | { 6 | public class PointCollection : Collection 7 | { 8 | public void Offset(double x, double y) 9 | { 10 | for (var index = 0; index < Items.Count; index++) 11 | { 12 | var point = Items[index]; 13 | point.Offset(x, y); 14 | Items[index] = point; 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Glass/Glass.Design/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34003 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 Glass.Design.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.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 | -------------------------------------------------------------------------------- /Glass/Glass.Design/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Glass/Glass.Design/ProportionalResizer.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using Glass.Design.CanvasItem; 3 | 4 | namespace Glass.Design 5 | { 6 | public class ProportionalResizer 7 | { 8 | private readonly ICanvasItem canvasItem; 9 | 10 | public ProportionalResizer(ICanvasItem canvasItem) 11 | { 12 | this.canvasItem = canvasItem; 13 | } 14 | 15 | private static CanvasItemResizeInfo DeltaResize(double delta, double hookOffset) 16 | { 17 | var sizeDelta = delta * (1 - hookOffset); 18 | var positionDelta = delta - sizeDelta; 19 | return new CanvasItemResizeInfo(positionDelta, sizeDelta); 20 | } 21 | 22 | public void DeltaResize(Vector resize) 23 | { 24 | var horzResize = DeltaResize(resize.X, HookPoint.X); 25 | var vertResize = DeltaResize(resize.Y, HookPoint.Y); 26 | 27 | canvasItem.Left += horzResize.PositionDelta; 28 | 29 | if (canvasItem.Width + horzResize.SizeDelta - horzResize.PositionDelta >= 0) 30 | { 31 | canvasItem.Width += horzResize.SizeDelta - horzResize.PositionDelta; 32 | } 33 | 34 | canvasItem.Top += vertResize.PositionDelta; 35 | if (canvasItem.Height + vertResize.SizeDelta - vertResize.PositionDelta >= 0) 36 | { 37 | canvasItem.Height += vertResize.SizeDelta - vertResize.PositionDelta; 38 | } 39 | } 40 | 41 | public Vector HookPoint { get; set; } 42 | } 43 | } -------------------------------------------------------------------------------- /SampleModel.Serialization/EllipseDto.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Serialization; 2 | 3 | namespace SampleModel.Serialization 4 | { 5 | [XmlType("Ellipse")] 6 | public class EllipseDto : ShapeDto 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /SampleModel.Serialization/GroupDto.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Serialization; 2 | using Glass.Design.Pcl.Annotations; 3 | 4 | namespace SampleModel.Serialization 5 | { 6 | [UsedImplicitly] 7 | [XmlType("Group")] 8 | public class GroupDto : ObjectDto 9 | { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /SampleModel.Serialization/LinkDto.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Serialization; 2 | using Glass.Design.Pcl.Annotations; 3 | 4 | namespace SampleModel.Serialization 5 | { 6 | [UsedImplicitly] 7 | [XmlType("Link")] 8 | public class LinkDto : ObjectDto 9 | { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /SampleModel.Serialization/MarioDto.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Serialization; 2 | using Glass.Design.Pcl.Annotations; 3 | 4 | namespace SampleModel.Serialization 5 | { 6 | [UsedImplicitly] 7 | [XmlType("Mario")] 8 | public class MarioDto : ObjectDto 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /SampleModel.Serialization/ModelDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Xml.Serialization; 3 | 4 | namespace SampleModel.Serialization 5 | { 6 | [XmlRoot("Composition")] 7 | public class ModelDto 8 | { 9 | 10 | public ModelDto() 11 | { 12 | 13 | } 14 | 15 | [XmlArray("Objects")] 16 | [XmlArrayItem("Object")] 17 | public List Objects { get; set; } 18 | 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /SampleModel.Serialization/ObjectDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Xml.Serialization; 3 | 4 | namespace SampleModel.Serialization 5 | { 6 | [XmlInclude(typeof(MarioDto))] 7 | [XmlInclude(typeof(LinkDto))] 8 | [XmlInclude(typeof(SonicDto))] 9 | [XmlInclude(typeof(GroupDto))] 10 | [XmlInclude(typeof(LabelDto))] 11 | //[XmlInclude(typeof(ShapeDto))] 12 | public class ObjectDto 13 | { 14 | public ObjectDto() 15 | { 16 | 17 | } 18 | 19 | [XmlAttribute] 20 | public double Left { get; set; } 21 | [XmlAttribute] 22 | public double Top { get; set; } 23 | [XmlAttribute] 24 | public double Width { get; set; } 25 | [XmlAttribute] 26 | public double Height { get; set; } 27 | 28 | [XmlArray("Objects")] 29 | [XmlArrayItem("Object")] 30 | public List Objects { get; set; } 31 | } 32 | } -------------------------------------------------------------------------------- /SampleModel.Serialization/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("SampleModel.Serialization")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("SampleModel.Serialization")] 12 | [assembly: AssemblyCopyright("Copyright © 2014")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("68ef78a5-99c8-4a23-88ee-cf7e752b7235")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /SampleModel.Serialization/RectangleDto.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Serialization; 2 | 3 | namespace SampleModel.Serialization 4 | { 5 | [XmlType("Rectangle")] 6 | public class RectangleDto : ShapeDto 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /SampleModel.Serialization/ShapeDto.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Serialization; 2 | 3 | namespace SampleModel.Serialization 4 | { 5 | [XmlInclude(typeof(RectangleDto))] 6 | [XmlInclude(typeof(EllipseDto))] 7 | public class ShapeDto: ObjectDto 8 | { 9 | [XmlAttribute] 10 | public Color FillColor { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /SampleModel.Serialization/SonicDto.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Serialization; 2 | using Glass.Design.Pcl.Annotations; 3 | 4 | namespace SampleModel.Serialization 5 | { 6 | [UsedImplicitly] 7 | [XmlType("Sonic")] 8 | public class SonicDto : ObjectDto 9 | { 10 | 11 | } 12 | 13 | [UsedImplicitly] 14 | [XmlType("Label")] 15 | public class LabelDto : ObjectDto 16 | { 17 | private string text; 18 | 19 | public string Text 20 | { 21 | get { return text; } 22 | set { text = value; } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /SampleModel.Serialization/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SampleModel.Serialization/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /SampleModel/CanvasDocument.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Glass.Design.Pcl.Canvas; 3 | using PostSharp.Patterns.Model; 4 | using PostSharp.Patterns.Recording; 5 | 6 | namespace SampleModel 7 | { 8 | [Recordable] 9 | public class CanvasDocument : ICanvasItemContainer 10 | { 11 | public CanvasDocument() 12 | { 13 | this.Children = new CanvasItemCollection(); 14 | } 15 | 16 | public CanvasDocument(IEnumerable items ) 17 | { 18 | this.Children = new CanvasItemCollection(items); 19 | } 20 | 21 | [Child] 22 | public CanvasItemCollection Children { get; set; } 23 | 24 | } 25 | } -------------------------------------------------------------------------------- /SampleModel/CanvasItemViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using Glass.Design.Pcl.Canvas; 3 | using PostSharp.Patterns.Contracts; 4 | 5 | namespace SampleModel 6 | { 7 | public class CanvasItemViewModel : CanvasModelItem 8 | { 9 | private static int nextId; 10 | private readonly int id = Interlocked.Increment(ref nextId); 11 | 12 | public CanvasItemViewModel() 13 | { 14 | this.Name = this.GetType().Name + id; 15 | } 16 | 17 | [Required] 18 | public string Name { get; set; } 19 | 20 | public override string GetName() 21 | { 22 | return this.Name; 23 | } 24 | 25 | 26 | public override string ToString() 27 | { 28 | // For better debugging. 29 | return string.Format("{0} #{5}, Left={1}, Top={2}, Width={3}, Height={4}", this.GetType().Name, this.Left, 30 | this.Top, this.Width, this.Height, this.id); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /SampleModel/CanvasRectangle.cs: -------------------------------------------------------------------------------- 1 | namespace SampleModel 2 | { 3 | public class CanvasRectangle : Shape 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /SampleModel/Color.cs: -------------------------------------------------------------------------------- 1 | namespace SampleModel 2 | { 3 | 4 | public struct Color 5 | { 6 | private readonly byte r; 7 | private readonly byte g; 8 | private readonly byte b; 9 | private readonly byte a; 10 | 11 | public Color(byte alpha, byte r, byte g, byte b) : this() 12 | { 13 | this.a = alpha; 14 | this.r = r; 15 | this.g = g; 16 | this.b = b; 17 | } 18 | 19 | public Color(byte r, byte g, byte b) : this(255, r, g, b) 20 | { 21 | 22 | } 23 | 24 | public byte R 25 | { 26 | get { return this.r; } 27 | } 28 | 29 | public byte G 30 | { 31 | get { return this.g; } 32 | } 33 | 34 | public byte B 35 | { 36 | get { return this.b; } 37 | } 38 | 39 | public byte A 40 | { 41 | get { return this.a; } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /SampleModel/Ellipse.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | namespace SampleModel 4 | { 5 | public class Ellipse : Shape 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /SampleModel/Group.cs: -------------------------------------------------------------------------------- 1 | namespace SampleModel 2 | { 3 | public class Group : CanvasItemViewModel 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /SampleModel/Label.cs: -------------------------------------------------------------------------------- 1 | namespace SampleModel 2 | { 3 | public class Label : CanvasItemViewModel 4 | { 5 | public string Text { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /SampleModel/Link.cs: -------------------------------------------------------------------------------- 1 | namespace SampleModel 2 | { 3 | public class Link : CanvasItemViewModel 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /SampleModel/Mario.cs: -------------------------------------------------------------------------------- 1 | namespace SampleModel 2 | { 3 | public class Mario : CanvasItemViewModel 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /SampleModel/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("SampleModel")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("SampleModel")] 12 | [assembly: AssemblyCopyright("Copyright © 2013")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | [assembly: NeutralResourcesLanguage("en")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | -------------------------------------------------------------------------------- /SampleModel/Shape.cs: -------------------------------------------------------------------------------- 1 | using PostSharp.Patterns.Model; 2 | 3 | namespace SampleModel 4 | { 5 | public class Shape : CanvasItemViewModel 6 | { 7 | public Color FillColor { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SampleModel/Sonic.cs: -------------------------------------------------------------------------------- 1 | namespace SampleModel 2 | { 3 | public class Sonic : CanvasItemViewModel 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /SampleModel/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SampleModel/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /SampleModelNoPCL/CanvasRectangle.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.CanvasItem.NotifyPropertyChanged; 2 | using SampleModel; 3 | 4 | namespace SampleModelNoPCL 5 | { 6 | public class CanvasRectangle : CanvasItemINPC 7 | { 8 | public Color FillColor { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SampleModelNoPCL/Color.cs: -------------------------------------------------------------------------------- 1 | namespace SampleModel 2 | { 3 | public class Color 4 | { 5 | public byte R { get; set; } 6 | public byte G { get; set; } 7 | public byte B { get; set; } 8 | public byte A { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /SampleModelNoPCL/Mario.cs: -------------------------------------------------------------------------------- 1 | using Glass.Design.Pcl.CanvasItem.NotifyPropertyChanged; 2 | 3 | namespace SampleModelNoPCL 4 | { 5 | public class Mario : CanvasItemINPC 6 | { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /SampleModelNoPCL/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SampleModelNoPCL")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SampleModelNoPCL")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e97b64f7-a8f8-4b87-8422-9bac4886e475")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /WPFTestApp/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /WPFTestApp/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /WPFTestApp/DockingPart.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Input; 5 | using PostSharp.Patterns.Recording; 6 | 7 | namespace Glass.Design.WpfTester 8 | { 9 | /// 10 | /// Interaction logic for DockingPart.xaml 11 | /// 12 | public partial class DockingPart : UserControl 13 | { 14 | public DockingPart() 15 | { 16 | this.InitializeComponent(); 17 | } 18 | 19 | private void Control_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) 20 | { 21 | Operation operation = (Operation)((FrameworkElement)e.Source).DataContext; 22 | // TODO: There should be a better way to get the recorder. 23 | ((MainWindowViewModel)this.DataContext).Recorder.UndoTo(operation); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /WPFTestApp/Images/Group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/WPFTestApp/Images/Group.png -------------------------------------------------------------------------------- /WPFTestApp/Images/Link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/WPFTestApp/Images/Link.png -------------------------------------------------------------------------------- /WPFTestApp/Images/Mario.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/WPFTestApp/Images/Mario.png -------------------------------------------------------------------------------- /WPFTestApp/Images/Sonic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SuperJMN/VisualDesigner/657f1f3f1ea21d08cedfd6a029a56f8e24fc0602/WPFTestApp/Images/Sonic.png -------------------------------------------------------------------------------- /WPFTestApp/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using PostSharp.Patterns.Recording; 3 | 4 | namespace Glass.Design.WpfTester 5 | { 6 | /// 7 | /// Interaction logic for MainWindow.xaml 8 | /// 9 | public partial class MainWindow 10 | { 11 | public MainWindow() 12 | { 13 | InitializeComponent(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WPFTestApp/ModelColorToSolidColorBrushConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | using AutoMapper; 6 | using Color = SampleModel.Color; 7 | 8 | namespace Glass.Design.WpfTester 9 | { 10 | public class ModelColorToSolidColorBrushConverter : IValueConverter 11 | { 12 | static ModelColorToSolidColorBrushConverter() 13 | { 14 | Mapper.CreateMap().ForMember(color => color.A, expression => expression.UseValue(255)); 15 | Mapper.CreateMap().ForMember(color => color.A, expression => expression.UseValue(255)); 16 | } 17 | 18 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | var color = Mapper.Map(value); 21 | var solidColorBrush = new SolidColorBrush(color); 22 | return solidColorBrush; 23 | } 24 | 25 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 26 | { 27 | var solidColorBrush = (SolidColorBrush) value; 28 | var colorFromBrush = solidColorBrush.Color; 29 | var color = Mapper.Map(colorFromBrush); 30 | return color; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /WPFTestApp/MyOperationFormatter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Security.Cryptography; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Glass.Design.Pcl.Canvas; 9 | using PostSharp.Patterns.Recording; 10 | using PostSharp.Patterns.Recording.Operations; 11 | 12 | namespace Glass.Design.WpfTester 13 | { 14 | class MyOperationFormatter : OperationFormatter 15 | { 16 | public MyOperationFormatter( OperationFormatter next ) : base( next ) 17 | { 18 | } 19 | 20 | protected override string FormatOperationDescriptor( IOperationDescriptor operation ) 21 | { 22 | if ( operation.OperationKind == OperationKind.Method ) 23 | { 24 | MethodExecutionOperationDescriptor descriptor = (MethodExecutionOperationDescriptor) operation; 25 | if ( descriptor.Method != null && 26 | (descriptor.Method.Attributes & MethodAttributes.SpecialName) != 0 && 27 | descriptor.Method.Name.StartsWith( "set_" ) ) 28 | { 29 | ICanvasItem canvasItem = (ICanvasItem) descriptor.Target; 30 | return string.Format( "Changing {0} of {1}", descriptor.Method.Name.Substring( 4 ), canvasItem.GetName() ); 31 | } 32 | } 33 | 34 | return null; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /WPFTestApp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34003 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 Glass.Design.WpfTester.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.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 | -------------------------------------------------------------------------------- /WPFTestApp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /WPFTestApp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | --------------------------------------------------------------------------------