当前位置: 首页>>代码示例>>C#>>正文


C# Visual.TransformToVisual方法代码示例

本文整理汇总了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);
        }
开发者ID:angad,项目名称:PeopleBAWX,代码行数:90,代码来源:Utilities.cs

示例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;
		}
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:32,代码来源:AnimatedScrollPanel.cs


注:本文中的System.Windows.Media.Visual.TransformToVisual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。