本文整理汇总了C#中System.Windows.Media.Visual.TransformToVisual方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.TransformToVisual方法的具体用法?C# Visual.TransformToVisual怎么用?C# Visual.TransformToVisual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Visual
的用法示例。
在下文中一共展示了Visual.TransformToVisual方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InternalRegisterFileAssociations
/*
private static void InternalRegisterFileAssociations(
bool unregister, string progId, bool registerInHKCU,
string appId, string openWith, string[] extensions)
{
ProcessStartInfo psi = new ProcessStartInfo(
typeof(RegistrationHelperMain).Assembly.Location);
psi.Arguments =
progId + " " +
registerInHKCU + " "
+ appId
+ " \"" + openWith + "\" " +
unregister + " "
+ string.Join(" ", extensions);
psi.UseShellExecute = true;
psi.Verb = "runas"; //Launch elevated
Process.Start(psi).WaitForExit();
}
/// <summary>
/// Registers file associations for an application.
/// </summary>
/// <param name="progId">The application's ProgID.</param>
/// <param name="registerInHKCU">Whether to register the
/// association per-user (in HKCU). The only supported value
/// at this time is <b>false</b>.</param>
/// <param name="appId">The application's app-id.</param>
/// <param name="openWith">The command and arguments to be used
/// when opening a shortcut to a document.</param>
/// <param name="extensions">The extensions to register.</param>
public static void RegisterFileAssociations(string progId,
bool registerInHKCU, string appId, string openWith,
params string[] extensions)
{
InternalRegisterFileAssociations(
false, progId, registerInHKCU, appId, openWith, extensions);
}
/// <summary>
/// Unregisters file associations for an application.
/// </summary>
/// <param name="progId">The application's ProgID.</param>
/// <param name="registerInHKCU">Whether to register the
/// association per-user (in HKCU). The only supported value
/// at this time is <b>false</b>.</param>
/// <param name="appId">The application's app-id.</param>
/// <param name="openWith">The command and arguments to be used
/// when opening a shortcut to a document.</param>
/// <param name="extensions">The extensions to unregister.</param>
public static void UnregisterFileAssociations(string progId,
bool registerInHKCU, string appId, string openWith,
params string[] extensions)
{
InternalRegisterFileAssociations(
true, progId, registerInHKCU, appId, openWith, extensions);
}
public static bool IsApplicationRegistered(string appId)
{
try
{
using (RegistryKey progIdKey = Registry.ClassesRoot.OpenSubKey(appId))
{
return progIdKey != null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source);
}
return false;
}
public static bool HasThumbnailPreview(UIElement element)
{
return TaskbarManager.Instance.TabbedThumbnail.GetThumbnailPreview(element) != null;
}
*/
#endregion
#region Thumbnail Clip
public static Vector GetOffset(Window parent, Visual visual)
{
GeneralTransform ge = visual.TransformToVisual(Application.Current.MainWindow);
Point offset = ge.Transform(new Point(0, 0));
return new Vector(offset.X, offset.Y);
}
示例2: MakeVisible
public Rect MakeVisible(Visual visual, Rect rectangle)
{
GeneralTransform transform = visual.TransformToVisual(this);
Rect scrollRect = new Rect(transform.Transform(new Point(rectangle.Left, rectangle.Top)), transform.Transform(new Point(rectangle.Right, rectangle.Bottom)));
scrollRect.X += this.HorizontalOffset;
scrollRect.Y += this.VerticalOffset;
double newHorizontallOffset = this.HorizontalOffset;
double newVerticalOffset = this.VerticalOffset;
if (newHorizontallOffset + this.ViewportWidth < scrollRect.Right)
{
newHorizontallOffset = scrollRect.Right - this.ViewportWidth;
}
if (newVerticalOffset + this.ViewportHeight < scrollRect.Bottom)
{
newVerticalOffset = scrollRect.Bottom - this.ViewportHeight;
}
if (newHorizontallOffset > scrollRect.Left)
{
newHorizontallOffset = scrollRect.Left;
}
if (newVerticalOffset > scrollRect.Top)
{
newVerticalOffset = scrollRect.Top;
}
this.SetVerticalOffset(newVerticalOffset);
this.SetHorizontalOffset(newHorizontallOffset);
return scrollRect;
}