Пример #1
2
        /// <summary>
        /// Creates the arc segment from parameters of the GDI+ DrawArc function.
        /// </summary>
        public static ArcSegment CreateArcSegment(double x, double y, double width, double height, double startAngle,
          double sweepAngle, out SysPoint startPoint)
        {
            // Normalize the angles.
            double α = startAngle;
            if (α < 0)
                α = α + (1 + Math.Floor((Math.Abs(α) / 360))) * 360;
            else if (α > 360)
                α = α - Math.Floor(α / 360) * 360;
            Debug.Assert(α >= 0 && α <= 360);

            if (Math.Abs(sweepAngle) >= 360)
                sweepAngle = Math.Sign(sweepAngle) * 360;
            double β = startAngle + sweepAngle;
            if (β < 0)
                β = β + (1 + Math.Floor((Math.Abs(β) / 360))) * 360;
            else if (β > 360)
                β = β - Math.Floor(β / 360) * 360;

            if (α == 0 && β < 0)
                α = 360;
            else if (α == 360 && β > 0)
                α = 0;

            // Scanling factor.
            double δx = width / 2;
            double δy = height / 2;

            // Center of ellipse.
            double x0 = x + δx;
            double y0 = y + δy;

            double cosα, cosβ, sinα, sinβ;
            if (width == height)
            {
                // Circular arc needs no correction.
                α = α * Calc.Deg2Rad;
                β = β * Calc.Deg2Rad;
            }
            else
            {
                // Elliptic arc needs the angles to be adjusted such that the scaling transformation is compensated.
                α = α * Calc.Deg2Rad;
                sinα = Math.Sin(α);
                if (Math.Abs(sinα) > 1E-10)
                {
                    if (α < Math.PI)
                        α = Math.PI / 2 - Math.Atan(δy * Math.Cos(α) / (δx * sinα));
                    else
                        α = 3 * Math.PI / 2 - Math.Atan(δy * Math.Cos(α) / (δx * sinα));
                }
                //α = Calc.πHalf - Math.Atan(δy * Math.Cos(α) / (δx * sinα));
                β = β * Calc.Deg2Rad;
                sinβ = Math.Sin(β);
                if (Math.Abs(sinβ) > 1E-10)
                {
                    if (β < Math.PI)
                        β = Math.PI / 2 - Math.Atan(δy * Math.Cos(β) / (δx * sinβ));
                    else
                        β = 3 * Math.PI / 2 - Math.Atan(δy * Math.Cos(β) / (δx * sinβ));
                }
                //β = Calc.πHalf - Math.Atan(δy * Math.Cos(β) / (δx * sinβ));
            }

            sinα = Math.Sin(α);
            cosα = Math.Cos(α);
            sinβ = Math.Sin(β);
            cosβ = Math.Cos(β);

            startPoint = new SysPoint(x0 + δx * cosα, y0 + δy * sinα);
            SysPoint destPoint = new SysPoint(x0 + δx * cosβ, y0 + δy * sinβ);
            SysSize size = new SysSize(δx, δy);
            bool isLargeArc = Math.Abs(sweepAngle) >= 180;
            SweepDirection sweepDirection = sweepAngle > 0 ? SweepDirection.Clockwise : SweepDirection.Counterclockwise;
#if !SILVERLIGHT && !NETFX_CORE
            bool isStroked = true;
            ArcSegment seg = new ArcSegment(destPoint, size, 0, isLargeArc, sweepDirection, isStroked);
#else
            ArcSegment seg = new ArcSegment();
            seg.Point = destPoint;
            seg.Size = size;
            seg.RotationAngle = 0;
            seg.IsLargeArc = isLargeArc;
            seg.SweepDirection = sweepDirection;
            // isStroked does not exist in Silverlight 3
#endif
            return seg;
        }
Пример #2
1
        // 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; 
        }
Пример #3
0
        /// <summary>
        ///     Gets the page bounds for all pages of the given PDF. If a relevant rotation is supplied, the bounds will
        ///     be rotated accordingly before returning.
        /// </summary>
        /// <param name="rotation">The rotation that should be applied</param>
        /// <param name="password">The password for the pdf file (if required)</param>
        /// <returns></returns>
        public static Size[] GetPageBounds(IPdfSource source, ImageRotation rotation = ImageRotation.None,
            string password = null)
        {
            Func<double, double, Size> sizeCallback = (width, height) => new Size(width, height);

            if (rotation == ImageRotation.Rotate90 || rotation == ImageRotation.Rotate270)
                sizeCallback = (width, height) => new Size(height, width); // switch width and height

            using (var stream = new PdfFileStream(source))
            {
                ValidatePassword(stream.Document, password);

                var pageCount = NativeMethods.CountPages(stream.Document); // gets the number of pages in the document
                var resultBounds = new Size[pageCount];

                for (var i = 0; i < pageCount; i++)
                {
                    var p = NativeMethods.LoadPage(stream.Document, i); // loads the page
                    var pageBound = NativeMethods.BoundPage(stream.Document, p);

                    resultBounds[i] = sizeCallback(pageBound.Width, pageBound.Height);

                    NativeMethods.FreePage(stream.Document, p); // releases the resources consumed by the page
                }

                return resultBounds;
            }
        }
Пример #4
0
        /// <summary>
        /// This method create drawing visual by bitmap image, widht and height
        /// </summary>
        /// <param name="image"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        public static DrawingVisual CreateVisual(BitmapImage image, int width, int height)
        {
            DrawingVisual visual = new DrawingVisual();

            using (DrawingContext dc = visual.RenderOpen())
            {
                System.Windows.Size size = new System.Windows.Size(width, height);

                dc.DrawImage(image, new System.Windows.Rect(new System.Windows.Point(0, 0), size));
            }

            return visual;
        }
Пример #5
0
        // Note: we can't remove this constructor, it would be a breaking change
        protected WizardBase(ITypeFactory typeFactory)
        {
            Argument.IsNotNull(() => typeFactory);

            _typeFactory = typeFactory;

            ResizeMode = System.Windows.ResizeMode.NoResize;
            MinSize = new System.Windows.Size(650d, 500d);
            MaxSize = new System.Windows.Size(650d, 500d);

            ShowInTaskbar = false;
            IsHelpVisible = false;
            CanShowHelp = true;
        }
Пример #6
0
 static void convert(double dpi, string path, string out_path)
 {
     double scale = dpi / 96.0;
     System.Windows.Xps.Packaging.XpsDocument xpsDoc =
             new System.Windows.Xps.Packaging.XpsDocument(
                     path, System.IO.FileAccess.Read);
     if (xpsDoc == null) {
         throw new System.Exception("XpsDocumentfailed");
     }
     System.Windows.Documents.FixedDocumentSequence docSeq =
             xpsDoc.GetFixedDocumentSequence();
     if (docSeq == null) {
         throw new System.Exception("GetFixedDocumentSequence failed");
     }
     System.Windows.Documents.DocumentReferenceCollection drc = docSeq.References;
     int index = 0;
     foreach (System.Windows.Documents.DocumentReference dr in drc) {
         System.Windows.Documents.FixedDocument dp = dr.GetDocument(false);
         foreach (System.Windows.Documents.PageContent pc in dp.Pages) {
             System.Windows.Documents.FixedPage fixedPage = pc.GetPageRoot(false);
             double width = fixedPage.Width;
             double height = fixedPage.Height;
             System.Windows.Size sz = new System.Windows.Size(width, height);
             fixedPage.Measure(sz);
             fixedPage.Arrange(
                     new System.Windows.Rect(new System.Windows.Point(), sz));
             fixedPage.UpdateLayout();
             System.Windows.Media.Imaging.BitmapImage bitmap =
                     new System.Windows.Media.Imaging.BitmapImage();
             System.Windows.Media.Imaging.RenderTargetBitmap renderTarget =
                     new System.Windows.Media.Imaging.RenderTargetBitmap(
                         ceil(scale * width), ceil(scale * height), dpi, dpi,
                         System.Windows.Media.PixelFormats.Default);
             renderTarget.Render(fixedPage);
             System.Windows.Media.Imaging.BitmapEncoder encoder =
                 new System.Windows.Media.Imaging.PngBitmapEncoder();
             encoder.Frames.Add(
                     System.Windows.Media.Imaging.BitmapFrame.Create(renderTarget));
             string filename = string.Format("{0}_{1}.png", out_path, index);
             System.IO.FileStream pageOutStream = new System.IO.FileStream(
                 filename, System.IO.FileMode.Create, System.IO.FileAccess.Write);
             encoder.Save(pageOutStream);
             pageOutStream.Close();
             System.Console.WriteLine(filename);
             ++index;
         }
     }
 }
        private static Bitmap FilterImage(RealBlueprint pRealBlueprint, Size pBlueprintSize)
        {
            var filters = new List<Func<Bitmap, Bitmap>>
            {
                ImageProcessor.ApplyGrayScaleFilter,
                ImageProcessor.ApplyBinarization,
                ImageProcessor.ApplyInvert,
                ImageProcessor.ApplyErosion,
                ImageProcessor.ApplyInvert,
                ImageProcessor.ApplyImageSmoothing,
                ImageProcessor.ApplyErosion,
                ImageProcessor.ApplyFillHoles
            };

            var bitmap = ImageProcessor.ApplyFilters(pRealBlueprint.Bitmap, filters);
            return ImageProcessor.ResizeImage(bitmap, (int)pBlueprintSize.Width, (int)pBlueprintSize.Height);
        }
Пример #8
0
        // Note: we can't remove this constructor, it would be a breaking change
        protected WizardBase(ITypeFactory typeFactory)
        {
            Argument.IsNotNull(() => typeFactory);

            _typeFactory          = typeFactory;
            _navigationController = _typeFactory.CreateInstanceWithParametersAndAutoCompletion <DefaultNavigationController>(this);

            ResizeMode = System.Windows.ResizeMode.NoResize;
            MinSize    = new System.Windows.Size(650d, 500d);
            MaxSize    = new System.Windows.Size(650d, 500d);

            HorizontalScrollbarVisibility = ScrollBarVisibility.Disabled;
            VerticalScrollbarVisibility   = ScrollBarVisibility.Auto;
            RestoreScrollPositionPerPage  = true;

            CacheViews             = true;
            ShowInTaskbar          = false;
            IsHelpVisible          = false;
            CanShowHelp            = true;
            HandleNavigationStates = true;
            AllowQuickNavigation   = false;
        }
Пример #9
0
        public IntPtr GetHBitmap(System.Windows.Size size, Boolean isCopyItem = false)
        {
            if (shellItemNative == null)
            {
                return(IntPtr.Zero);
            }
            // Create a size structure to pass to the native method
            var nativeSIZE = new Size()
            {
                Width = Convert.ToInt32(size.Width), Height = Convert.ToInt32(size.Height)
            };
            var nativeItem = isCopyItem && !this._Item.IsSearchFolder && this._Item.DisplayName != "Search.search-ms"
            ? new ShellItem(this._Item.CachedParsingName.ToShellParsingName()).ComInterface
            : shellItemNative;

            // Use IShellItemImageFactory to get an icon
            // Options passed in: Resize to fit
            IntPtr  hbitmap = IntPtr.Zero;
            HResult hr      = ((IShellItemImageFactory)nativeItem).GetImage(nativeSIZE, CalculateFlags(), out hbitmap);

            return(hr == HResult.S_OK ? hbitmap : IntPtr.Zero);
        }
Пример #10
0
        private void Test_NativeSizeFloat_Operators()
        {
            var nativeSize1         = new NativeSizeFloat(123, 456);
            var nativeSize2         = new NativeSizeFloat(123, 456);
            var drawingSize         = new System.Drawing.Size(123, 456);
            var windowsSize         = new System.Windows.Size(123, 456);
            var drawingSizeNotEqual = new System.Drawing.Size(456, 123);
            var windowsSizeNotEqual = new System.Windows.Size(456, 123);

            Assert.True(nativeSize1 == nativeSize2);
            Assert.True(nativeSize1 == drawingSize);
            Assert.True(drawingSize == nativeSize1);
            Assert.False(nativeSize1 != drawingSize);
            Assert.False(drawingSize != nativeSize1);
            Assert.True(drawingSizeNotEqual != nativeSize1);

            Assert.True(nativeSize1 == windowsSize);
            Assert.True(windowsSize == nativeSize1);
            Assert.False(nativeSize1 != windowsSize);
            Assert.False(windowsSize != nativeSize1);
            Assert.True(windowsSizeNotEqual != nativeSize1);
        }
Пример #11
0
        static System.Windows.Size InitWindowSize()
        {
            RegistryKey writableKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\ClipboardJisho");

            var windowW = (string)writableKey.GetValue("WindowW");
            var windowH = (string)writableKey.GetValue("WindowH");

            if (windowW == null || windowH == null)
            {
                writableKey.SetValue("windowW", 300, RegistryValueKind.String);
                writableKey.SetValue("windowH", 800, RegistryValueKind.String);
                windowW = "300";
                windowH = "800";
            }
            var size = new System.Windows.Size(Convert.ToInt32(windowW), Convert.ToInt32(windowH));

            WindowSize = size;

            writableKey.Close();

            return(size);
        }
Пример #12
0
        public ExampleWizard(ITypeFactory typeFactory, IMessageService messageService)
            : base(typeFactory)
        {
            Argument.IsNotNull(() => messageService);

            _messageService = messageService;

            Title = "Orc.Wizard example";

            this.AddPage <PersonWizardPage>();
            this.AddPage <AgeWizardPage>();
            this.AddPage <SkillsWizardPage>();
            this.AddPage <ComponentsWizardPage>();
            this.AddPage <SummaryWizardPage>();

            // Test for numbers being updated correctly
            this.InsertPage <GadgetsWizardPage>(3);

            MinSize    = new System.Windows.Size(800, 600);
            MaxSize    = new System.Windows.Size(1000, 800);
            ResizeMode = System.Windows.ResizeMode.CanResize;
        }
Пример #13
0
        public ImageToPrint(string path, double widthIn, double heightIn, double mirrorIn, int numberOfMirrors, double horizontalWhiteSpaceIn, double verticalWhiteSpaceIn, int pixelsToRemove, ImageFormat imgFormat)
        {
            this.path  = path;
            image      = Image.FromFile(path);
            isVertical = image.Height > image.Width;
            double min = Math.Min(heightIn, widthIn);
            double max = Math.Max(heightIn, widthIn);

            if (isVertical)
            {
                sizeIn = new System.Windows.Size(min, max);
            }
            else
            {
                sizeIn = new System.Windows.Size(max, min);
            }
            this.mirrorIn        = mirrorIn;
            horizontalMarginsIn  = horizontalWhiteSpaceIn;
            verticalMarginsIn    = verticalWhiteSpaceIn;
            this.pixelsToRemove  = pixelsToRemove;
            this.imgFormat       = imgFormat;
            this.numberOfMirrors = numberOfMirrors;
        }
Пример #14
0
        private BitmapSource GetBitmapSource(System.Windows.Size size, Boolean isCopyItem = false)
        {
            //FIXME: fix the cache retrieval options
            //RetrievalOption = ShellThumbnailRetrievalOption.Default;
            IntPtr hBitmap = GetHBitmap(size, isCopyItem);

            // return a System.Media.Imaging.BitmapSource
            // Use interop to create a BitmapSource from hBitmap.
            if (hBitmap != IntPtr.Zero)
            {
                BitmapSource returnValue = Imaging.CreateBitmapSourceFromHBitmap(
                    hBitmap,
                    IntPtr.Zero,
                    System.Windows.Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions()).Clone();

                // delete HBitmap to avoid memory leaks
                Gdi32.DeleteObject(hBitmap);
                return(returnValue);
            }

            return(null);
        }
Пример #15
0
        /// <summary>
        /// Sets the media format for the <paramref name="streamType"/> given.
        /// </summary>
        /// <param name="streamType">Type of the stream to set format for.</param>
        /// <param name="formatSize">The desired format area size.</param>
        /// <returns>Awaitable task.</returns>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="formatSize"/> is invalid.</exception>
        /// <exception cref="ArgumentException"><paramref name="streamType"/> is not supported.</exception>
        /// <exception cref="InvalidOperationException">
        /// No suitable media formats found for the <paramref name="streamType"/> given.
        /// </exception>
        public Task SetMediaFormatAsync(MediaStreamType streamType, Size formatSize)
        {
            if (formatSize.Height <= 0.0 || formatSize.Width <= 0.0)
            {
                throw new ArgumentOutOfRangeException("formatSize", formatSize, "Format size is invalid.");
            }

            switch (streamType)
            {
            case MediaStreamType.Photo:
            case MediaStreamType.VideoRecord:
                // Valid stream types.
                break;

            case MediaStreamType.VideoPreview:
                throw new ArgumentException("Unable to set video preview format. Use 'StartPreviewAsync' methods instead.");

            default:
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Stream type {0} is not supported.", streamType));
            }

            return(this.DoSetMediaFormatAsync(streamType, CameraController.CreateMediaFormatSelector(formatSize)));
        }
Пример #16
0
        public static void DoItTTT()
        {
            string filename    = "c:\\tmp\\goof.xps";
            string newFilename = "c:\\tmp\\new_goof.xps";

            XpsDocument xpsOld = new XpsDocument(filename, System.IO.FileAccess.Read);

            System.Windows.Documents.FixedDocumentSequence seqOld = xpsOld.GetFixedDocumentSequence();
            System.IO.Packaging.Package container = System.IO.Packaging.Package.Open(newFilename, System.IO.FileMode.Create);
            XpsDocumentWriter           writer    = XpsDocument.CreateXpsDocumentWriter(new XpsDocument(container));

            System.Windows.Documents.Serialization.SerializerWriterCollator vxpsd = writer.CreateVisualsCollator();
            int pageno = 1;

            foreach (System.Windows.Documents.DocumentReference r in seqOld.References)
            {
                System.Windows.Documents.FixedDocument d = r.GetDocument(false);
                foreach (System.Windows.Documents.PageContent pc in d.Pages)
                {
                    System.Windows.Documents.FixedPage fixedPage = pc.GetPageRoot(false);
                    double width           = fixedPage.Width;
                    double height          = fixedPage.Height;
                    System.Windows.Size sz = new System.Windows.Size(width, height);
                    fixedPage.Measure(sz);
                    fixedPage.Arrange(new System.Windows.Rect(new System.Windows.Point(), sz));
                    fixedPage.UpdateLayout();
                    ContainerVisual newpage = new ContainerVisual();
                    newpage.Children.Add(fixedPage);
                    newpage.Children.Add(CreateWatermark(400, 400, "hello world"));
                    pageno++;
                    vxpsd.Write(newpage);
                }
            }
            vxpsd.EndBatchWrite();
            container.Close();
            xpsOld.Close();
        }
Пример #17
0
        public static System.Drawing.Size ToDrawing(this System.Windows.Size size, int rounding = 0)
        {
            const double rounder = 0.4999999999; // Difficult to be precise without posible error.
            int          x;
            int          y;

            switch (rounding)
            {
            case 2:     // Ceiling
                x = (int)Math.Ceiling(size.Width);
                y = (int)Math.Ceiling(size.Height);
                break;

            case 1:     // Roundup
                x = (int)Math.Round(size.Width + (Math.Sign(size.Width) > 0 ? rounder : -rounder));
                y = (int)Math.Round(size.Height + (Math.Sign(size.Height) > 0 ? rounder : -rounder));
                break;

            case 0:     // Round
            default:
                x = (int)Math.Round(size.Width);
                y = (int)Math.Round(size.Height);
                break;

            case -1:     // Rounddown
                x = (int)Math.Round(size.Width + (Math.Sign(size.Width) < 0 ? rounder : -rounder));
                y = (int)Math.Round(size.Height + (Math.Sign(size.Height) < 0 ? rounder : -rounder));
                break;

            case -2:     // Floor
                x = (int)Math.Floor(size.Width);
                y = (int)Math.Floor(size.Height);
                break;
            }

            return(new System.Drawing.Size(x, y));
        }
Пример #18
0
        public static void UserDrawRasterWPFScreenCoordinate(System.Windows.Media.DrawingContext dc, System.Windows.Media.ImageSource ImageSource,
                                                             int PixelX, int PixelY, int Width, int Height, double angle = 0.0, System.Windows.Media.ImageBrush pImageBrush = null)
        {
            System.Windows.Size  sz       = new System.Windows.Size(Width, Height);
            System.Windows.Point pnt      = new System.Windows.Point(PixelX - sz.Width / 2, PixelY - sz.Height / 2);
            System.Windows.Rect  rectBack = new System.Windows.Rect(pnt, sz);
            //if (angle == 0.0)
            //{
            //    dc.DrawImage(ImageSource, rectBack);
            //}
            //else
            //{
            System.Windows.Media.RotateTransform rotRect = new System.Windows.Media.RotateTransform(angle, PixelX, PixelY);

            System.Windows.Media.RectangleGeometry RectGeo = new System.Windows.Media.RectangleGeometry(rectBack);
            RectGeo.Transform = rotRect;
            System.Windows.Media.ImageBrush imbrush = null;
            if (pImageBrush != null)
            {
                imbrush = pImageBrush;
            }
            else if (ImageSource != null)
            {
                imbrush = new System.Windows.Media.ImageBrush(ImageSource);
            }
            // imbrush.Viewport = imbrush.Viewport = new Rect(0, 0, 16, 16);
            //dc.DrawImage(_ImageSource, rectBack);

            if (imbrush != null)
            {
                imbrush.Transform = rotRect;
                dc.DrawGeometry(imbrush, null, RectGeo);
            }


            // }
        }
Пример #19
0
        public static void UserDrawRasterWPFScreenCoordinate(System.Windows.Media.DrawingContext dc, System.Windows.Media.ImageSource ImageSource,
                                                              int PixelX, int PixelY, int Width, int Height, double angle = 0.0, System.Windows.Media.ImageBrush pImageBrush = null)
        {
            System.Windows.Size sz = new System.Windows.Size(Width, Height);
            System.Windows.Point pnt = new System.Windows.Point(PixelX - sz.Width / 2, PixelY - sz.Height / 2);
            System.Windows.Rect rectBack = new System.Windows.Rect(pnt, sz);
            //if (angle == 0.0)
            //{
            //    dc.DrawImage(ImageSource, rectBack);
            //}
            //else
            //{
            System.Windows.Media.RotateTransform rotRect = new System.Windows.Media.RotateTransform(angle, PixelX, PixelY);

            System.Windows.Media.RectangleGeometry RectGeo = new System.Windows.Media.RectangleGeometry(rectBack);
            RectGeo.Transform = rotRect;
            System.Windows.Media.ImageBrush imbrush = null;
            if (pImageBrush != null)
            {
                imbrush = pImageBrush;
            }
            else if (ImageSource != null)
            {
                imbrush = new System.Windows.Media.ImageBrush(ImageSource);
            }
            // imbrush.Viewport = imbrush.Viewport = new Rect(0, 0, 16, 16);
            //dc.DrawImage(_ImageSource, rectBack);

            if (imbrush != null)
            {
                imbrush.Transform = rotRect;
                dc.DrawGeometry(imbrush, null, RectGeo);
            }


            // }
        }
Пример #20
0
        public Size GetPageSize(int pageId, double zoomFactor)
        {
            if (pageId < 0 || pageId >= TotalPages)
            {
                throw new OverflowException(
                          $"Page id {pageId} should greater or equal than 0 and less than total page count {TotalPages}.");
            }

            var p = LibMuPdf.NativeMethods.LoadPage(_doc, pageId);

            var realSize = new LibMuPdf.Rectangle();

            LibMuPdf.NativeMethods.BoundPage(_doc, p, ref realSize);

            var size = new Size
            {
                Width  = realSize.Right * zoomFactor,
                Height = realSize.Bottom * zoomFactor
            };

            LibMuPdf.NativeMethods.FreePage(_doc, p);

            return(size);
        }
Пример #21
0
        /// <summary>Convert the string representation of a point to its double-precision 2D point structure equivalent.
        /// A return value indicates whether the conversion succeeded or failed.</summary>
        /// <param name="pointTag">A string containing a 2D point to convert.<see cref="System.String"/></param>
        /// <param name="size">When this method returns, the double-precision 2D point equivalent contains the
        /// point coordinates, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter
        /// is null, is not a point in a valid format, or represents a point with coordinates less than System.Double.MinValue or
        /// greater than System.Double.MaxValue. This parameter is passed uninitialized.<see cref="System.Windows.Size"/></param>
        /// <returns>True if s was converted successfully, or false otherwise.<see cref="System.Boolean"/></returns>
        public static bool TryParse(string s, out System.Windows.Size size)
        {
            size = new System.Windows.Size(0, 0);

            string[] sTags = s.Split(new char[] { ',' });
            if (sTags.Length != 2)
            {
                return(false);
            }
            double w;
            double h;

            if (double.TryParse(sTags[0], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out w) &&
                double.TryParse(sTags[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out h))
            {
                size.Width  = w;
                size.Height = h;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #22
0
        internal static void DrawRichText(ExcelFile Workbook, IFlxGraphics Canvas, TFontCache FontCache, real Zoom100, bool ReverseRightToLeftStrings,
                                          ref RectangleF CellRect, ref RectangleF PaintClipRect, ref RectangleF TextRect, ref RectangleF ContainingRect,
                                          real Clp, THFlxAlignment HJustify, TVFlxAlignment VJustify, real Alpha,
                                          Color DrawFontColor, TSubscriptData SubData, TRichString OutText, SizeF TextExtent,
                                          TXRichStringList TextLines,
                                          Font AFont, TFloatList MaxDescent, real[] X, real[] Y)
        {
            RectangleF FinalRect = CellRect;

            if (ContainingRect.Right > PaintClipRect.Left &&
                ContainingRect.Left < PaintClipRect.Right &&
                Intersect(TextRect, PaintClipRect, out FinalRect))
            {
                real dy             = 0;
                int  TextLinesCount = TextLines.Count;

                if (VJustify == TVFlxAlignment.justify || VJustify == TVFlxAlignment.distributed)
                {
                    if (TextLinesCount > 1)
                    {
                        dy = (CellRect.Height - TextExtent.Height - 2 * Clp) / (TextLinesCount - 1);
                    }
                }

                float eps = 0.0001F; //Tolerance for the comparison, these are floats, not doubles, and we get rounding errors soon.
                if (TextRect.Left - eps <= ContainingRect.Left && TextRect.Right + eps >= ContainingRect.Right && TextRect.Top - eps <= ContainingRect.Top && TextRect.Bottom + eps >= ContainingRect.Bottom)
                {
                    Canvas.SetClipReplace(PaintClipRect);                      //This will improve pdf export a lot, since we can now join all the BT/ET tags inside one, and then we can also join fonts inside the ET/BT tags.
                }
                else
                {
                    if (Alpha == 0 || Alpha == 90)
                    {
                        Canvas.SetClipReplace(FinalRect);
                    }
                    else
                    {
                        Canvas.SetClipReplace(RectangleF.FromLTRB(PaintClipRect.Left, FinalRect.Top, PaintClipRect.Right, FinalRect.Bottom));                         //rotated text can move to other used cells horizontally.
                    }
                }

                real AcumDy = 0;
                for (int i = 0; i < TextLinesCount; i++)
                {
                    TXRichString TextLine = TextLines[i];
                    if ((Alpha == 0) &&
                        (HJustify == THFlxAlignment.justify && TextLine.Split) ||
                        (HJustify == THFlxAlignment.distributed)
                        )
                    {
                        Canvas.SetClipReplace(FinalRect);
                        WriteJustText(Workbook, Canvas, FontCache, Zoom100, ReverseRightToLeftStrings,
                                      AFont, DrawFontColor, Y[i] + AcumDy, SubData.Offset(Canvas, AFont), CellRect, Clp, TextLine.s,
                                      TextLine.XExtent, MaxDescent[i], HJustify == THFlxAlignment.distributed, TextLine.AdaptFormat);
                    }
                    else
                    {
                        WriteText(Workbook, Canvas, FontCache, Zoom100, AFont, DrawFontColor, X[i],
                                  Y[i] + AcumDy, SubData.Offset(Canvas, AFont), GetVisualString(TextLine.s, ReverseRightToLeftStrings),
                                  Alpha, MaxDescent[i], TextLine.AdaptFormat);
                    }
                    AcumDy += dy;
                }
            }
        }
Пример #23
0
 public BlameLayout WithRenderSize(Size renderSize)
 {
     return renderSize == m_renderSize ? this : new BlameLayout(this, renderSize: renderSize);
 }
Пример #24
0
        /// <summary>
        /// Exporte les actions spécifiées.
        /// </summary>
        /// <param name="actions">Les actions.</param>
        /// <param name="cellReference">La référence de la cellule.</param>
        /// <param name="sheet">La feuille.</param>
        private void ExportActions(ICollection <KAction> actions, WorksheetPart sheet, ref CellReference cellReference)
        {
            var timeFormatService = IoC.Resolve <IServiceBus>().Get <ITimeTicksFormatService>();

            var timeScale = _data.Project.TimeScale;

            #region Format pour les actions

            // Actions
            var actionsFormats = new List <ColumnFormat>()
            {
                // Thumbnail
                new ColumnFormat()
                {
                    Header = string.Empty
                },

                // Label
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Task")
                },

                // Start
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Start")
                },

                // Duration
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Duration")
                },

                // Finish
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Finish")
                },

                // BuildStart
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_BuildStart")
                },

                // BuildDuration
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_BuildDuration")
                },

                // BuildFinish
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_BuildFinish")
                },

                // WBS
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_WBS")
                },

                // Category
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Category")
                },

                // Resource
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Resource")
                },

                // Video
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Video")
                },

                // Predecessors
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Predecessors")
                },

                // Original
                new ColumnFormat()
                {
                    Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Original")
                },
            };

            // Ref1
            if (_referentialsUse[ProcessReferentialIdentifier.Ref1].IsEnabled)
            {
                actionsFormats.Add(new ColumnFormat()
                {
                    Header = IoC.Resolve <IReferentialsUseService>().GetLabel(ProcessReferentialIdentifier.Ref1)
                });
            }

            // Ref2
            if (_referentialsUse[ProcessReferentialIdentifier.Ref2].IsEnabled)
            {
                actionsFormats.Add(new ColumnFormat()
                {
                    Header = IoC.Resolve <IReferentialsUseService>().GetLabel(ProcessReferentialIdentifier.Ref2)
                });
            }

            // Ref3
            if (_referentialsUse[ProcessReferentialIdentifier.Ref3].IsEnabled)
            {
                actionsFormats.Add(new ColumnFormat()
                {
                    Header = IoC.Resolve <IReferentialsUseService>().GetLabel(ProcessReferentialIdentifier.Ref3)
                });
            }

            // Ref4
            if (_referentialsUse[ProcessReferentialIdentifier.Ref4].IsEnabled)
            {
                actionsFormats.Add(new ColumnFormat()
                {
                    Header = IoC.Resolve <IReferentialsUseService>().GetLabel(ProcessReferentialIdentifier.Ref4)
                });
            }

            // Ref5
            if (_referentialsUse[ProcessReferentialIdentifier.Ref5].IsEnabled)
            {
                actionsFormats.Add(new ColumnFormat()
                {
                    Header = IoC.Resolve <IReferentialsUseService>().GetLabel(ProcessReferentialIdentifier.Ref5)
                });
            }

            // Ref6
            if (_referentialsUse[ProcessReferentialIdentifier.Ref6].IsEnabled)
            {
                actionsFormats.Add(new ColumnFormat()
                {
                    Header = IoC.Resolve <IReferentialsUseService>().GetLabel(ProcessReferentialIdentifier.Ref6)
                });
            }

            // Ref7
            if (_referentialsUse[ProcessReferentialIdentifier.Ref7].IsEnabled)
            {
                actionsFormats.Add(new ColumnFormat()
                {
                    Header = IoC.Resolve <IReferentialsUseService>().GetLabel(ProcessReferentialIdentifier.Ref7)
                });
            }

            // IsRandom
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_IsRandom")
            });

            // Custom Text
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_CustomValue_Text1")
            });
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_CustomValue_Text2")
            });
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_CustomValue_Text3")
            });
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_CustomValue_Text4")
            });

            // Custom Numeric
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_CustomValue_Numeric1")
            });
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_CustomValue_Numeric2")
            });
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_CustomValue_Numeric3")
            });
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_CustomValue_Numeric4")
            });

            // DifferenceReason
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_DifferenceReason")
            });

            // Amélioration I/E/S
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Reduced_IES")
            });

            // Solution
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Reduced_Solution")
            });

            // Reduction ratio
            actionsFormats.Add(new ColumnFormat()
            {
                Header = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Reduced_ReductionRatio")
            });

            #endregion

            CellContent[][] data = new CellContent[actions.Count][];

            uint tableRowIndex = cellReference.RowIndex;

            int i = 0;
            foreach (var action in actions)
            {
                CellContent[] row = new CellContent[actionsFormats.Count];

                // Mettre à jour IsGroup
                action.IsGroup = WBSHelper.HasChildren(action, actions);

                int j = 0;

                #region Data pour les actions

                // Thumbnail
                j++;

                // Label
                row[j++] = action.Label;

                if (!action.IsGroup)
                {
                    // Start
                    row[j++] = CellContent.TimeSpan(timeFormatService.RoundTime(action.Start, timeScale));

                    // Duration
                    row[j++] = CellContent.TimeSpan(timeFormatService.RoundTime(action.Duration, timeScale));

                    // Finish
                    row[j++] = CellContent.TimeSpan(timeFormatService.RoundTime(action.Finish, timeScale));
                }
                else
                {
                    j += 3; // Nombre de colonnes précédentes
                }
                // BuildStart
                row[j++] = CellContent.TimeSpan(timeFormatService.RoundTime(action.BuildStart, timeScale));

                // BuildDuration
                row[j++] = CellContent.TimeSpan(timeFormatService.RoundTime(action.BuildDuration, timeScale));

                // BuildFinish
                row[j++] = CellContent.TimeSpan(timeFormatService.RoundTime(action.BuildFinish, timeScale));

                // WBS
                row[j++] = action.WBS;


                if (!action.IsGroup)
                {
                    // Category
                    if (action.Category != null)
                    {
                        row[j++] = action.Category.Label;
                    }
                    else
                    {
                        row[j++] = null;
                    }

                    // Resource
                    if (action.Resource != null)
                    {
                        row[j++] = action.Resource.Label;
                    }
                    else
                    {
                        row[j++] = null;
                    }

                    // Video
                    if (action.Video != null)
                    {
                        row[j++] = action.Video.Filename;
                    }
                    else
                    {
                        row[j++] = null;
                    }

                    // Predecessors
                    row[j++] = FormatPredecessorsString(action);

                    // Original
                    if (action.Original != null)
                    {
                        row[j++] = action.Original.Label;
                    }
                    else
                    {
                        row[j++] = null;
                    }

                    // Ref1
                    if (_referentialsUse[ProcessReferentialIdentifier.Ref1].IsEnabled)
                    {
                        row[j++] = GetMultiReferentialLabels(action.Ref1, ProcessReferentialIdentifier.Ref1);
                    }

                    // Ref2
                    if (_referentialsUse[ProcessReferentialIdentifier.Ref2].IsEnabled)
                    {
                        row[j++] = GetMultiReferentialLabels(action.Ref2, ProcessReferentialIdentifier.Ref2);
                    }

                    // Ref3
                    if (_referentialsUse[ProcessReferentialIdentifier.Ref3].IsEnabled)
                    {
                        row[j++] = GetMultiReferentialLabels(action.Ref3, ProcessReferentialIdentifier.Ref3);
                    }

                    // Ref4
                    if (_referentialsUse[ProcessReferentialIdentifier.Ref4].IsEnabled)
                    {
                        row[j++] = GetMultiReferentialLabels(action.Ref4, ProcessReferentialIdentifier.Ref4);
                    }

                    // Ref5
                    if (_referentialsUse[ProcessReferentialIdentifier.Ref5].IsEnabled)
                    {
                        row[j++] = GetMultiReferentialLabels(action.Ref5, ProcessReferentialIdentifier.Ref5);
                    }

                    // Ref6
                    if (_referentialsUse[ProcessReferentialIdentifier.Ref6].IsEnabled)
                    {
                        row[j++] = GetMultiReferentialLabels(action.Ref6, ProcessReferentialIdentifier.Ref6);
                    }

                    // Ref7
                    if (_referentialsUse[ProcessReferentialIdentifier.Ref7].IsEnabled)
                    {
                        row[j++] = GetMultiReferentialLabels(action.Ref7, ProcessReferentialIdentifier.Ref7);
                    }

                    // IsRandom
                    row[j++] = action.IsRandom.ToString();

                    // Custom Text
                    row[j++] = action.CustomTextValue;
                    row[j++] = action.CustomTextValue2;
                    row[j++] = action.CustomTextValue3;
                    row[j++] = action.CustomTextValue4;

                    // Custom Numeric
                    row[j++] = action.CustomNumericValue;
                    row[j++] = action.CustomNumericValue2;
                    row[j++] = action.CustomNumericValue3;
                    row[j++] = action.CustomNumericValue4;

                    // DifferenceReason
                    row[j++] = action.DifferenceReason;

                    // Amélioration
                    if (action.Reduced != null)
                    {
                        // Amélioration I/E/S
                        string label;

                        if (ActionsTimingsMoveManagement.IsActionInternal(action))
                        {
                            label = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Reduced_Internal");
                        }
                        else if (ActionsTimingsMoveManagement.IsActionExternal(action))
                        {
                            label = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Reduced_External");
                        }
                        else if (ActionsTimingsMoveManagement.IsActionDeleted(action))
                        {
                            label = LocalizationManager.GetString("ViewModel_AnalyzeRestitution_Export_Action_Reduced_Deleted");
                        }
                        else
                        {
                            throw new ArgumentOutOfRangeException();
                        }

                        row[j++] = label;

                        row[j++] = action.Reduced.Solution;
                        row[j++] = CellContent.Percentage(action.Reduced.ReductionRatio);
                    }
                    else
                    {
                        row[j++] = null;
                        row[j++] = null;
                        row[j++] = null;
                    }
                }

                #endregion

                data[i] = row;
                i++;
            }

            _file.AddTable(sheet, actionsFormats.ToArray(), data, cellReference);


            // Ajouter une image

            cellReference.NewLine();

            i = 0;
            foreach (var action in actions)
            {
                if (action.Thumbnail != null)
                {
                    // Ajout du libellé du lien
                    var tableCellRef = new CellReference(1, tableRowIndex + (uint)i + 1);
                    _file.SetCellValue(sheet, tableCellRef, new CellContent(action.ActionId.ToString(), CellDataType.Hyperlink));

                    // Ajout du lien
                    string definedName = string.Format("Action.{0}", action.ActionId);
                    _file.CreateDefinedName(sheet, cellReference, definedName);

                    _file.AddHyperlinkToDefinedName(sheet, tableCellRef, definedName, "");

                    // Ajout du libellé
                    _file.SetCellValue(sheet, cellReference, string.Format("{0} {1}", action.WBS, action.Label ?? string.Empty));
                    cellReference.MoveRight();

                    // Ajout de l'image
                    using (var ms = new System.IO.MemoryStream(action.Thumbnail.Data))
                    {
                        var decoder   = System.Windows.Media.Imaging.BitmapDecoder.Create(ms, System.Windows.Media.Imaging.BitmapCreateOptions.PreservePixelFormat, System.Windows.Media.Imaging.BitmapCacheOption.OnLoad);
                        var size      = new System.Windows.Size(decoder.Frames[0].PixelWidth, decoder.Frames[0].PixelHeight);
                        var mimeTypes = decoder.CodecInfo.MimeTypes;

                        ImagePartType imageType;
                        if (mimeTypes.Contains("image/jpeg"))
                        {
                            imageType = ImagePartType.Jpeg;
                        }
                        else if (mimeTypes.Contains("image/bmp"))
                        {
                            imageType = ImagePartType.Bmp;
                        }
                        else if (mimeTypes.Contains("image/png"))
                        {
                            imageType = ImagePartType.Png;
                        }
                        else
                        {
                            continue;
                        }

                        string pictureName = string.Format("Thumbnail.{0}", action.ActionId);

                        uint rowsLength = _file.AddImage(sheet, action.Thumbnail.Data, imageType, action.ActionId.ToString(), pictureName, size, cellReference);

                        // On déplace la cellule active à après l'image
                        cellReference = new CellReference(1, cellReference.RowIndex + rowsLength);
                    }
                }
                i++;
            }
        }
Пример #25
0
 /// <summary>
 ///     Constructor from S.W.Size
 /// </summary>
 /// <param name="size"></param>
 public NativeSizeFloat(System.Windows.Size size) : this((float)size.Width, (float)size.Height)
 {
 }
Пример #26
0
        /// <summary>
        /// Gets the video resolution of a pin on a renderer.
        /// </summary>
        /// <param name="renderer">The renderer to inspect</param>
        /// <param name="direction">The direction the pin is</param>
        /// <param name="pinIndex">The zero based index of the pin to inspect</param>
        /// <returns>If successful a video resolution is returned.  If not, a 0x0 size is returned</returns>
        protected static Size GetVideoSize(IBaseFilter renderer, PinDirection direction, int pinIndex)
        {
            var size = new Size();

            var mediaType = new AMMediaType();
            IPin pin = DsFindPin.ByDirection(renderer, direction, pinIndex);

            if (pin == null)
                goto done;

            int hr = pin.ConnectionMediaType(mediaType);

            if (hr != 0)
                goto done;

            /* Check to see if its a video media type */
            if (mediaType.formatType != FormatType.VideoInfo2 && mediaType.formatType != FormatType.VideoInfo)
            {
                goto done;
            }

            var videoInfo = new VideoInfoHeader();

            /* Read the video info header struct from the native pointer */
            Marshal.PtrToStructure(mediaType.formatPtr, videoInfo);

            Rectangle rect = videoInfo.SrcRect.ToRectangle();
            size = new Size(rect.Width, rect.Height);

            done:
            DsUtils.FreeAMMediaType(mediaType);

            return size;
        }
        public static void MapBlueprintToCells(List<List<Cell>> pCells, Size pBlueprintSize, RealBlueprint pRealBlueprint)
        {
            var bitmap = FilterImage(pRealBlueprint, pBlueprintSize);

            SetObstacles(pCells, bitmap, pRealBlueprint.DefaultObstacle);
        }
Пример #28
0
        private void GenerateBlueprintFromImage(RealBlueprint pRealBlueprint)
        {
            mRealSize = pRealBlueprint.Size;
            Cells = AdjustNewCellArea();

            BlueprintCreator.MapBlueprintToCells(mCells, new Size(CellAreaWidth, CellAreaHeight), pRealBlueprint);
        }
		public BitmapConverter(Size size)
		{
			_renderTargetBitmap = new RenderTargetBitmap((int)size.Width, (int)size.Height, 96d, 96d, PixelFormats.Pbgra32);
		}
Пример #30
0
        public static ImageSource ImageSourceAtom(structTransportCommonProperty refTarget)
        {

            string imageKey = "";

            ImageSource imageSource = null;

            System.Windows.Size sz = new System.Windows.Size(24, 24);
            System.Windows.Size szFor = new System.Windows.Size(15, 15);

            System.Windows.Size szP = new System.Windows.Size(20, 20);

            System.Windows.Point pnt = new System.Windows.Point(0, 0);
            System.Windows.Point pntP = new System.Windows.Point(5, 5);
            System.Windows.Point pntFor = new System.Windows.Point(2, 2);


            System.Windows.Rect rectBack = new System.Windows.Rect(pnt, sz);
            System.Windows.Rect rectP = new System.Windows.Rect(pntP, szP);

            System.Windows.Rect rectFor = new System.Windows.Rect(pntFor, szFor);

            ImageSource ImageSourceDrawHand = new BitmapImage(new Uri("pack://application:,,,/Images/PanDrag.ico"));


            

          //  if (refTarget.AtomClass == "GameService.clsGroundAtom" || refTarget.AtomClass == "GameService.clsTarget" || refTarget.AtomClass == "GameService.NavalTask.clsNavalAtom")
            {
                char ch = new char();
                System.Windows.Media.SolidColorBrush curBrush = new System.Windows.Media.SolidColorBrush();


               
                curBrush.Color = System.Windows.Media.Colors.Red;
               



               // ch = (char)refTarget.FontKey;
                ch = (char)150;
                //switch (refTarget.CountryColorSide)
                //{
                //    case COLOR_SIDE.BLUE:
                //        curBrush.Color = System.Windows.Media.Colors.Blue;
                //        break;
                //    case COLOR_SIDE.RED:
                //        curBrush.Color = System.Windows.Media.Colors.Red;
                //        break;
                //    case COLOR_SIDE.GREEN:
                //        curBrush.Color = System.Windows.Media.Colors.Green;
                //        break;
                //    case COLOR_SIDE.WHITE:
                //        curBrush.Color = System.Windows.Media.Colors.Gray;
                //        break;
                //}

                //System.Windows.Media.FormattedText frm = new System.Windows.Media.FormattedText(new string(ch, 1),
                //                                     System.Globalization.CultureInfo.GetCultureInfo("en-us"),
                //                                     System.Windows.FlowDirection.LeftToRight,
                //                                     new System.Windows.Media.Typeface("Simulation Font Environmental"),
                //                                     14, curBrush);

                System.Windows.Media.FormattedText frm = new System.Windows.Media.FormattedText(new string(ch, 1),
                                               System.Globalization.CultureInfo.GetCultureInfo("en-us"),
                                               System.Windows.FlowDirection.LeftToRight,
                                               new System.Windows.Media.Typeface("Wingdings 2"),
                                               42, curBrush);


                frm.TextAlignment = System.Windows.TextAlignment.Center;
                // frm.SetFontWeight(System.Windows.FontWeights.Bold);

                RenderTargetBitmap bmp = new RenderTargetBitmap(36, 36, 120, 96, PixelFormats.Pbgra32);

                DrawingVisual drawingVisual = new DrawingVisual();
                DrawingContext drawingContext = drawingVisual.RenderOpen();

                drawingContext.DrawText(frm, new System.Windows.Point(15, 5));
                drawingContext.DrawImage(ImageSourceDrawHand, rectP);

                drawingContext.Close();

                bmp.Render(drawingVisual);
                imageSource = bmp;


            }

            return imageSource;
        }
Пример #31
0
        /// <summary>
        /// Reads the video stream information for the media file
        /// </summary>
        private void ReadVideoFormat(AMMediaType mediaType)
        {
            m_videoSubType = mediaType.subType;

            int hr = m_mediaDet.get_StreamLength(out m_videoStreamLength);
            DsError.ThrowExceptionForHR(hr);

            if(mediaType.formatType == FormatType.VideoInfo) /* Most common video major type */
            {
                HasVideo = true;

                /* 'Cast' the unmanaged pointer to our managed struct so we can read the meta data */
                var header = (VideoInfoHeader)Marshal.PtrToStructure(mediaType.formatPtr, typeof(VideoInfoHeader));
                m_fourCC = ConvertFourCC(header.BmiHeader.Compression);
                m_videoBitsPerPixel = header.BmiHeader.BitCount;
                m_videoResolution = new Size(header.BmiHeader.Width, header.BmiHeader.Height);
            }
            else if (mediaType.formatType == FormatType.VideoInfo2) /* Usually for interlaced video */
            {
                HasVideo = true;

                /* 'Cast' the unmanaged pointer to our managed struct so we can read the meta data */
                var header = (VideoInfoHeader2)Marshal.PtrToStructure(mediaType.formatPtr, typeof(VideoInfoHeader2));
                m_fourCC = ConvertFourCC(header.BmiHeader.Compression);
                m_videoResolution = new Size(header.BmiHeader.Width, header.BmiHeader.Height);
                m_videoBitsPerPixel = header.BmiHeader.BitCount;
                /* TODO: Pull out VideoInfoHeader2 specifics */
            }
        }
Пример #32
0
        /// <summary>
        /// Frees any memory and resets to a default state
        /// </summary>
        private void FreeResources()
        {
            m_audioBitsPerSample = 0;
            m_audioChannels = 0;
            m_audioSamplesPerSecond = 0;
            m_audioStreamLength = 0;
            m_audioSubType = Guid.Empty;
            m_filename = "";
            m_fourCC = "";
            m_streamCount = 0;
            m_videoBitsPerPixel = 0;
            m_videoResolution = Size.Empty;
            m_videoStreamLength = 0;
            m_videoSubType = Guid.Empty;
            HasAudio = false;
            HasVideo = false;

            if (m_bitmap != null)
                m_bitmap.Dispose();

            m_bitmap = null;

            if(m_mediaDet != null)
            {
                Marshal.ReleaseComObject(m_mediaDet);
                m_mediaDet = null;
            }
        }
Пример #33
0
 public void SetSize(Size size)
 {
     this.ClientSize = size;
     this.axWindowsMediaPlayer1.Size = new System.Drawing.Size((int) size.Width, (int) size.Height);
 }
 protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint)
 {
     return(default(System.Windows.Size));
 }
Пример #35
0
        /// <summary>
        ///     if hasHeader is true, then UpdateImage(byte[]) is called
        ///     otherwise, the size is compared to lastSize,
        ///     if they differ or header is null, a header is created, and concatinated with data, then UpdateImage(byte[]) is
        ///     called
        /// </summary>
        /// <param name="data">
        ///     image data
        /// </param>
        /// <param name="size">
        ///     image size
        /// </param>
        /// <param name="hasHeader">
        ///     whether or not a header needs to be concatinated
        /// </param>
        public void UpdateImage(byte[] data, Size size, bool hasHeader, string encoding=null)
        {
            //Console.WriteLine(1 / DateTime.Now.Subtract(wtf).TotalSeconds);
            //wtf = DateTime.Now;
            if (hasHeader)
            {
                UpdateImage(data);
                return;
            }

            if (data != null)
            {
                byte[] correcteddata;
                switch (encoding)
                {
                    case "mono16":
                        correcteddata = new byte[(int) Math.Round(3d*data.Length/2d)];
                        for (int i = 0, ci = 0; i < data.Length; i += 2, ci += 3)
                        {
                            ushort realDepth = (ushort) ((data[i] << 8) | (data[i + 1]));
                            byte pixelcomponent = (byte) Math.Floor(realDepth/255d);
                            correcteddata[ci] = correcteddata[ci + 1] = correcteddata[ci + 2] = pixelcomponent;
                        }
                        break;
                    case "16UC1":
                    {
                        correcteddata = new byte[(int) Math.Round(3d*data.Length/2d)];
                        int[] balls = new int[(int) Math.Round(data.Length/2d)];
                        int maxball = 0;
                        int minball = int.MaxValue;
                        for (int i = 0, ci = 0; i < data.Length; i += 2, ci += 3)
                        {
                            balls[i/2] = (data[i + 1] << 8) | (data[i]);
                            if (balls[i/2] > maxball)
                                maxball = balls[i/2];
                            if (balls[i/2] < minball)
                                minball = balls[i/2];
                        }
                        for (int i = 0, ci = 0; i < balls.Length; i++, ci += 3)
                        {
                            byte intensity = (byte) Math.Round((maxball - (255d*balls[i]/(maxball - minball))));
                            correcteddata[ci] = correcteddata[ci + 1] = correcteddata[ci + 2] = intensity;
                        }
                    }
                        break;
                    case "mono8":
                    case "bayer_grbg8":
                        correcteddata = new byte[3*data.Length];
                        for (int i = 0, ci = 0; i < data.Length; i += 1, ci += 3)
                        {
                            correcteddata[ci] = correcteddata[ci + 1] = correcteddata[ci + 2] = data[i];
                        }
                        break;
                    case "32FC1":
                    {
                        correcteddata = new byte[(int) Math.Round(3d*data.Length/4d)];
                        for (int i = 0, ci = 0; i < data.Length; i += 4, ci += 3)
                        {
                            correcteddata[ci] = correcteddata[ci + 1] = correcteddata[ci + 2] = (byte) Math.Floor(255d*BitConverter.ToSingle(data, i));
                        }
                    }
                        break;
                    default:
                        correcteddata = data;
                        break;
                }
                // make a bitmap file header if we don't already have one
                if (header == null || size != lastSize)
                    MakeHeader(correcteddata, size);

                // stick it on the bitmap data
                try
                {
                    UpdateImage(concat(header, correcteddata));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                data = null;
                correcteddata = null;
            }
        }
Пример #36
0
        bool GetCameraFormat(int index, out System.Windows.Size dim)
        {
            dim = new System.Windows.Size();
            IEnumerable<System.Windows.Size> res = mCamera.AvailableResolutions;
            if (res == null) return false;
            IEnumerator<System.Windows.Size> resolutions = res.GetEnumerator();
            resolutions.MoveNext();
            int number = 0;
            while (resolutions.Current != null)
            {
                if (index == number)
                    break;
                number++;
            }

            dim = resolutions.Current;
            return true;
        }
Пример #37
0
 public static BitmapImage ResizeImage(BitmapImage bitmapImage, Size size)
 {
     var bitmap = GetBitmap(bitmapImage);
     var resizedBitmap =  new Bitmap(bitmap, (int) size.Width, (int) size.Height);
     return GetBitmapImage(resizedBitmap);
 }
        private static void DrawCenteredText(FixedContentEditor editor, string text, Size size)
        {
            Block block = new Block();

            block.TextProperties.TrySetFont(new FontFamily("Arial"));
            block.HorizontalAlignment = HorizontalAlignment.Center;
            block.VerticalAlignment = VerticalAlignment.Center;
            block.GraphicProperties.FillColor = RgbColors.White;
            block.TextProperties.FontSize = 16;
            block.InsertText(text);

            editor.DrawBlock(block, size);
        }
        private void DrawFunnelBlock(double startPercentHeight, double endPercentHeight)
        {
            Point[] contourPoints = ExampleDocumentSizes.GetSubFunnelBlockContourPoints(startPercentHeight, endPercentHeight);
            editor.GraphicProperties.IsStroked = false;
            var path = new G.PathGeometry();
            var figure = path.Figures.AddPathFigure();
            figure.StartPoint = contourPoints[0];
            figure.IsClosed = true;
            string funnelBlockText;
            double textYOffset = 0;

            if (startPercentHeight == 0)
            {
                funnelBlockText = "IMAGES";
                editor.GraphicProperties.FillColor = new RgbColor(37, 160, 219);
                var arc = figure.Segments.AddArcSegment();
                arc.Point = contourPoints[1];
                arc.IsLargeArc = false;
                arc.SweepDirection = G.SweepDirection.Counterclockwise;
                arc.RadiusX = ExampleDocumentSizes.EllipseRadiuses.Width;
                arc.RadiusY = ExampleDocumentSizes.EllipseRadiuses.Height;
                textYOffset = arc.RadiusY / 2;
                figure.Segments.AddLineSegment(contourPoints[2]);
                figure.Segments.AddLineSegment(contourPoints[3]);
                textYOffset = ExampleDocumentSizes.EllipseRadiuses.Height;
            }
            else if (endPercentHeight == 1)
            {
                funnelBlockText = "FONTS";
                editor.GraphicProperties.FillColor = new RgbColor(42, 180, 0);
                figure.Segments.AddLineSegment(contourPoints[1]);
                figure.Segments.AddLineSegment(contourPoints[2]);
                var arc = figure.Segments.AddArcSegment();
                arc.Point = contourPoints[3];
                arc.IsLargeArc = false;
                arc.SweepDirection = G.SweepDirection.Clockwise;
                arc.RadiusX = ExampleDocumentSizes.EllipseRadiuses.Width;
                arc.RadiusY = ExampleDocumentSizes.EllipseRadiuses.Height + 100;
            }
            else
            {
                funnelBlockText = "SHAPES";
                editor.GraphicProperties.FillColor = new RgbColor(255, 127, 0);
                figure.Segments.AddLineSegment(contourPoints[1]);
                figure.Segments.AddLineSegment(contourPoints[2]);
                figure.Segments.AddLineSegment(contourPoints[3]);
            }

            editor.DrawPath(path);

            using (editor.SavePosition())
            {
                Size textSize = new Size(contourPoints[1].X - contourPoints[0].X, ExampleDocumentSizes.FunnelBlockHeight - textYOffset);
                editor.Position.Translate(contourPoints[0].X, contourPoints[0].Y + textYOffset);
                DrawCenteredText(editor, funnelBlockText, textSize);
            }
        }
 protected override System.Windows.Size ArrangeOverride(System.Windows.Size arrangeSize) =>
 VerticalStackLayoutManager.Instance.ArrangeOverride(this, arrangeSize.ToStandardUISize()).ToWpfSize();
Пример #41
0
 /// <summary>
 ///     Constructor from System.Windows.Size
 /// </summary>
 /// <param name="size">System.Windows.Size</param>
 public NativeSize(System.Windows.Size size)
     : this((int)size.Width, (int)size.Height)
 {
 }
Пример #42
0
        private void SetupAreaSize(Size pCellAreaSize)
        {
            var precision = Tools.GetPrecisionValue(mNodeNetwork.EstimationPrecision);

            CellWidth = CellHeight = precision * 20;
            CellAreaHeight = pCellAreaSize.Height * CellHeight;
            CellAreaWidth = pCellAreaSize.Width * CellWidth;

            Log.Write(LogLevel.Info, string.Format("Rozmiary planu budynku w pikselach to: {0}x{1} px, rozmiary pojedynczego pola to: {2}x{3} px", CellAreaWidth, CellAreaHeight, CellWidth, CellHeight));
        }
Пример #43
0
 public System.Windows.Size?PreferredPreviewSize(System.Windows.Size currentSize)
 {
     return(new System.Windows.Size(980, 600));
 }
Пример #44
0
        private static void AddWildcard(IFlxGraphics Canvas, TFontCache FontCache, real Zoom100,
                                        Font AFont, real MaxTextWidth, TXRichStringList TextLines, ref SizeF TextExtent)
        {
            TXRichString LineWithWildcard = null;

            foreach (TXRichString line in TextLines)
            {
                if (line.s == null || line.s.RTFRunCount > 0)
                {
                    return;                                           //wildcards only apply to non formatted lines.
                }
                if (line.AdaptFormat != null && line.AdaptFormat.WildcardPos >= 0)
                {
                    LineWithWildcard = line;
                    break;
                }
            }

            if (LineWithWildcard == null)
            {
                return;
            }
            AddWilcardtoLine(Canvas, FontCache, Zoom100, AFont, MaxTextWidth, ref TextExtent, LineWithWildcard);
        }
Пример #45
0
        /// <summary>
        /// Creates the arc segment from parameters of the GDI+ DrawArc function.
        /// </summary>
        public static ArcSegment CreateArcSegment(double x, double y, double width, double height, double startAngle,
                                                  double sweepAngle, out SysPoint startPoint)
        {
            // Normalize the angles.
            double α = startAngle;

            if (α < 0)
            {
                α = α + (1 + Math.Floor((Math.Abs(α) / 360))) * 360;
            }
            else if (α > 360)
            {
                α = α - Math.Floor(α / 360) * 360;
            }
            Debug.Assert(α >= 0 && α <= 360);

            if (Math.Abs(sweepAngle) >= 360)
            {
                sweepAngle = Math.Sign(sweepAngle) * 360;
            }
            double β = startAngle + sweepAngle;

            if (β < 0)
            {
                β = β + (1 + Math.Floor((Math.Abs(β) / 360))) * 360;
            }
            else if (β > 360)
            {
                β = β - Math.Floor(β / 360) * 360;
            }

            if (α == 0 && β < 0)
            {
                α = 360;
            }
            else if (α == 360 && β > 0)
            {
                α = 0;
            }

            // Scanling factor.
            double δx = width / 2;
            double δy = height / 2;

            // Center of ellipse.
            double x0 = x + δx;
            double y0 = y + δy;

            double cosα, cosβ, sinα, sinβ;

            if (width == height)
            {
                // Circular arc needs no correction.
                α = α * Calc.Deg2Rad;
                β = β * Calc.Deg2Rad;
            }
            else
            {
                // Elliptic arc needs the angles to be adjusted such that the scaling transformation is compensated.
                α    = α * Calc.Deg2Rad;
                sinα = Math.Sin(α);
                if (Math.Abs(sinα) > 1E-10)
                {
                    if (α < Math.PI)
                    {
                        α = Math.PI / 2 - Math.Atan(δy * Math.Cos(α) / (δx * sinα));
                    }
                    else
                    {
                        α = 3 * Math.PI / 2 - Math.Atan(δy * Math.Cos(α) / (δx * sinα));
                    }
                }
                //α = Calc.πHalf - Math.Atan(δy * Math.Cos(α) / (δx * sinα));
                β    = β * Calc.Deg2Rad;
                sinβ = Math.Sin(β);
                if (Math.Abs(sinβ) > 1E-10)
                {
                    if (β < Math.PI)
                    {
                        β = Math.PI / 2 - Math.Atan(δy * Math.Cos(β) / (δx * sinβ));
                    }
                    else
                    {
                        β = 3 * Math.PI / 2 - Math.Atan(δy * Math.Cos(β) / (δx * sinβ));
                    }
                }
                //β = Calc.πHalf - Math.Atan(δy * Math.Cos(β) / (δx * sinβ));
            }

            sinα = Math.Sin(α);
            cosα = Math.Cos(α);
            sinβ = Math.Sin(β);
            cosβ = Math.Cos(β);

            startPoint = new SysPoint(x0 + δx * cosα, y0 + δy * sinα);
            SysPoint       destPoint      = new SysPoint(x0 + δx * cosβ, y0 + δy * sinβ);
            SysSize        size           = new SysSize(δx, δy);
            bool           isLargeArc     = Math.Abs(sweepAngle) >= 180;
            SweepDirection sweepDirection = sweepAngle > 0 ? SweepDirection.Clockwise : SweepDirection.Counterclockwise;

#if !SILVERLIGHT && !NETFX_CORE
            bool       isStroked = true;
            ArcSegment seg       = new ArcSegment(destPoint, size, 0, isLargeArc, sweepDirection, isStroked);
#else
            ArcSegment seg = new ArcSegment();
            seg.Point          = destPoint;
            seg.Size           = size;
            seg.RotationAngle  = 0;
            seg.IsLargeArc     = isLargeArc;
            seg.SweepDirection = sweepDirection;
            // isStroked does not exist in Silverlight 3
#endif
            return(seg);
        }
Пример #46
0
        internal static RectangleF CalcTextCoords(out real[] X, out real[] Y, TRichString OutText, TVAlign VAlign,
                                                  ref THAlign HAlign, real Indent, real Alpha, RectangleF CellRect, real Clp, SizeF TextExtent,
                                                  bool FmtGeneral, bool Vertical, real SinAlpha, real CosAlpha, TXRichStringList TextLines, double Linespacing0, TVFlxAlignment VJustify)
        {
            double Linespacing = VJustify == TVFlxAlignment.distributed || VJustify == TVFlxAlignment.justify ? 1.0 : Linespacing0;

            bool TextLeftToRight = IsLeftToRight(OutText.ToString());

            X = new real[TextLines.Count]; Y = new real[TextLines.Count];

            if (Alpha == 0)              //optimize the most common case
            {
                return(CalcTextCoordsAlpha0(X, Y, VAlign, ref HAlign, Indent, ref CellRect, Clp, ref TextExtent, FmtGeneral, Vertical, TextLeftToRight, TextLines, Linespacing));
            }

            else
            {
                // There is rotation. Now values of TextExtent are not ok, since lines will stack.for example ///////  Each line has the same y, and the x is calculated as height/cosAlpha
                return(CalcTextCoordsRotated(X, Y, VAlign, HAlign, Alpha, ref CellRect, Clp, FmtGeneral, SinAlpha, CosAlpha, TextLines, Linespacing));
            }
        }
Пример #47
0
        internal static void CalcTextBox(IFlxGraphics Canvas, TFontCache FontCache, real Zoom100, RectangleF CellRect, real Clp, bool MultiLine, real Alpha, bool Vertical, TRichString OutText, Font AFont, TAdaptativeFormats AdaptativeFormats, out SizeF TextExtent, out TXRichStringList TextLines, out TFloatList MaxDescent)
        {
            TextExtent = new SizeF(0, 0);
            TextLines  = new TXRichStringList();

            MaxDescent = new TFloatList();
            real MaxTextWidth;

            if (MultiLine || Vertical)
            {
                real Md;
                real TextHeight = RenderMetrics.CalcTextExtent(Canvas, FontCache, Zoom100, AFont, new TRichString("M"), out Md).Height; //not perfect since the rich string might have different fonts, but a good approx.
                MaxTextWidth = CalcMaxTextWidth(ref CellRect, Clp, Alpha, TextHeight);

                RenderMetrics.SplitText(Canvas, FontCache, Zoom100, OutText, AFont, MaxTextWidth, TextLines, out TextExtent, Vertical, MaxDescent, AdaptativeFormats);
            }
            else
            {
                TextLines.Add(new TXRichString(OutText, false, 0, 0, AdaptativeFormats));
                real mdx = 0;
                TextExtent           = RenderMetrics.CalcTextExtent(Canvas, FontCache, Zoom100, AFont, OutText, out mdx);
                TextLines[0].XExtent = TextExtent.Width;
                TextLines[0].YExtent = TextExtent.Height;
                MaxTextWidth         = CalcMaxTextWidth(ref CellRect, Clp, Alpha, TextExtent.Height);
                MaxDescent.Add(mdx);
            }

            if (AdaptativeFormats != null && AdaptativeFormats.WildcardPos >= 0)
            {
                MaxTextWidth -= 2 * Clp; //Add some extra clipping so the text doesn't go through the line.
                if (Vertical)
                {
                }
                else
                {
                    AddWildcard(Canvas, FontCache, Zoom100, AFont, MaxTextWidth, TextLines, ref TextExtent);
                }
            }
        }
Пример #48
0
        private BlameLayout(BlameLayout layout, int? topLineNumber = null, Size? renderSize = null, double? lineHeight = null,
			double? lineNumberColumnWidth = null, double? codeColumnWidth = null, bool fullRefresh = false)
            : this()
        {
            // copy values from other BlameLayout
            m_blame = layout.m_blame;
            m_columnWidths = layout.m_columnWidths;

            // copy or replace values from other BlameLayout
            m_topLineNumber = topLineNumber ?? layout.m_topLineNumber;
            m_renderSize = renderSize ?? layout.m_renderSize;
            m_lineHeight = lineHeight ?? layout.m_lineHeight;
            m_columnWidths[c_lineNumberColumnIndex] = lineNumberColumnWidth ?? m_columnWidths[c_lineNumberColumnIndex];
            m_columnWidths[c_codeColumnIndex] = codeColumnWidth ?? m_columnWidths[c_codeColumnIndex];
            m_authorIndex = fullRefresh ? GetBlameAuthors(m_blame) : layout.m_authorIndex;
            m_oldestCommit = fullRefresh ? GetOldestCommit(m_blame) : layout.m_oldestCommit;
            m_dateScale = fullRefresh ? GetDateScale(m_blame, m_oldestCommit) : layout.m_dateScale;

            // calculate new values
            m_lineCount = (int) Math.Ceiling(m_renderSize.Height / m_lineHeight);
        }
Пример #49
0
        internal static void AddWilcardtoLine(IFlxGraphics Canvas, TFontCache FontCache, real Zoom100, Font AFont, real MaxTextWidth, ref SizeF TextExtent, TXRichString LineWithWildcard)
        {
            if (LineWithWildcard == null || LineWithWildcard.AdaptFormat == null)
            {
                return;
            }
            int WildcardPos = LineWithWildcard.AdaptFormat.WildcardPos;

            if (WildcardPos < 0)
            {
                return;
            }

            string s1           = LineWithWildcard.s.ToString();
            string WildcardChar = String.Empty + s1[WildcardPos];

            if (CharUtils.IsSurrogatePair(s1, WildcardPos) && WildcardPos + 1 < s1.Length)
            {
                WildcardChar += s1[WildcardPos + 1];
            }
            string sOrg = s1;

            s1 = s1.Remove(WildcardPos, WildcardChar.Length);//consider the case the string has 0 wildcards.
            string sOld = s1;
            real   wc;
            real   OldWc = LineWithWildcard.XExtent;

            do
            {
                real md;
                wc = RenderMetrics.CalcTextExtent(Canvas, FontCache, Zoom100, AFont, new TRichString(s1), out md).Width;
                if (wc < MaxTextWidth)
                {
                    sOld  = s1;
                    OldWc = wc;
                    s1    = s1.Insert(WildcardPos, WildcardChar);
                }
            }while (wc < MaxTextWidth);

            LineWithWildcard.s = new TRichString(sOld);
            if (sOrg.Length > sOld.Length)
            {
                LineWithWildcard.AdaptFormat.RemovedPosition(WildcardPos, sOrg.Length - sOld.Length);                            //a line with a wildcard can have 0 characters in the wildcard.
            }
            if (sOrg.Length < sOld.Length)
            {
                LineWithWildcard.AdaptFormat.InsertedPosition(WildcardPos, sOld.Length - sOrg.Length);
            }
            LineWithWildcard.XExtent = OldWc;
            if (TextExtent.Width < OldWc)
            {
                TextExtent.Width = OldWc;
            }
        }
Пример #50
0
        /// <summary>
        /// Initializes video preview with the <paramref name="previewSize"/> specified.
        /// </summary>
        /// <param name="previewSize">Size of the preview.</param>
        /// <returns>Awaitable task.</returns>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="previewSize"/> is invalid.</exception>
        /// <exception cref="InvalidOperationException">No suitable video preview formats found.</exception>
        public Task StartPreviewAsync(Size previewSize)
        {
            if (previewSize.Height <= 0.0 || previewSize.Width <= 0.0)
            {
                throw new ArgumentOutOfRangeException("previewSize", previewSize, "Preview size is invalid.");
            }

            return this.StartPreviewAsync(CameraController.CreateMediaFormatSelector(previewSize));
        }
Пример #51
0
        private static RectangleF CalcTextCoordsAlpha0(real[] X, real[] Y, TVAlign VAlign, ref THAlign HAlign, real Indent, ref RectangleF CellRect, real Clp, ref SizeF TextExtent, bool FmtGeneral, bool Vertical, bool IsLeftToRight, TXRichStringList TextLines, double Linespacing)
        {
            RectangleF ContainingRect;
            real       AcumY      = 0;
            real       MinX       = 0;
            real       TextHeight = Y.Length < 1 ? TextExtent.Height : (float)(TextLines[Y.Length - 1].YExtent + (TextExtent.Height - TextLines[Y.Length - 1].YExtent) * Linespacing); //Last line doesn't add linespace.

            for (int i = 0; i < X.Length; i++)
            {
                switch (VAlign)
                {
                case TVAlign.Top: Y[i] = AcumY + CellRect.Top + Clp + TextLines[i].YExtent; break;                         //Used to be "CellRect.Top + Clp + TextExtent.Height * Lines" instead, but it goes too low.

                case TVAlign.Center: Y[i] = AcumY + (CellRect.Top + CellRect.Bottom - TextHeight) / 2 + TextLines[i].YExtent; break;

                default: Y[i] = AcumY + CellRect.Bottom - Clp - TextHeight + TextLines[i].YExtent; break;
                }                 //case

                AcumY += (float)(TextLines[i].YExtent * Linespacing);


                THAlign RHAlign = HAlign;
                if (FmtGeneral)
                {
                    if (IsLeftToRight)
                    {
                        RHAlign = THAlign.Right; HAlign = RHAlign;
                    }
                    if (Vertical)
                    {
                        RHAlign = THAlign.Center; HAlign = RHAlign;
                    }
                }
                switch (RHAlign)
                {
                case THAlign.Right: X[i] = CellRect.Right - Clp - TextLines[i].XExtent - Indent; break;

                case THAlign.Center: X[i] = (CellRect.Left + CellRect.Right - TextLines[i].XExtent) / 2; break;

                default: X[i] = CellRect.Left + Clp + 1f * FlexCelRender.DispMul / 100f + Indent; break;
                }                 //case

                if (i == 0 || MinX > X[i])
                {
                    MinX = X[i];
                }
            }
            ContainingRect = new RectangleF(MinX, Y[0] - TextLines[0].YExtent, TextExtent.Width, TextHeight);
            return(ContainingRect);
        }
Пример #52
0
        /// <summary>
        /// Sets the media format for the <paramref name="streamType"/> given.
        /// </summary>
        /// <param name="streamType">Type of the stream to set format for.</param>
        /// <param name="formatSize">The desired format area size.</param>
        /// <returns>Awaitable task.</returns>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="formatSize"/> is invalid.</exception>
        /// <exception cref="ArgumentException"><paramref name="streamType"/> is not supported.</exception>
        /// <exception cref="InvalidOperationException">
        /// No suitable media formats found for the <paramref name="streamType"/> given.
        /// </exception>
        public Task SetMediaFormatAsync(MediaStreamType streamType, Size formatSize)
        {
            if (formatSize.Height <= 0.0 || formatSize.Width <= 0.0)
            {
                throw new ArgumentOutOfRangeException("formatSize", formatSize, "Format size is invalid.");
            }

            switch (streamType)
            {
                case MediaStreamType.Photo:
                case MediaStreamType.VideoRecord:
                    // Valid stream types.
                    break;
                case MediaStreamType.VideoPreview:
                    throw new ArgumentException("Unable to set video preview format. Use 'StartPreviewAsync' methods instead.");
                default:
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Stream type {0} is not supported.", streamType));
            }

            return this.DoSetMediaFormatAsync(streamType, CameraController.CreateMediaFormatSelector(formatSize));
        }
 protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize)
 {
     return(default(System.Windows.Size));
 }
Пример #54
0
        /// <summary>
        /// Creates a new selector used in the <see cref="StartPreviewAsync(Size)"/> and <see cref="SetMediaFormatAsync(MediaStreamType,Size)"/>
        /// that determines the video format to be used.
        /// </summary>
        /// <param name="formatSize">The desired format area size.</param>
        /// <returns>The desired video format to be used.</returns>
        private static Func<IEnumerable<VideoEncodingProperties>, VideoEncodingProperties> CreateMediaFormatSelector(Size formatSize)
        {
            return encodingProperties =>
            {
                if (encodingProperties == null)
                {
                    return null;
                }

                List<VideoEncodingProperties> validProperties = encodingProperties.Where(CameraController.IsValidFormat).ToList();

                // The more the item's area size differs from the requested size, the farther it will be in the list.
                double area = formatSize.Height * formatSize.Width;
                validProperties.Sort((p1, p2) => Math.Abs(p1.Height * p1.Width - area).CompareTo(Math.Abs(p2.Height * p2.Width - area)));

                return validProperties.FirstOrDefault();
            };
        }
Пример #55
0
 public WpfSize Resize(WpfSize availableSize)
 {
     Size       = ConvertSize(Document.PageSizes[Page], availableSize, out var renderSize);
     RenderSize = renderSize;
     return(Size);
 }
Пример #56
0
        /// <summary>
        ///     makes a file header with appropriate width, height, length, and such for the bytearray + drawing.size sent as
        ///     members of the lazycopypastefixerupper
        /// </summary>
        /// <param name="rawdata">
        ///     The rawdata.
        /// </param>
        /// <param name="size">
        ///     The size.
        /// </param>
        private void MakeHeader(byte[] rawdata, Size size)
        {
            lastSize = size;
            int length = rawdata.Length;
            int wholelength = rawdata.Length + 54;
            int width = (int) size.Width;
            int height = (int) size.Height;

            //Console.WriteLine("width= " + width + "\nheight= " + height + "\nlength=" + length + "\nbpp= " + (length / (width * height)));
            byte bitmask = 255;
            header = new byte[54];
            header[0] = (byte) 'B';
            header[1] = (byte) 'M';
            header[2] = (byte) (wholelength & bitmask);
            wholelength = wholelength >> 8;
            header[3] = (byte) (wholelength & bitmask);
            wholelength = wholelength >> 8;
            header[4] = (byte) (wholelength & bitmask);
            wholelength = wholelength >> 8;
            header[5] = (byte) (wholelength & bitmask);

            header[10] = 54;
            header[11] = 0;
            header[12] = 0;
            header[13] = 0;

            header[14] = 40;
            header[15] = 0;
            header[16] = 0;
            header[17] = 0;

            header[18] = (byte) (width & bitmask);
            width = width >> 8;
            header[19] = (byte) (width & bitmask);
            width = width >> 8;
            header[20] = (byte) (width & bitmask);
            width = width >> 8;
            header[21] = (byte) (width & bitmask);

            header[22] = (byte) (height & bitmask);
            height = height >> 8;
            header[23] = (byte) (height & bitmask);
            height = height >> 8;
            header[24] = (byte) (height & bitmask);
            height = height >> 8;
            header[25] = (byte) (height & bitmask);
            header[26] = 1;
            header[27] = 0;
            int bpp = ((int) (Math.Floor(rawdata.Length/(size.Width*size.Height)))*8);
            //Console.WriteLine("BPP = " + bpp);
            header[28] = (byte) bpp;
            header[29] = 0;

            header[30] = 0;
            header[31] = 0;
            header[32] = 0;
            header[33] = 0;

            header[34] = 0x13;
            header[35] = 0x0B;
            header[36] = 0;
            header[37] = 0;

            header[38] = 0x13;
            header[39] = 0x0B;
            header[40] = 0;
            header[41] = 0;

            header[42] = 0;
            header[43] = 0;
            header[44] = 0;
            header[45] = 0;

            header[46] = 0;
            header[47] = 0;
            header[48] = 0;
            header[49] = 0;

            header[50] = (byte) (length & bitmask);
            length = length >> 8;
            header[51] = (byte) (length & bitmask);
            length = length >> 8;
            header[52] = (byte) (length & bitmask);
            length = length >> 8;
            header[53] = (byte) (length & bitmask);
        }
 protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint) =>
 VerticalStackLayoutManager.Instance.MeasureOverride(this, constraint.ToStandardUISize()).ToWpfSize();
Пример #58
0
 public void Setze_Fenstergröße(System.Windows.Size size) {
     fenstergröße = size;
 }
Пример #59
0
 public System.Windows.Size?PreferredPreviewSize(System.Windows.Size currentSize)
 {
     return(new System.Windows.Size(image.PixelWidth, image.PixelHeight));
 }
Пример #60
0
        public void Print(System.Windows.Controls.Image image)
        {
            System.Printing.LocalPrintServer localPrintServer = new System.Printing.LocalPrintServer();
            PrintDialog printDialog = new PrintDialog();

            System.Printing.PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
            double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / image.ActualWidth, capabilities.PageImageableArea.ExtentHeight/image.ActualHeight);
            image.LayoutTransform = new System.Windows.Media.ScaleTransform(scale, scale);
            System.Windows.Size sz = new System.Windows.Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
            image.Measure(sz);
            image.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

            printDialog.PrintVisual(image, "Print Image");
        }