Esempio n. 1
0
        public static Vector CalculateTranslate(
            AlignmentX alignmentX,
            AlignmentY alignmentY,
            Rect sourceRect,
            Rect destinationRect,
            Vector scale)
        {
            var x    = 0.0;
            var y    = 0.0;
            var size = sourceRect.Size * scale;

            switch (alignmentX)
            {
            case AlignmentX.Center:
                x += (destinationRect.Width - size.Width) / 2;
                break;

            case AlignmentX.Right:
                x += destinationRect.Width - size.Width;
                break;
            }

            switch (alignmentY)
            {
            case AlignmentY.Center:
                y += (destinationRect.Height - size.Height) / 2;
                break;

            case AlignmentY.Bottom:
                y += destinationRect.Height - size.Height;
                break;
            }

            return(new Vector(x, y));
        }
 public AlignmentY aliy;         // Alignment position
 private void Defaults()
 {
     posx = 0.5f;
     posy = 0.5f;
     alix = AlignmentX.Center;
     aliy = AlignmentY.Center;
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TileBrushCalculator"/> class.
        /// </summary>
        /// <param name="tileMode">The brush's tile mode.</param>
        /// <param name="stretch">The brush's stretch.</param>
        /// <param name="alignmentX">The brush's horizontal alignment.</param>
        /// <param name="alignmentY">The brush's vertical alignment.</param>
        /// <param name="sourceRect">The brush's source rect</param>
        /// <param name="destinationRect">The brush's destination rect.</param>
        /// <param name="contentSize">The size of the content of the tile brush.</param>
        /// <param name="targetSize">The size of the control to which the brush is being rendered.</param>
        public TileBrushCalculator(
            TileMode tileMode,
            Stretch stretch,
            AlignmentX alignmentX,
            AlignmentY alignmentY,
            RelativeRect sourceRect,
            RelativeRect destinationRect,
            Size contentSize,
            Size targetSize)
        {
            _imageSize = contentSize;

            SourceRect      = sourceRect.ToPixels(_imageSize);
            DestinationRect = destinationRect.ToPixels(targetSize);

            var scale     = stretch.CalculateScaling(DestinationRect.Size, SourceRect.Size);
            var translate = CalculateTranslate(alignmentX, alignmentY, SourceRect, DestinationRect, scale);

            IntermediateSize      = tileMode == TileMode.None ? targetSize : DestinationRect.Size;
            IntermediateTransform = CalculateIntermediateTransform(
                tileMode,
                SourceRect,
                DestinationRect,
                scale,
                translate,
                out _drawRect);
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImmutableImageBrush"/> class.
 /// </summary>
 /// <param name="source">The image to draw.</param>
 /// <param name="alignmentX">The horizontal alignment of a tile in the destination.</param>
 /// <param name="alignmentY">The vertical alignment of a tile in the destination.</param>
 /// <param name="destinationRect">The rectangle on the destination in which to paint a tile.</param>
 /// <param name="opacity">The opacity of the brush.</param>
 /// <param name="transform">The transform of the brush.</param>
 /// <param name="transformOrigin">The transform origin of the brush</param>
 /// <param name="sourceRect">The rectangle of the source image that will be displayed.</param>
 /// <param name="stretch">
 /// How the source rectangle will be stretched to fill the destination rect.
 /// </param>
 /// <param name="tileMode">The tile mode.</param>
 /// <param name="bitmapInterpolationMode">The bitmap interpolation mode.</param>
 public ImmutableImageBrush(
     IBitmap source,
     AlignmentX alignmentX        = AlignmentX.Center,
     AlignmentY alignmentY        = AlignmentY.Center,
     RelativeRect?destinationRect = null,
     double opacity = 1,
     ImmutableTransform?transform  = null,
     RelativePoint transformOrigin = new RelativePoint(),
     RelativeRect?sourceRect       = null,
     Stretch stretch   = Stretch.Uniform,
     TileMode tileMode = TileMode.None,
     BitmapInterpolationMode bitmapInterpolationMode = BitmapInterpolationMode.Default)
     : base(
         alignmentX,
         alignmentY,
         destinationRect ?? RelativeRect.Fill,
         opacity,
         transform,
         transformOrigin,
         sourceRect ?? RelativeRect.Fill,
         stretch,
         tileMode,
         bitmapInterpolationMode)
 {
     Source = source;
 }
Esempio n. 5
0
        /// <summary>
        ///     Returns whether or not an enumeration instance a valid value.
        ///     This method is designed to be used with ValidateValueCallback, and thus
        ///     matches it's prototype.
        /// </summary>
        /// <param name="valueObject">
        ///     Enumeration value to validate.
        /// </param>
        /// <returns> 'true' if the enumeration contains a valid value, 'false' otherwise. </returns>
        public static bool IsAlignmentYValid(object valueObject)
        {
            AlignmentY value = (AlignmentY)valueObject;

            return((value == AlignmentY.Top) ||
                   (value == AlignmentY.Center) ||
                   (value == AlignmentY.Bottom));
        }
 public SerializableImageBrush(ImageBrush Brush)
 {
     this.ImageSource = Brush.ImageSource;
     this.TileMode    = Brush.TileMode;
     this.Stretch     = Brush.Stretch;
     this.AlignmentX  = Brush.AlignmentX;
     this.AlignmentY  = Brush.AlignmentY;
 }
Esempio n. 7
0
 public void Init(AlignmentX alignX, AlignmentY alignY, float xOffset, float yOffset)
 {
     alignmentX = alignX;
     alignmentY = alignY;
     offsetX = xOffset;
     offsetY = yOffset;
     Init();
 }
Esempio n. 8
0
 /// <inheritdoc />
 protected TextElement()
 {
     _font            = "Roboto";
     _text            = "Label";
     _fontSize        = 16.0f;
     _fontWeight      = SharpDX.DirectWrite.FontWeight.Normal;
     _textAlignmentX  = AlignmentX.Center;
     _textAlignmentY  = AlignmentY.Middle;
     _wordWrapping    = WordWrapping.NoWrap;
     TextColour       = Colour.Black;
     TextStrokeColour = new Colour(0, 0, 0, 0);
     _textReady       = true;
 }
        public override int GetHashCode()
        {
            var hashCode = base.GetHashCode();

            unchecked {
                hashCode = hashCode * -1521134295 + AlignmentX.GetHashCode();
                hashCode = hashCode * -1521134295 + AlignmentY.GetHashCode();
                hashCode = hashCode * -1521134295 + Stretch.GetHashCode();
                hashCode = hashCode * -1521134295 + TileMode.GetHashCode();
                hashCode = hashCode * -1521134295 + ViewBox.GetHashCode();
                hashCode = hashCode * -1521134295 + ViewBoxUnits.GetHashCode();
                hashCode = hashCode * -1521134295 + ViewPort.GetHashCode();
                hashCode = hashCode * -1521134295 + ViewPortUnits.GetHashCode();
            }
            return(hashCode);
        }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageBrush"/> class.
 /// </summary>
 /// <param name="alignmentX">The horizontal alignment of a tile in the destination.</param>
 /// <param name="alignmentY">The vertical alignment of a tile in the destination.</param>
 /// <param name="destinationRect">The rectangle on the destination in which to paint a tile.</param>
 /// <param name="opacity">The opacity of the brush.</param>
 /// <param name="sourceRect">The rectangle of the source image that will be displayed.</param>
 /// <param name="stretch">
 /// How the source rectangle will be stretched to fill the destination rect.
 /// </param>
 /// <param name="tileMode">The tile mode.</param>
 protected ImmutableTileBrush(
     AlignmentX alignmentX,
     AlignmentY alignmentY,
     RelativeRect destinationRect,
     double opacity,
     RelativeRect sourceRect,
     Stretch stretch,
     TileMode tileMode)
 {
     AlignmentX      = alignmentX;
     AlignmentY      = alignmentY;
     DestinationRect = destinationRect;
     Opacity         = opacity;
     SourceRect      = sourceRect;
     Stretch         = stretch;
     TileMode        = tileMode;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ImmutableImageBrush"/> class.
 /// </summary>
 /// <param name="source">The image to draw.</param>
 /// <param name="alignmentX">The horizontal alignment of a tile in the destination.</param>
 /// <param name="alignmentY">The vertical alignment of a tile in the destination.</param>
 /// <param name="destinationRect">The rectangle on the destination in which to paint a tile.</param>
 /// <param name="opacity">The opacity of the brush.</param>
 /// <param name="sourceRect">The rectangle of the source image that will be displayed.</param>
 /// <param name="stretch">
 /// How the source rectangle will be stretched to fill the destination rect.
 /// </param>
 /// <param name="tileMode">The tile mode.</param>
 public ImmutableImageBrush(
     IBitmap source,
     AlignmentX alignmentX        = AlignmentX.Center,
     AlignmentY alignmentY        = AlignmentY.Center,
     RelativeRect?destinationRect = null,
     double opacity          = 1,
     RelativeRect?sourceRect = null,
     Stretch stretch         = Stretch.Uniform,
     TileMode tileMode       = TileMode.None)
     : base(
         alignmentX,
         alignmentY,
         destinationRect ?? RelativeRect.Fill,
         opacity,
         sourceRect ?? RelativeRect.Fill,
         stretch,
         tileMode)
 {
     Source = source;
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImmutableImageBrush"/> class.
 /// </summary>
 /// <param name="visual">The visual to draw.</param>
 /// <param name="alignmentX">The horizontal alignment of a tile in the destination.</param>
 /// <param name="alignmentY">The vertical alignment of a tile in the destination.</param>
 /// <param name="destinationRect">The rectangle on the destination in which to paint a tile.</param>
 /// <param name="opacity">The opacity of the brush.</param>
 /// <param name="sourceRect">The rectangle of the source image that will be displayed.</param>
 /// <param name="stretch">
 /// How the source rectangle will be stretched to fill the destination rect.
 /// </param>
 /// <param name="tileMode">The tile mode.</param>
 public ImmutableVisualBrush(
     IVisual visual,
     AlignmentX alignmentX        = AlignmentX.Center,
     AlignmentY alignmentY        = AlignmentY.Center,
     RelativeRect?destinationRect = null,
     double opacity          = 1,
     RelativeRect?sourceRect = null,
     Stretch stretch         = Stretch.Uniform,
     TileMode tileMode       = TileMode.None)
     : base(
         alignmentX,
         alignmentY,
         destinationRect ?? RelativeRect.Fill,
         opacity,
         sourceRect ?? RelativeRect.Fill,
         stretch,
         tileMode)
 {
     Visual = visual;
 }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageBrush"/> class.
 /// </summary>
 /// <param name="alignmentX">The horizontal alignment of a tile in the destination.</param>
 /// <param name="alignmentY">The vertical alignment of a tile in the destination.</param>
 /// <param name="destinationRect">The rectangle on the destination in which to paint a tile.</param>
 /// <param name="opacity">The opacity of the brush.</param>
 /// <param name="transform">The transform of the brush.</param>
 /// <param name="sourceRect">The rectangle of the source image that will be displayed.</param>
 /// <param name="stretch">
 /// How the source rectangle will be stretched to fill the destination rect.
 /// </param>
 /// <param name="tileMode">The tile mode.</param>
 /// <param name="bitmapInterpolationMode">The bitmap interpolation mode.</param>
 protected ImmutableTileBrush(
     AlignmentX alignmentX,
     AlignmentY alignmentY,
     RelativeRect destinationRect,
     double opacity,
     ImmutableTransform?transform,
     RelativeRect sourceRect,
     Stretch stretch,
     TileMode tileMode,
     BitmapInterpolationMode bitmapInterpolationMode)
 {
     AlignmentX              = alignmentX;
     AlignmentY              = alignmentY;
     DestinationRect         = destinationRect;
     Opacity                 = opacity;
     Transform               = transform;
     SourceRect              = sourceRect;
     Stretch                 = stretch;
     TileMode                = tileMode;
     BitmapInterpolationMode = bitmapInterpolationMode;
 }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImmutableImageBrush"/> class.
 /// </summary>
 /// <param name="visual">The visual to draw.</param>
 /// <param name="alignmentX">The horizontal alignment of a tile in the destination.</param>
 /// <param name="alignmentY">The vertical alignment of a tile in the destination.</param>
 /// <param name="destinationRect">The rectangle on the destination in which to paint a tile.</param>
 /// <param name="opacity">The opacity of the brush.</param>
 /// <param name="transform">The transform of the brush.</param>
 /// <param name="sourceRect">The rectangle of the source image that will be displayed.</param>
 /// <param name="stretch">
 /// How the source rectangle will be stretched to fill the destination rect.
 /// </param>
 /// <param name="tileMode">The tile mode.</param>
 /// <param name="bitmapInterpolationMode">Controls the quality of interpolation.</param>
 public ImmutableVisualBrush(
     IVisual visual,
     AlignmentX alignmentX        = AlignmentX.Center,
     AlignmentY alignmentY        = AlignmentY.Center,
     RelativeRect?destinationRect = null,
     double opacity = 1,
     ImmutableTransform?transform = null,
     RelativeRect?sourceRect      = null,
     Stretch stretch   = Stretch.Uniform,
     TileMode tileMode = TileMode.None,
     BitmapInterpolationMode bitmapInterpolationMode = BitmapInterpolationMode.Default)
     : base(
         alignmentX,
         alignmentY,
         destinationRect ?? RelativeRect.Fill,
         opacity,
         transform,
         sourceRect ?? RelativeRect.Fill,
         stretch,
         tileMode,
         bitmapInterpolationMode)
 {
     Visual = visual;
 }
Esempio n. 15
0
        public MainWindow()
        {
            InitializeComponent();



            FormattedText formattedText = new(
                MyText,
                CultureInfo.CurrentCulture,
                FlowDirection.LeftToRight,
                new Typeface(
                    FontFamily,
                    FontStyle,
                    FontWeight,
                    FontStretch),
                40,
                Brushes.Red,
                96);

            //formattedText.SetTextDecorations(TextDecorations.Strikethrough, 1, 5);
            //formattedText.SetTextDecorations(TextDecorations.Strikethrough, 10, 5);
            TextDecoration textDecoration = new();

            textDecoration.Pen      = new(Brushes.Black, 1);
            textDecoration.Location = TextDecorationLocation.Strikethrough;
            TextDecorationCollection textDecorations = new();

            textDecorations.Add(textDecoration);

            formattedText.SetTextDecorations(textDecorations);

            TextEffect textEffect = new();

            textEffect.PositionStart    = 2;
            MyTextBlock.TextDecorations = textDecorations;
            MyTextBox.TextDecorations   = textDecorations;

            DrawingVisual dv = new();

            using (var dc = dv.RenderOpen())
            {
                dc.DrawText(formattedText, new Point());
            }
            Rect drawRect = dv.ContentBounds;
            RenderTargetBitmap targetBitmap = new((int)drawRect.Width, (int)drawRect.Height, 96, 96, PixelFormats.Pbgra32);

            targetBitmap.Render(dv);


            var geo   = formattedText.BuildGeometry(new Point());
            Pen MyPen = new(Brushes.DarkMagenta, 1);

            MyPen.LineJoin = PenLineJoin.Round;

            GeometryDrawing geometryDrawing = new(Brushes.Aqua, MyPen, geo);
            DrawingBrush    MyBrush         = new(geometryDrawing);

            MyBrush.Stretch = Stretch.None;

            Rect       geoRect    = geo.Bounds;
            Rect       renderRect = geo.GetRenderBounds(MyPen);
            AlignmentX alignmentx = MyBrush.AlignmentX;
            AlignmentY alignmentY = MyBrush.AlignmentY;

            Grid grid = new();

            grid.Background = MyBrush;
            _           = MyStackPanel.Children.Add(grid);
            grid.Width  = drawRect.Width;
            grid.Height = drawRect.Height;


            Path MyPath = new();

            MyStackPanel.Children.Add(MyPath);
            MyPath.Data            = geo;
            MyPath.Fill            = Brushes.Aqua;
            MyPath.Stroke          = Brushes.DarkMagenta;
            MyPath.StrokeThickness = 1;

            var renderGeo = MyPath.RenderedGeometry;
            var renderW1  = renderGeo.Bounds.Width;
            var renderW2  = renderGeo.GetRenderBounds(MyPen).Width;

            ////ぼかし
            //BlurEffect blurEffect = new();
            //blurEffect.Radius = 3.0;
            //MyPath.Effect = blurEffect;

            //ドロップシャドウ
            DropShadowEffect dropShadowEffect = new();

            dropShadowEffect.BlurRadius  = 10.0;               //ぼかし半径
            dropShadowEffect.Color       = Colors.DarkMagenta; //色
            dropShadowEffect.Direction   = 315;                //方向
            dropShadowEffect.Opacity     = 1.0;                //不透明度
            dropShadowEffect.ShadowDepth = 10;                 //距離
            MyPath.Effect = dropShadowEffect;


            //ぼかし&ドロップシャドウはできない?
            System.Windows.Media.Effects.Effect effect;
        }
Esempio n. 16
0
        /// <summary>
        /// Updates the CompositionSurfaceBrush's Stretch and Alignment options
        /// </summary>
        /// <param name="surfaceBrush">CompositionSurfaceBrush</param>
        /// <param name="stretch">Stretch mode</param>
        /// <param name="alignX">Horizontal Alignment</param>
        /// <param name="alignY">Vertical Alignment</param>
        /// <param name="alignXAnimation">The animation to use to update the horizontal alignment of the surface brush</param>
        /// <param name="alignYAnimation">The animation to use to update the vertical alignment of the surface brush</param>
        public static void UpdateSurfaceBrushOptions(this CompositionSurfaceBrush surfaceBrush, Stretch stretch,
                                                     AlignmentX alignX, AlignmentY alignY, ScalarKeyFrameAnimation alignXAnimation = null,
                                                     ScalarKeyFrameAnimation alignYAnimation = null)
        {
            // Stretch Mode
            switch (stretch)
            {
            case Stretch.None:
                surfaceBrush.Stretch = CompositionStretch.None;
                break;

            case Stretch.Fill:
                surfaceBrush.Stretch = CompositionStretch.Fill;
                break;

            case Stretch.Uniform:
                surfaceBrush.Stretch = CompositionStretch.Uniform;
                break;

            case Stretch.UniformToFill:
                surfaceBrush.Stretch = CompositionStretch.UniformToFill;
                break;
            }

            // Horizontal Alignment
            var finalAlignX = surfaceBrush.HorizontalAlignmentRatio;

            switch (alignX)
            {
            case AlignmentX.Left:
                finalAlignX = 0;
                break;

            case AlignmentX.Center:
                finalAlignX = 0.5f;
                break;

            case AlignmentX.Right:
                finalAlignX = 1;
                break;
            }

            // If animation is available, animate to the new value
            // otherwise set it explicitly
            if (alignXAnimation == null)
            {
                surfaceBrush.HorizontalAlignmentRatio = finalAlignX;
            }
            else
            {
                alignXAnimation.InsertKeyFrame(1f, finalAlignX);
                surfaceBrush.StartAnimation(() => surfaceBrush.HorizontalAlignmentRatio, alignXAnimation);
            }

            // Vertical Alignment
            var finalAlignY = surfaceBrush.VerticalAlignmentRatio;

            switch (alignY)
            {
            case AlignmentY.Top:
                finalAlignY = 0;
                break;

            case AlignmentY.Center:
                finalAlignY = 0.5f;
                break;

            case AlignmentY.Bottom:
                finalAlignY = 1;
                break;
            }

            // If animation is available, animate to the new value
            // otherwise set it explicitly
            if (alignYAnimation == null)
            {
                surfaceBrush.VerticalAlignmentRatio = finalAlignY;
            }
            else
            {
                alignYAnimation.InsertKeyFrame(1f, finalAlignY);
                surfaceBrush.StartAnimation(() => surfaceBrush.VerticalAlignmentRatio, alignYAnimation);
            }
        }
Esempio n. 17
0
 private void OnScrollbarTextureFetched(Texture texture, AlignmentY alignment)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
 public void SetJustification()
 {
     hAlign = (AlignmentX)(int)((Alignment + 3) % 3);
     vAlign = (AlignmentY)(Math.Ceiling(((Alignment + 1) / 3.0)) - 1);
 }
 /// <summary>
 ///     Sets the alignment y.
 /// </summary>
 /// <param name="obj">The object.</param>
 /// <param name="alignment">The alignment.</param>
 public static void SetAlignmentY(DependencyObject obj, AlignmentY alignment)
 {
     obj.SetValue(AlignmentYProperty, alignment);
 }
Esempio n. 20
0
 public void Init(AlignmentX alignX, AlignmentY alignY)
 {
     alignmentX = alignX;
     alignmentY = alignY;
     Init();
 }
Esempio n. 21
0
		private bool CheckResizeingState (Point position)
			{
			if (position.X < ResizeAreaWidth && position.Y < ResizeAreaHeight)
				{
				alignmentX = AlignmentX.Left;
				alignmentY = AlignmentY.Top;
				return true;
				}
			else if (position.X < ResizeAreaWidth && position.Y > Containergrid.Height - ResizeAreaHeight)
				{
				alignmentX = AlignmentX.Left;
				alignmentY = AlignmentY.Bottom;
				return true;
				}
			else if (position.X > Containergrid.Width - ResizeAreaWidth && position.Y < ResizeAreaHeight)
				{
				alignmentX = AlignmentX.Right;
				alignmentY = AlignmentY.Top;
				return true;
				}
			else if (position.X > Containergrid.Width - ResizeAreaWidth && position.Y > Containergrid.Height - ResizeAreaHeight)
				{
				alignmentX = AlignmentX.Right;
				alignmentY = AlignmentY.Bottom;
				return true;
				}
			return false;
			}
Esempio n. 22
0
        public static Storyboard AnimateResize(Window w, double changeWidth      = 0d, double changeHeight = 0d, double durationMilisec = 200.0,
                                               AlignmentX LocationLockHorizontal = AlignmentX.Left, AlignmentY LocationLockVertical = AlignmentY.Top)
        {
            Storyboard sb = new Storyboard {
                Duration = new Duration(TimeSpan.FromMilliseconds(durationMilisec))
            };

            DoubleAnimationUsingKeyFrames daw;
            DoubleAnimationUsingKeyFrames dah;

            // animate window width
            // animate window height
            if (changeHeight != 0.0)
            {
                dah = new DoubleAnimationUsingKeyFrames();
                dah.KeyFrames.Add(new EasingDoubleKeyFrame(w.ActualHeight, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 00))));
                dah.KeyFrames.Add(new EasingDoubleKeyFrame(w.ActualHeight, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(durationMilisec / 2))));
                dah.KeyFrames.Add(new EasingDoubleKeyFrame(w.ActualHeight + changeHeight, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(durationMilisec))));
                dah.Duration          = new Duration(TimeSpan.FromMilliseconds(durationMilisec));
                dah.AccelerationRatio = 0.4;
                dah.DecelerationRatio = 0.6;
                Storyboard.SetTarget(dah, w);
                Storyboard.SetTargetProperty(dah, new PropertyPath(Window.HeightProperty));
                sb.Children.Add(dah);
            }

            if (changeWidth != 0.0)
            {
                daw = new DoubleAnimationUsingKeyFrames();
                daw.KeyFrames.Add(new EasingDoubleKeyFrame(w.ActualWidth, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 00))));
                daw.KeyFrames.Add(new EasingDoubleKeyFrame(w.ActualWidth + changeWidth, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(durationMilisec / 2))));
                daw.Duration          = new Duration(TimeSpan.FromMilliseconds(durationMilisec / 2));
                daw.AccelerationRatio = 0.4;
                daw.DecelerationRatio = 0.6;
                w.BeginAnimation(Window.WidthProperty, daw);
                Storyboard.SetTarget(daw, w);
                Storyboard.SetTargetProperty(daw, new PropertyPath(Window.WidthProperty));
                sb.Children.Add(daw);
            }

            DoubleAnimationUsingKeyFrames dax;
            DoubleAnimationUsingKeyFrames day;

            // animate window move in horizontal way
            if (LocationLockHorizontal == AlignmentX.Center || LocationLockHorizontal == AlignmentX.Right)
            {
                dax = new DoubleAnimationUsingKeyFrames();
                dax.KeyFrames.Add(new EasingDoubleKeyFrame(w.Left, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 00))));
                switch (LocationLockHorizontal)
                {
                case AlignmentX.Center:
                    dax.KeyFrames.Add(new EasingDoubleKeyFrame(w.Left - changeWidth / 2.0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(durationMilisec / 2))));
                    break;

                case AlignmentX.Right:
                    dax.KeyFrames.Add(new EasingDoubleKeyFrame(w.Left - changeWidth, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(durationMilisec / 2))));
                    break;
                }
                dax.Duration = new Duration(TimeSpan.FromMilliseconds(durationMilisec));

                dax.AccelerationRatio = 0.4; dax.DecelerationRatio = 0.6;

                Storyboard.SetTarget(dax, w);
                Storyboard.SetTargetProperty(dax, new PropertyPath(Window.LeftProperty));
                sb.Children.Add(dax);
            }

            // animate window move vertical
            if (LocationLockVertical == AlignmentY.Center || LocationLockVertical == AlignmentY.Bottom)
            {
                day = new DoubleAnimationUsingKeyFrames();
                day.KeyFrames.Add(new EasingDoubleKeyFrame(w.Top, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 00))));
                day.KeyFrames.Add(new EasingDoubleKeyFrame(w.Top, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(durationMilisec / 2))));

                switch (LocationLockVertical)
                {
                case AlignmentY.Center:
                    day.KeyFrames.Add(new EasingDoubleKeyFrame(w.Top - changeWidth / 2.0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(durationMilisec))));
                    break;

                case AlignmentY.Bottom:
                    day.KeyFrames.Add(new EasingDoubleKeyFrame(w.Top - changeHeight, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(durationMilisec))));
                    break;
                }
                day.Duration          = new Duration(TimeSpan.FromMilliseconds(durationMilisec));
                day.AccelerationRatio = 0.4; day.DecelerationRatio = 0.6;

                Storyboard.SetTarget(day, w);
                Storyboard.SetTargetProperty(day, new PropertyPath(Window.TopProperty));
                sb.Children.Add(day);
            }
            return(sb);
        }
Esempio n. 23
0
        protected override void Invoke(object parameter)
        {
            var visualBrush = Target.GridBackground as VisualBrush;
            var panel       = ((this.Target.GridBackground as VisualBrush).Visual as Panel);

            if (panel != null && panel.Children.Count > 1 && panel.Children[0] is Image && panel.Children[1] is TextBlock)
            {
                if (parameter is SelectionChangedEventArgs && ((parameter as SelectionChangedEventArgs).Source as ComboBox).Name == "combo_hralign")
                {
                    string selectedValue = ((parameter as SelectionChangedEventArgs).Source as ComboBox).SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                    switch (selectedValue)
                    {
                    case "Left":
                        visualBrush.AlignmentX = AlignmentX.Left;
                        horizontalAlignment    = AlignmentX.Left;
                        break;

                    case "Right":
                        visualBrush.AlignmentX = AlignmentX.Right;
                        horizontalAlignment    = AlignmentX.Right;
                        break;

                    case "Center":
                        visualBrush.AlignmentX = AlignmentX.Center;
                        horizontalAlignment    = AlignmentX.Center;
                        break;
                    }
                }
                else if (parameter is SelectionChangedEventArgs && ((parameter as SelectionChangedEventArgs).Source as ComboBox).Name == "combo_vralign")
                {
                    string selectedValue = ((parameter as SelectionChangedEventArgs).Source as ComboBox).SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                    switch (selectedValue)
                    {
                    case "Top":
                        visualBrush.AlignmentY = AlignmentY.Top;
                        verticalAlignment      = AlignmentY.Top;
                        break;

                    case "Bottom":
                        visualBrush.AlignmentY = AlignmentY.Bottom;
                        verticalAlignment      = AlignmentY.Bottom;
                        break;

                    case "Center":
                        visualBrush.AlignmentY = AlignmentY.Center;
                        verticalAlignment      = AlignmentY.Center;
                        break;
                    }
                }
                else if (parameter is EventArgs && (parameter as RoutedEventArgs).Source is RadioButton && ((parameter as RoutedEventArgs).Source as RadioButton).Name == "rd_imagewatermark")
                {
                    (panel.Children[0] as Image).Visibility     = Visibility.Visible;
                    (panel.Children[1] as TextBlock).Visibility = Visibility.Hidden;
                    visualBrush.AlignmentY = verticalAlignment;
                    visualBrush.AlignmentX = horizontalAlignment;
                    (panel.Children[0] as Image).Source = new BitmapImage(new Uri(@"/syncfusion.olapchartdemos.wpf;component/Assets/olapchart/Watermark.png", UriKind.Relative));
                }
                else if (parameter is EventArgs && (parameter as RoutedEventArgs).Source is RadioButton && ((parameter as RoutedEventArgs).Source as RadioButton).Name == "rd_textwatermark")
                {
                    (panel.Children[0] as Image).Source         = null;
                    (panel.Children[0] as Image).Visibility     = Visibility.Hidden;
                    (panel.Children[1] as TextBlock).Visibility = Visibility.Visible;
                    visualBrush.AlignmentY = verticalAlignment;
                    visualBrush.AlignmentX = horizontalAlignment;
                }
                if (parameter is EventArgs)
                {
                    int      i      = 0;
                    string[] colors = { "Red", "Lime", "Cyan", "Violet", "DeepSkyBlue", "DarkGray", "Blue" };
                    foreach (ChartSeries series in this.Target.Series)
                    {
                        var color = ColorConverter.ConvertFromString(colors[i]);
                        if (color != null)
                        {
                            SolidColorBrush brush = new SolidColorBrush((Color)color);
                            series.StrokeThickness = 3;
                            series.Interior        = brush;
                        }
                        i += 1;
                    }
                }
            }
        }
Esempio n. 24
0
 private static Double GetSignedShiftForDirection(AlignmentY Direction, Double ShiftLength)
 {
     switch (Direction)
     {
         case AlignmentY.Top: return +ShiftLength;
         case AlignmentY.Bottom: return -ShiftLength;
         default: return 0;
     }
 }
Esempio n. 25
0
 private void rbBottom_Checked(object sender, RoutedEventArgs e)
 {
     alignY = AlignmentY.Bottom;
     ppcPrint.InvalidatePreview();
 }
 public LoadingView(Window owner, Action action, string friendlyText, AlignmentX x, AlignmentY y) : this(owner, action, friendlyText)
 {
     BlurHolder.AlignmentX = x;
     BlurHolder.AlignmentY = y;
 }
Esempio n. 27
0
        /// <summary>
        /// Calculates the best size that can fit in the destination area based on the given stretch and alignment options.
        /// </summary>
        /// <param name="srcWidth">Width of the source.</param>
        /// <param name="srcHeight">Height of the source.</param>
        /// <param name="destWidth">Width of the destination area.</param>
        /// <param name="destHeight">Height of the destination area.</param>
        /// <param name="stretch">Defines how the source should stretch to fit the destination.</param>
        /// <param name="horizontalAlignment">Horizontal Alignment</param>
        /// <param name="verticalAlignment">Vertical Alignment</param>
        /// <returns>The best fitting Rectangle in the destination area.</returns>
        public static Rect GetOptimumSize(double srcWidth, double srcHeight, double destWidth, double destHeight, Stretch stretch, AlignmentX horizontalAlignment, AlignmentY verticalAlignment)
        {
            var ratio        = srcWidth / srcHeight;
            var targetWidth  = 0d;
            var targetHeight = 0d;

            // Stretch Mode
            switch (stretch)
            {
            case Stretch.None:
                targetWidth  = srcWidth;
                targetHeight = srcHeight;
                break;

            case Stretch.Fill:
                targetWidth  = destWidth;
                targetHeight = destHeight;
                break;

            case Stretch.Uniform:
                // If width is greater than height
                if (ratio > 1.0)
                {
                    targetHeight = Math.Min(destWidth / ratio, destHeight);
                    targetWidth  = targetHeight * ratio;
                }
                else
                {
                    targetWidth  = Math.Min(destHeight * ratio, destWidth);
                    targetHeight = targetWidth / ratio;
                }

                break;

            case Stretch.UniformToFill:
                // If width is greater than height
                if (ratio > 1.0)
                {
                    targetHeight = Math.Max(destWidth / ratio, destHeight);
                    targetWidth  = targetHeight * ratio;
                }
                else
                {
                    targetWidth  = Math.Max(destHeight * ratio, destWidth);
                    targetHeight = targetWidth / ratio;
                }

                break;
            }

            var left = 0d;

            switch (horizontalAlignment)
            {
            case AlignmentX.Left:
                left = 0;
                break;

            case AlignmentX.Center:
                left = (destWidth - targetWidth) / 2.0;
                break;

            case AlignmentX.Right:
                left = destWidth - targetWidth;
                break;
            }

            var top = 0d;

            switch (verticalAlignment)
            {
            case AlignmentY.Top:
                top = 0;
                break;

            case AlignmentY.Center:
                top = (destHeight - targetHeight) / 2.0;
                break;

            case AlignmentY.Bottom:
                top = destHeight - targetHeight;
                break;
            }

            return(new Rect(left, top, targetWidth, targetHeight));
        }
Esempio n. 28
0
        public override void WriteGroupCodes()
        {
            int flags;

            WriteGroupCodeValue(10, X0.ToString().Trim());
            WriteGroupCodeValue(20, Y0.ToString().Trim());
            WriteGroupCodeValue(30, Z0.ToString().Trim());

            WriteGroupCodeValue(11, AlignmentX.ToString().Trim());
            WriteGroupCodeValue(21, AlignmentY.ToString().Trim());
            WriteGroupCodeValue(31, AlignmentZ.ToString().Trim());

            WriteGroupCodeValue(40, Height.ToString().Trim());

            WriteGroupCodeValue(1, Text.Trim());

            WriteGroupCodeValue(50, RotationAngle.ToString().Trim());
            WriteGroupCodeValue(51, ObliqueAngle.ToString().Trim());

            WriteGroupCodeValue(41, XScale.ToString().Trim());

            WriteGroupCodeValue(7, TextStyle.Trim());

            flags = 0;

            if (Backwards)
            {
                flags += 2;
            }
            if (UpsideDown)
            {
                flags += 4;
            }

            WriteGroupCodeValue(71, flags.ToString().Trim());

            if (HorizontalAlignment == CGlobals.TextHorizontalAlignment.Left)
            {
                WriteGroupCodeValue(72, "0");
            }
            else if (HorizontalAlignment == CGlobals.TextHorizontalAlignment.Center)
            {
                WriteGroupCodeValue(72, "1");
            }
            else if (HorizontalAlignment == CGlobals.TextHorizontalAlignment.Right)
            {
                WriteGroupCodeValue(72, "2");
            }
            else if (HorizontalAlignment == CGlobals.TextHorizontalAlignment.Aligned)
            {
                WriteGroupCodeValue(72, "3");
            }
            else if (HorizontalAlignment == CGlobals.TextHorizontalAlignment.Middle)
            {
                WriteGroupCodeValue(72, "4");
            }
            else if (HorizontalAlignment == CGlobals.TextHorizontalAlignment.Fit)
            {
                WriteGroupCodeValue(72, "5");
            }
            else
            {
                WriteGroupCodeValue(72, "0");
            }

            if (VerticalAlignment == CGlobals.TextVerticalAlignment.Baseline)
            {
                WriteGroupCodeValue(73, "0");
            }
            else if (VerticalAlignment == CGlobals.TextVerticalAlignment.Bottom)
            {
                WriteGroupCodeValue(73, "1");
            }
            else if (VerticalAlignment == CGlobals.TextVerticalAlignment.Middle)
            {
                WriteGroupCodeValue(73, "2");
            }
            else if (VerticalAlignment == CGlobals.TextVerticalAlignment.Top)
            {
                WriteGroupCodeValue(73, "4");
            }
            else
            {
                WriteGroupCodeValue(73, "0");
            }
        }
Esempio n. 29
0
        public static AlignmentY Unbox_AlignmentY(IntPtr val)
        {
            AlignmentY ret = (AlignmentY)NoesisGUI_PINVOKE.Unbox_AlignmentY(val);

            return(ret);
        }
Esempio n. 30
0
        public static IntPtr Box_AlignmentY(AlignmentY val)
        {
            IntPtr ret = NoesisGUI_PINVOKE.Box_AlignmentY((int)val);

            return(ret);
        }
 unsafe internal static extern void MilUtility_GetTileBrushMapping(
     D3DMATRIX* transform,
     D3DMATRIX* relativeTransform,
     Stretch stretch, 
     AlignmentX alignmentX,
     AlignmentY alignmentY, 
     BrushMappingMode viewPortUnits, 
     BrushMappingMode viewBoxUnits,
     Rect* shapeFillBounds, 
     Rect* contentBounds,
     ref Rect viewport,
     ref Rect viewbox,
     out D3DMATRIX contentToShape, 
     out int brushIsEmpty
     ); 
Esempio n. 32
0
 private void rbVCenter_Checked(object sender, RoutedEventArgs e)
 {
     alignY = AlignmentY.Center;
     ppcPrint.InvalidatePreview();
 }