本文整理汇总了C#中CanvasControl类的典型用法代码示例。如果您正苦于以下问题:C# CanvasControl类的具体用法?C# CanvasControl怎么用?C# CanvasControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CanvasControl类属于命名空间,在下文中一共展示了CanvasControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: canvasCtrl_Draw
private void canvasCtrl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
if (!this.initialized) {
return;
}
this.host.CallFunction("drawScene");
var target = (CanvasRenderTarget)this.host.Window.Render();
args.DrawingSession.DrawImage(target);
if (drawCount == 0) {
this.start = DateTime.Now;
}
drawCount++;
var seconds = (DateTime.Now - this.start).TotalSeconds;
if (seconds > 0) {
var fps = drawCount / seconds;
args.DrawingSession.DrawText(fps.ToString("0.#") + "fps", 10, 10, Colors.Red);
}
// triggers next Draw event at max 60fps
this.canvasCtrl.Invalidate();
}
示例2: ExportSVG
/// <summary>
/// Export SVG file.
/// </summary>
/// <param name="canvas"></param>
/// <param name="filename"></param>
public static void ExportSVG(CanvasControl canvas, string filename)
{
// Start writing SVG format.
StreamWriter writer = new StreamWriter(filename);
writer.WriteLine(XML_HEADER);
writer.WriteLine(CreateSVGHeader(canvas));
// Create brushes.
foreach (ComponentSetting setting in canvas.Control.ComponentManager.GetAllSettings())
writer.WriteLine(GetGradationBrush(setting));
// Create SVG objects.
foreach (PNode node in canvas.PCanvas.Root.ChildrenReference)
{
if (!(node is PPathwayLayer) || !node.Visible)
continue;
PPathwayLayer layer = (PPathwayLayer)node;
foreach (PPathwayObject obj in layer.GetNodes())
writer.WriteLine(CreateSVGObject(obj));
}
// Create Graph
foreach (PNode node in canvas.ControlLayer.ChildrenReference)
{
if (!(node is PPathwayGraph))
continue;
writer.WriteLine(CreateSVGGraph((PPathwayGraph)node));
}
// Close SVG file.
writer.WriteLine(SVG_FOOTER);
writer.Flush();
writer.Close();
}
示例3: Canvas_Draw
private void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
var a = new Vector2(10, 10);
var b = new Vector2(100, 100);
args.DrawingSession.DrawLine(a, b, Colors.Yellow);
}
示例4: POverviewCanvas
/// <summary>
/// Constructor
/// </summary>
/// <param name="canvas"></param>
public POverviewCanvas(CanvasControl canvas)
{
m_canvas = canvas;
this.Dock = DockStyle.Fill;
m_area = new PDisplayedArea();
m_transparentNode = PPath.CreateRectangle(-500, -500, 1300, 1300);
m_transparentNode.Brush = new SolidBrush(Color.Transparent);
m_transparentNode.Pickable = true;
this.AnimatingRenderQuality = RenderQuality.HighQuality;
this.DefaultRenderQuality = RenderQuality.HighQuality;
this.InteractingRenderQuality = RenderQuality.HighQuality;
this.Interacting = true;
this.Camera.AddLayer(canvas.PCanvas.Layer);
this.RemoveInputEventListener(this.PanEventHandler);
this.RemoveInputEventListener(this.ZoomEventHandler);
this.Camera.AddInputEventListener(new AreaDragEventHandler(canvas.PCanvas.Camera));
this.Camera.ScaleViewBy(REDUCTION_SCALE);
this.Camera.TranslateViewBy(500, 500);
this.Layer.AddChild(m_transparentNode);
this.Layer.AddChild(m_area);
m_ctrlLayer = this.Layer;
this.Camera.AddLayer(this.Layer);
this.Camera.ChildrenPickable = false;
this.Camera.BoundsChanged += new PPropertyEventHandler(Camera_BoundsChanged);
}
示例5: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var currentView = SystemNavigationManager.GetForCurrentView();
displayRequest.RequestActive(); //to request keep display on
currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
currentView.BackRequested += CurrentView_BackRequested;
if (e.NavigationMode != NavigationMode.Back)
{
try
{
_mainPageViewModel = MainPage.Current.MainPageViewModel;
LayoutRoot.DataContext = _mainPageViewModel;
_currentTrack = _mainPageViewModel.PlayingTrack;
_canvasControl = new CanvasControl();
_canvasControl.Draw += _canvasControl_Draw;
App.AudioPlayer.CurrentTrackChanged += AudioPlayer_CurrentTrackChanged;
ContentPresenter.Content = _canvasControl;
CreateWaveForm();
}
catch (Exception ex)
{
ErrorLogProxy.LogError(ex.ToString());
ErrorLogProxy.NotifyErrorInDebug(ex.ToString());
}
}
}
示例6: OnApplyTemplate
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
this._canvasControl = (CanvasControl)this.GetTemplateChild(CANVAS_CONTROL_NAME);
this._canvasControl.Draw += OnDraw;
}
示例7: DrawLine
private void DrawLine(CanvasControl sender, CanvasDrawingSession ds)
{
var width = (float)sender.ActualWidth;
var height = (float)sender.ActualHeight;
var middle = height / 2;
int steps = Math.Min((int)(width / 10), 30);
for (int i = 0; i < steps; ++i)
{
var mu = (float)i / steps;
var a = (float)(mu * Math.PI * 2);
var color = GradientColor(mu);
var x = width * mu;
var y = (float)(middle + Math.Sin(a) * (middle * 0.3));
var strokeWidth = (float)(Math.Cos(a) + 1) * 5;
ds.DrawLine(x, 0, x, y, color, strokeWidth);
ds.DrawLine(x, height, x, y, color, 10 - strokeWidth);
}
}
示例8: TextDirectionControl_Loaded
void TextDirectionControl_Loaded(object sender, RoutedEventArgs e)
{
canvas = new CanvasControl();
canvas.Draw += OnDraw;
Content = canvas;
}
示例9: WindowsPurchase
public WindowsPurchase(CanvasControl _screen)
{
screen = _screen;
grantedConsumableTransactionIds = new Dictionary<string, List<Guid>>();
CurrentApp.LicenseInformation.LicenseChanged += licenseChangeHandler;
grantedConsumableTransactionIds = new Dictionary<string, List<Guid>>();
}
示例10: OnApplyTemplate
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
_canvasControl = GetTemplateChild(CanvasControlPartName) as CanvasControl;
if (_canvasControl != null)
_canvasControl.Draw += Draw;
_contentPresenter = GetTemplateChild(ContentPresenterPartName) as ContentPresenter;
}
示例11: CanvasControl_Draw
private void CanvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
CubeHelper helper = new CubeHelper(GetLength());
foreach (Tuple<Vector2, Vector2> edge in helper.GetEdges(currentTransformation))
{
ColorValue colorValue = ColorComboBox.SelectedValue as ColorValue;
Color color = (colorValue == null ? Colors.Black : colorValue.Color);
args.DrawingSession.DrawLine(edge.Item1, edge.Item2, color);
}
}
示例12: Canvas_Draw
private void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
GaussianBlurEffect effect = new GaussianBlurEffect()
{
Source = _bitmap,
BlurAmount = 5,
BorderMode = EffectBorderMode.Hard
};
args.DrawingSession.DrawImage(effect);
}
示例13: Canvas_CreateResourcesAsync
async Task Canvas_CreateResourcesAsync(CanvasControl sender)
{
bitmap = await CanvasBitmap.LoadAsync(sender, "imageTiger.jpg");
redBrush = CreateGradientBrush(sender, 255, 0, 0);
greenBrush = CreateGradientBrush(sender, 0, 255, 0);
blueBrush = CreateGradientBrush(sender, 0, 0, 255);
brightnessEffect = new BrightnessEffect { Source = bitmap };
saturationEffect = new SaturationEffect { Source = brightnessEffect };
hueEffect = new HueRotationEffect { Source = saturationEffect };
}
示例14: BackgroundCanvas_CreateResources
private void BackgroundCanvas_CreateResources(CanvasControl sender, CanvasCreateResourcesEventArgs args)
{
args.TrackAsyncAction(Task.Run(async () =>
{
// Load the background image and create an image brush from it
this.backgroundImage = await CanvasBitmap.LoadAsync(sender, new Uri("ms-appx:///Background.jpg"));
this.backgroundBrush = new CanvasImageBrush(sender, this.backgroundImage);
// Set the brush's edge behaviour to wrap, so the image repeats if the drawn region is too big
this.backgroundBrush.ExtendX = this.backgroundBrush.ExtendY = CanvasEdgeBehavior.Wrap;
this.resourcesLoaded = true;
}).AsAsyncAction());
}
示例15: Canvas_Draw
void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
var ds = args.DrawingSession;
ds.Clear(Color.FromArgb(0,0,0,0));
var shape = this.Shapes.SelectedItem as Shape;
if (shape == null)
return;
var width = sender.ActualWidth;
var height = sender.ActualHeight;
if (shape.Drawer != null)
shape.Drawer(sender, ds);
}