/// <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); }
/// <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; }
public AlignmentY aliy; // Alignment position private void Defaults() { posx = 0.5f; posy = 0.5f; alix = AlignmentX.Center; aliy = AlignmentY.Center; }
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 void Init(AlignmentX alignX, AlignmentY alignY, float xOffset, float yOffset) { alignmentX = alignX; alignmentY = alignY; offsetX = xOffset; offsetY = yOffset; Init(); }
/// <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 IsAlignmentXValid(object valueObject) { AlignmentX value = (AlignmentX)valueObject; return((value == AlignmentX.Left) || (value == AlignmentX.Center) || (value == AlignmentX.Right)); }
/// <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); }
/// <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="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; }
/// <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; }
/// <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; }
/// <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; }
public KeyboardInput(BaseGame game, Color oskColor, float oskAlpha, bool visible) { Game = game; Typed = new List <string>(); _oskShowHide = new Tween(new TimeSpan(0, 0, 0, 0, 500), 1, 0); _oskShowHide.Finish(); _oskButtonHits = new List <OSKButton>(); OSKAlpha = oskAlpha; OSKColor = oskColor; _oskVisible = visible; _oskLower = Game.Content.Load <Texture2D>(@"OSK\OSKLC.png"); _oskUpper = Game.Content.Load <Texture2D>(@"OSK\OSKUC.png"); _oskFrame = Game.Content.Load <Texture2D>(@"OSK\OSKF.png"); _oskUnShift = Game.Content.Load <Texture2D>(@"OSK\OSKUSFT.png"); _oskShift = Game.Content.Load <Texture2D>(@"OSK\OSKSFT.png"); OSKAlignment = AlignmentX.Center; _oskRects = new Dictionary <Keys, Rectangle> { { Keys.Escape, new Rectangle(3, 5, 53, 45) }, { Keys.NumPad1, new Rectangle(58, 5, 33, 45) }, { Keys.NumPad2, new Rectangle(94, 5, 33, 45) }, { Keys.NumPad3, new Rectangle(130, 5, 33, 45) }, { Keys.NumPad4, new Rectangle(166, 5, 33, 45) }, { Keys.NumPad5, new Rectangle(200, 5, 33, 45) }, { Keys.NumPad6, new Rectangle(238, 5, 33, 45) }, { Keys.NumPad7, new Rectangle(274, 5, 33, 45) }, { Keys.NumPad8, new Rectangle(310, 5, 33, 45) }, { Keys.NumPad9, new Rectangle(346, 5, 33, 45) }, { Keys.NumPad0, new Rectangle(382, 5, 33, 45) }, // {Keys.D1, new Rectangle(58,5,33,45)}, // {Keys.D2, new Rectangle(94,5,33,45)}, // {Keys.D3, new Rectangle(130,5,33,45)}, // {Keys.D4, new Rectangle(166,5,33,45)}, // {Keys.D5, new Rectangle(200,5,33,45)}, // {Keys.D6, new Rectangle(238,5,33,45)}, // {Keys.D7, new Rectangle(274,5,33,45)}, // {Keys.D8, new Rectangle(310,5,33,45)}, // {Keys.D9, new Rectangle(346,5,33,45)}, // {Keys.D0, new Rectangle(382,5,33,45)}, { Keys.Back, new Rectangle(417, 5, 52, 45) }, { Keys.Tab, new Rectangle(4, 52, 51, 43) }, { Keys.Q, new Rectangle(58, 52, 33, 43) }, { Keys.W, new Rectangle(94, 52, 33, 43) }, { Keys.E, new Rectangle(130, 52, 33, 43) }, { Keys.R, new Rectangle(166, 52, 33, 43) }, { Keys.T, new Rectangle(200, 52, 33, 43) }, { Keys.Y, new Rectangle(238, 52, 33, 43) }, { Keys.U, new Rectangle(274, 52, 33, 43) }, { Keys.I, new Rectangle(310, 52, 33, 43) }, { Keys.O, new Rectangle(346, 52, 33, 43) }, { Keys.P, new Rectangle(382, 52, 33, 43) }, { Keys.Enter, new Rectangle(418, 52, 51, 89) }, { Keys.CapsLock, new Rectangle(4, 98, 51, 43) }, { Keys.A, new Rectangle(58, 98, 33, 43) }, { Keys.S, new Rectangle(94, 98, 33, 43) }, { Keys.D, new Rectangle(130, 98, 33, 43) }, { Keys.F, new Rectangle(166, 98, 33, 43) }, { Keys.G, new Rectangle(200, 98, 33, 43) }, { Keys.H, new Rectangle(238, 98, 33, 43) }, { Keys.J, new Rectangle(274, 98, 33, 43) }, { Keys.K, new Rectangle(310, 98, 33, 43) }, { Keys.L, new Rectangle(346, 98, 33, 43) }, { Keys.LeftShift, new Rectangle(3, 143, 53, 44) }, { Keys.Z, new Rectangle(58, 144, 33, 43) }, { Keys.X, new Rectangle(94, 144, 33, 43) }, { Keys.C, new Rectangle(130, 144, 33, 43) }, { Keys.V, new Rectangle(166, 144, 33, 43) }, { Keys.B, new Rectangle(200, 144, 33, 43) }, { Keys.N, new Rectangle(238, 144, 33, 43) }, { Keys.M, new Rectangle(274, 144, 33, 43) }, { Keys.OemQuotes, new Rectangle(382, 98, 33, 43) }, //" { Keys.OemComma, new Rectangle(310, 144, 33, 43) }, //; { Keys.OemPeriod, new Rectangle(346, 144, 33, 43) }, //: //{Keys.OemSemicolon, new Rectangle(346,52,33,43)}, SHIFT oemSemicolon { Keys.Up, new Rectangle(382, 144, 51, 43) }, { Keys.RightShift, new Rectangle(418, 143, 51, 44) }, { Keys.Space, new Rectangle(94, 190, 249, 43) }, { Keys.Left, new Rectangle(346, 190, 33, 43) }, { Keys.Down, new Rectangle(382, 190, 33, 43) }, { Keys.Right, new Rectangle(418, 190, 33, 43) } }; _keyboardListeners = new List <Procedure <KeyboardInput> >(); _taps = new List <Vector2>(); _oskCurrentState = new List <Keys>(); _oskPreviousState = new List <Keys>(); OSKArea = new Rectangle((int)(Game.Center.X - (_oskLower.Width / 2f)), (int)Game.Height, _oskLower.Width, _oskLower.Height); }
internal virtual void DrawConnectButtons(Rectangle bounds, SpriteBatch sb, Computer c, int margin, int y, AlignmentX ButtonAlignment = AlignmentX.Middle) { int num1 = bounds.X + margin; int num2 = c.daemons.Count + 6; int height = 40; int num3 = bounds.Height - (y - bounds.Y) - 20 - num2 * 5; if ((double)num3 / (double)num2 < (double)height) { height = (int)((double)num3 / (double)num2); } int width = bounds.Width / 2; int x; switch (ButtonAlignment) { case AlignmentX.Left: x = bounds.X + margin; break; case AlignmentX.Right: x = bounds.X + bounds.Width - (width + margin); break; default: x = bounds.X + bounds.Width / 2 - width / 2; break; } if (c.daemons.Count > 0) { y += height + 5; } for (int index = 0; index < c.daemons.Count; ++index) { if (!(c.daemons[index] is CustomConnectDisplayOverride)) { if (Button.doButton(29000 + index, x, y, width, height, c.daemons[index].name, new Color?(this.os.highlightColor))) { this.os.display.command = c.daemons[index].name; c.daemons[index].navigatedTo(); } y += height + 5; } } if (Button.doButton(300000, x, y, width, height, LocaleTerms.Loc("Login"), new Color?(this.os.subtleTextColor))) { this.os.runCommand("login"); this.os.terminal.clearCurrentLine(); } y += height + 5; if (Button.doButton(300002, x, y, width, height, LocaleTerms.Loc("Probe System"), new Color?(this.os.highlightColor))) { this.os.runCommand("probe"); } y += height + 5; if (Button.doButton(300003, x, y, width, height, LocaleTerms.Loc("View Filesystem"), new Color?(this.os.hasConnectionPermission(false) ? this.os.highlightColor : this.os.subtleTextColor))) { this.os.runCommand("ls"); } y += height + 5; if (Button.doButton(300006, x, y, width, height, LocaleTerms.Loc("View Logs"), new Color?(this.os.hasConnectionPermission(false) ? this.os.highlightColor : this.os.subtleTextColor))) { this.os.runCommand("cd log"); } y += height + 5; if (Button.doButton(300009, x, y, width, height, LocaleTerms.Loc("Scan Network"), new Color?(this.os.hasConnectionPermission(true) ? this.os.highlightColor : this.os.subtleTextColor))) { this.os.runCommand("scan"); } y = bounds.Y + bounds.Height - 30; if (!Button.doButton(300012, x, y, width, 20, LocaleTerms.Loc("Disconnect"), new Color?(this.os.lockedColor))) { return; } this.os.runCommand("dc"); }
public void Init(AlignmentX alignX, AlignmentY alignY) { alignmentX = alignX; alignmentY = alignY; Init(); }
public void SetJustification() { hAlign = (AlignmentX)(int)((Alignment + 3) % 3); vAlign = (AlignmentY)(Math.Ceiling(((Alignment + 1) / 3.0)) - 1); }
/// <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)); }
public LoadingView(Window owner, Action action, string friendlyText, AlignmentX x, AlignmentY y) : this(owner, action, friendlyText) { BlurHolder.AlignmentX = x; BlurHolder.AlignmentY = y; }
public static AlignmentX Unbox_AlignmentX(IntPtr val) { AlignmentX ret = (AlignmentX)NoesisGUI_PINVOKE.Unbox_AlignmentX(val); return(ret); }
public static IntPtr Box_AlignmentX(AlignmentX val) { IntPtr ret = NoesisGUI_PINVOKE.Box_AlignmentX((int)val); return(ret); }
private void rbRight_Checked(object sender, RoutedEventArgs e) { alignX = AlignmentX.Right; ppcPrint.InvalidatePreview(); }
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; }
/// <summary> /// Sets the alignment x. /// </summary> /// <param name="obj">The object.</param> /// <param name="alignment">The alignment.</param> public static void SetAlignmentX(DependencyObject obj, AlignmentX alignment) { obj.SetValue(AlignmentXProperty, alignment); }
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; }
public static void SetSlideDirectionX(DependencyObject obj, AlignmentX value) { obj.SetValue(SlideDirectionXProperty, value); }
/// <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); } }
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); }
public override void UpdateSettings() { try { string text = Gw2Plugin.Instance.ScriptsManager.FormatString(this.config.GetString("textFormat")); this.oldText = text; this.hideWhenGw2IsInactive = this.config.GetBoolean("hideWhenGw2IsInactive"); FontFamily fontFamily = new FontFamily(this.config.GetString("textFont")); int fontSize = this.config.GetInt("textFontSize"); Color textColor = this.config.GetColor2("textColor"); Color backColor = this.config.GetColor2("backColor"); bool effectBold = this.config.GetBoolean("textBold"); bool effectItalic = this.config.GetBoolean("textItalic"); bool effectUnderline = this.config.GetBoolean("textUnderline"); bool outline = this.config.GetBoolean("outline"); Color outlineColor = outline ? this.config.GetColor2("outlineColor") : Colors.Transparent; double outlineThickness = outline ? this.config.GetFloat("outlineThickness") : 0; bool scrolling = this.config.GetBoolean("scrolling"); int scrollingSpeed = this.config.GetInt("scrollingSpeed"); string scrollingDelimiter = this.config.GetString("scrollingDelimiter"); int scrollingMaxWidth = this.config.GetInt("scrollingMaxWidth"); AlignmentX scrollingAlign = AlignmentX.Left; switch (this.config.GetString("scrollingAlign")) { case "Left": scrollingAlign = AlignmentX.Left; break; case "Center": scrollingAlign = AlignmentX.Center; break; case "Right": scrollingAlign = AlignmentX.Right; break; } bool scrollingLargeOnly = this.config.GetBoolean("scrollingLargeOnly"); this.textImage = new TextImage() { Text = text, FontFamily = fontFamily, FontSize = fontSize, TextColor = textColor, BackColor = backColor, EffectBold = effectBold, EffectItalic = effectItalic, EffectUnderline = effectUnderline, OutlineColor = outlineColor, OutlineThickness = outlineThickness }; if (scrolling) { TextImage scrollingDelimiterImage = new TextImage() { Text = scrollingDelimiter, FontFamily = fontFamily, FontSize = fontSize, TextColor = textColor, BackColor = backColor, EffectBold = effectBold, EffectItalic = effectItalic, EffectUnderline = effectUnderline, OutlineColor = outlineColor, OutlineThickness = outlineThickness }; ScrollingAnimator scrollingAnimator = new ScrollingAnimator() { DelimiterImage = scrollingDelimiterImage, PixelsPerSecond = scrollingSpeed, MaxWidth = scrollingMaxWidth, TextAlign = scrollingAlign, ScrollMode = scrollingLargeOnly ? ScrollMode.TooWideOnly : ScrollMode.ForcedContinuous }; this.textImage.CustomWidth = scrollingMaxWidth; this.textImage.Animators.Add(scrollingAnimator); } this.UpdateTexture(); this.config.Parent.SetInt("cx", this.textImage.CustomWidth ?? this.textImage.Bitmap.PixelWidth); this.config.Parent.SetInt("cy", this.textImage.Bitmap.PixelHeight); this.Size.X = this.textImage.CustomWidth ?? this.textImage.Bitmap.PixelWidth; this.Size.Y = this.textImage.Bitmap.PixelHeight; } catch (Exception ex) { API.Instance.Log("Gw2Plugin: {0}", ex.ToString()); Debug.BreakDebugger(); } }
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; } } } }
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"); } }
private static Double GetSignedShiftForDirection(AlignmentX Direction, Double ShiftLength) { switch (Direction) { case AlignmentX.Left: return +ShiftLength; case AlignmentX.Right: return -ShiftLength; default: return 0; } }
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 );
private void rbHCenter_Checked(object sender, RoutedEventArgs e) { alignX = AlignmentX.Center; ppcPrint.InvalidatePreview(); }