本文整理汇总了C#中System.Windows.UIElement.TranslatePoint方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.TranslatePoint方法的具体用法?C# UIElement.TranslatePoint怎么用?C# UIElement.TranslatePoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.UIElement
的用法示例。
在下文中一共展示了UIElement.TranslatePoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPosition
protected Point GetPosition(UIElement relativeTo, FrameworkElement element, bool centered)
{
Point point = new Point(Canvas.GetLeft(element), Canvas.GetTop(element));
if(centered)
point.Offset(element.Width / 2, element.Height / 2);
return relativeTo.TranslatePoint(point, window);
}
示例2: myCanvas_PreviewMouseLeftButtonDown
// Handler for element selection on the canvas providing resizing adorner
void myCanvas_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// Remove selection on clicking anywhere the window
if (selected)
{
selected = false;
if (selectedElement != null && aLayer.GetAdorners(selectedElement) != null)
{
// Remove the adorner from the selected element
aLayer.Remove(aLayer.GetAdorners(selectedElement)[0]);
selectedElement = null;
}
}
//If adding a new link
if (e.Source.GetType() == typeof(SystemBasicView))
{
if (e.Source.GetType() == typeof(SystemBasicView) && _isAddNewLink)
{
if (!_isLinkStarted)
{
if (_link == null || _link.EndPoint != _link.StartPoint)
{
_isLinkStarted = true;
_linkedSystem = e.Source as SystemBasicView;
SystemViewModel svm = (_linkedSystem.DataContext) as SystemViewModel;
_tempLink = new TemporaryConnectorViewModel(svm);
_tempLink.StartPostion = _linkedSystem.Position;
e.Handled = true;
}
}
}
// If a componentView is selected, add adorner layer to it
else
{
_isDown = true;
_startPoint = e.GetPosition(myCanvas);
selectedElement = e.Source as UIElement;
_originalPoint = selectedElement.TranslatePoint(new Point(0, 0), myCanvas);
aLayer = AdornerLayer.GetAdornerLayer(selectedElement);
aLayer.Add(new ResizingAdorner(selectedElement, myCanvas));
selected = true;
e.Handled = true;
}
}
}
示例3: AddDraggedColumnGhost
public void AddDraggedColumnGhost( UIElement element )
{
if( ( element == null ) || m_elementToDraggedElementAdorner.ContainsKey( element ) )
return;
// Get the Rect for the DataGridControl
DataGridControl dataGridControl = this.DraggedDataGridContext.DataGridControl;
Rect dataGridControlRect = new Rect( 0, 0, dataGridControl.ActualWidth, dataGridControl.ActualHeight );
Point elementToDataGridControl = element.TranslatePoint( ColumnReorderingDragSourceManager.EmptyPoint, dataGridControl );
// Get the Rect for the element that request a ghost
Rect elementRect = new Rect( elementToDataGridControl, element.RenderSize );
// This is a special case with the current Element that is always layouted, but can be out of view
if( !elementRect.IntersectsWith( dataGridControlRect ) )
return;
AnimatedDraggedElementAdorner adorner = new AnimatedDraggedElementAdorner( element, this.AdornerLayerInsideDragContainer, true );
this.ApplyContainerClip( adorner );
this.AdornerLayerInsideDragContainer.Add( adorner );
m_elementToDraggedElementAdorner.Add( element, adorner );
}