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


C# Transform.GetType方法代码示例

本文整理汇总了C#中System.Windows.Media.Transform.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.GetType方法的具体用法?C# Transform.GetType怎么用?C# Transform.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Transform的用法示例。


在下文中一共展示了Transform.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddTransformation

 public void AddTransformation(Transform tx)
 {
     var tg = RenderTransform as TransformGroup;
     if (tg == null)
     {
         tg = new TransformGroup();
         RenderTransform = tg;
     }
     // Don't add duplicates
     if (tg.Children.Any(child => child.GetType() == tx.GetType()))
     {
         return;
     }
     tg.Children.Add(tx);
     RenderTransform = tg;
 }
开发者ID:jonte,项目名称:RabbitCards,代码行数:16,代码来源:Card.xaml.cs

示例2: SerializeTransform

 private void SerializeTransform(Transform ict, StringBuilder sb)
 {
     if (ict.GetType() == typeof(RotateTransform))
     {
         sb.Append("<RotateTransform><RotateTransform.Angle>");
         var be = BindingOperations.GetBindingExpression(ict, RotateTransform.AngleProperty);
         if (be != null)
         {
             var bpd = new BoundPropertyDesigner();
             bpd.Initialize(ict, ict.GetType().GetProperty("Angle"));
             sb.Append(bpd.GetValue());
         }
         else
             sb.Append((ict as RotateTransform).Angle);
         sb.Append("</RotateTransform.Angle></RotateTransform>");
     }
     else if (ict is TranslateTransform)
     {
         sb.Append("<TranslateTransform><TranslateTransform.X>");
         var be = BindingOperations.GetBindingExpression(ict, TranslateTransform.XProperty);
         if (be != null)
         {
             var bpd = new BoundPropertyDesigner();
             bpd.Initialize(ict, ict.GetType().GetProperty("X"));
             sb.Append(bpd.GetValue());
             sb.Append("</TranslateTransform.X><TranslateTransform.Y>");
         }
         else
             sb.Append("0</TranslateTransform.X><TranslateTransform.Y>");
         be = BindingOperations.GetBindingExpression(ict, TranslateTransform.YProperty);
         if (be != null)
         {
             var bpd = new BoundPropertyDesigner();
             bpd.Initialize(ict, ict.GetType().GetProperty("Y"));
             sb.Append(bpd.GetValue());
         }
         else
             sb.Append("0");
         sb.Append("</TranslateTransform.Y></TranslateTransform>");
     }
     else if (ict is SkewTransform)
     {
         sb.Append("<SkewTransform><SkewTransform.AngleX>");
         var be = BindingOperations.GetBindingExpression(ict, SkewTransform.AngleXProperty);
         if (be != null)
         {
             var bpd = new BoundPropertyDesigner();
             bpd.Initialize(ict, ict.GetType().GetProperty("AngleX"));
             sb.Append(bpd.GetValue());
             sb.Append("</SkewTransform.AngleX><SkewTransform.AngleY>");
         }
         else
             sb.Append("0</SkewTransform.AngleX><SkewTransform.AngleY>");
         be = BindingOperations.GetBindingExpression(ict, SkewTransform.AngleYProperty);
         if (be != null)
         {
             var bpd = new BoundPropertyDesigner();
             bpd.Initialize(ict, ict.GetType().GetProperty("AngleY"));
             sb.Append(bpd.GetValue());
         }
         else
             sb.Append("0");
         sb.Append("</SkewTransform.AngleY><SkewTransform.CenterX>");
         sb.Append((ict as SkewTransform).CenterX);
         sb.Append("</SkewTransform.CenterX><SkewTransform.CenterY>");
         sb.Append((ict as SkewTransform).CenterY);
         sb.Append("</SkewTransform.CenterY></SkewTransform>");
     }
 }
开发者ID:byteit101,项目名称:ZomB-Dashboard-System,代码行数:69,代码来源:TransformDesigner.cs

示例3: ApplyTransform

		public static void ApplyTransform(DesignItem designItem, Transform transform, bool relative = true)
		{
			var changeGroup = designItem.OpenGroup("Apply Transform");
			
			Transform oldTransform = null;
			if (designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).IsSet) {
				oldTransform = designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).ValueOnInstance as Transform;
			}
			
			if (oldTransform is MatrixTransform) {
				var mt = oldTransform as MatrixTransform;
				var tg = new TransformGroup();
				if (mt.Matrix.OffsetX != 0 && mt.Matrix.OffsetY != 0)
					tg.Children.Add(new TranslateTransform(){ X = mt.Matrix.OffsetX, Y = mt.Matrix.OffsetY });
				if (mt.Matrix.M11 != 0 && mt.Matrix.M22 != 0)
					tg.Children.Add(new ScaleTransform(){ ScaleX = mt.Matrix.M11, ScaleY = mt.Matrix.M22 });

				var angle = Math.Atan2(mt.Matrix.M21, mt.Matrix.M11) * 180 / Math.PI;
				if (angle != 0)
					tg.Children.Add(new RotateTransform(){ Angle = angle });
				//if (mt.Matrix.M11 != 0 && mt.Matrix.M22 != 0)
				//	tg.Children.Add(new SkewTransform(){ ScaleX = mt.Matrix.M11, ScaleY = mt.Matrix.M22 });
			} else if (oldTransform != null && oldTransform.GetType() != transform.GetType()) {
				var tg = new TransformGroup();
				var tgDes = designItem.Services.Component.RegisterComponentForDesigner(tg);
				tgDes.ContentProperty.CollectionElements.Add(designItem.Services.Component.GetDesignItem(oldTransform));
				designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(tg);
				oldTransform = tg;
			}
			
			
			
			if (transform is RotateTransform) {
				var rotateTransform = transform as RotateTransform;
				
				if (oldTransform is RotateTransform || oldTransform == null) {
					if (rotateTransform.Angle != 0) {
						designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(transform);
						var angle = rotateTransform.Angle;
						if (relative && oldTransform != null) {
							angle = rotateTransform.Angle + ((RotateTransform)oldTransform).Angle;
						}
						designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Value.Properties.GetProperty(RotateTransform.AngleProperty).SetValue(angle);
						if (rotateTransform.CenterX != 0.0)
							designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Value.Properties.GetProperty(RotateTransform.CenterXProperty).SetValue(rotateTransform.CenterX);
						if (rotateTransform.CenterY != 0.0)
							designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Value.Properties.GetProperty(RotateTransform.CenterYProperty).SetValue(rotateTransform.CenterY);
						
						if (oldTransform == null)
							designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
					}
					else {
						designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Reset();
						designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).Reset();
					}
				} else if (oldTransform is TransformGroup) {
					var tg = oldTransform as TransformGroup;
					var rot = tg.Children.FirstOrDefault(x=> x is RotateTransform);
					if  (rot != null) {
						designItem.Services.Component.GetDesignItem(tg).ContentProperty.CollectionElements.Remove(designItem.Services.Component.GetDesignItem(rot));
					}
					if (rotateTransform.Angle != 0) {
						var des = designItem.Services.Component.GetDesignItem(transform);
						if (des == null)
							des = designItem.Services.Component.RegisterComponentForDesigner(transform);
						designItem.Services.Component.GetDesignItem(tg).ContentProperty.CollectionElements.Add(des);
						if (oldTransform == null)
							designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
					}
				} else {
						if (rotateTransform.Angle != 0) {
							designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(transform);
							if (oldTransform == null)
								designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
					}
				}
			}
		
			((DesignPanel) designItem.Services.DesignPanel).AdornerLayer.UpdateAdornersForElement(designItem.View, true);
			
			changeGroup.Commit();
		}
开发者ID:modulexcite,项目名称:WpfDesigner,代码行数:82,代码来源:ModelTools.cs


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