本文整理汇总了C#中SolidColorBrush类的典型用法代码示例。如果您正苦于以下问题:C# SolidColorBrush类的具体用法?C# SolidColorBrush怎么用?C# SolidColorBrush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SolidColorBrush类属于命名空间,在下文中一共展示了SolidColorBrush类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Player
public Player(string name, Color color, float scale, string pos)
{
Name = name;
Color = new SolidColorBrush(color);
Scale = scale;
Pos = pos;
}
示例2: Initialize
partial void Initialize()
{
Background = new SolidColorBrush(Colors.Transparent);
Clip = new RectangleGeometry();
SizeChanged += OnRenderSizeChanged;
}
示例3: OnInitialize
/// <summary>
/// In a derived class, implements logic to initialize the sample.
/// </summary>
protected override void OnInitialize() {
DeviceSettings2D settings = new DeviceSettings2D {
Width = WindowWidth,
Height = WindowHeight
};
InitializeDevice(settings);
geometry = new PathGeometry(Context2D.RenderTarget.Factory);
using (GeometrySink sink = geometry.Open()) {
PointF p0 = new PointF(0.50f * WindowWidth, 0.25f * WindowHeight);
PointF p1 = new PointF(0.75f * WindowWidth, 0.75f * WindowHeight);
PointF p2 = new PointF(0.25f * WindowWidth, 0.75f * WindowHeight);
sink.BeginFigure(p0, FigureBegin.Filled);
sink.AddLine(p1);
sink.AddLine(p2);
sink.EndFigure(FigureEnd.Closed);
// Note that Close() and Dispose() are not equivalent like they are for
// some other IDisposable() objects.
sink.Close();
}
brush = new SolidColorBrush(Context2D.RenderTarget, new Color4(0.93f, 0.40f, 0.08f));
}
示例4: CustomTextRenderer
public CustomTextRenderer(Direct2DFactory factory, WindowRenderTarget renderTarget, SolidColorBrush outlineBrush, BitmapBrush fillBrush)
{
_factory = factory;
_renderTarget = renderTarget;
_outlineBrush = outlineBrush;
_fillBrush = fillBrush;
}
示例5: ColorChanging
protected internal void ColorChanging(Color color)
{
Color = color;
SolidColorBrush = new SolidColorBrush(Color);
if (ColorChanged != null)
ColorChanged(this, Color);
}
示例6: TestSerialization
public void TestSerialization()
{
var solidColorBrush = new SolidColorBrush { Color = Colors.Aqua };
var writer = new StringWriter();
_serializer.Serialize(writer, solidColorBrush);
var reader = new StringReader(writer.ToString());
Assert.AreEqual(solidColorBrush, _serializer.Deserialize(reader));
}
示例7: PDirect2DRenderer
public PDirect2DRenderer(IntPtr winHandle)
{
fWindowHandle = winHandle;
CreateFactories();
CreateDeviceResources();
Graphics = hwndRenderTarget;
fStrokeBrush = Graphics.CreateSolidColorBrush(new ColorF(0, 0, 0, 1));
fFillBrush = Graphics.CreateSolidColorBrush(new ColorF(1, 1, 1, 1));
}
示例8: VpaidImageAdPlayer
/// <summary>
/// Creates a new instance of VpaidImageAdPlayer.
/// </summary>
/// <param name="skippableOffset">The position in the ad at which the ad can be skipped. If null, the ad cannot be skipped.</param>
/// <param name="suggestedDuration">The duration of the ad. If not specified, the ad is closed when the next ad is played.</param>
/// <param name="clickThru">The Uri to navigate to when the ad is clicked or tapped. Can be null of no action should take place.</param>
public VpaidImageAdPlayer(FlexibleOffset skippableOffset, TimeSpan? suggestedDuration, Uri clickThru)
{
IsHitTestVisible = false;
image = new Image();
Background = new SolidColorBrush(Colors.Transparent);
image.Stretch = Stretch.None;
Opacity = 0;
State = AdState.None;
AdLinear = false;
SkippableOffset = skippableOffset;
SuggestedDuration = suggestedDuration;
ClickThru = clickThru;
this.NavigateUri = ClickThru;
}
示例9: OnApplyTemplate
public override void OnApplyTemplate()
{
WatermarkBrush = new SolidColorBrush(Colors.DarkGray);
#endif
base.OnApplyTemplate();
_textBox = (TextBox)GetTemplateChild("_textBox");
_textBox.GotFocus += TextBoxOnGotFocus;
_textBox.LostFocus += TextBoxOnLostFocus;
_textBox.TextChanged += TextBoxOnTextChanged;
originalForeground = _textBox.Foreground;
UpdateText();
}
示例10: _render
/**
* Render with or without texture
**/
protected override void _render()
{
if (this._bitmap == null)
{
// Render in solid color
if (_brush == null)
_brush = new SolidColorBrush(Device.RenderTarget, Color);
Device.RenderTarget.FillRectangle(_brush, _rectangle);
return;
}
if (this._d2dBitmap == null)
{
// Load the texture
var bitmapData = this._bitmap.LockBits(
new Rectangle(new Point(0, 0), this._bitmap.Size),
System.Drawing.Imaging.ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format32bppPArgb
);
var dataStream = new SlimDX.DataStream(
bitmapData.Scan0,
bitmapData.Stride * bitmapData.Height,
true,
false
);
var d2dPixelFormat = new SlimDX.Direct2D.PixelFormat(
SlimDX.DXGI.Format.B8G8R8A8_UNorm,
SlimDX.Direct2D.AlphaMode.Premultiplied
);
var d2dBitmapProperties = new SlimDX.Direct2D.BitmapProperties();
d2dBitmapProperties.PixelFormat = d2dPixelFormat;
_d2dBitmap = new SlimDX.Direct2D.Bitmap(
Device.RenderTarget,
new Size(this._bitmap.Width, this._bitmap.Height),
dataStream,
bitmapData.Stride,
d2dBitmapProperties
);
this._bitmap.UnlockBits(bitmapData);
}
// Render the texture
Device.RenderTarget.DrawBitmap(_d2dBitmap, _rectangle);
}
示例11: VpaidVideoAdPlayer
/// <summary>
/// Creates a new instance of VpaidVideoAdPlayer.
/// </summary>
/// <param name="skippableOffset">The position in the ad at which the ad can be skipped. If null, the ad cannot be skipped.</param>
/// <param name="maxDuration">The max duration of the ad. If not specified, the length of the video is assumed.</param>
/// <param name="clickThru">The Uri to navigate to when the ad is clicked or tapped. Can be null of no action should take place.</param>
public VpaidVideoAdPlayer(FlexibleOffset skippableOffset, TimeSpan? maxDuration, Uri clickThru)
{
IsHitTestVisible = false;
mediaElement = new MediaElement();
Background = new SolidColorBrush(Colors.Black);
#if !WINDOWS80
Opacity = 0.01; // HACK: Win8.1 won't load the video if opacity = 0
#else
Opacity = 0;
#endif
State = AdState.None;
AdLinear = true;
SkippableOffset = skippableOffset;
MaxDuration = maxDuration;
this.NavigateUri = clickThru;
}
示例12: CreateDeviceResources
/// <summary>
/// This method creates the render target and all associated D2D and DWrite resources
/// </summary>
void CreateDeviceResources()
{
// Only calls if resources have not been initialize before
if (renderTarget == null)
{
// The text format
textFormat = dwriteFactory.CreateTextFormat("Bodoni MT", 24, DWrite.FontWeight.Normal, DWrite.FontStyle.Italic, DWrite.FontStretch.Normal);
// Create the render target
SizeU size = new SizeU((uint)host.ActualWidth, (uint)host.ActualHeight);
RenderTargetProperties props = new RenderTargetProperties();
HwndRenderTargetProperties hwndProps = new HwndRenderTargetProperties(host.Handle, size, PresentOptions.None);
renderTarget = d2dFactory.CreateHwndRenderTarget(props, hwndProps);
// A black brush to be used for drawing text
ColorF cf = new ColorF(0, 0, 0, 1);
blackBrush = renderTarget.CreateSolidColorBrush(cf);
// Create a linear gradient.
GradientStop[] stops =
{
new GradientStop(1, new ColorF(1f, 0f, 0f, 0.25f)),
new GradientStop(0, new ColorF(0f, 0f, 1f, 1f))
};
GradientStopCollection pGradientStops = renderTarget.CreateGradientStopCollection(stops, Gamma.Linear, ExtendMode.Wrap);
LinearGradientBrushProperties gradBrushProps = new LinearGradientBrushProperties(new Point2F(50, 25), new Point2F(25, 50));
linearGradientBrush = renderTarget.CreateLinearGradientBrush(gradBrushProps, pGradientStops);
gridPatternBitmapBrush = CreateGridPatternBrush(renderTarget);
solidBrush1 = renderTarget.CreateSolidColorBrush(new ColorF(0.3F, 0.5F, 0.65F, 0.25F));
solidBrush2 = renderTarget.CreateSolidColorBrush(new ColorF(0.0F, 0.0F, 0.65F, 0.5F));
solidBrush3 = renderTarget.CreateSolidColorBrush(new ColorF(0.9F, 0.5F, 0.3F, 0.75F));
// Create a linear gradient.
stops[0] = new GradientStop(1, new ColorF(0f, 0f, 0f, 0.25f));
stops[1] = new GradientStop(0, new ColorF(1f, 1f, 0.2f, 1f));
GradientStopCollection radiantGradientStops = renderTarget.CreateGradientStopCollection(stops, Gamma.Linear, ExtendMode.Wrap);
RadialGradientBrushProperties radialBrushProps = new RadialGradientBrushProperties(new Point2F(25, 25), new Point2F(0, 0), 10, 10);
radialGradientBrush = renderTarget.CreateRadialGradientBrush(radialBrushProps, radiantGradientStops);
}
}
示例13: CreateImage
/// <summary>
/// Renders a UI control into an image.
/// </summary>
/// <param name="control"></param>
/// <param name="isWideTile"></param>
/// <returns></returns>
public static void CreateImage(UIElement control, string imagePath, int width, int height, SolidColorBrush tileBackgroundColor)
{
// 1. Setup dimensions for wide tile.
var bmp = new WriteableBitmap(width, height);
// 2. Get the name of the background image based on theme
var canvas = new System.Windows.Controls.Canvas();
canvas.Width = width;
canvas.Height = height;
canvas.Background = tileBackgroundColor;
canvas.Children.Add(control);
canvas.Measure(new Size(width, height));
canvas.Arrange(new Rect(0, 0, width, height));
canvas.UpdateLayout();
// 4. Now output the control as text.
bmp.Render(canvas, null);
bmp.Invalidate();
// 8. Now save the image to local folder.
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
// FileMode.Open, FileAccess.Read, FileShare.Read,
using (var st = new IsolatedStorageFileStream(imagePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, store))
{
bmp.SaveJpeg(st, width, height, 0, 100);
st.Close();
}
}
try
{
bmp = null;
canvas.Children.Clear();
GC.Collect();
GC.WaitForPendingFinalizers();
}
catch (Exception ex)
{
Slate.Core.Logging.Logger.Error("Create image", "Warning, attempt to clear up memory for tile image failed", ex);
}
}
示例14: Pen
/// <summary>
/// Initializes a new instance of the <see cref="Pen"/> class.
/// </summary>
/// <param name="color">The stroke color.</param>
/// <param name="thickness">The stroke thickness.</param>
/// <param name="dashStyle">The dash style.</param>
/// <param name="dashCap">The dash cap.</param>
/// <param name="startLineCap">The start line cap.</param>
/// <param name="endLineCap">The end line cap.</param>
/// <param name="lineJoin">The line join.</param>
/// <param name="miterLimit">The miter limit.</param>
public Pen(
uint color,
double thickness = 1.0,
DashStyle dashStyle = null,
PenLineCap dashCap = PenLineCap.Flat,
PenLineCap startLineCap = PenLineCap.Flat,
PenLineCap endLineCap = PenLineCap.Flat,
PenLineJoin lineJoin = PenLineJoin.Miter,
double miterLimit = 10.0)
{
Brush = new SolidColorBrush(color);
Thickness = thickness;
StartLineCap = startLineCap;
EndLineCap = endLineCap;
LineJoin = lineJoin;
MiterLimit = miterLimit;
DashStyle = dashStyle;
DashCap = dashCap;
}
示例15: TextRenderTarget
public TextRenderTarget(RenderTargetTexture renderTargetTexture)
{
var surface = renderTargetTexture.AsSurface();
var factory2D = new SlimDX.Direct2D.Factory(SlimDX.Direct2D.FactoryType.SingleThreaded);
var renderTargetProperties = new RenderTargetProperties
{
PixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Premultiplied),
Usage = RenderTargetUsage.None,
HorizontalDpi = 96,
VerticalDpi = 96,
MinimumFeatureLevel = FeatureLevel.Direct3D10,
Type = RenderTargetType.Default
};
mRenderTarget = RenderTarget.FromDXGI(factory2D, surface,
renderTargetProperties);
mBrush = new SolidColorBrush(mRenderTarget, new Color4(1, 1, 1));
CreateTextFormat();
}