本文整理汇总了C#中System.Windows.Media.DrawingGroup类的典型用法代码示例。如果您正苦于以下问题:C# DrawingGroup类的具体用法?C# DrawingGroup怎么用?C# DrawingGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawingGroup类属于System.Windows.Media命名空间,在下文中一共展示了DrawingGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateARectangleWithDrawingBrush
private Brush CreateARectangleWithDrawingBrush()
{
// Create a DrawingBrush
DrawingBrush blackBrush = new DrawingBrush();
// Create a Geometry with white background
GeometryDrawing backgroundSquare =
new GeometryDrawing(
Brushes.DarkGray,
null,
new RectangleGeometry(new Rect(0, 0, 400, 400)));
// Create a GeometryGroup that will be added to Geometry
GeometryGroup gGroup = new GeometryGroup();
gGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 200, 200)));
gGroup.Children.Add(new RectangleGeometry(new Rect(200, 200, 200, 200)));
// Create a GeomertyDrawing
GeometryDrawing checkers = new GeometryDrawing(new SolidColorBrush(Colors.Gray), null, gGroup);
DrawingGroup checkersDrawingGroup = new DrawingGroup();
checkersDrawingGroup.Children.Add(backgroundSquare);
checkersDrawingGroup.Children.Add(checkers);
blackBrush.Drawing = checkersDrawingGroup;
// Set Viewport and TimeMode
blackBrush.Viewport = new Rect(0, 0, 0.1, 0.2);
blackBrush.TileMode = TileMode.Tile;
return blackBrush;
}
开发者ID:riezebosch,项目名称:Glitter,代码行数:30,代码来源:ColorConverter.cs
示例2: KinectBodyView
/// <summary>
/// Initializes a new instance of the KinectBodyView class
/// </summary>
/// <param name="kinectSensor">Active instance of the KinectSensor</param>
public KinectBodyView(KinectSensor kinectSensor)
{
if (kinectSensor == null)
{
throw new ArgumentNullException("kinectSensor");
}
// get the coordinate mapper
_coordinateMapper = kinectSensor.CoordinateMapper;
// get the depth (display) extents
FrameDescription frameDescription = kinectSensor.DepthFrameSource.FrameDescription;
// get size of joint space
_displayWidth = frameDescription.Width;
_displayHeight = frameDescription.Height;
// Create the drawing group we'll use for drawing
_drawingGroup = new DrawingGroup();
// Create an image source that we can use in our image control
_imageSource = new DrawingImage(_drawingGroup);
}
开发者ID:praveenv4k,项目名称:indriya,代码行数:29,代码来源:KinectBodyView.cs
示例3: CreateDottedImage
public static int[] CreateDottedImage(int width, int height)
{
Random rnd = new Random();
const int pointsNum = 100000;
const double radius = 1.5;
var randomPoints = Enumerable.Range(0, pointsNum).Select(_ => new Point(rnd.NextDouble() * width, rnd.NextDouble() * height));
randomPoints = Filter(randomPoints, radius);
DrawingGroup drawing = new DrawingGroup();
var dc = drawing.Append();
foreach (var point in randomPoints)
{
HsbColor color = new HsbColor(0, 0, Math.Round(5 * rnd.NextDouble()) / 4);
SolidColorBrush brush = new SolidColorBrush(color.ToArgbColor());
//drawing.Children.Add(new GeometryDrawing(brush, null, new EllipseGeometry(point, radius, radius)));
dc.DrawEllipse(brush, null, point, radius, radius);
}
dc.Close();
DrawingImage drawingImage = new DrawingImage();
drawingImage.Drawing = drawing;
drawingImage.Freeze();
if ((imageCreatingThread.ThreadState | ThreadState.Running) != imageCreatingThread.ThreadState)
imageCreatingThread.Start();
imageQueue.Add(new RequestInfo { Width = width, Heigth = height, DrawingImage = drawingImage });
var pixels = resultQueue.Take();
return pixels;
}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:32,代码来源:ImageHelper.cs
示例4: ProjectorViewWindow
public ProjectorViewWindow()
{
InitializeComponent();
drawingGroup = new DrawingGroup();
var imageSource = new DrawingImage(drawingGroup);
Display.Source = imageSource;
}
开发者ID:virrkharia,项目名称:dynamight,代码行数:7,代码来源:ProjectorViewWindow.xaml.cs
示例5: SetFillBrush
public void SetFillBrush()
{
DrawingGroup rootDrawingGroup = new DrawingGroup();
GeometryDrawing aDrawing = new GeometryDrawing();
aDrawing.Brush = Brushes.Gray.CloneCurrentValue();
aDrawing.Pen = new Pen(Brushes.Gray, 1);
aDrawing.Brush.Opacity = .5;
aDrawing.Geometry = Primitives.PolygonLine(WallElementDetails.StartPoint, WallElementDetails.EndPoint, 10, 10);
rootDrawingGroup.Children.Add(aDrawing);
//create a transition line
GeometryDrawing aCenterLine = new GeometryDrawing();
aCenterLine.Brush = Brushs.WallBoundaryStroke;
aCenterLine.Pen = Pens.WallBoundaryStroke;
aCenterLine.Geometry = Primitives.Line(WallElementDetails.StartPoint, WallElementDetails.EndPoint);
rootDrawingGroup.Children.Add(aCenterLine);
DrawingBrush brush = new DrawingBrush(rootDrawingGroup);
this.Fill = brush;
}
开发者ID:RookieOne,项目名称:Adorners,代码行数:26,代码来源:WallElement.cs
示例6: MainWindow
public MainWindow()
{
drawingGroup = new DrawingGroup();
imageSource = new DrawingImage( drawingGroup );
this.DataContext = this;
InitializeComponent();
}
开发者ID:noa99kee,项目名称:K4W2-Book,代码行数:7,代码来源:MainWindow.xaml.cs
示例7: Draw
public ImageSource Draw()
{
var drawing = new DrawingGroup();
//background
drawing.DrawRectangle(new Rect(-5, -100, 300, 200), Brushes.White, new Pen(Brushes.AntiqueWhite, 1));
//5 point marker
drawing.DrawLine(new Point(200, -100), new Point(200, 100), Brushes.BurlyWood);
drawing.DrawText(201, -7, "5");
//10 point marker
drawing.DrawLine(new Point(220, -100), new Point(220, 100), Brushes.BurlyWood);
drawing.DrawText(221, -7, "10");
//20 point marker
drawing.DrawLine(new Point(240, -100), new Point(240, 100), Brushes.BurlyWood);
drawing.DrawText(241, -7, "20");
//50 point marker
drawing.DrawLine(new Point(260, -100), new Point(260, 100), Brushes.BurlyWood);
drawing.DrawText(261, -7, "50");
drawing.DrawLine(new Point(280, -100), new Point(280, 100), Brushes.BurlyWood);
drawing.DrawText(281, -7, "0");
//disc
drawing.DrawCircle(new Point(_discXPosition, 0), 3, Brushes.Red);
return new DrawingImage(drawing);
}
开发者ID:W0dan,项目名称:physicsExperiments,代码行数:30,代码来源:FrictionExperiment.cs
示例8: PaintBackground
private void PaintBackground()
{
var backgroundSquare = new GeometryDrawing(Brushes.Black, null, new RectangleGeometry(new Rect(0, 0, 100, 100)));
var aGeometryGroup = new GeometryGroup();
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 50, 50)));
aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(50, 50, 50, 50)));
var checkerBrush = new LinearGradientBrush();
checkerBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0));
checkerBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 22, 0), 1.0));
var checkers = new GeometryDrawing(checkerBrush, null, aGeometryGroup);
var checkersDrawingGroup = new DrawingGroup();
checkersDrawingGroup.Children.Add(backgroundSquare);
checkersDrawingGroup.Children.Add(checkers);
var myBrush = new DrawingBrush
{
Drawing = checkersDrawingGroup,
Viewport = new Rect(0, 0, 0.02, 0.02),
TileMode = TileMode.Tile,
Opacity = 0.5
};
LayoutRoot.Background = myBrush;
}
开发者ID:estromsnes,项目名称:CodeNinjaSpy,代码行数:28,代码来源:CodeNinjaSpyShell.xaml.cs
示例9: Render
public override void Render(WpfDrawingRenderer renderer)
{
Geometry clipGeom = this.ClipGeometry;
Transform transform = this.Transform;
if (clipGeom != null || transform != null)
{
WpfDrawingContext context = renderer.Context;
_drawGroup = new DrawingGroup();
DrawingGroup currentGroup = context.Peek();
if (currentGroup == null)
{
throw new InvalidOperationException("An existing group is expected.");
}
currentGroup.Children.Add(_drawGroup);
context.Push(_drawGroup);
if (clipGeom != null)
{
_drawGroup.ClipGeometry = clipGeom;
}
if (transform != null)
{
_drawGroup.Transform = transform;
}
}
base.Render(renderer);
}
开发者ID:udayanroy,项目名称:SvgSharp,代码行数:33,代码来源:WpfSwitchRendering.cs
示例10: BeforeRender
// disable default rendering
public override void BeforeRender(WpfDrawingRenderer renderer)
{
base.BeforeRender(renderer);
_matrix = Matrix.Identity;
WpfDrawingContext context = renderer.Context;
_drawGroup = new DrawingGroup();
//string elementId = this.GetElementName();
//if (!String.IsNullOrEmpty(elementId))
//{
// _drawGroup.SetValue(FrameworkElement.NameProperty, elementId);
//}
DrawingGroup currentGroup = context.Peek();
if (currentGroup == null)
{
throw new InvalidOperationException("An existing group is expected.");
}
currentGroup.Children.Add(_drawGroup);
context.Push(_drawGroup);
}
开发者ID:udayanroy,项目名称:SvgSharp,代码行数:26,代码来源:WpfMarkerRendering.cs
示例11: MainWindow_Loaded
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
if (KinectSensor.KinectSensors.Count > 0)
{
this.sensor = KinectSensor.KinectSensors[0];
if (!this.sensor.IsRunning)
{
this.sensor.DepthStream.Range = DepthRange.Near;
this.sensor.DepthFrameReady += sensor_DepthFrameReady;
this.sensor.DepthStream.Enable();
this.sensor.SkeletonStream.EnableTrackingInNearRange = true;
this.sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
this.sensor.SkeletonFrameReady += sensor_SkeletonFrameReady;
this.sensor.SkeletonStream.Enable();
this.sensor.Start();
}
this.drawingGroup = new DrawingGroup();
this.imageSource = new DrawingImage(this.drawingGroup);
this.SkeletonController.Source = this.imageSource;
}
}
开发者ID:hh54188,项目名称:King,代码行数:26,代码来源:MainWindow.xaml.cs
示例12: Init
public void Init()
{
DrawingGroup dg = new DrawingGroup();
ImageDrawing id = new ImageDrawing(UnderlayImage, new Rect(0, 0, UnderlayImage.PixelWidth, UnderlayImage.PixelHeight));
dg.Children.Add(id);
pointsGeometryGroup = new GeometryGroup();
linesGeometryGroup = new GeometryGroup();
middlePointGeoGrp = new GeometryGroup();
if (points != null)
{
SetPointsGeometry();
}
GeometryDrawing gd = new GeometryDrawing(Brushes.Blue, null, pointsGeometryGroup);
dg.Children.Add(gd);
GeometryDrawing gd2 = new GeometryDrawing(null, new Pen(Brushes.LightGreen,3), linesGeometryGroup);
dg.Children.Add(gd2);
GeometryDrawing gd1 = new GeometryDrawing(Brushes.Red, null, middlePointGeoGrp);
dg.Children.Add(gd1);
Brush b = new SolidColorBrush(Colors.Red);
b.Opacity = 0.5;
mousePointGeometryDrwaing = new GeometryDrawing(b, null, null);
dg.Children.Add(mousePointGeometryDrwaing);
DrawingImage di = new DrawingImage(dg);
this.Source = di;
chosenPoint = -1;
}
开发者ID:gp1313,项目名称:morethantechnical,代码行数:33,代码来源:Window1.xaml.cs
示例13: SelectionRectVisual
/// <summary>
/// Construct new SelectionRectVisual object for the given rectangle
/// </summary>
public SelectionRectVisual(Point firstPointP, Point secondPointP, double zoomP)
{
DrawingGroup drawing = new DrawingGroup();
DrawingContext context = drawing.Open();
context.DrawRectangle(Brushes.White, null, new Rect(-1, -1, 3, 3));
context.DrawRectangle(Brushes.Black, null, new Rect(0.25, -1, 0.5, 3));
context.Close();
drawing.Freeze();
// Create a drawing brush that tiles the unit square from the drawing created above.
// The size of the viewport and the rotation angle will be updated as we use the
// dashed pen.
DrawingBrush drawingBrush = new DrawingBrush(drawing);
drawingBrush.ViewportUnits = BrushMappingMode.Absolute;
drawingBrush.Viewport = new Rect(0, 0, _dashRepeatLength, _dashRepeatLength);
drawingBrush.ViewboxUnits = BrushMappingMode.Absolute;
drawingBrush.Viewbox = new Rect(0, 0, 1, 1);
drawingBrush.Stretch = Stretch.Uniform;
drawingBrush.TileMode = TileMode.Tile;
// Store the drawing brush and a copy that's rotated by 90 degrees.
_horizontalDashBrush = drawingBrush;
_verticalDashBrush = drawingBrush.Clone();
_verticalDashBrush.Transform = new RotateTransform(90);
this._firstPoint = firstPointP;
this._secondPoint = secondPointP;
this._zoom = zoomP;
_visualForRect = new DrawingVisual();
this.AddVisualChild(_visualForRect);
this.AddLogicalChild(_visualForRect);
}
开发者ID:hultqvist,项目名称:Eto,代码行数:35,代码来源:SelectionRectVisual.cs
示例14: BeforeRender
public override void BeforeRender(WpfDrawingRenderer renderer)
{
base.BeforeRender(renderer);
WpfDrawingContext context = renderer.Context;
_drawGroup = new DrawingGroup();
string elementId = this.GetElementName();
if (!String.IsNullOrEmpty(elementId) && !context.IsRegisteredId(elementId))
{
_drawGroup.SetValue(FrameworkElement.NameProperty, elementId);
context.RegisterId(elementId);
if (context.IncludeRuntime)
{
SvgObject.SetId(_drawGroup, elementId);
}
}
DrawingGroup currentGroup = context.Peek();
if (currentGroup == null)
{
throw new InvalidOperationException("An existing group is expected.");
}
currentGroup.Children.Add(_drawGroup);
context.Push(_drawGroup);
}
开发者ID:udayanroy,项目名称:SvgSharp,代码行数:30,代码来源:WpfGroupRendering.cs
示例15: OnRender
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
{
base.OnRender(drawingContext);
// allows the points to be rendered as an image that can be further manipulated
PathGeometry geometry = new PathGeometry();
this.Siz
// Add all points to the geometry
foreach (Points pointXY in _points)
{
PathFigure figure = new PathFigure();
figure.StartPoint = pointXY.FromPoint;
figure.Segments.Add(new LineSegment(pointXY.ToPoint, true));
geometry.Figures.Add(figure);
}
// Add the first point to close the gap from the graph's end point
// to graph's start point
PathFigure lastFigure = new PathFigure();
lastFigure.StartPoint = _points[_points.Count - 1].FromPoint;
lastFigure.Segments.Add(new LineSegment(_firstPoint, true));
geometry.Figures.Add(lastFigure);
// Create a new drawing and drawing group in order to apply
// a custom drawing effect
GeometryDrawing drawing = new GeometryDrawing(this.Pen.Brush, this.Pen, geometry);
DrawingGroup drawingGroup = new DrawingGroup();
drawingGroup.Children.Add(drawing);
}
开发者ID:valentine-palazkov,项目名称:tictactoe-wpf,代码行数:32,代码来源:BoardCellView.xaml.cs
示例16: Draw
public ImageSource Draw()
{
var drawing = new DrawingGroup();
//background
drawing.DrawRectangle(new Rect(-5, -210, 300, 220), Brushes.White, new Pen(Brushes.AntiqueWhite, 1));
drawing.DrawLine(new Point(-5, 0), new Point(295, 0), Brushes.AntiqueWhite);
//5 point marker
drawing.DrawLine(new Point(200, -210), new Point(200, 10), Brushes.BurlyWood);
drawing.DrawText(201, -107, "5");
//10 point marker
drawing.DrawLine(new Point(220, -210), new Point(220, 10), Brushes.BurlyWood);
drawing.DrawText(221, -107, "10");
//20 point marker
drawing.DrawLine(new Point(240, -210), new Point(240, 10), Brushes.BurlyWood);
drawing.DrawText(241, -107, "20");
//50 point marker
drawing.DrawLine(new Point(260, -210), new Point(260, 10), Brushes.BurlyWood);
drawing.DrawText(261, -107, "50");
drawing.DrawLine(new Point(280, -210), new Point(280, 10), Brushes.BurlyWood);
drawing.DrawText(281, -107, "0");
//disc
drawing.DrawCircle(_cannonballPosition, 1.5, Brushes.Black);
var imageDrawing = new ImageDrawing(ResourceProvider.GetImage(Images.Cannon), new Rect(0, -25, 34.0, 24.4));
drawing.Children.Add(imageDrawing);
return new DrawingImage(drawing);
}
开发者ID:W0dan,项目名称:physicsExperiments,代码行数:35,代码来源:KinematicsExperiment.cs
示例17: Convert
public object Convert (object [] values, Type targetType, object parameter, CultureInfo culture)
{
Brush foreground;
//FIXME: How is it used?
bool is_indeterminate;
double indicator_lenght_in_orientation_direction;
double indicator_lenght_in_other_direction;
double track_lenght_in_orientation_direction;
try {
foreground = (Brush)values [0];
is_indeterminate = (bool)values [1];
indicator_lenght_in_orientation_direction = (double)values [2];
indicator_lenght_in_other_direction = (double)values [3];
track_lenght_in_orientation_direction = (double)values [4];
} catch (InvalidCastException) {
return null;
}
const double LineWidth = 6;
const double LineSpacing = 2;
DrawingGroup drawing = new DrawingGroup ();
DrawingContext drawing_context = drawing.Open ();
int lines = (int)Math.Ceiling (indicator_lenght_in_orientation_direction / (LineWidth + LineSpacing));
int line_index;
for (line_index = 0; line_index < lines - 1; line_index++)
drawing_context.DrawRectangle (foreground, null, new Rect (line_index * (LineWidth + LineSpacing), 0, LineWidth, indicator_lenght_in_other_direction));
drawing_context.DrawRectangle (foreground, null, new Rect (line_index * (LineWidth + LineSpacing), 0, indicator_lenght_in_orientation_direction - (lines - 1) * (LineWidth + LineSpacing), indicator_lenght_in_other_direction));
drawing_context.Close ();
DrawingBrush result = new DrawingBrush (drawing);
result.Stretch = Stretch.None;
result.Viewbox = new Rect (new Size (indicator_lenght_in_orientation_direction, indicator_lenght_in_other_direction));
result.Viewport = result.Viewbox;
return result;
}
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:33,代码来源:ProgressBarBrushConverter.cs
示例18: DepthViewWindow
public DepthViewWindow(MainWindow parent)
{
InitializeComponent();
_running = true;
drawingGroup = new DrawingGroup();
//parent.OnDepthFrameReceived += new GiveDepthFrame(GiveFrame);
}
开发者ID:siavash65,项目名称:CSE481-3DAuth,代码行数:7,代码来源:DepthViewWindow.xaml.cs
示例19: Screen
/// <summary>
/// Creates a new screen
/// </summary>
public Screen(int width, int height, int fps)
{
Fps = Config.Get("Fps", fps);
base.Width = Config.Get("ScreenWidth", width);
base.Height = Config.Get("ScreenHeight", height);
Trace.Info("new Screen(Fps = {0}, Width = {1}, Height = {2})", Fps, Width, Height);
_dirty = true;
_clipping = new Rect(0, 0, Width, Height);
_backBuffer = new DrawingImage(_buffer = new DrawingGroup());
_keyMapping = Module.Get<IKeyMapping>();
(_window = new Window()
{
WindowStyle = WindowStyle.None,
ResizeMode = ResizeMode.NoResize,
WindowStartupLocation = WindowStartupLocation.CenterScreen,
Content = this,
SizeToContent = SizeToContent.WidthAndHeight,
}).Show();
_window.KeyDown += _window_KeyDown;
_window.KeyUp += _window_KeyUp;
(_refreshTimer = new Timer(FrameTime)).Update += OnRenderCallback;
}
开发者ID:jeffbernard,项目名称:fcbrd,代码行数:28,代码来源:Screen.cs
示例20: HudRenderer
public HudRenderer(DrawingGroup drawGroup, DrawingImage drawImage, int width, int height)
{
drawingGroup = drawGroup;
drawingImage = drawImage;
displayHeight = height;
displayWidth = width;
}
开发者ID:NathanielRose,项目名称:KinectKannon,代码行数:7,代码来源:HudRenderer.cs
注:本文中的System.Windows.Media.DrawingGroup类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论