// Code compiled into PresentationFramework.dll // Initialize known object types internal static object CreateKnownElement(KnownElements knownElement) { object o = null; switch (knownElement) { case KnownElements.AccessText: o = new System.Windows.Controls.AccessText(); break; case KnownElements.AdornedElementPlaceholder: o = new System.Windows.Controls.AdornedElementPlaceholder(); break; case KnownElements.AdornerDecorator: o = new System.Windows.Documents.AdornerDecorator(); break; case KnownElements.AmbientLight: o = new System.Windows.Media.Media3D.AmbientLight(); break; case KnownElements.Application: o = new System.Windows.Application(); break; case KnownElements.ArcSegment: o = new System.Windows.Media.ArcSegment(); break; case KnownElements.ArrayExtension: o = new System.Windows.Markup.ArrayExtension(); break; case KnownElements.AxisAngleRotation3D: o = new System.Windows.Media.Media3D.AxisAngleRotation3D(); break; case KnownElements.BeginStoryboard: o = new System.Windows.Media.Animation.BeginStoryboard(); break; case KnownElements.BevelBitmapEffect: o = new System.Windows.Media.Effects.BevelBitmapEffect(); break; case KnownElements.BezierSegment: o = new System.Windows.Media.BezierSegment(); break; case KnownElements.Binding: o = new System.Windows.Data.Binding(); break; case KnownElements.BitmapEffectCollection: o = new System.Windows.Media.Effects.BitmapEffectCollection(); break; case KnownElements.BitmapEffectGroup: o = new System.Windows.Media.Effects.BitmapEffectGroup(); break; case KnownElements.BitmapEffectInput: o = new System.Windows.Media.Effects.BitmapEffectInput(); break; case KnownElements.BitmapImage: o = new System.Windows.Media.Imaging.BitmapImage(); break; case KnownElements.BlockUIContainer: o = new System.Windows.Documents.BlockUIContainer(); break; case KnownElements.BlurBitmapEffect: o = new System.Windows.Media.Effects.BlurBitmapEffect(); break; case KnownElements.BmpBitmapEncoder: o = new System.Windows.Media.Imaging.BmpBitmapEncoder(); break; case KnownElements.Bold: o = new System.Windows.Documents.Bold(); break; case KnownElements.BoolIListConverter: o = new System.Windows.Media.Converters.BoolIListConverter(); break; case KnownElements.BooleanAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.BooleanAnimationUsingKeyFrames(); break; case KnownElements.BooleanConverter: o = new System.ComponentModel.BooleanConverter(); break; case KnownElements.BooleanKeyFrameCollection: o = new System.Windows.Media.Animation.BooleanKeyFrameCollection(); break; case KnownElements.BooleanToVisibilityConverter: o = new System.Windows.Controls.BooleanToVisibilityConverter(); break; case KnownElements.Border: o = new System.Windows.Controls.Border(); break; case KnownElements.BorderGapMaskConverter: o = new System.Windows.Controls.BorderGapMaskConverter(); break; case KnownElements.BrushConverter: o = new System.Windows.Media.BrushConverter(); break; case KnownElements.BulletDecorator: o = new System.Windows.Controls.Primitives.BulletDecorator(); break; case KnownElements.Button: o = new System.Windows.Controls.Button(); break; case KnownElements.ByteAnimation: o = new System.Windows.Media.Animation.ByteAnimation(); break; case KnownElements.ByteAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ByteAnimationUsingKeyFrames(); break; case KnownElements.ByteConverter: o = new System.ComponentModel.ByteConverter(); break; case KnownElements.ByteKeyFrameCollection: o = new System.Windows.Media.Animation.ByteKeyFrameCollection(); break; case KnownElements.Canvas: o = new System.Windows.Controls.Canvas(); break; case KnownElements.CharAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.CharAnimationUsingKeyFrames(); break; case KnownElements.CharConverter: o = new System.ComponentModel.CharConverter(); break; case KnownElements.CharIListConverter: o = new System.Windows.Media.Converters.CharIListConverter(); break; case KnownElements.CharKeyFrameCollection: o = new System.Windows.Media.Animation.CharKeyFrameCollection(); break; case KnownElements.CheckBox: o = new System.Windows.Controls.CheckBox(); break; case KnownElements.CollectionContainer: o = new System.Windows.Data.CollectionContainer(); break; case KnownElements.CollectionViewSource: o = new System.Windows.Data.CollectionViewSource(); break; case KnownElements.Color: o = new System.Windows.Media.Color(); break; case KnownElements.ColorAnimation: o = new System.Windows.Media.Animation.ColorAnimation(); break; case KnownElements.ColorAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ColorAnimationUsingKeyFrames(); break; case KnownElements.ColorConvertedBitmap: o = new System.Windows.Media.Imaging.ColorConvertedBitmap(); break; case KnownElements.ColorConvertedBitmapExtension: o = new System.Windows.ColorConvertedBitmapExtension(); break; case KnownElements.ColorConverter: o = new System.Windows.Media.ColorConverter(); break; case KnownElements.ColorKeyFrameCollection: o = new System.Windows.Media.Animation.ColorKeyFrameCollection(); break; case KnownElements.ColumnDefinition: o = new System.Windows.Controls.ColumnDefinition(); break; case KnownElements.CombinedGeometry: o = new System.Windows.Media.CombinedGeometry(); break; case KnownElements.ComboBox: o = new System.Windows.Controls.ComboBox(); break; case KnownElements.ComboBoxItem: o = new System.Windows.Controls.ComboBoxItem(); break; case KnownElements.CommandConverter: o = new System.Windows.Input.CommandConverter(); break; case KnownElements.ComponentResourceKey: o = new System.Windows.ComponentResourceKey(); break; case KnownElements.ComponentResourceKeyConverter: o = new System.Windows.Markup.ComponentResourceKeyConverter(); break; case KnownElements.Condition: o = new System.Windows.Condition(); break; case KnownElements.ContainerVisual: o = new System.Windows.Media.ContainerVisual(); break; case KnownElements.ContentControl: o = new System.Windows.Controls.ContentControl(); break; case KnownElements.ContentElement: o = new System.Windows.ContentElement(); break; case KnownElements.ContentPresenter: o = new System.Windows.Controls.ContentPresenter(); break; case KnownElements.ContextMenu: o = new System.Windows.Controls.ContextMenu(); break; case KnownElements.Control: o = new System.Windows.Controls.Control(); break; case KnownElements.ControlTemplate: o = new System.Windows.Controls.ControlTemplate(); break; case KnownElements.CornerRadius: o = new System.Windows.CornerRadius(); break; case KnownElements.CornerRadiusConverter: o = new System.Windows.CornerRadiusConverter(); break; case KnownElements.CroppedBitmap: o = new System.Windows.Media.Imaging.CroppedBitmap(); break; case KnownElements.CultureInfoConverter: o = new System.ComponentModel.CultureInfoConverter(); break; case KnownElements.CultureInfoIetfLanguageTagConverter: o = new System.Windows.CultureInfoIetfLanguageTagConverter(); break; case KnownElements.CursorConverter: o = new System.Windows.Input.CursorConverter(); break; case KnownElements.DashStyle: o = new System.Windows.Media.DashStyle(); break; case KnownElements.DataTemplate: o = new System.Windows.DataTemplate(); break; case KnownElements.DataTemplateKey: o = new System.Windows.DataTemplateKey(); break; case KnownElements.DataTrigger: o = new System.Windows.DataTrigger(); break; case KnownElements.DateTimeConverter: o = new System.ComponentModel.DateTimeConverter(); break; case KnownElements.DateTimeConverter2: o = new System.Windows.Markup.DateTimeConverter2(); break; case KnownElements.DecimalAnimation: o = new System.Windows.Media.Animation.DecimalAnimation(); break; case KnownElements.DecimalAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.DecimalAnimationUsingKeyFrames(); break; case KnownElements.DecimalConverter: o = new System.ComponentModel.DecimalConverter(); break; case KnownElements.DecimalKeyFrameCollection: o = new System.Windows.Media.Animation.DecimalKeyFrameCollection(); break; case KnownElements.Decorator: o = new System.Windows.Controls.Decorator(); break; case KnownElements.DependencyObject: o = new System.Windows.DependencyObject(); break; case KnownElements.DependencyPropertyConverter: o = new System.Windows.Markup.DependencyPropertyConverter(); break; case KnownElements.DialogResultConverter: o = new System.Windows.DialogResultConverter(); break; case KnownElements.DiffuseMaterial: o = new System.Windows.Media.Media3D.DiffuseMaterial(); break; case KnownElements.DirectionalLight: o = new System.Windows.Media.Media3D.DirectionalLight(); break; case KnownElements.DiscreteBooleanKeyFrame: o = new System.Windows.Media.Animation.DiscreteBooleanKeyFrame(); break; case KnownElements.DiscreteByteKeyFrame: o = new System.Windows.Media.Animation.DiscreteByteKeyFrame(); break; case KnownElements.DiscreteCharKeyFrame: o = new System.Windows.Media.Animation.DiscreteCharKeyFrame(); break; case KnownElements.DiscreteColorKeyFrame: o = new System.Windows.Media.Animation.DiscreteColorKeyFrame(); break; case KnownElements.DiscreteDecimalKeyFrame: o = new System.Windows.Media.Animation.DiscreteDecimalKeyFrame(); break; case KnownElements.DiscreteDoubleKeyFrame: o = new System.Windows.Media.Animation.DiscreteDoubleKeyFrame(); break; case KnownElements.DiscreteInt16KeyFrame: o = new System.Windows.Media.Animation.DiscreteInt16KeyFrame(); break; case KnownElements.DiscreteInt32KeyFrame: o = new System.Windows.Media.Animation.DiscreteInt32KeyFrame(); break; case KnownElements.DiscreteInt64KeyFrame: o = new System.Windows.Media.Animation.DiscreteInt64KeyFrame(); break; case KnownElements.DiscreteMatrixKeyFrame: o = new System.Windows.Media.Animation.DiscreteMatrixKeyFrame(); break; case KnownElements.DiscreteObjectKeyFrame: o = new System.Windows.Media.Animation.DiscreteObjectKeyFrame(); break; case KnownElements.DiscretePoint3DKeyFrame: o = new System.Windows.Media.Animation.DiscretePoint3DKeyFrame(); break; case KnownElements.DiscretePointKeyFrame: o = new System.Windows.Media.Animation.DiscretePointKeyFrame(); break; case KnownElements.DiscreteQuaternionKeyFrame: o = new System.Windows.Media.Animation.DiscreteQuaternionKeyFrame(); break; case KnownElements.DiscreteRectKeyFrame: o = new System.Windows.Media.Animation.DiscreteRectKeyFrame(); break; case KnownElements.DiscreteRotation3DKeyFrame: o = new System.Windows.Media.Animation.DiscreteRotation3DKeyFrame(); break; case KnownElements.DiscreteSingleKeyFrame: o = new System.Windows.Media.Animation.DiscreteSingleKeyFrame(); break; case KnownElements.DiscreteSizeKeyFrame: o = new System.Windows.Media.Animation.DiscreteSizeKeyFrame(); break; case KnownElements.DiscreteStringKeyFrame: o = new System.Windows.Media.Animation.DiscreteStringKeyFrame(); break; case KnownElements.DiscreteThicknessKeyFrame: o = new System.Windows.Media.Animation.DiscreteThicknessKeyFrame(); break; case KnownElements.DiscreteVector3DKeyFrame: o = new System.Windows.Media.Animation.DiscreteVector3DKeyFrame(); break; case KnownElements.DiscreteVectorKeyFrame: o = new System.Windows.Media.Animation.DiscreteVectorKeyFrame(); break; case KnownElements.DockPanel: o = new System.Windows.Controls.DockPanel(); break; case KnownElements.DocumentPageView: o = new System.Windows.Controls.Primitives.DocumentPageView(); break; case KnownElements.DocumentReference: o = new System.Windows.Documents.DocumentReference(); break; case KnownElements.DocumentViewer: o = new System.Windows.Controls.DocumentViewer(); break; case KnownElements.DoubleAnimation: o = new System.Windows.Media.Animation.DoubleAnimation(); break; case KnownElements.DoubleAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames(); break; case KnownElements.DoubleAnimationUsingPath: o = new System.Windows.Media.Animation.DoubleAnimationUsingPath(); break; case KnownElements.DoubleCollection: o = new System.Windows.Media.DoubleCollection(); break; case KnownElements.DoubleCollectionConverter: o = new System.Windows.Media.DoubleCollectionConverter(); break; case KnownElements.DoubleConverter: o = new System.ComponentModel.DoubleConverter(); break; case KnownElements.DoubleIListConverter: o = new System.Windows.Media.Converters.DoubleIListConverter(); break; case KnownElements.DoubleKeyFrameCollection: o = new System.Windows.Media.Animation.DoubleKeyFrameCollection(); break; case KnownElements.DrawingBrush: o = new System.Windows.Media.DrawingBrush(); break; case KnownElements.DrawingCollection: o = new System.Windows.Media.DrawingCollection(); break; case KnownElements.DrawingGroup: o = new System.Windows.Media.DrawingGroup(); break; case KnownElements.DrawingImage: o = new System.Windows.Media.DrawingImage(); break; case KnownElements.DrawingVisual: o = new System.Windows.Media.DrawingVisual(); break; case KnownElements.DropShadowBitmapEffect: o = new System.Windows.Media.Effects.DropShadowBitmapEffect(); break; case KnownElements.Duration: o = new System.Windows.Duration(); break; case KnownElements.DurationConverter: o = new System.Windows.DurationConverter(); break; case KnownElements.DynamicResourceExtension: o = new System.Windows.DynamicResourceExtension(); break; case KnownElements.DynamicResourceExtensionConverter: o = new System.Windows.DynamicResourceExtensionConverter(); break; case KnownElements.Ellipse: o = new System.Windows.Shapes.Ellipse(); break; case KnownElements.EllipseGeometry: o = new System.Windows.Media.EllipseGeometry(); break; case KnownElements.EmbossBitmapEffect: o = new System.Windows.Media.Effects.EmbossBitmapEffect(); break; case KnownElements.EmissiveMaterial: o = new System.Windows.Media.Media3D.EmissiveMaterial(); break; case KnownElements.EventSetter: o = new System.Windows.EventSetter(); break; case KnownElements.EventTrigger: o = new System.Windows.EventTrigger(); break; case KnownElements.Expander: o = new System.Windows.Controls.Expander(); break; case KnownElements.ExpressionConverter: o = new System.Windows.ExpressionConverter(); break; case KnownElements.Figure: o = new System.Windows.Documents.Figure(); break; case KnownElements.FigureLength: o = new System.Windows.FigureLength(); break; case KnownElements.FigureLengthConverter: o = new System.Windows.FigureLengthConverter(); break; case KnownElements.FixedDocument: o = new System.Windows.Documents.FixedDocument(); break; case KnownElements.FixedDocumentSequence: o = new System.Windows.Documents.FixedDocumentSequence(); break; case KnownElements.FixedPage: o = new System.Windows.Documents.FixedPage(); break; case KnownElements.Floater: o = new System.Windows.Documents.Floater(); break; case KnownElements.FlowDocument: o = new System.Windows.Documents.FlowDocument(); break; case KnownElements.FlowDocumentPageViewer: o = new System.Windows.Controls.FlowDocumentPageViewer(); break; case KnownElements.FlowDocumentReader: o = new System.Windows.Controls.FlowDocumentReader(); break; case KnownElements.FlowDocumentScrollViewer: o = new System.Windows.Controls.FlowDocumentScrollViewer(); break; case KnownElements.FontFamily: o = new System.Windows.Media.FontFamily(); break; case KnownElements.FontFamilyConverter: o = new System.Windows.Media.FontFamilyConverter(); break; case KnownElements.FontSizeConverter: o = new System.Windows.FontSizeConverter(); break; case KnownElements.FontStretch: o = new System.Windows.FontStretch(); break; case KnownElements.FontStretchConverter: o = new System.Windows.FontStretchConverter(); break; case KnownElements.FontStyle: o = new System.Windows.FontStyle(); break; case KnownElements.FontStyleConverter: o = new System.Windows.FontStyleConverter(); break; case KnownElements.FontWeight: o = new System.Windows.FontWeight(); break; case KnownElements.FontWeightConverter: o = new System.Windows.FontWeightConverter(); break; case KnownElements.FormatConvertedBitmap: o = new System.Windows.Media.Imaging.FormatConvertedBitmap(); break; case KnownElements.Frame: o = new System.Windows.Controls.Frame(); break; case KnownElements.FrameworkContentElement: o = new System.Windows.FrameworkContentElement(); break; case KnownElements.FrameworkElement: o = new System.Windows.FrameworkElement(); break; case KnownElements.FrameworkElementFactory: o = new System.Windows.FrameworkElementFactory(); break; case KnownElements.FrameworkPropertyMetadata: o = new System.Windows.FrameworkPropertyMetadata(); break; case KnownElements.GeneralTransformCollection: o = new System.Windows.Media.GeneralTransformCollection(); break; case KnownElements.GeneralTransformGroup: o = new System.Windows.Media.GeneralTransformGroup(); break; case KnownElements.GeometryCollection: o = new System.Windows.Media.GeometryCollection(); break; case KnownElements.GeometryConverter: o = new System.Windows.Media.GeometryConverter(); break; case KnownElements.GeometryDrawing: o = new System.Windows.Media.GeometryDrawing(); break; case KnownElements.GeometryGroup: o = new System.Windows.Media.GeometryGroup(); break; case KnownElements.GeometryModel3D: o = new System.Windows.Media.Media3D.GeometryModel3D(); break; case KnownElements.GestureRecognizer: o = new System.Windows.Ink.GestureRecognizer(); break; case KnownElements.GifBitmapEncoder: o = new System.Windows.Media.Imaging.GifBitmapEncoder(); break; case KnownElements.GlyphRun: o = new System.Windows.Media.GlyphRun(); break; case KnownElements.GlyphRunDrawing: o = new System.Windows.Media.GlyphRunDrawing(); break; case KnownElements.GlyphTypeface: o = new System.Windows.Media.GlyphTypeface(); break; case KnownElements.Glyphs: o = new System.Windows.Documents.Glyphs(); break; case KnownElements.GradientStop: o = new System.Windows.Media.GradientStop(); break; case KnownElements.GradientStopCollection: o = new System.Windows.Media.GradientStopCollection(); break; case KnownElements.Grid: o = new System.Windows.Controls.Grid(); break; case KnownElements.GridLength: o = new System.Windows.GridLength(); break; case KnownElements.GridLengthConverter: o = new System.Windows.GridLengthConverter(); break; case KnownElements.GridSplitter: o = new System.Windows.Controls.GridSplitter(); break; case KnownElements.GridView: o = new System.Windows.Controls.GridView(); break; case KnownElements.GridViewColumn: o = new System.Windows.Controls.GridViewColumn(); break; case KnownElements.GridViewColumnHeader: o = new System.Windows.Controls.GridViewColumnHeader(); break; case KnownElements.GridViewHeaderRowPresenter: o = new System.Windows.Controls.GridViewHeaderRowPresenter(); break; case KnownElements.GridViewRowPresenter: o = new System.Windows.Controls.GridViewRowPresenter(); break; case KnownElements.GroupBox: o = new System.Windows.Controls.GroupBox(); break; case KnownElements.GroupItem: o = new System.Windows.Controls.GroupItem(); break; case KnownElements.GuidConverter: o = new System.ComponentModel.GuidConverter(); break; case KnownElements.GuidelineSet: o = new System.Windows.Media.GuidelineSet(); break; case KnownElements.HeaderedContentControl: o = new System.Windows.Controls.HeaderedContentControl(); break; case KnownElements.HeaderedItemsControl: o = new System.Windows.Controls.HeaderedItemsControl(); break; case KnownElements.HierarchicalDataTemplate: o = new System.Windows.HierarchicalDataTemplate(); break; case KnownElements.HostVisual: o = new System.Windows.Media.HostVisual(); break; case KnownElements.Hyperlink: o = new System.Windows.Documents.Hyperlink(); break; case KnownElements.Image: o = new System.Windows.Controls.Image(); break; case KnownElements.ImageBrush: o = new System.Windows.Media.ImageBrush(); break; case KnownElements.ImageDrawing: o = new System.Windows.Media.ImageDrawing(); break; case KnownElements.ImageSourceConverter: o = new System.Windows.Media.ImageSourceConverter(); break; case KnownElements.InkCanvas: o = new System.Windows.Controls.InkCanvas(); break; case KnownElements.InkPresenter: o = new System.Windows.Controls.InkPresenter(); break; case KnownElements.InlineUIContainer: o = new System.Windows.Documents.InlineUIContainer(); break; case KnownElements.InputScope: o = new System.Windows.Input.InputScope(); break; case KnownElements.InputScopeConverter: o = new System.Windows.Input.InputScopeConverter(); break; case KnownElements.InputScopeName: o = new System.Windows.Input.InputScopeName(); break; case KnownElements.InputScopeNameConverter: o = new System.Windows.Input.InputScopeNameConverter(); break; case KnownElements.Int16Animation: o = new System.Windows.Media.Animation.Int16Animation(); break; case KnownElements.Int16AnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Int16AnimationUsingKeyFrames(); break; case KnownElements.Int16Converter: o = new System.ComponentModel.Int16Converter(); break; case KnownElements.Int16KeyFrameCollection: o = new System.Windows.Media.Animation.Int16KeyFrameCollection(); break; case KnownElements.Int32Animation: o = new System.Windows.Media.Animation.Int32Animation(); break; case KnownElements.Int32AnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Int32AnimationUsingKeyFrames(); break; case KnownElements.Int32Collection: o = new System.Windows.Media.Int32Collection(); break; case KnownElements.Int32CollectionConverter: o = new System.Windows.Media.Int32CollectionConverter(); break; case KnownElements.Int32Converter: o = new System.ComponentModel.Int32Converter(); break; case KnownElements.Int32KeyFrameCollection: o = new System.Windows.Media.Animation.Int32KeyFrameCollection(); break; case KnownElements.Int32Rect: o = new System.Windows.Int32Rect(); break; case KnownElements.Int32RectConverter: o = new System.Windows.Int32RectConverter(); break; case KnownElements.Int64Animation: o = new System.Windows.Media.Animation.Int64Animation(); break; case KnownElements.Int64AnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Int64AnimationUsingKeyFrames(); break; case KnownElements.Int64Converter: o = new System.ComponentModel.Int64Converter(); break; case KnownElements.Int64KeyFrameCollection: o = new System.Windows.Media.Animation.Int64KeyFrameCollection(); break; case KnownElements.Italic: o = new System.Windows.Documents.Italic(); break; case KnownElements.ItemsControl: o = new System.Windows.Controls.ItemsControl(); break; case KnownElements.ItemsPanelTemplate: o = new System.Windows.Controls.ItemsPanelTemplate(); break; case KnownElements.ItemsPresenter: o = new System.Windows.Controls.ItemsPresenter(); break; case KnownElements.JournalEntryListConverter: o = new System.Windows.Navigation.JournalEntryListConverter(); break; case KnownElements.JournalEntryUnifiedViewConverter: o = new System.Windows.Navigation.JournalEntryUnifiedViewConverter(); break; case KnownElements.JpegBitmapEncoder: o = new System.Windows.Media.Imaging.JpegBitmapEncoder(); break; case KnownElements.KeyBinding: o = new System.Windows.Input.KeyBinding(); break; case KnownElements.KeyConverter: o = new System.Windows.Input.KeyConverter(); break; case KnownElements.KeyGestureConverter: o = new System.Windows.Input.KeyGestureConverter(); break; case KnownElements.KeySpline: o = new System.Windows.Media.Animation.KeySpline(); break; case KnownElements.KeySplineConverter: o = new System.Windows.KeySplineConverter(); break; case KnownElements.KeyTime: o = new System.Windows.Media.Animation.KeyTime(); break; case KnownElements.KeyTimeConverter: o = new System.Windows.KeyTimeConverter(); break; case KnownElements.Label: o = new System.Windows.Controls.Label(); break; case KnownElements.LengthConverter: o = new System.Windows.LengthConverter(); break; case KnownElements.Line: o = new System.Windows.Shapes.Line(); break; case KnownElements.LineBreak: o = new System.Windows.Documents.LineBreak(); break; case KnownElements.LineGeometry: o = new System.Windows.Media.LineGeometry(); break; case KnownElements.LineSegment: o = new System.Windows.Media.LineSegment(); break; case KnownElements.LinearByteKeyFrame: o = new System.Windows.Media.Animation.LinearByteKeyFrame(); break; case KnownElements.LinearColorKeyFrame: o = new System.Windows.Media.Animation.LinearColorKeyFrame(); break; case KnownElements.LinearDecimalKeyFrame: o = new System.Windows.Media.Animation.LinearDecimalKeyFrame(); break; case KnownElements.LinearDoubleKeyFrame: o = new System.Windows.Media.Animation.LinearDoubleKeyFrame(); break; case KnownElements.LinearGradientBrush: o = new System.Windows.Media.LinearGradientBrush(); break; case KnownElements.LinearInt16KeyFrame: o = new System.Windows.Media.Animation.LinearInt16KeyFrame(); break; case KnownElements.LinearInt32KeyFrame: o = new System.Windows.Media.Animation.LinearInt32KeyFrame(); break; case KnownElements.LinearInt64KeyFrame: o = new System.Windows.Media.Animation.LinearInt64KeyFrame(); break; case KnownElements.LinearPoint3DKeyFrame: o = new System.Windows.Media.Animation.LinearPoint3DKeyFrame(); break; case KnownElements.LinearPointKeyFrame: o = new System.Windows.Media.Animation.LinearPointKeyFrame(); break; case KnownElements.LinearQuaternionKeyFrame: o = new System.Windows.Media.Animation.LinearQuaternionKeyFrame(); break; case KnownElements.LinearRectKeyFrame: o = new System.Windows.Media.Animation.LinearRectKeyFrame(); break; case KnownElements.LinearRotation3DKeyFrame: o = new System.Windows.Media.Animation.LinearRotation3DKeyFrame(); break; case KnownElements.LinearSingleKeyFrame: o = new System.Windows.Media.Animation.LinearSingleKeyFrame(); break; case KnownElements.LinearSizeKeyFrame: o = new System.Windows.Media.Animation.LinearSizeKeyFrame(); break; case KnownElements.LinearThicknessKeyFrame: o = new System.Windows.Media.Animation.LinearThicknessKeyFrame(); break; case KnownElements.LinearVector3DKeyFrame: o = new System.Windows.Media.Animation.LinearVector3DKeyFrame(); break; case KnownElements.LinearVectorKeyFrame: o = new System.Windows.Media.Animation.LinearVectorKeyFrame(); break; case KnownElements.List: o = new System.Windows.Documents.List(); break; case KnownElements.ListBox: o = new System.Windows.Controls.ListBox(); break; case KnownElements.ListBoxItem: o = new System.Windows.Controls.ListBoxItem(); break; case KnownElements.ListItem: o = new System.Windows.Documents.ListItem(); break; case KnownElements.ListView: o = new System.Windows.Controls.ListView(); break; case KnownElements.ListViewItem: o = new System.Windows.Controls.ListViewItem(); break; case KnownElements.MaterialCollection: o = new System.Windows.Media.Media3D.MaterialCollection(); break; case KnownElements.MaterialGroup: o = new System.Windows.Media.Media3D.MaterialGroup(); break; case KnownElements.Matrix: o = new System.Windows.Media.Matrix(); break; case KnownElements.Matrix3D: o = new System.Windows.Media.Media3D.Matrix3D(); break; case KnownElements.Matrix3DConverter: o = new System.Windows.Media.Media3D.Matrix3DConverter(); break; case KnownElements.MatrixAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.MatrixAnimationUsingKeyFrames(); break; case KnownElements.MatrixAnimationUsingPath: o = new System.Windows.Media.Animation.MatrixAnimationUsingPath(); break; case KnownElements.MatrixCamera: o = new System.Windows.Media.Media3D.MatrixCamera(); break; case KnownElements.MatrixConverter: o = new System.Windows.Media.MatrixConverter(); break; case KnownElements.MatrixKeyFrameCollection: o = new System.Windows.Media.Animation.MatrixKeyFrameCollection(); break; case KnownElements.MatrixTransform: o = new System.Windows.Media.MatrixTransform(); break; case KnownElements.MatrixTransform3D: o = new System.Windows.Media.Media3D.MatrixTransform3D(); break; case KnownElements.MediaElement: o = new System.Windows.Controls.MediaElement(); break; case KnownElements.MediaPlayer: o = new System.Windows.Media.MediaPlayer(); break; case KnownElements.MediaTimeline: o = new System.Windows.Media.MediaTimeline(); break; case KnownElements.Menu: o = new System.Windows.Controls.Menu(); break; case KnownElements.MenuItem: o = new System.Windows.Controls.MenuItem(); break; case KnownElements.MenuScrollingVisibilityConverter: o = new System.Windows.Controls.MenuScrollingVisibilityConverter(); break; case KnownElements.MeshGeometry3D: o = new System.Windows.Media.Media3D.MeshGeometry3D(); break; case KnownElements.Model3DCollection: o = new System.Windows.Media.Media3D.Model3DCollection(); break; case KnownElements.Model3DGroup: o = new System.Windows.Media.Media3D.Model3DGroup(); break; case KnownElements.ModelVisual3D: o = new System.Windows.Media.Media3D.ModelVisual3D(); break; case KnownElements.ModifierKeysConverter: o = new System.Windows.Input.ModifierKeysConverter(); break; case KnownElements.MouseActionConverter: o = new System.Windows.Input.MouseActionConverter(); break; case KnownElements.MouseBinding: o = new System.Windows.Input.MouseBinding(); break; case KnownElements.MouseGesture: o = new System.Windows.Input.MouseGesture(); break; case KnownElements.MouseGestureConverter: o = new System.Windows.Input.MouseGestureConverter(); break; case KnownElements.MultiBinding: o = new System.Windows.Data.MultiBinding(); break; case KnownElements.MultiDataTrigger: o = new System.Windows.MultiDataTrigger(); break; case KnownElements.MultiTrigger: o = new System.Windows.MultiTrigger(); break; case KnownElements.NameScope: o = new System.Windows.NameScope(); break; case KnownElements.NavigationWindow: o = new System.Windows.Navigation.NavigationWindow(); break; case KnownElements.NullExtension: o = new System.Windows.Markup.NullExtension(); break; case KnownElements.NullableBoolConverter: o = new System.Windows.NullableBoolConverter(); break; case KnownElements.NumberSubstitution: o = new System.Windows.Media.NumberSubstitution(); break; case KnownElements.Object: o = new System.Object(); break; case KnownElements.ObjectAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ObjectAnimationUsingKeyFrames(); break; case KnownElements.ObjectDataProvider: o = new System.Windows.Data.ObjectDataProvider(); break; case KnownElements.ObjectKeyFrameCollection: o = new System.Windows.Media.Animation.ObjectKeyFrameCollection(); break; case KnownElements.OrthographicCamera: o = new System.Windows.Media.Media3D.OrthographicCamera(); break; case KnownElements.OuterGlowBitmapEffect: o = new System.Windows.Media.Effects.OuterGlowBitmapEffect(); break; case KnownElements.Page: o = new System.Windows.Controls.Page(); break; case KnownElements.PageContent: o = new System.Windows.Documents.PageContent(); break; case KnownElements.Paragraph: o = new System.Windows.Documents.Paragraph(); break; case KnownElements.ParallelTimeline: o = new System.Windows.Media.Animation.ParallelTimeline(); break; case KnownElements.ParserContext: o = new System.Windows.Markup.ParserContext(); break; case KnownElements.PasswordBox: o = new System.Windows.Controls.PasswordBox(); break; case KnownElements.Path: o = new System.Windows.Shapes.Path(); break; case KnownElements.PathFigure: o = new System.Windows.Media.PathFigure(); break; case KnownElements.PathFigureCollection: o = new System.Windows.Media.PathFigureCollection(); break; case KnownElements.PathFigureCollectionConverter: o = new System.Windows.Media.PathFigureCollectionConverter(); break; case KnownElements.PathGeometry: o = new System.Windows.Media.PathGeometry(); break; case KnownElements.PathSegmentCollection: o = new System.Windows.Media.PathSegmentCollection(); break; case KnownElements.PauseStoryboard: o = new System.Windows.Media.Animation.PauseStoryboard(); break; case KnownElements.Pen: o = new System.Windows.Media.Pen(); break; case KnownElements.PerspectiveCamera: o = new System.Windows.Media.Media3D.PerspectiveCamera(); break; case KnownElements.PixelFormat: o = new System.Windows.Media.PixelFormat(); break; case KnownElements.PixelFormatConverter: o = new System.Windows.Media.PixelFormatConverter(); break; case KnownElements.PngBitmapEncoder: o = new System.Windows.Media.Imaging.PngBitmapEncoder(); break; case KnownElements.Point: o = new System.Windows.Point(); break; case KnownElements.Point3D: o = new System.Windows.Media.Media3D.Point3D(); break; case KnownElements.Point3DAnimation: o = new System.Windows.Media.Animation.Point3DAnimation(); break; case KnownElements.Point3DAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Point3DAnimationUsingKeyFrames(); break; case KnownElements.Point3DCollection: o = new System.Windows.Media.Media3D.Point3DCollection(); break; case KnownElements.Point3DCollectionConverter: o = new System.Windows.Media.Media3D.Point3DCollectionConverter(); break; case KnownElements.Point3DConverter: o = new System.Windows.Media.Media3D.Point3DConverter(); break; case KnownElements.Point3DKeyFrameCollection: o = new System.Windows.Media.Animation.Point3DKeyFrameCollection(); break; case KnownElements.Point4D: o = new System.Windows.Media.Media3D.Point4D(); break; case KnownElements.Point4DConverter: o = new System.Windows.Media.Media3D.Point4DConverter(); break; case KnownElements.PointAnimation: o = new System.Windows.Media.Animation.PointAnimation(); break; case KnownElements.PointAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.PointAnimationUsingKeyFrames(); break; case KnownElements.PointAnimationUsingPath: o = new System.Windows.Media.Animation.PointAnimationUsingPath(); break; case KnownElements.PointCollection: o = new System.Windows.Media.PointCollection(); break; case KnownElements.PointCollectionConverter: o = new System.Windows.Media.PointCollectionConverter(); break; case KnownElements.PointConverter: o = new System.Windows.PointConverter(); break; case KnownElements.PointIListConverter: o = new System.Windows.Media.Converters.PointIListConverter(); break; case KnownElements.PointKeyFrameCollection: o = new System.Windows.Media.Animation.PointKeyFrameCollection(); break; case KnownElements.PointLight: o = new System.Windows.Media.Media3D.PointLight(); break; case KnownElements.PolyBezierSegment: o = new System.Windows.Media.PolyBezierSegment(); break; case KnownElements.PolyLineSegment: o = new System.Windows.Media.PolyLineSegment(); break; case KnownElements.PolyQuadraticBezierSegment: o = new System.Windows.Media.PolyQuadraticBezierSegment(); break; case KnownElements.Polygon: o = new System.Windows.Shapes.Polygon(); break; case KnownElements.Polyline: o = new System.Windows.Shapes.Polyline(); break; case KnownElements.Popup: o = new System.Windows.Controls.Primitives.Popup(); break; case KnownElements.PriorityBinding: o = new System.Windows.Data.PriorityBinding(); break; case KnownElements.ProgressBar: o = new System.Windows.Controls.ProgressBar(); break; case KnownElements.PropertyPathConverter: o = new System.Windows.PropertyPathConverter(); break; case KnownElements.QuadraticBezierSegment: o = new System.Windows.Media.QuadraticBezierSegment(); break; case KnownElements.Quaternion: o = new System.Windows.Media.Media3D.Quaternion(); break; case KnownElements.QuaternionAnimation: o = new System.Windows.Media.Animation.QuaternionAnimation(); break; case KnownElements.QuaternionAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.QuaternionAnimationUsingKeyFrames(); break; case KnownElements.QuaternionConverter: o = new System.Windows.Media.Media3D.QuaternionConverter(); break; case KnownElements.QuaternionKeyFrameCollection: o = new System.Windows.Media.Animation.QuaternionKeyFrameCollection(); break; case KnownElements.QuaternionRotation3D: o = new System.Windows.Media.Media3D.QuaternionRotation3D(); break; case KnownElements.RadialGradientBrush: o = new System.Windows.Media.RadialGradientBrush(); break; case KnownElements.RadioButton: o = new System.Windows.Controls.RadioButton(); break; case KnownElements.Rect: o = new System.Windows.Rect(); break; case KnownElements.Rect3D: o = new System.Windows.Media.Media3D.Rect3D(); break; case KnownElements.Rect3DConverter: o = new System.Windows.Media.Media3D.Rect3DConverter(); break; case KnownElements.RectAnimation: o = new System.Windows.Media.Animation.RectAnimation(); break; case KnownElements.RectAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.RectAnimationUsingKeyFrames(); break; case KnownElements.RectConverter: o = new System.Windows.RectConverter(); break; case KnownElements.RectKeyFrameCollection: o = new System.Windows.Media.Animation.RectKeyFrameCollection(); break; case KnownElements.Rectangle: o = new System.Windows.Shapes.Rectangle(); break; case KnownElements.RectangleGeometry: o = new System.Windows.Media.RectangleGeometry(); break; case KnownElements.RelativeSource: o = new System.Windows.Data.RelativeSource(); break; case KnownElements.RemoveStoryboard: o = new System.Windows.Media.Animation.RemoveStoryboard(); break; case KnownElements.RepeatBehavior: o = new System.Windows.Media.Animation.RepeatBehavior(); break; case KnownElements.RepeatBehaviorConverter: o = new System.Windows.Media.Animation.RepeatBehaviorConverter(); break; case KnownElements.RepeatButton: o = new System.Windows.Controls.Primitives.RepeatButton(); break; case KnownElements.ResizeGrip: o = new System.Windows.Controls.Primitives.ResizeGrip(); break; case KnownElements.ResourceDictionary: o = new System.Windows.ResourceDictionary(); break; case KnownElements.ResumeStoryboard: o = new System.Windows.Media.Animation.ResumeStoryboard(); break; case KnownElements.RichTextBox: o = new System.Windows.Controls.RichTextBox(); break; case KnownElements.RotateTransform: o = new System.Windows.Media.RotateTransform(); break; case KnownElements.RotateTransform3D: o = new System.Windows.Media.Media3D.RotateTransform3D(); break; case KnownElements.Rotation3DAnimation: o = new System.Windows.Media.Animation.Rotation3DAnimation(); break; case KnownElements.Rotation3DAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Rotation3DAnimationUsingKeyFrames(); break; case KnownElements.Rotation3DKeyFrameCollection: o = new System.Windows.Media.Animation.Rotation3DKeyFrameCollection(); break; case KnownElements.RoutedCommand: o = new System.Windows.Input.RoutedCommand(); break; case KnownElements.RoutedEventConverter: o = new System.Windows.Markup.RoutedEventConverter(); break; case KnownElements.RoutedUICommand: o = new System.Windows.Input.RoutedUICommand(); break; case KnownElements.RowDefinition: o = new System.Windows.Controls.RowDefinition(); break; case KnownElements.Run: o = new System.Windows.Documents.Run(); break; case KnownElements.SByteConverter: o = new System.ComponentModel.SByteConverter(); break; case KnownElements.ScaleTransform: o = new System.Windows.Media.ScaleTransform(); break; case KnownElements.ScaleTransform3D: o = new System.Windows.Media.Media3D.ScaleTransform3D(); break; case KnownElements.ScrollBar: o = new System.Windows.Controls.Primitives.ScrollBar(); break; case KnownElements.ScrollContentPresenter: o = new System.Windows.Controls.ScrollContentPresenter(); break; case KnownElements.ScrollViewer: o = new System.Windows.Controls.ScrollViewer(); break; case KnownElements.Section: o = new System.Windows.Documents.Section(); break; case KnownElements.SeekStoryboard: o = new System.Windows.Media.Animation.SeekStoryboard(); break; case KnownElements.Separator: o = new System.Windows.Controls.Separator(); break; case KnownElements.SetStoryboardSpeedRatio: o = new System.Windows.Media.Animation.SetStoryboardSpeedRatio(); break; case KnownElements.Setter: o = new System.Windows.Setter(); break; case KnownElements.SingleAnimation: o = new System.Windows.Media.Animation.SingleAnimation(); break; case KnownElements.SingleAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.SingleAnimationUsingKeyFrames(); break; case KnownElements.SingleConverter: o = new System.ComponentModel.SingleConverter(); break; case KnownElements.SingleKeyFrameCollection: o = new System.Windows.Media.Animation.SingleKeyFrameCollection(); break; case KnownElements.Size: o = new System.Windows.Size(); break; case KnownElements.Size3D: o = new System.Windows.Media.Media3D.Size3D(); break; case KnownElements.Size3DConverter: o = new System.Windows.Media.Media3D.Size3DConverter(); break; case KnownElements.SizeAnimation: o = new System.Windows.Media.Animation.SizeAnimation(); break; case KnownElements.SizeAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.SizeAnimationUsingKeyFrames(); break; case KnownElements.SizeConverter: o = new System.Windows.SizeConverter(); break; case KnownElements.SizeKeyFrameCollection: o = new System.Windows.Media.Animation.SizeKeyFrameCollection(); break; case KnownElements.SkewTransform: o = new System.Windows.Media.SkewTransform(); break; case KnownElements.SkipStoryboardToFill: o = new System.Windows.Media.Animation.SkipStoryboardToFill(); break; case KnownElements.Slider: o = new System.Windows.Controls.Slider(); break; case KnownElements.SolidColorBrush: o = new System.Windows.Media.SolidColorBrush(); break; case KnownElements.SoundPlayerAction: o = new System.Windows.Controls.SoundPlayerAction(); break; case KnownElements.Span: o = new System.Windows.Documents.Span(); break; case KnownElements.SpecularMaterial: o = new System.Windows.Media.Media3D.SpecularMaterial(); break; case KnownElements.SplineByteKeyFrame: o = new System.Windows.Media.Animation.SplineByteKeyFrame(); break; case KnownElements.SplineColorKeyFrame: o = new System.Windows.Media.Animation.SplineColorKeyFrame(); break; case KnownElements.SplineDecimalKeyFrame: o = new System.Windows.Media.Animation.SplineDecimalKeyFrame(); break; case KnownElements.SplineDoubleKeyFrame: o = new System.Windows.Media.Animation.SplineDoubleKeyFrame(); break; case KnownElements.SplineInt16KeyFrame: o = new System.Windows.Media.Animation.SplineInt16KeyFrame(); break; case KnownElements.SplineInt32KeyFrame: o = new System.Windows.Media.Animation.SplineInt32KeyFrame(); break; case KnownElements.SplineInt64KeyFrame: o = new System.Windows.Media.Animation.SplineInt64KeyFrame(); break; case KnownElements.SplinePoint3DKeyFrame: o = new System.Windows.Media.Animation.SplinePoint3DKeyFrame(); break; case KnownElements.SplinePointKeyFrame: o = new System.Windows.Media.Animation.SplinePointKeyFrame(); break; case KnownElements.SplineQuaternionKeyFrame: o = new System.Windows.Media.Animation.SplineQuaternionKeyFrame(); break; case KnownElements.SplineRectKeyFrame: o = new System.Windows.Media.Animation.SplineRectKeyFrame(); break; case KnownElements.SplineRotation3DKeyFrame: o = new System.Windows.Media.Animation.SplineRotation3DKeyFrame(); break; case KnownElements.SplineSingleKeyFrame: o = new System.Windows.Media.Animation.SplineSingleKeyFrame(); break; case KnownElements.SplineSizeKeyFrame: o = new System.Windows.Media.Animation.SplineSizeKeyFrame(); break; case KnownElements.SplineThicknessKeyFrame: o = new System.Windows.Media.Animation.SplineThicknessKeyFrame(); break; case KnownElements.SplineVector3DKeyFrame: o = new System.Windows.Media.Animation.SplineVector3DKeyFrame(); break; case KnownElements.SplineVectorKeyFrame: o = new System.Windows.Media.Animation.SplineVectorKeyFrame(); break; case KnownElements.SpotLight: o = new System.Windows.Media.Media3D.SpotLight(); break; case KnownElements.StackPanel: o = new System.Windows.Controls.StackPanel(); break; case KnownElements.StaticExtension: o = new System.Windows.Markup.StaticExtension(); break; case KnownElements.StaticResourceExtension: o = new System.Windows.StaticResourceExtension(); break; case KnownElements.StatusBar: o = new System.Windows.Controls.Primitives.StatusBar(); break; case KnownElements.StatusBarItem: o = new System.Windows.Controls.Primitives.StatusBarItem(); break; case KnownElements.StopStoryboard: o = new System.Windows.Media.Animation.StopStoryboard(); break; case KnownElements.Storyboard: o = new System.Windows.Media.Animation.Storyboard(); break; case KnownElements.StreamGeometry: o = new System.Windows.Media.StreamGeometry(); break; case KnownElements.StreamResourceInfo: o = new System.Windows.Resources.StreamResourceInfo(); break; case KnownElements.StringAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.StringAnimationUsingKeyFrames(); break; case KnownElements.StringConverter: o = new System.ComponentModel.StringConverter(); break; case KnownElements.StringKeyFrameCollection: o = new System.Windows.Media.Animation.StringKeyFrameCollection(); break; case KnownElements.StrokeCollection: o = new System.Windows.Ink.StrokeCollection(); break; case KnownElements.StrokeCollectionConverter: o = new System.Windows.StrokeCollectionConverter(); break; case KnownElements.Style: o = new System.Windows.Style(); break; case KnownElements.TabControl: o = new System.Windows.Controls.TabControl(); break; case KnownElements.TabItem: o = new System.Windows.Controls.TabItem(); break; case KnownElements.TabPanel: o = new System.Windows.Controls.Primitives.TabPanel(); break; case KnownElements.Table: o = new System.Windows.Documents.Table(); break; case KnownElements.TableCell: o = new System.Windows.Documents.TableCell(); break; case KnownElements.TableColumn: o = new System.Windows.Documents.TableColumn(); break; case KnownElements.TableRow: o = new System.Windows.Documents.TableRow(); break; case KnownElements.TableRowGroup: o = new System.Windows.Documents.TableRowGroup(); break; case KnownElements.TemplateBindingExpressionConverter: o = new System.Windows.TemplateBindingExpressionConverter(); break; case KnownElements.TemplateBindingExtension: o = new System.Windows.TemplateBindingExtension(); break; case KnownElements.TemplateBindingExtensionConverter: o = new System.Windows.TemplateBindingExtensionConverter(); break; case KnownElements.TemplateKeyConverter: o = new System.Windows.Markup.TemplateKeyConverter(); break; case KnownElements.TextBlock: o = new System.Windows.Controls.TextBlock(); break; case KnownElements.TextBox: o = new System.Windows.Controls.TextBox(); break; case KnownElements.TextDecoration: o = new System.Windows.TextDecoration(); break; case KnownElements.TextDecorationCollection: o = new System.Windows.TextDecorationCollection(); break; case KnownElements.TextDecorationCollectionConverter: o = new System.Windows.TextDecorationCollectionConverter(); break; case KnownElements.TextEffect: o = new System.Windows.Media.TextEffect(); break; case KnownElements.TextEffectCollection: o = new System.Windows.Media.TextEffectCollection(); break; case KnownElements.ThemeDictionaryExtension: o = new System.Windows.ThemeDictionaryExtension(); break; case KnownElements.Thickness: o = new System.Windows.Thickness(); break; case KnownElements.ThicknessAnimation: o = new System.Windows.Media.Animation.ThicknessAnimation(); break; case KnownElements.ThicknessAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ThicknessAnimationUsingKeyFrames(); break; case KnownElements.ThicknessConverter: o = new System.Windows.ThicknessConverter(); break; case KnownElements.ThicknessKeyFrameCollection: o = new System.Windows.Media.Animation.ThicknessKeyFrameCollection(); break; case KnownElements.Thumb: o = new System.Windows.Controls.Primitives.Thumb(); break; case KnownElements.TickBar: o = new System.Windows.Controls.Primitives.TickBar(); break; case KnownElements.TiffBitmapEncoder: o = new System.Windows.Media.Imaging.TiffBitmapEncoder(); break; case KnownElements.TimeSpanConverter: o = new System.ComponentModel.TimeSpanConverter(); break; case KnownElements.TimelineCollection: o = new System.Windows.Media.Animation.TimelineCollection(); break; case KnownElements.ToggleButton: o = new System.Windows.Controls.Primitives.ToggleButton(); break; case KnownElements.ToolBar: o = new System.Windows.Controls.ToolBar(); break; case KnownElements.ToolBarOverflowPanel: o = new System.Windows.Controls.Primitives.ToolBarOverflowPanel(); break; case KnownElements.ToolBarPanel: o = new System.Windows.Controls.Primitives.ToolBarPanel(); break; case KnownElements.ToolBarTray: o = new System.Windows.Controls.ToolBarTray(); break; case KnownElements.ToolTip: o = new System.Windows.Controls.ToolTip(); break; case KnownElements.Track: o = new System.Windows.Controls.Primitives.Track(); break; case KnownElements.Transform3DCollection: o = new System.Windows.Media.Media3D.Transform3DCollection(); break; case KnownElements.Transform3DGroup: o = new System.Windows.Media.Media3D.Transform3DGroup(); break; case KnownElements.TransformCollection: o = new System.Windows.Media.TransformCollection(); break; case KnownElements.TransformConverter: o = new System.Windows.Media.TransformConverter(); break; case KnownElements.TransformGroup: o = new System.Windows.Media.TransformGroup(); break; case KnownElements.TransformedBitmap: o = new System.Windows.Media.Imaging.TransformedBitmap(); break; case KnownElements.TranslateTransform: o = new System.Windows.Media.TranslateTransform(); break; case KnownElements.TranslateTransform3D: o = new System.Windows.Media.Media3D.TranslateTransform3D(); break; case KnownElements.TreeView: o = new System.Windows.Controls.TreeView(); break; case KnownElements.TreeViewItem: o = new System.Windows.Controls.TreeViewItem(); break; case KnownElements.Trigger: o = new System.Windows.Trigger(); break; case KnownElements.TypeExtension: o = new System.Windows.Markup.TypeExtension(); break; case KnownElements.TypeTypeConverter: o = new System.Windows.Markup.TypeTypeConverter(); break; case KnownElements.UIElement: o = new System.Windows.UIElement(); break; case KnownElements.UInt16Converter: o = new System.ComponentModel.UInt16Converter(); break; case KnownElements.UInt32Converter: o = new System.ComponentModel.UInt32Converter(); break; case KnownElements.UInt64Converter: o = new System.ComponentModel.UInt64Converter(); break; case KnownElements.UShortIListConverter: o = new System.Windows.Media.Converters.UShortIListConverter(); break; case KnownElements.Underline: o = new System.Windows.Documents.Underline(); break; case KnownElements.UniformGrid: o = new System.Windows.Controls.Primitives.UniformGrid(); break; case KnownElements.UriTypeConverter: o = new System.UriTypeConverter(); break; case KnownElements.UserControl: o = new System.Windows.Controls.UserControl(); break; case KnownElements.Vector: o = new System.Windows.Vector(); break; case KnownElements.Vector3D: o = new System.Windows.Media.Media3D.Vector3D(); break; case KnownElements.Vector3DAnimation: o = new System.Windows.Media.Animation.Vector3DAnimation(); break; case KnownElements.Vector3DAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Vector3DAnimationUsingKeyFrames(); break; case KnownElements.Vector3DCollection: o = new System.Windows.Media.Media3D.Vector3DCollection(); break; case KnownElements.Vector3DCollectionConverter: o = new System.Windows.Media.Media3D.Vector3DCollectionConverter(); break; case KnownElements.Vector3DConverter: o = new System.Windows.Media.Media3D.Vector3DConverter(); break; case KnownElements.Vector3DKeyFrameCollection: o = new System.Windows.Media.Animation.Vector3DKeyFrameCollection(); break; case KnownElements.VectorAnimation: o = new System.Windows.Media.Animation.VectorAnimation(); break; case KnownElements.VectorAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.VectorAnimationUsingKeyFrames(); break; case KnownElements.VectorCollection: o = new System.Windows.Media.VectorCollection(); break; case KnownElements.VectorCollectionConverter: o = new System.Windows.Media.VectorCollectionConverter(); break; case KnownElements.VectorConverter: o = new System.Windows.VectorConverter(); break; case KnownElements.VectorKeyFrameCollection: o = new System.Windows.Media.Animation.VectorKeyFrameCollection(); break; case KnownElements.VideoDrawing: o = new System.Windows.Media.VideoDrawing(); break; case KnownElements.Viewbox: o = new System.Windows.Controls.Viewbox(); break; case KnownElements.Viewport3D: o = new System.Windows.Controls.Viewport3D(); break; case KnownElements.Viewport3DVisual: o = new System.Windows.Media.Media3D.Viewport3DVisual(); break; case KnownElements.VirtualizingStackPanel: o = new System.Windows.Controls.VirtualizingStackPanel(); break; case KnownElements.VisualBrush: o = new System.Windows.Media.VisualBrush(); break; case KnownElements.Window: o = new System.Windows.Window(); break; case KnownElements.WmpBitmapEncoder: o = new System.Windows.Media.Imaging.WmpBitmapEncoder(); break; case KnownElements.WrapPanel: o = new System.Windows.Controls.WrapPanel(); break; case KnownElements.XamlBrushSerializer: o = new System.Windows.Markup.XamlBrushSerializer(); break; case KnownElements.XamlInt32CollectionSerializer: o = new System.Windows.Markup.XamlInt32CollectionSerializer(); break; case KnownElements.XamlPathDataSerializer: o = new System.Windows.Markup.XamlPathDataSerializer(); break; case KnownElements.XamlPoint3DCollectionSerializer: o = new System.Windows.Markup.XamlPoint3DCollectionSerializer(); break; case KnownElements.XamlPointCollectionSerializer: o = new System.Windows.Markup.XamlPointCollectionSerializer(); break; case KnownElements.XamlStyleSerializer: o = new System.Windows.Markup.XamlStyleSerializer(); break; case KnownElements.XamlTemplateSerializer: o = new System.Windows.Markup.XamlTemplateSerializer(); break; case KnownElements.XamlVector3DCollectionSerializer: o = new System.Windows.Markup.XamlVector3DCollectionSerializer(); break; case KnownElements.XmlDataProvider: o = new System.Windows.Data.XmlDataProvider(); break; case KnownElements.XmlLanguageConverter: o = new System.Windows.Markup.XmlLanguageConverter(); break; case KnownElements.XmlNamespaceMapping: o = new System.Windows.Data.XmlNamespaceMapping(); break; case KnownElements.ZoomPercentageConverter: o = new System.Windows.Documents.ZoomPercentageConverter(); break; } return o; }
private static void _Draw(PointerBitmap ptr, System.Windows.Media.PixelFormat fmt, Action <System.Windows.Media.DrawingContext> onDraw) { // https://stackoverflow.com/questions/88488/getting-a-drawingcontext-for-a-wpf-writeablebitmap // https://social.msdn.microsoft.com/Forums/vstudio/en-US/84299fec-94a1-49a1-b3bc-ec48b8bdf04f/getting-a-drawingcontext-for-a-writeablebitmap?forum=wpf // https://stackoverflow.com/questions/7250282/how-to-draw-directly-on-bitmap-bitmapsource-writeablebitmap-in-wpf var src = BitmapSource.Create(ptr.Info.Width, ptr.Info.Height, 96, 96, fmt, null, ptr.Pointer, ptr.Info.BitmapByteSize, ptr.Info.StepByteSize); var dv = new System.Windows.Media.DrawingVisual(); var dc = dv.RenderOpen(); { // dc.DrawImage(src, new System.Windows.Rect(0, 0, src.PixelWidth, src.PixelHeight)); dc.DrawRectangle(System.Windows.Media.Brushes.Green, null, new System.Windows.Rect(50, 50, 200, 100)); onDraw(dc); } var rt = new RenderTargetBitmap(src.PixelWidth, src.PixelHeight, src.DpiX, src.DpiY, System.Windows.Media.PixelFormats.Pbgra32); rt.Render(dv); // ptr.Bitmap.SetPixels(0, 0, rt.ToMemoryBitmap()); rt.CopyPixels(System.Windows.Int32Rect.Empty, ptr.Pointer, ptr.Info.BitmapByteSize, ptr.Info.StepByteSize); }
/// <summary> /// Save image as file from WriteableBitmap /// </summary> /// <param name="wtbBmp">WriteableBitmap</param> /// <param name="path">full path with file name</param> public static void SaveWriteableBitmap(WriteableBitmap wtbBmp, string path) { if (wtbBmp == null) { return; } RenderTargetBitmap rtbitmap = new RenderTargetBitmap(wtbBmp.PixelWidth, wtbBmp.PixelHeight, wtbBmp.DpiX, wtbBmp.DpiY, System.Windows.Media.PixelFormats.Default); System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); using (var dc = drawingVisual.RenderOpen()) { dc.DrawImage(wtbBmp, new Rect(0, 0, wtbBmp.Width, wtbBmp.Height)); } rtbitmap.Render(drawingVisual); JpegBitmapEncoder bitmapEncoder = new JpegBitmapEncoder(); bitmapEncoder.Frames.Add(BitmapFrame.Create(rtbitmap)); //string strDir = @"Images\"; //string strpath = strDir + DateTime.Now.ToString("yyyyMMddfff") + ".jpg"; if (!File.Exists(path)) { MemoryStream ms = new MemoryStream(); //bitmapEncoder.Save(File.OpenWrite(path)); bitmapEncoder.Save(ms); System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(ms); bitmap.Save(path); } }
public void Save(string fileName, bool compositeBackground) { iApp.File.EnsureDirectoryExistsForFile(fileName); var target = compositeBackground ? backCanvas : (FrameworkElement)inkCanvas; var bitmap = new RenderTargetBitmap((int)target.ActualWidth, (int)target.ActualHeight, 96, 96, System.Windows.Media.PixelFormats.Default); var visual = new System.Windows.Media.DrawingVisual(); using (var context = visual.RenderOpen()) { var brush = new System.Windows.Media.VisualBrush(target); context.DrawRectangle(brush, null, new Rect(0, 0, target.ActualWidth, target.ActualHeight)); } bitmap.Render(visual); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmap)); using (var stream = new MemoryStream()) { encoder.Save(stream); System.IO.File.WriteAllBytes(fileName, stream.ToArray()); } var handler = DrawingSaved; if (handler != null) { handler(Pair ?? this, new SaveEventArgs(fileName)); } }
public static Image <Emgu.CV.Structure.Rgb, float> ConvertImage2RGB(WriteableBitmap wtbBmp, Rect useToCheckFaceRect) { RenderTargetBitmap rtbitmap = new RenderTargetBitmap(wtbBmp.PixelWidth, wtbBmp.PixelHeight, wtbBmp.DpiX, wtbBmp.DpiY, System.Windows.Media.PixelFormats.Default); System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); using (var dc = drawingVisual.RenderOpen()) { dc.DrawImage(wtbBmp, new Rect(0, 0, wtbBmp.Width, wtbBmp.Height)); } rtbitmap.Render(drawingVisual); JpegBitmapEncoder bitmapEncoder = new JpegBitmapEncoder(); bitmapEncoder.Frames.Add(BitmapFrame.Create(rtbitmap)); MemoryStream ms = new MemoryStream(); bitmapEncoder.Save(ms); using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(ms)) { Image <Emgu.CV.Structure.Rgb, float> image = new Image <Emgu.CV.Structure.Rgb, float>(bitmap).GetSubRect(new System.Drawing.Rectangle((int)useToCheckFaceRect.X, (int)useToCheckFaceRect.Y, (int)useToCheckFaceRect.Width, (int)useToCheckFaceRect.Height)).Convert <Emgu.CV.Structure.Rgb, float>(); bitmapEncoder = null; rtbitmap = null; drawingVisual = null; return(image); } }
public static Byte[] BitmapImage2Byte(BitmapImage imageSource) { try { //resize ve 32x32 Rect rect = new Rect(0, 0, 32, 32); // Create a DrawingVisual/Context to render with System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); using (System.Windows.Media.DrawingContext drawingContext = drawingVisual.RenderOpen()) { drawingContext.DrawImage(imageSource, rect); } RenderTargetBitmap resizedImage = new RenderTargetBitmap(32, 32, 96, 96, System.Windows.Media.PixelFormats.Default); resizedImage.Render(drawingVisual); // MemoryStream memStream = new MemoryStream(); PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(resizedImage)); encoder.Save(memStream); return(memStream.GetBuffer()); } catch { return(new Byte[0]); } }
public static BitmapSource Capture(FrameworkElement view) { if (view == null) { throw new ArgumentNullException(nameof(view)); } var width = (int)view.ActualWidth; var height = (int)view.ActualHeight; if (width <= 0 || height <= 0) { return(null); } var bmp = new RenderTargetBitmap( width, height, 96, // TODO: Handle other DPI settings 96, System.Windows.Media.PixelFormats.Default); var dv = new System.Windows.Media.DrawingVisual(); using (var dc = dv.RenderOpen()) { dc.DrawRectangle( new System.Windows.Media.VisualBrush(view), null, new Rect(0, 0, width, height)); } bmp.Render(dv); return(bmp); }
public _DrawingContext(System.Windows.Media.Imaging.RenderTargetBitmap rt) { _RenderTarget = rt; _Visual = new System.Windows.Media.DrawingVisual(); _Context = _Visual.RenderOpen(); SetContext(_Context); }
// Create a DrawingVisual that contains an ellipse. private System.Windows.Media.DrawingVisual CreateDrawingVisualEllipses() { System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); drawingContext.DrawEllipse(Brushes.Maroon, null, new Point(430, 136), 20, 20); drawingContext.Close(); return(drawingVisual); }
public void DrawStringTest() { const int ColumnCount = 10; const int MaxDrawCount = 30; // use int.MaxValue to draw them all const double fontSize = 50d; // the height of each cell has to include over/under hanging glyphs var cellSize = new Size(fontSize, fontSize * _glyphTypeface.Height); var glyphs = from glyphIndex in _glyphTypeface.CharacterToGlyphMap.Values select _glyphTypeface.GetGlyphOutline(glyphIndex, fontSize, 1d); // now create the visual we'll draw them to var dv = new System.Windows.Media.DrawingVisual(); var drawCount = -1; using (var dc = dv.RenderOpen()) { foreach (var g in glyphs) { drawCount++; if (drawCount >= MaxDrawCount) { break; // don't draw more than you want } if (g.IsEmpty()) { continue; // don't draw the blank ones } // center horizontally in the cell var xOffset = (drawCount % ColumnCount) * cellSize.Width + (cellSize.Width - g.Bounds.Width) / 2d; // place the character on the baseline of the cell var yOffset = (drawCount / ColumnCount) * cellSize.Height + fontSize * _glyphTypeface.Baseline; dc.PushTransform(new System.Windows.Media.TranslateTransform(xOffset, yOffset)); dc.DrawGeometry(System.Windows.Media.Brushes.Red, null, g); dc.Pop(); // get rid of the transform } } var rowCount = drawCount / ColumnCount; if (drawCount % ColumnCount != 0) { rowCount++; // to include partial rows } var bitWidth = (int)Math.Ceiling(cellSize.Width * ColumnCount); var bitHeight = (int)Math.Ceiling(cellSize.Height * rowCount); var bmp = new System.Windows.Media.Imaging.RenderTargetBitmap(bitWidth, bitHeight, 96, 96, System.Windows.Media.PixelFormats.Pbgra32); bmp.Render(dv); var encoder = new System.Windows.Media.Imaging.PngBitmapEncoder(); encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(bmp)); using (var file = new FileStream("FontTable.png", FileMode.Create)) encoder.Save(file); }
private ToolStripMenuItem SetFonts() { ToolStripMenuItem menuItem = new ToolStripMenuItem("Insert Font"); List <string> fonts = new List <string>(); foreach (System.Windows.Media.FontFamily font in System.Windows.Media.Fonts.SystemFontFamilies) //WPF fonts { fonts.Add(font.FamilyNames.Values.First()); } fonts.Sort(); foreach (string fontName in fonts) { Bitmap bmp = null; try { int size = 20; //bmp = new Bitmap(4 * size, 5 * size / 4); //Graphics g = Graphics.FromImage(bmp); //g.SmoothingMode = SmoothingMode.HighQuality; //g.InterpolationMode = InterpolationMode.HighQualityBicubic; //g.PixelOffsetMode = PixelOffsetMode.HighQuality; //g.DrawString("Basic", new Font(new FontFamily(fontName), size, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, 1, 1); System.Windows.Media.DrawingVisual dv = new System.Windows.Media.DrawingVisual(); using (System.Windows.Media.DrawingContext dc = dv.RenderOpen()) { dc.DrawRectangle(System.Windows.Media.Brushes.White, null, new System.Windows.Rect(0, 0, 4 * size, 5 * size / 4)); dc.DrawText(new System.Windows.Media.FormattedText("Basic", System.Globalization.CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, new System.Windows.Media.Typeface(fontName), size, System.Windows.Media.Brushes.Black), new System.Windows.Point(1, 1)); } System.Windows.Media.Imaging.RenderTargetBitmap rtb = new System.Windows.Media.Imaging.RenderTargetBitmap(4 * size, 5 * size / 4, 96, 96, System.Windows.Media.PixelFormats.Pbgra32); rtb.Render(dv); rtb.Freeze(); MemoryStream stream = new MemoryStream(); System.Windows.Media.Imaging.BitmapEncoder encoder = new System.Windows.Media.Imaging.BmpBitmapEncoder(); encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(rtb)); encoder.Save(stream); bmp = new Bitmap(stream); } catch { } ToolStripMenuItem item = new ToolStripMenuItem(fontName, bmp, Insert); item.ImageScaling = ToolStripItemImageScaling.None; menuItem.DropDownItems.Add(item); } return(menuItem); }
public System.Drawing.Bitmap RenderSingleCharacter(ushort glyphIndex, System.Drawing.Color backColor, System.Drawing.Color foreColor, int fontSize) { try { var geometry = _glyphTypeface.GetGlyphOutline(glyphIndex, fontSize, 1); var advanceWidth = _glyphTypeface.AdvanceWidths[glyphIndex]; var cellSize = new Size(fontSize, fontSize * _glyphTypeface.Height); var offsetX = advanceWidth * cellSize.Width; var offsetY = fontSize * _glyphTypeface.Baseline; var drawingVisual = new System.Windows.Media.DrawingVisual(); var brush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(foreColor.A, foreColor.R, foreColor.G, foreColor.B)); var pen = new System.Windows.Media.Pen(); using (var dc = drawingVisual.RenderOpen()) { dc.PushTransform(new System.Windows.Media.TranslateTransform(0, offsetY)); dc.DrawGeometry(brush, null, geometry); dc.Pop(); // get rid of the transform } var bitWidth = (int)Math.Ceiling(offsetX); var bitHeight = (int)Math.Ceiling(cellSize.Height); var targetImage = new System.Windows.Media.Imaging.RenderTargetBitmap(bitWidth, bitHeight, Dpi, Dpi, System.Windows.Media.PixelFormats.Pbgra32); targetImage.Render(drawingVisual); var bmpEncoder = new System.Windows.Media.Imaging.PngBitmapEncoder(); bmpEncoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(targetImage)); var bmp = new System.Drawing.Bitmap(bitWidth, bitHeight); bmp.SetResolution(Dpi, Dpi); using (var graphics = System.Drawing.Graphics.FromImage(bmp)) { graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; graphics.Clear(backColor); using (var ms = new MemoryStream()) { bmpEncoder.Save(ms); graphics.DrawImage(System.Drawing.Image.FromStream(ms), new System.Drawing.PointF(0, 0)); } graphics.Save(); } return(bmp); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
private void printimage(System.Windows.Media.ImageSource bi) { var vis = new System.Windows.Media.DrawingVisual(); System.Windows.Media.DrawingContext dc = vis.RenderOpen(); dc.DrawImage(bi, new System.Windows.Rect { Width = bi.Width, Height = bi.Height }); dc.Close(); var pdialog = new System.Windows.Controls.PrintDialog(); // if (pdialog.ShowDialog() == true) { pdialog.PrintVisual(vis, "My Image"); } }
// Create a DrawingVisual that contains a rectangle. private System.Windows.Media.DrawingVisual CreateDrawingVisualRectangle() { System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); // Retrieve the DrawingContext in order to create new drawing content. DrawingContext drawingContext = drawingVisual.RenderOpen(); // Create a rectangle and draw it in the DrawingContext. Rect rect = new Rect(new Point(160, 100), new Size(320, 80)); drawingContext.DrawRectangle(Brushes.LightBlue, null, rect); // Persist the drawing content. drawingContext.Close(); return(drawingVisual); }
/// <summary> /// Converts the framework element to drawing visual. /// </summary> /// <param name="element">The framework element that must be converted.</param> /// <param name="size">The size of the diagram.</param> /// <returns>A new DrawingVisual with the Diagram.</returns> internal static System.Windows.Media.DrawingVisual DrawingVisualFromFrameworkElement(System.Windows.FrameworkElement element, System.Windows.Size size) { System.Windows.Media.DrawingVisual dv = new System.Windows.Media.DrawingVisual(); System.Windows.Media.Imaging.RenderTargetBitmap renderBitmap = new System.Windows.Media.Imaging.RenderTargetBitmap( (int)size.Width, (int)size.Height, 96D, 96D, System.Windows.Media.PixelFormats.Default); renderBitmap.Render(element); using (System.Windows.Media.DrawingContext context = dv.RenderOpen()) { context.DrawImage(renderBitmap, new System.Windows.Rect(size)); } return dv; }
// Create a DrawingVisual that contains text. private System.Windows.Media.DrawingVisual CreateDrawingVisualText() { // Create an instance of a DrawingVisual. System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); // Retrieve the DrawingContext from the DrawingVisual. DrawingContext drawingContext = drawingVisual.RenderOpen(); // Draw a formatted text string into the DrawingContext. drawingContext.DrawText( new FormattedText("Click Me!", CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Verdana"), 36, Brushes.Black), new Point(200, 116)); // Close the DrawingContext to persist changes to the DrawingVisual. drawingContext.Close(); return(drawingVisual); }
/* * // Windows Forms版 TODO: 直書きあり * public static void DrawString(string str, double fontSize) * { * var window = System.Windows.Application.Current.MainWindow; * * double[] glDoubleColor = new double[4]; * GL.GetDouble(GetPName.CurrentColor, glDoubleColor); * byte glR = (byte)(glDoubleColor[0] * 255); * byte glG = (byte)(glDoubleColor[1] * 255); * byte glB = (byte)(glDoubleColor[2] * 255); * byte glA = (byte)(glDoubleColor[3] * 255); //255; * var glColor = System.Drawing.Color.FromArgb(glA, glR, glG, glB); * System.Drawing.Brush foreground = new System.Drawing.SolidBrush(glColor); * * //var font = new System.Drawing.Font("Arial", 12); * //var font = new System.Drawing.Font(window.FontFamily.Source, (int)window.FontSize); * // 1 point = 1 / 72.0 inch = (1 / 72.0) * 96 = 1.333333 pixel * var font = new System.Drawing.Font(window.FontFamily.Source, (int)(fontSize / 1.333333)); * // サイズ取得用に生成 * var bmp = new System.Drawing.Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb); * System.Drawing.SizeF size; * using (var g = System.Drawing.Graphics.FromImage(bmp)) * { * g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; * * size = g.MeasureString(str, font); * } * * // 再生成 * { * int width = (int)size.Width; * //int height = (int)size.Height; * // TODO: テキストのY座標がずれている : 画像の高さが大きすぎる * int height = (int)(size.Height * 0.75); * bmp = new System.Drawing.Bitmap(width, height, * System.Drawing.Imaging.PixelFormat.Format32bppArgb); * } * * using (var g = System.Drawing.Graphics.FromImage(bmp)) * { * g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; * * g.DrawString(str, font, foreground, new System.Drawing.Point(0, 0)); * } * * // check * //bmp.Save("1.bmp"); * * // 上下反転する * bmp.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipY); * * var bitmapData = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), * System.Drawing.Imaging.ImageLockMode.ReadOnly, * System.Drawing.Imaging.PixelFormat.Format32bppArgb); * int bmpWidth = bitmapData.Width; * int bmpHeight = bitmapData.Height; * * bool isTexture = GL.IsEnabled(EnableCap.Texture2D); * bool isBlend = GL.IsEnabled(EnableCap.Blend); * GL.Enable(EnableCap.Texture2D); * GL.Enable(EnableCap.Blend); * GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); * * int texture = GL.GenTexture(); * GL.BindTexture(TextureTarget.Texture2D, texture); * GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, * (int)TextureMinFilter.Linear); * GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, * (int)TextureMagFilter.Linear); * GL.TexImage2D(TextureTarget.Texture2D, 0, * PixelInternalFormat.Rgba, * bmpWidth, bmpHeight, 0, * PixelFormat.Bgra, PixelType.UnsignedByte, bitmapData.Scan0); * * GL.PushMatrix(); * OpenTK.Matrix4d m; * GL.GetDouble(GetPName.ModelviewMatrix, out m); * //GL.Translate(0, 0, -m.M14); * GL.Scale(1.0 / m.M11, 1.0 / m.M22, 1.0 / m.M33); * GL.Scale(FontScale, FontScale, 1.0); // TODO: これを計算で求める必要がある * * GL.Begin(PrimitiveType.Quads); * GL.TexCoord2(0, 0); * GL.Vertex2(0, 0); * * GL.TexCoord2(1, 0); * GL.Vertex2(bmpWidth, 0); * * GL.TexCoord2(1, 1); * GL.Vertex2(bmpWidth, bmpHeight); * * GL.TexCoord2(0, 1); * GL.Vertex2(0, bmpHeight); * GL.End(); * GL.PopMatrix(); * * bmp.UnlockBits(bitmapData); * * if (!isTexture) * { * GL.Disable(EnableCap.Texture2D); * } * if (!isBlend) * { * GL.Disable(EnableCap.Blend); * } * } */ // WPF版 TODO: 直書きあり public static void DrawString(string str, double fontSize) { var window = System.Windows.Application.Current.MainWindow; double[] glDoubleColor = new double[4]; GL.GetDouble(GetPName.CurrentColor, glDoubleColor); var glColor = new System.Windows.Media.Color(); glColor.R = (byte)(glDoubleColor[0] * 255); glColor.G = (byte)(glDoubleColor[1] * 255); glColor.B = (byte)(glDoubleColor[2] * 255); glColor.A = (byte)(glDoubleColor[3] * 255); //255; System.Windows.Media.Brush foreground = new System.Windows.Media.SolidColorBrush(glColor); //System.Windows.Media.Brush foreground = window.Foreground; var text = new System.Windows.Media.FormattedText( str, new System.Globalization.CultureInfo("en-us"), System.Windows.FlowDirection.LeftToRight, new System.Windows.Media.Typeface( window.FontFamily, System.Windows.FontStyles.Normal, System.Windows.FontWeights.Normal, new System.Windows.FontStretch()), fontSize, //window.FontSize, foreground); var drawingVisual = new System.Windows.Media.DrawingVisual(); using (System.Windows.Media.DrawingContext drawingContext = drawingVisual.RenderOpen()) { drawingContext.DrawText(text, new System.Windows.Point(0, 0)); } System.Windows.Media.Imaging.RenderTargetBitmap bmp = null; { int width = (int)text.Width; int height = (int)text.Height; int dpiX = 96; int dpiY = 96; bmp = new System.Windows.Media.Imaging.RenderTargetBitmap( width, height, dpiX, dpiY, System.Windows.Media.PixelFormats.Pbgra32); } bmp.Render(drawingVisual); int bmpWidth = bmp.PixelWidth; int bmpHeight = bmp.PixelHeight; int stride = bmpWidth * 4; byte[] tmpbits = new byte[stride * bmpHeight]; var rectangle = new System.Windows.Int32Rect(0, 0, bmpWidth, bmpHeight); bmp.CopyPixels(rectangle, tmpbits, stride, 0); // 上下反転する byte[] bits = new byte[stride * bmpHeight]; for (int h = 0; h < bmpHeight; h++) { for (int w = 0; w < stride; w++) { bits[h * stride + w] = tmpbits[(bmpHeight - 1 - h) * stride + w]; } } // check //var png = new System.Windows.Media.Imaging.PngBitmapEncoder(); //png.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(bmp)); //using (var fs = new FileStream("1.png", FileMode.Create)) //{ // png.Save(fs); //} bool isTexture = GL.IsEnabled(EnableCap.Texture2D); bool isBlend = GL.IsEnabled(EnableCap.Blend); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); int texture = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, texture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmpWidth, bmpHeight, 0, PixelFormat.Bgra, PixelType.UnsignedByte, bits); GL.PushMatrix(); OpenTK.Matrix4d m; GL.GetDouble(GetPName.ModelviewMatrix, out m); GL.Scale(1.0 / m.M11, 1.0 / m.M22, 1.0 / m.M33); GL.Scale(FontScale, FontScale, 1.0); // TODO: これを計算で求める必要がある GL.Begin(PrimitiveType.Quads); GL.TexCoord2(0, 0); GL.Vertex2(0, 0); GL.TexCoord2(1, 0); GL.Vertex2(bmpWidth, 0); GL.TexCoord2(1, 1); GL.Vertex2(bmpWidth, bmpHeight); GL.TexCoord2(0, 1); GL.Vertex2(0, bmpHeight); GL.End(); GL.PopMatrix(); if (!isTexture) { GL.Disable(EnableCap.Texture2D); } if (!isBlend) { GL.Disable(EnableCap.Blend); } }
public static void CreateRemappedRasterFromVector(string xamlFile, System.Windows.Media.Color newColor, System.IO.Stream stream, double height, double width, string dynamicText) { string remapBase = "ReMapMe_"; int max = 3; int index = 0; int missed = 0; Object temp = null; string dynamText = "DynamicText"; System.Windows.Controls.Canvas theVisual = System.Windows.Markup.XamlReader.Load(new System.IO.FileStream(xamlFile, System.IO.FileMode.Open)) as System.Windows.Controls.Canvas; if (null == theVisual) { return; } System.Windows.Size size = new System.Windows.Size(width, height); System.Windows.Media.DrawingVisual drawingVisual = new System.Windows.Media.DrawingVisual(); System.Windows.Media.VisualBrush visualBrush = new System.Windows.Media.VisualBrush(theVisual); System.Windows.Rect rect = new System.Windows.Rect(new System.Windows.Point(), size); while (missed < max) { string elementid = remapBase + index; temp = theVisual.FindName(elementid); if (null == temp) { missed++; index++; continue; } System.Windows.Media.SolidColorBrush scb = ((temp as System.Windows.Shapes.Path).Fill as System.Windows.Media.SolidColorBrush); System.Windows.Media.Color c = scb.Color; c.B = newColor.B; c.R = newColor.R; c.G = newColor.G; scb.Color = c; index++; } theVisual.Arrange(rect); theVisual.UpdateLayout(); using (System.Windows.Media.DrawingContext dc = drawingVisual.RenderOpen()) { dc.DrawRectangle(visualBrush, null, rect); } if (!dynamText.IsNullOrWhitespace()) { temp = theVisual.FindName(dynamText); if (null != temp) { //do dynamic text shit } } System.Windows.Media.Imaging.RenderTargetBitmap render = new System.Windows.Media.Imaging.RenderTargetBitmap((int)height, (int)width, 96, 96, System.Windows.Media.PixelFormats.Pbgra32); render.Render(drawingVisual); System.Windows.Media.Imaging.PngBitmapEncoder encoder = new System.Windows.Media.Imaging.PngBitmapEncoder(); encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(render)); encoder.Save(stream); stream.Flush(); stream.Close(); visualBrush = null; drawingVisual = null; theVisual = null; render = null; encoder = null; }
public override DocumentPage GetPage(int pageNumber) { // This is called starting at zero, but we are really starting at the given page. pageNumber += startingPage; if (showProgressDialog) { if (outer.controller.UpdateProgressDialog(string.Format(MiscText.PrintingPage, pageNumber + 1, outer.totalPages), (double)pageNumber / (double)outer.totalPages)) { throw new Exception(MiscText.CancelledByUser); } } Margins margins = new Margins(this.margins.Left, this.margins.Right, this.margins.Top, this.margins.Bottom); bool landscape = outer.pageSettings.Landscape; PaperSize paperSize = outer.pageSettings.PaperSize; bool rotate; outer.ChangePageSettings(pageNumber, ref landscape, ref paperSize, margins); rotate = (landscape != outer.pageSettings.Landscape); this.pageSize = new System.Windows.Size(HundrethsToPoints(paperSize.Width), HundrethsToPoints(paperSize.Height)); if (outer.pageSettings.Landscape) { this.pageSize = new System.Windows.Size(this.pageSize.Height, this.pageSize.Width); } // Get margins in terms of normal page orientation, in points. double leftMargin = HundrethsToPoints(rotate ? margins.Bottom : margins.Left); double rightMargin = HundrethsToPoints(rotate ? margins.Top : margins.Right); double topMargin = HundrethsToPoints(rotate ? margins.Left : margins.Top); double bottomMargin = HundrethsToPoints(rotate ? margins.Right : margins.Bottom); System.Windows.Rect contentRect = new System.Windows.Rect(leftMargin, topMargin, pageSize.Width - leftMargin - rightMargin, pageSize.Height - topMargin - bottomMargin); System.Windows.Rect boundingRect = new System.Windows.Rect(0, 0, pageSize.Width - leftMargin - rightMargin, pageSize.Height - topMargin - bottomMargin); System.Windows.Media.DrawingVisual visual = new System.Windows.Media.DrawingVisual(); using (System.Windows.Media.DrawingContext dc = visual.RenderOpen()) { if (outer.printingToBitmaps) { // This is kind of hacky way to get the printing to bitmaps white, but much easier than the alternative. dc.DrawRectangle(System.Windows.Media.Brushes.White, null, new System.Windows.Rect(-1, -1, pageSize.Width + 2, pageSize.Height + 2)); } // Clip to the bounding rect within margins. dc.PushClip(new System.Windows.Media.RectangleGeometry(boundingRect)); if (rotate) { // Rotate and translate to handle landscape mode. dc.PushTransform(new System.Windows.Media.TranslateTransform(0, boundingRect.Height)); dc.PushTransform(new System.Windows.Media.RotateTransform(-90)); } // Scale to hundreths of an inch instead of points (1/96 of inch). dc.PushTransform(new System.Windows.Media.ScaleTransform(96.0 / 100.0, 96.0 / 100.0)); IGraphicsTarget graphicsTarget; if (outer.colorModel == ColorModel.RGB) { graphicsTarget = new WPF_GraphicsTarget(dc); } else if (outer.colorModel == ColorModel.CMYK) { graphicsTarget = new WPF_GraphicsTarget(dc, new WPFSwopColorConverter()); } else { throw new NotImplementedException(); } using (graphicsTarget) { outer.DrawPage(graphicsTarget, pageNumber, new SizeF((float)contentRect.Width, (float)contentRect.Height), dpi); } graphicsTarget = null; } return(new DocumentPage(visual, pageSize, contentRect, contentRect)); }
protected override void ComposeCore(System.Windows.Media.DrawingContext drawingContext, System.Windows.Media.DrawingVisual visual) { //Text and Caption size string tempText = string.Empty; double textWidth = Utilities.GetTextWidth(this.Text); double captionWidth = Utilities.GetTextWidth(this.Caption); if (this.Text.Count() > 25) { tempText = this.Text.Substring(0, 25); tempText += "..."; textWidth = Utilities.GetTextWidth(tempText); } else { tempText = this.Text; } //Node width if (textWidth > captionWidth) { this.nodeDimension.Width = (int)(Configurations.NodeWidthProperty + textWidth + 1); } else { this.nodeDimension.Width = (int)(Configurations.NodeWidthProperty + captionWidth + 1); } //Node height this.nodeDimension.Height = Configurations.NodeHeightProperty; base.ComposeCore(drawingContext, visual); Rect rect = new Rect(new Point(1, 1), new Size((int)(this.nodeDimension.Width - 1), (int)(this.nodeDimension.Height - 1))); drawingContext.DrawRectangle(Configurations.RectGrey, Configurations.NoBorderPen, rect); //horizontal Line Point p1 = new Point(1, 1); p1.Offset(Configurations.TextHorizontalOffset, (int)(this.Height) / 2); p1.Offset(0, 0.5); Point p2 = p1; p2.X = (this.Width - 1) - Configurations.TextHorizontalOffset; drawingContext.DrawLine(Configurations.BorderPen, p1, p2); //draw caption and text p1 = new Point(1, 1); p1.Offset(0, Configurations.TextVerticalOffset); p1.X = (this.Width / 2) - captionWidth / 2; Utilities.DrawText(drawingContext, this.Caption, p1, Configurations.TextNormalColor); p1.Y = ((this.Height - 3) / 2) + Configurations.TextVerticalOffset; p1.X = (this.Width / 2) - textWidth / 2; Utilities.DrawBoldText(drawingContext, tempText, p1); //OutputSlot p1 = new Point(this.Width, (this.Height / 4)); p1.Y += (this.Height / 2) - 2; DrawingUtilities.DrawDots(drawingContext, DotTypes.TopRight | DotTypes.MiddleRight | DotTypes.BottomRight, p1, AnchorPoint.TopRight, false); //OutputSlotHittestPixels p1.Y -= (this.Height / 4) - 1; drawingContext.DrawRectangle(Configurations.SlotHitTestColor, Configurations.NoBorderPen, new Rect(p1, new Size(Configurations.HittestPixels, this.Height / 2))); //NorthEast Point p = new Point(0, 0); p.Offset(this.Width, Configurations.ContextMenuMargin); if (dotsFlag.HasFlag(MenuDots.NorthEast)) { DrawingUtilities.DrawDots(drawingContext, DotTypes.Top | DotTypes.TopRight | DotTypes.MiddleRight, p, AnchorPoint.TopRight, false); } //NorthWest p = new Point(0, 0); p.Offset(Configurations.ContextMenuMargin, Configurations.ContextMenuMargin); //DrawingUtilities.DrawDots(drawingContext, DotTypes.TopLeft | DotTypes.Top | DotTypes.MiddleLeft, p, AnchorPoint.TopLeft, false); //South p = new Point(0, 0); p.Offset(Configurations.ContextMenuMargin, this.Height); //DrawingUtilities.DrawDots(drawingContext, DotTypes.MiddleLeft | DotTypes.BottomLeft | DotTypes.Bottom, p, AnchorPoint.BottomLeft, false); //input Slots if (this.inputSlots.Count != 0) { p1 = new Point(-1, 1); p1.Y += Configurations.TextVerticalOffset + Configurations.SlotSize / 2; Utilities.DrawSlot(drawingContext, p1); } // Fix: IDE-1616 Geometry property previews are not showing up. // Fix: IDE-1623 Preview not coming for the property nodes. if (previewBubble != null) { this.previewBubble.Compose(); } }
protected override void ComposeCore(System.Windows.Media.DrawingContext drawingContext, System.Windows.Media.DrawingVisual visual) { this.nodeDimension.Width = Configurations.NodeWidthRender; this.nodeDimension.Height = Configurations.NodeHeightRender; base.ComposeCore(drawingContext, visual); //NorthEast Point p = new Point(0, 0); p.Offset(Width, Configurations.ContextMenuMargin); DrawingUtilities.DrawDots(drawingContext, DotTypes.Top | DotTypes.TopRight | DotTypes.MiddleRight, p, AnchorPoint.TopRight, false); //NorthWest p = new Point(0, 0); p.Offset(Configurations.ContextMenuMargin, Configurations.ContextMenuMargin); DrawingUtilities.DrawDots(drawingContext, DotTypes.TopLeft | DotTypes.Top | DotTypes.MiddleLeft, p, AnchorPoint.TopLeft, false); //OutputSlots p = new Point(0, 0); p.Offset(Width, Height - Configurations.ContextMenuMargin); DrawingUtilities.DrawDots(drawingContext, DotTypes.TopRight | DotTypes.MiddleRight | DotTypes.BottomRight, p, AnchorPoint.BottomRight, false); }
private System.Windows.Media.DrawingVisual CreateDrawingVisualProvince(Prov prov, MapColorModes mapColor = MapColorModes.Provs) { var drawingVisual = new System.Windows.Media.DrawingVisual(); var dc = drawingVisual.RenderOpen(); Brush brush = null; if (mapColor == MapColorModes.Provs) { var color1 = System.Drawing.Color.FromArgb(prov.Color); brush = new SolidColorBrush(Color.FromRgb(color1.R, color1.G, color1.B)); } else if (mapColor == MapColorModes.Country) { var color = Logic.GetCountryColor(prov.Owner); if (color == null) { if (prov.IsLake || prov.IsSea) { var color1 = System.Drawing.Color.FromArgb(prov.Color); brush = new SolidColorBrush(Color.FromRgb(color1.R, color1.G, color1.B)); } else if (!prov.IsWaste) { brush = new SolidColorBrush(Colors.LightGray); } else { brush = new SolidColorBrush(Colors.DimGray); } } else { brush = new SolidColorBrush(color.Value); } } //dc.DrawGeometry(brush,new Pen(Brushes.Red,0),prov.Geometry ); dc.DrawGeometry(brush, new Pen(brush, 0.45), prov.Geometry); ////////////////////////////////////////// // FormattedText formattedText = new FormattedText( //"11", //CultureInfo.GetCultureInfo("en-us"), //FlowDirection.LeftToRight, //new Typeface(new FontFamily("宋体"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal), //12, //Brushes.Red); // Geometry textGeometry = formattedText.BuildGeometry(new Point(0, 0)); // var rect = prov.Geometry.Bounds; // var rect1 = textGeometry.Bounds; // var w = rect.Width/rect1.Width; // var h = rect.Height/rect1.Height; // var scale = Math.Min(w, h); // //var max=t // var translateTransform = new ScaleTransform(); // //translateTransform.X = -textGeometry.Bounds.Left; // //translateTransform.Y = -textGeometry.Bounds.Top; // dc.PushTransform(translateTransform); // dc.DrawGeometry(Brushes.Red, new Pen(Brushes.Red, 1.0), textGeometry); dc.Close(); return(drawingVisual); }
public override DocumentPage GetPage(int pageNumber) { // This is called starting at zero, but we are really starting at the given page. pageNumber += startingPage; if (showProgressDialog) { if (outer.controller.UpdateProgressDialog(string.Format(MiscText.PrintingPage, pageNumber + 1, outer.totalPages), (double)pageNumber / (double)outer.totalPages)) throw new Exception(MiscText.CancelledByUser); } Margins margins = new Margins(this.margins.Left, this.margins.Right, this.margins.Top, this.margins.Bottom); bool landscape = outer.pageSettings.Landscape; PaperSize paperSize = outer.pageSettings.PaperSize; bool rotate; outer.ChangePageSettings(pageNumber, ref landscape, ref paperSize, margins); rotate = (landscape != outer.pageSettings.Landscape); this.pageSize = new System.Windows.Size(HundrethsToPoints(paperSize.Width), HundrethsToPoints(paperSize.Height)); if (outer.pageSettings.Landscape) { this.pageSize = new System.Windows.Size(this.pageSize.Height, this.pageSize.Width); } // Get margins in terms of normal page orientation, in points. double leftMargin = HundrethsToPoints(rotate ? margins.Bottom : margins.Left); double rightMargin = HundrethsToPoints(rotate ? margins.Top : margins.Right); double topMargin = HundrethsToPoints(rotate ? margins.Left : margins.Top); double bottomMargin = HundrethsToPoints(rotate ? margins.Right : margins.Bottom); System.Windows.Rect contentRect = new System.Windows.Rect(leftMargin, topMargin, pageSize.Width - leftMargin - rightMargin, pageSize.Height - topMargin - bottomMargin); System.Windows.Rect boundingRect = new System.Windows.Rect(0, 0, pageSize.Width - leftMargin - rightMargin, pageSize.Height - topMargin - bottomMargin); System.Windows.Media.DrawingVisual visual = new System.Windows.Media.DrawingVisual(); using (System.Windows.Media.DrawingContext dc = visual.RenderOpen()) { if (outer.printingToBitmaps) { // This is kind of hacky way to get the printing to bitmaps white, but much easier than the alternative. dc.DrawRectangle(System.Windows.Media.Brushes.White, null, new System.Windows.Rect(-1, -1, pageSize.Width + 2, pageSize.Height + 2)); } // Clip to the bounding rect within margins. dc.PushClip(new System.Windows.Media.RectangleGeometry(boundingRect)); if (rotate) { // Rotate and translate to handle landscape mode. dc.PushTransform(new System.Windows.Media.TranslateTransform(0, boundingRect.Height)); dc.PushTransform(new System.Windows.Media.RotateTransform(-90)); } // Scale to hundreths of an inch instead of points (1/96 of inch). dc.PushTransform(new System.Windows.Media.ScaleTransform(96.0 / 100.0, 96.0 / 100.0)); IGraphicsTarget graphicsTarget; if (outer.colorModel == ColorModel.RGB) graphicsTarget = new WPF_GraphicsTarget(dc); else if (outer.colorModel == ColorModel.CMYK) graphicsTarget = new WPF_GraphicsTarget(dc, new WPFSwopColorConverter()); else throw new NotImplementedException(); using (graphicsTarget) { outer.DrawPage(graphicsTarget, pageNumber, new SizeF((float)contentRect.Width, (float)contentRect.Height), dpi); } graphicsTarget = null; } return new DocumentPage(visual, pageSize, contentRect, contentRect); }
/// <summary> /// 渲染字符串 /// </summary> /// <param name="previewText"></param> /// <param name="backColor">背景色</param> /// <param name="foreColor">前景色</param> /// <param name="fontSize">font size in pixel</param> /// <returns></returns> public System.Drawing.Bitmap RenderString(string previewText, System.Drawing.Color backColor, System.Drawing.Color foreColor, int fontSize) { try { if (string.IsNullOrWhiteSpace(previewText)) { if (_glyphTypeface.FamilyNames.Count == 0) { previewText = "no name"; } else if (_glyphTypeface.FamilyNames.ContainsKey(CultureInfo.CurrentCulture)) { previewText = _glyphTypeface.FamilyNames[CultureInfo.CurrentCulture]; } else { previewText = _glyphTypeface.FamilyNames[_glyphTypeface.FamilyNames.Keys.First()]; } } var glyphIndexList = GetGlyphIndexList(previewText); if (glyphIndexList.Count <= 0) { return(null); } var geometryList = glyphIndexList.Select(glyphIndex => _glyphTypeface.GetGlyphOutline(glyphIndex, fontSize, 1d)).ToList(); var advanceWidthList = glyphIndexList.Select(glyphIndex => _glyphTypeface.AdvanceWidths[glyphIndex]).ToList(); var cellSize = new Size(fontSize, fontSize * _glyphTypeface.Height); var offsetX = 0d; var offsetY = fontSize * _glyphTypeface.Baseline; var drawingVisual = new System.Windows.Media.DrawingVisual(); var brush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(foreColor.R, foreColor.G, foreColor.B)); //var pen = new System.Windows.Media.Pen(brush, 0); using (var dc = drawingVisual.RenderOpen()) { for (var i = 0; i < geometryList.Count; i++) { var geometry = geometryList[i]; var advanceWidth = advanceWidthList[i]; //if (geometry.IsEmpty()) continue; dc.PushTransform(new System.Windows.Media.TranslateTransform(offsetX, offsetY)); dc.DrawGeometry(brush, null, geometry); dc.Pop(); // get rid of the transform offsetX += advanceWidth * cellSize.Width; } } var bitWidth = (int)Math.Ceiling(offsetX); var bitHeight = (int)Math.Ceiling(cellSize.Height); var targetImage = new System.Windows.Media.Imaging.RenderTargetBitmap(bitWidth, bitHeight, Dpi, Dpi, System.Windows.Media.PixelFormats.Pbgra32); targetImage.Render(drawingVisual); var bmpEncoder = new System.Windows.Media.Imaging.PngBitmapEncoder(); bmpEncoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(targetImage)); //redraw to Bitmap var bmp = new System.Drawing.Bitmap(bitWidth, bitHeight); bmp.SetResolution(Dpi, Dpi); using (var graphics = System.Drawing.Graphics.FromImage(bmp)) { graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; graphics.Clear(backColor); using (var ms = new MemoryStream()) { bmpEncoder.Save(ms); graphics.DrawImage(System.Drawing.Image.FromStream(ms), new System.Drawing.PointF(0, 0)); } graphics.Save(); } return(bmp); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }