本文整理汇总了C#中System.Windows.UIElement类的典型用法代码示例。如果您正苦于以下问题:C# UIElement类的具体用法?C# UIElement怎么用?C# UIElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UIElement类属于System.Windows命名空间,在下文中一共展示了UIElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HelpAdorner
public HelpAdorner(UIElement element)
: base(element)
{
this.MouseEnter += HelpAdorner_MouseEnter;
this.MouseLeave += HelpAdorner_MouseLeave;
this.MouseDown += HelpAdorner_MouseDown;
}
示例2: DropTargetAdorner
protected DropTargetAdorner(UIElement adornedElement)
: base(adornedElement)
{
_adornerLayer = AdornerLayer.GetAdornerLayer(adornedElement);
_adornerLayer.Add(this);
IsHitTestVisible = false;
}
示例3: StartAnimation
/// <summary>
/// Starts an animation to a particular value on the specified dependency property.
/// You can pass in an event handler to call when the animation has completed.
/// </summary>
public static void StartAnimation(UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
{
double fromValue = (double)animatableElement.GetValue(dependencyProperty);
DoubleAnimation animation = new DoubleAnimation();
animation.From = fromValue;
animation.To = toValue;
animation.Duration = TimeSpan.FromSeconds(animationDurationSeconds);
animation.Completed += delegate(object sender, EventArgs e)
{
//
// When the animation has completed bake final value of the animation
// into the property.
//
animatableElement.SetValue(dependencyProperty, animatableElement.GetValue(dependencyProperty));
CancelAnimation(animatableElement, dependencyProperty);
if (completedEvent != null)
{
completedEvent(sender, e);
}
};
animation.Freeze();
animatableElement.BeginAnimation(dependencyProperty, animation);
}
示例4: RemoveCustomControl
public void RemoveCustomControl(UIElement control)
{
_customControlSurface.RemoveControl(control);
var customControlInfo = _customControls.FirstOrDefault(it => it.Control == control);
if (customControlInfo != null)
_customControls.Remove(customControlInfo);
}
示例5: AdornerCursorCoordinateDrawer
// ********************************************************************
// Public Methods
// ********************************************************************
#region Public Methods
/// <summary>
/// Constructor. Initializes class fields.
/// </summary>
public AdornerCursorCoordinateDrawer(XYLineChart xyLineChart, UIElement adornedElement, MatrixTransform shapeTransform)
: base(adornedElement)
{
elementTransform = shapeTransform;
IsHitTestVisible = false;
this.xyLineChart = xyLineChart;
}
示例6: GetPosition
public static Point GetPosition(RoutedEventArgs args, UIElement relativeTo)
{
if (args is MouseEventArgs)
{
return ((MouseEventArgs) args).GetPosition(relativeTo);
}
if (args is ManipulationDeltaEventArgs)
{
var manipulationDeltaEventArg = args as ManipulationDeltaEventArgs;
return
UIElementEx.C1TransformToVisual(manipulationDeltaEventArg.ManipulationContainer as UIElement, relativeTo)
.Transform(manipulationDeltaEventArg.ManipulationOrigin);
}
if (args is ManipulationStartedEventArgs)
{
var manipulationStartedEventArg = args as ManipulationStartedEventArgs;
return
UIElementEx.C1TransformToVisual(manipulationStartedEventArg.ManipulationContainer as UIElement, relativeTo)
.Transform(manipulationStartedEventArg.ManipulationOrigin);
}
if (!(args is TouchEventArgs) || relativeTo != null && relativeTo == null)
{
return new Point();
}
return ((TouchEventArgs) args).GetTouchPoint(relativeTo).Position;
}
示例7: AdornerChartMarkers
public AdornerChartMarkers(UIElement adornedElement, Transform shapeTransform, IList<ChartMarkerSet> markerSets, XYLineChart parentChart) : base(adornedElement)
{
_adornedElement = adornedElement;
_parentChart = parentChart;
_markerSets = markerSets;
_transform = shapeTransform;
}
示例8: DragAdorner
public DragAdorner(UIElement owner, UIElement adornElement, bool useVisualBrush, double opacity)
: base(owner)
{
this.owner = owner;
if (useVisualBrush)
{
VisualBrush brush = new VisualBrush(adornElement);
Rectangle rect = new Rectangle();
brush.Opacity = opacity;
rect.RadiusX = 3;
rect.RadiusY = 3;
rect.Width = adornElement.DesiredSize.Width;
rect.Height = adornElement.DesiredSize.Height;
this.XCenter = adornElement.DesiredSize.Width / 2;
this.YCenter = adornElement.DesiredSize.Height / 2;
rect.Fill = brush;
this.child = rect;
}
else
{
this.child = adornElement;
}
}
示例9: CreateCursor
public static Cursor CreateCursor(UIElement element, int xHotSpot,
int yHotSpot)
{
element.Measure(new Size(double.PositiveInfinity,
double.PositiveInfinity));
element.Arrange(new Rect(0, 0, element.DesiredSize.Width,
element.DesiredSize.Height));
RenderTargetBitmap rtb =
new RenderTargetBitmap((int)element.DesiredSize.Width,
(int)element.DesiredSize.Height, 96, 96, PixelFormats.Pbgra32);
rtb.Render(element);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(rtb));
MemoryStream ms = new MemoryStream();
encoder.Save(ms);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);
ms.Close();
ms.Dispose();
Cursor cur = InternalCreateCursor(bmp, xHotSpot, yHotSpot);
bmp.Dispose();
return cur;
}
示例10: DragBehavior
public DragBehavior(UIElement element)
{
_element = element;
element.MouseLeftButtonDown += OnMouseButtonDown;
element.MouseLeftButtonUp += OnMouseButtonUp;
element.MouseMove += OnMouseMove;
}
示例11: ContentAdorner
public ContentAdorner(UIElement element, UIElement adornedElement)
: base(adornedElement)
{
_element = element;
AddLogicalChild(element);
AddVisualChild(element);
}
示例12: GetJpgImage
/// <summary>
/// </summary>
/// <param name="source"> </param>
/// <param name="scale"> </param>
/// <param name="quality"> </param>
/// <returns> </returns>
public static byte[] GetJpgImage(UIElement source, double scale, int quality)
{
var actualHeight = source.RenderSize.Height;
var actualWidth = source.RenderSize.Width;
var renderHeight = actualHeight * scale;
var renderWidth = actualWidth * scale;
var renderTarget = new RenderTargetBitmap((int) renderWidth, (int) renderHeight, 96, 96, PixelFormats.Pbgra32);
var sourceBrush = new VisualBrush(source);
var drawingVisual = new DrawingVisual();
var drawingContext = drawingVisual.RenderOpen();
using (drawingContext)
{
drawingContext.PushTransform(new ScaleTransform(scale, scale));
drawingContext.DrawRectangle(sourceBrush, null, new Rect(new Point(0, 0), new Point(actualWidth, actualHeight)));
}
renderTarget.Render(drawingVisual);
var jpgEncoder = new JpegBitmapEncoder
{
QualityLevel = quality
};
jpgEncoder.Frames.Add(BitmapFrame.Create(renderTarget));
Byte[] imageArray;
using (var outputStream = new MemoryStream())
{
jpgEncoder.Save(outputStream);
imageArray = outputStream.ToArray();
}
return imageArray;
}
示例13: Initialize
public void Initialize(UIElement element)
{
_element = element;
element.MouseLeftButtonDown += MouseLeftButtonDown;
element.MouseLeftButtonUp += MouseLeftButtonUp;
element.MouseMove += MouseMove;
}
示例14: SendToUIThread
private void SendToUIThread(UIElement element, string text)
{
element.Dispatcher.BeginInvoke(
new Action(() => { SendKeys.Send(text); }),
DispatcherPriority.Input
);
}
示例15: SizeChangedInfo
/// <summary>
/// Initializes a new instance of the SizeChangedinfo class.
/// </summary>
/// <param name="element">
/// The element which size is changing.
/// </param>
/// <param name="previousSize">
/// The size of the object before update. New size is element.RenderSize
/// </param>
/// <param name="widthChanged">
/// The flag indicating that width component of the size changed. Note that due to double math
/// effects, the it may be (previousSize.Width != newSize.Width) and widthChanged = true.
/// This may happen in layout when sizes of objects are fluctuating because of a precision "jitter" of
/// the input parameters, but the overall scene is considered to be "the same" so no visible changes
/// will be detected. Typically, the handler of SizeChangedEvent should check this bit to avoid
/// invalidation of layout if the dimension didn't change.
/// </param>
/// <param name="heightChanged">
/// The flag indicating that height component of the size changed. Note that due to double math
/// effects, the it may be (previousSize.Height != newSize.Height) and heightChanged = true.
/// This may happen in layout when sizes of objects are fluctuating because of a precision "jitter" of
/// the input parameters, but the overall scene is considered to be "the same" so no visible changes
/// will be detected. Typically, the handler of SizeChangedEvent should check this bit to avoid
/// invalidation of layout if the dimension didn't change.
/// </param>
public SizeChangedInfo(UIElement element, Size previousSize, bool widthChanged, bool heightChanged)
{
_element = element;
_previousSize = previousSize;
_widthChanged = widthChanged;
_heightChanged = heightChanged;
}