|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Reflection;
using System.Windows.Threading;
using System.Threading;
namespace ObjectPresentation.Examples.Client
{
/// <summary>
/// Interaction logic for MethodPresenterExample.xaml
/// </summary>
public partial class MethodPresenterExample : Window
{
public MethodPresenterExample()
{
InitializeComponent();
myMethodPresenter.MethodInformation = this.GetType().GetMethod("AddShape");
myMethodPresenter.ObjectInstance = this;
}
public void AddShape(MyShape shape)
{
if (shape == null)
{
return;
}
Dispatcher.BeginInvoke(DispatcherPriority.Normal,
new ThreadStart(() =>
{
Shape element = null;
if (shape is MyCircle)
{
MyCircle mc = shape as MyCircle;
element = new Ellipse
{
Width = mc.Diameter,
Height = mc.Diameter
};
}
else if (shape is MyRectangle)
{
MyRectangle mr = shape as MyRectangle;
element = new Rectangle
{
Width = mr.Width,
Height = mr.Height,
};
}
if (element != null)
{
element.Fill = new SolidColorBrush(shape.FillColor);
element.Stroke = new SolidColorBrush(shape.StrokeColor);
element.StrokeThickness = shape.StrokeThickness;
Canvas.SetLeft(element, shape.Left);
Canvas.SetTop(element, shape.Top);
myCanvas.Children.Add(element);
}
}));
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.