本文整理汇总了C#中System.Windows.Media.Drawing类的典型用法代码示例。如果您正苦于以下问题:C# Drawing类的具体用法?C# Drawing怎么用?C# Drawing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Drawing类属于System.Windows.Media命名空间,在下文中一共展示了Drawing类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DiagramDocumentPaginator
/// <summary>
/// Initializes a new instance of the <see cref="DiagramDocumentPaginator"/> class.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="printSize">Size of the print.</param>
internal DiagramDocumentPaginator(DrawingVisual source, Size printSize)
{
this.PageSize = printSize;
this.contentSize = new Size(this.PageSize.Width - (2 * Constants.Margin), this.PageSize.Height - (2 * Constants.Margin));
this.frameRect = new Rect(new Point(Constants.Margin, Constants.Margin), this.contentSize);
this.frameRect.Inflate(1, 1);
this.framePen = new Pen(Brushes.Black, 0.1);
// Transformation to borderless print size
Rect bounds = source.DescendantBounds;
bounds.Union(source.ContentBounds);
Matrix m = new Matrix();
m.Translate(-bounds.Left, -bounds.Top);
double scale = 1; // hardcoded zoom for printing
this.pageCountX = (int)((bounds.Width * scale) / this.contentSize.Width) + 1;
this.pageCountY = (int)((bounds.Height * scale) / this.contentSize.Height) + 1;
m.Scale(scale, scale);
// Center on available pages
m.Translate(((this.pageCountX * this.contentSize.Width) - (bounds.Width * scale)) / 2, ((this.pageCountY * this.contentSize.Height) - (bounds.Height * scale)) / 2);
// Create a new Visual
DrawingVisual v = new DrawingVisual();
using (DrawingContext dc = v.RenderOpen())
{
dc.PushTransform(new MatrixTransform(m));
dc.DrawDrawing(source.Drawing);
foreach (DrawingVisual dv in source.Children)
{
dc.DrawDrawing(dv.Drawing);
}
}
this.diagram = v.Drawing;
}
开发者ID:WrongDog,项目名称:Sequence,代码行数:40,代码来源:DiagramDocumentPaginator.cs
示例2: XamlDrawingToPngBase64String
/// <summary>
/// Преобразует XAML Drawing/DrawingGroup в png base64 string
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="drawing"></param>
/// <returns>Base64 string containing png bitmap</returns>
public static string XamlDrawingToPngBase64String(int width, int height, Drawing drawing) {
var bitmapEncoder = new PngBitmapEncoder();
// The image parameters...
double dpiX = 96;
double dpiY = 96;
// The Visual to use as the source of the RenderTargetBitmap.
var drawingVisual = new DrawingVisual();
using (var drawingContext = drawingVisual.RenderOpen()) {
drawingContext.DrawDrawing(drawing);
}
var bounds = drawingVisual.ContentBounds;
var targetBitmap = new RenderTargetBitmap(
width * 10, height * 10, dpiX, dpiY,
PixelFormats.Pbgra32);
drawingVisual.Transform = new ScaleTransform(width * 10 / bounds.Width, height * 10 / bounds.Height);
targetBitmap.Render(drawingVisual);
// Encoding the RenderBitmapTarget as an image.
bitmapEncoder.Frames.Add(BitmapFrame.Create(targetBitmap));
byte[] values;
using (var str = new MemoryStream()) {
bitmapEncoder.Save(str);
values = str.ToArray();
}
return Convert.ToBase64String(values);
}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:38,代码来源:InternalConverter.cs
示例3: GetPathGeometries
public static IEnumerable<PathGeometry> GetPathGeometries(Drawing drawing)
{
var result = new List<PathGeometry>();
Action<Drawing> HandleDrawing = null;
HandleDrawing = aDrawing =>
{
if (aDrawing is DrawingGroup)
foreach (Drawing d in ((DrawingGroup)aDrawing).Children)
{
HandleDrawing(d);
}
if (aDrawing is GeometryDrawing)
{
var gd = (GeometryDrawing)aDrawing;
Geometry geometry = gd.Geometry;
if (geometry is PathGeometry)
{
result.Add((PathGeometry)geometry);
}
}
};
HandleDrawing(drawing);
return result;
}
开发者ID:JuniperPhoton,项目名称:SvgToXAML,代码行数:26,代码来源:ConverterLogic.cs
示例4: InternalMakeDrawingSerializable
static void InternalMakeDrawingSerializable(Drawing drawing, GeometryValueSerializer gvs) {
var dg = drawing as DrawingGroup;
if (dg != null)
for(var i = 0; i < dg.Children.Count; ++i)
InternalMakeDrawingSerializable(dg.Children[i], gvs);
else {
var gd = drawing as GeometryDrawing;
if (gd != null) {
var sg = gd.Geometry as StreamGeometry;
if (sg != null && !gvs.CanConvertToString(sg, null))
gd.Geometry = PathGeometry.CreateFromGeometry(sg);
}
}
}
开发者ID:goutkannan,项目名称:ironlab,代码行数:14,代码来源:XamlToys.cs
示例5: HitTestPoint
/// <summary>
/// Determines whether or not a point exists in a Drawing
/// </summary>
/// <param name="drawing"> Drawing to hit-test</param>
/// <param name="point"> Point to hit-test for </param>
/// <returns>
/// 'true' if the point exists within the drawing, 'false' otherwise
/// </returns>
internal static bool HitTestPoint(Drawing drawing, Point point)
{
if (drawing != null)
{
HitTestDrawingContextWalker ctx = new HitTestWithPointDrawingContextWalker(point);
drawing.WalkCurrentValue(ctx);
return ctx.IsHit;
}
else
{
return false;
}
}
开发者ID:JianwenSun,项目名称:cc,代码行数:23,代码来源:DrawingServices.cs
示例6: DrawingToBitmap
public static BitmapSource DrawingToBitmap(Drawing drawing, int size)
{
DrawingVisual drawingVisual = new DrawingVisual();
DrawingContext drawingContext = drawingVisual.RenderOpen();
drawingContext.PushTransform(new ScaleTransform((double)size / 100, (double)size / 100));
drawingContext.DrawDrawing(drawing);
drawingContext.Pop();
drawingContext.Close();
RenderTargetBitmap bmp = new RenderTargetBitmap(size, size, 96, 96, PixelFormats.Default);
bmp.Render(drawingVisual);
bmp.Freeze();
return bmp;
}
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:16,代码来源:TileSetLoaderHelpers.cs
示例7: HitTestGeometry
/// <summary>
/// Hit-tests a Drawing against a PathGeometry
/// </summary>
/// <param name="drawing"> The drawing to hit test against </param>
/// <param name="geometry"> The geometry (in local coordinate space) to hit test. </param>
/// <returns>
/// IntersectionDetail that describes the hit result
/// </returns>
internal static IntersectionDetail HitTestGeometry(Drawing drawing, PathGeometry geometry)
{
if (drawing != null)
{
HitTestDrawingContextWalker ctx =
new HitTestWithGeometryDrawingContextWalker(geometry);
drawing.WalkCurrentValue(ctx);
return ctx.IntersectionDetail;
}
else
{
return IntersectionDetail.Empty;
}
}
开发者ID:JianwenSun,项目名称:cc,代码行数:24,代码来源:DrawingServices.cs
示例8: DrawingToBitmap
/// <summary>
/// Conerts a drawing into a bitmap object compatible with System.Drawing.
/// </summary>
/// <param name="drawing"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="stretch"></param>
/// <returns></returns>
public static System.Drawing.Bitmap DrawingToBitmap(Drawing drawing, int width, int height, Stretch stretch = Stretch.None)
{
var encoder = new PngBitmapEncoder();
var drawingImage = new DrawingImage(drawing);
var image = new Image() { Source = drawingImage };
image.Stretch = stretch;
image.HorizontalAlignment = HorizontalAlignment.Left;
image.VerticalAlignment = VerticalAlignment.Top;
image.Arrange(new Rect(0, 0, width, height));
var bitmap = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
bitmap.Render(image);
encoder.Frames.Add(BitmapFrame.Create(bitmap));
var stream = new MemoryStream();
encoder.Save(stream);
return new System.Drawing.Bitmap(stream);
}
开发者ID:EusthEnoptEron,项目名称:Sketchball,代码行数:29,代码来源:Booster.cs
示例9: GuessingPanel
/// <summary>
/// Default constructor.
/// </summary>
public GuessingPanel(Drawing.Drawing drawingToGuess)
{
InitializeComponent();
currentDrawing = drawingToGuess;
drawTimer = new System.Windows.Threading.DispatcherTimer();
drawTimer.Tick += new EventHandler(DrawFrame);
drawTimer.Interval = new TimeSpan(0, 0, 0, 0, REFRESH_TIME_DRAW);
timerIsOver = false;
// Hide buttons and everything
ButtonPlayAgain.Visibility = System.Windows.Visibility.Collapsed;
ButtonCheckScore.Visibility = System.Windows.Visibility.Collapsed;
ButtonTryAgain.Visibility = System.Windows.Visibility.Collapsed;
UserAttemptFeedbackRight.Visibility = System.Windows.Visibility.Collapsed;
UserAttemptFeedbackWrong.Visibility = System.Windows.Visibility.Collapsed;
UserAttemptFeedbackTooLate.Visibility = System.Windows.Visibility.Collapsed;
DoDraw();
// No drawing in this phase
canvas.EditingMode = SurfaceInkEditingMode.None;
}
开发者ID:TheAaltoWindrawTeam,项目名称:AaltoWindraw,代码行数:24,代码来源:GuessingPanel.xaml.cs
示例10: NormalizeDrawing
static Drawing NormalizeDrawing(Drawing drawing, Point location, Size size, double angle)
{
DrawingGroup dGroup = new DrawingGroup();
using (DrawingContext dc = dGroup.Open())
{
dc.DrawRectangle(Brushes.Transparent, null, new Rect(new Size(100, 100)));
dc.PushTransform(new RotateTransform(angle, 50, 50));
dc.PushTransform(new TranslateTransform(location.X, location.Y));
dc.PushTransform(new ScaleTransform(size.Width / drawing.Bounds.Width, size.Height / drawing.Bounds.Height));
dc.PushTransform(new TranslateTransform(-drawing.Bounds.Left, -drawing.Bounds.Top));
dc.DrawDrawing(drawing);
dc.Pop();
dc.Pop();
dc.Pop();
dc.Pop();
}
return dGroup;
}
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:22,代码来源:SymbolDrawingCache.cs
示例11: BuzyWait
static BuzyWait()
{
var drawingVisual = new DrawingVisual ();
using (var drawingContext = drawingVisual.RenderOpen())
{
for (var i = 0; i < Spokes; ++i)
{
var t = ((double)i) / Spokes;
drawingContext.PushOpacity (1 - t);
drawingContext.PushTransform (new RotateTransform (360.0 * t));
drawingContext.DrawRoundedRectangle(
Brushes.White,
null,
new Rect(MinRadius, -WidthRadius/2, RadiusRadius - MinRadius, WidthRadius),
WidthRadius,
WidthRadius
);
drawingContext.Pop ();
drawingContext.Pop ();
}
}
s_drawing = drawingVisual.Drawing.FreezeObject ();
s_animationClock = new DoubleAnimation (
0,
1,
new Duration (TimeSpan.FromSeconds(2))
)
{
RepeatBehavior = RepeatBehavior.Forever
};
s_animationClock.FreezeObject ();
}
开发者ID:mrange,项目名称:T4Include,代码行数:38,代码来源:BuzyWait.cs
示例12: GraphPaginator
internal GraphPaginator( DrawingVisual source, Size printSize )
{
PageSize = printSize;
contentSize = new Size( printSize.Width - 2 * Margin, printSize.Height - 2 * Margin );
myFrameRect = new Rect( new Point( Margin, Margin ), contentSize );
myFrameRect.Inflate( 1, 1 );
myFramePen = new Pen( Brushes.Black, 0.1 );
// Transformation to borderless print size
var bounds = source.DescendantBounds;
bounds.Union( source.ContentBounds );
var m = new Matrix();
m.Translate( -bounds.Left, -bounds.Top );
double scale = 16; // hardcoded zoom for printing
myPageCountX = ( int )( ( bounds.Width * scale ) / contentSize.Width ) + 1;
myPageCountY = ( int )( ( bounds.Height * scale ) / contentSize.Height ) + 1;
m.Scale( scale, scale );
// Center on available pages
m.Translate( ( myPageCountX * contentSize.Width - bounds.Width * scale ) / 2, ( myPageCountY * contentSize.Height - bounds.Height * scale ) / 2 );
var target = new DrawingVisual();
using( var dc = target.RenderOpen() )
{
dc.PushTransform( new MatrixTransform( m ) );
dc.DrawDrawing( source.Drawing );
foreach( DrawingVisual child in source.Children )
{
dc.DrawDrawing( child.Drawing );
}
}
myGraph = target.Drawing;
}
开发者ID:JackWangCUMT,项目名称:Plainion.GraphViz,代码行数:38,代码来源:GraphPaginator.cs
示例13: AfterGuessingPanel
public AfterGuessingPanel(Drawing.Drawing drawingGuessed, ulong userScore)
{
this.InitializeComponent();
this.userScore = userScore;
bool isHighscore = false;
IsHighScoreFeedback.Visibility = System.Windows.Visibility.Collapsed;
IsNotHighScoreFeedback.Visibility = System.Windows.Visibility.Collapsed;
SaveFeedbackOK.Visibility = System.Windows.Visibility.Collapsed;
SaveFeedbackNOTOK.Visibility = System.Windows.Visibility.Collapsed;
ButtonGoBackHome.Visibility = System.Windows.Visibility.Collapsed;
currentDrawing = drawingGuessed;
UserScore.Text = FormatScore(userScore);
Highscores.Highscore high = App.client.GetHighscoreFromServer(drawingGuessed);
if (high != null)
{
ChampionScore.Text = FormatScore(high.score);
ChampionIdentity.Text = "By " + high.scorerName + " at " + high.scoreTimestamp;
isHighscore = Highscores.Highscore.CompareScores(userScore, high.score);
}
else
{
ChampionScore.Text = FormatScore(userScore);
ChampionIdentity.Text = "";
ChampionIdentity.Visibility = System.Windows.Visibility.Collapsed;
isHighscore = true;
}
if (isHighscore)
{
IsHighScoreFeedback.Visibility = System.Windows.Visibility.Visible;
IsNotHighScoreFeedback.Visibility = System.Windows.Visibility.Collapsed;
}
else
{
IsHighScoreFeedback.Visibility = System.Windows.Visibility.Collapsed;
IsNotHighScoreFeedback.Visibility = System.Windows.Visibility.Visible;
}
}
开发者ID:TheAaltoWindrawTeam,项目名称:AaltoWindraw,代码行数:38,代码来源:AfterGuessingPanel.xaml.cs
示例14: ColorizeDrawing
static void ColorizeDrawing(Drawing drawing, Color tintColor)
{
if (drawing is DrawingGroup)
{
var dg = (DrawingGroup)drawing;
foreach (var d in dg.Children)
{
ColorizeDrawing(d, tintColor);
}
}
else if (drawing is GeometryDrawing)
{
var gd = (GeometryDrawing)drawing;
if (gd.Brush != null)
ColorizeBrush(gd.Brush, tintColor);
if (gd.Pen != null)
ColorizeBrush(gd.Pen.Brush, tintColor);
}
else
{
throw new NotImplementedException();
}
}
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:23,代码来源:DrawingCache.cs
示例15: AddDrawing
public void AddDrawing(Drawing drawing)
{
_drawings.Clear();
_drawings.Add(drawing);
}
开发者ID:mcwatt77,项目名称:vimcontrols,代码行数:6,代码来源:VIMGraphPanel.cs
示例16: DrawingImage
public DrawingImage(Drawing drawing)
{
}
开发者ID:nbulp,项目名称:CodeContracts,代码行数:3,代码来源:System.Windows.Media.DrawingImage.cs
示例17: SetWidgetColor
protected override void SetWidgetColor (Drawing.Color value)
{
// Do nothing
}
开发者ID:m13253,项目名称:xwt,代码行数:4,代码来源:CanvasBackend.cs
示例18: CreateStandardDrawingBrush
private static DrawingBrush CreateStandardDrawingBrush(Drawing drawing)
{
return new DrawingBrush
{
Drawing = drawing,
TileMode = TileMode.Tile,
Viewport = new Rect(0, 0, 10, 10),
ViewportUnits = BrushMappingMode.Absolute,
};
}
开发者ID:RyanGano,项目名称:GitBlame,代码行数:10,代码来源:BlameControl.cs
示例19: DrawDrawing
/// <summary>
/// DrawDrawing -
/// Draw a Drawing by appending a sub-Drawing to the current Drawing.
/// </summary>
/// <param name="drawing"> The drawing to draw. </param>
public abstract void DrawDrawing(
Drawing drawing);
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:7,代码来源:DrawingContext.cs
示例20: DrawingBrush
public DrawingBrush(Drawing drawing)
{
}
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:3,代码来源:System.Windows.Media.DrawingBrush.cs
注:本文中的System.Windows.Media.Drawing类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论