示例#1
0
文件: Rect.cs 项目: mono/uia2atk
		public Rect (SW.Rect rect)
		{
			x = rect.X;
			y = rect.Y;
			width = rect.Width;
			height = rect.Height;
		}
示例#2
0
			/// <summary>
			/// Initializes a new instance of the MARGINS struct
			/// </summary>
			/// <param name="t">
			/// The supplied thickness
			/// </param>
			public MARGINS (sw.Thickness t)
			{
				this.Left = (int)t.Left;
				this.Right = (int)t.Right;
				this.Top = (int)t.Top;
				this.Bottom = (int)t.Bottom;
			}
示例#3
0
		public static Size GetSize (sw.FrameworkElement element)
		{
			if (!double.IsNaN(element.ActualWidth) && !double.IsNaN(element.ActualHeight))
				return new Size ((int)element.ActualWidth, (int)element.ActualHeight);
			else
				return new Size ((int)(double.IsNaN(element.Width) ? -1 : element.Width), (int)(double.IsNaN(element.Height) ? -1 : element.Height));
		}
示例#4
0
        public bool? InDesignMode()
        {
            #if SILVERLIGHT
            if (Application.Current.RootVisual != null) {
                return System.ComponentModel.DesignerProperties.GetIsInDesignMode(Application.Current.RootVisual);
            }

            return false;
            #elif NETFX_CORE
            return DesignMode.DesignModeEnabled;
            #else
            var designEnvironments = new[] {
                "BLEND.EXE",
                "XDESPROC.EXE",
            };

            var entry = Assembly.GetEntryAssembly();
            if (entry != null) {
                var exeName = (new FileInfo(entry.Location)).Name.ToUpperInvariant();

                if (designEnvironments.Any(x => x.Contains(exeName))) {
                    return true;
                }
            }

            return false;
            #endif
        }
示例#5
0
        public static WPFMEDIA.LineGeometry PerpendicularLine(WPF.Point StartPoint, WPF.Point EndPoint, double Length)
        {
            //Get Current Angle Don't need the actual angle, radians is fine.
            double angle = CurrentAngle(StartPoint, EndPoint);
            double radians = Math.Atan2(StartPoint.Y - EndPoint.Y, StartPoint.X - EndPoint.X);

            //Take 90 deg
            double newAngle = angle + 90;
            double newRadians = radians + Math.PI / 2;

            //need to determine the shift.

            double shiftX = Length * Math.Cos(newRadians);
            //double shiftX2 = Length * Math.Cos(newAngle * Math.PI / 180);

            double shiftY = Length * Math.Sin(newRadians);

            double newStartPointX = StartPoint.X - shiftX;
            double newStartPointY = StartPoint.Y - shiftY;

            double newEndPointX = StartPoint.X + shiftX;
            double newEndPointY = StartPoint.Y + shiftY;

            WPF.Point newStartPoint = new WPF.Point(newStartPointX, newStartPointY);
            WPF.Point newEndPoint = new WPF.Point(newEndPointX, newEndPointY);

            //get the second point

            //draw line from center of the point.
            WPFMEDIA.LineGeometry newLine = new System.Windows.Media.LineGeometry(newStartPoint, newEndPoint);
            return newLine;
        }
示例#6
0
 public static DialogResult ShowDesignerDialog(string title, Wpf.UIElement wpfContent, int width, int height)
 {
     DesignerDialog dlg = new DesignerDialog(title, wpfContent);
     dlg.Width = width;
     dlg.Height = height;
     dlg.SizeGripStyle = SizeGripStyle.Hide;
     return dlg.ShowDialog();
 }
示例#7
0
		void ConnectTo (sw.Point startPoint, bool startNewFigure = false)
		{
			if (startNewFigure || figure == null) {
				figure = new swm.PathFigure ();
				figure.StartPoint = startPoint;
				figure.Segments = new swm.PathSegmentCollection ();
				Control.Figures.Add (figure);
			} else
				figure.Segments.Add (new swm.LineSegment (startPoint, true));
		}
示例#8
0
        public static FontStretch ToXwtFontStretch(SW.FontStretch value)
        {
            // No, SW.FontStretches is not an enum
            if (value == SW.FontStretches.UltraCondensed) return FontStretch.UltraCondensed;
            if (value == SW.FontStretches.ExtraCondensed) return FontStretch.ExtraCondensed;
            if (value == SW.FontStretches.Condensed) return FontStretch.Condensed;
            if (value == SW.FontStretches.SemiCondensed) return FontStretch.SemiCondensed;
            if (value == SW.FontStretches.SemiExpanded) return FontStretch.SemiExpanded;
            if (value == SW.FontStretches.Expanded) return FontStretch.Expanded;
            if (value == SW.FontStretches.ExtraExpanded) return FontStretch.ExtraExpanded;
            if (value == SW.FontStretches.UltraExpanded) return FontStretch.UltraExpanded;

            return FontStretch.Normal;
        }
示例#9
0
        public bool? InUnitTestRunner()
        {
            var testAssemblies = new[] {
                "CSUNIT",
                "NUNIT",
                "XUNIT",
                "MBUNIT",
                "NBEHAVE",
            };

            try {
                return searchForAssembly(testAssemblies);
            } catch (Exception) {
                return null;
            }
        }
        public Button(List<Texture2D> textures, DotNET.Point location, long minInteractionTime)
        {
            this.textures = textures;
            this.Location = location;
            representation = 0;
            this.numTextures = textures.Count;

            radius = ((textures[0].Height / 2) + (textures[0].Width / 2)) / 2;
            radiusSq = radius * radius;

            minNecessaryInteractionTime = minInteractionTime;
            stopwatch = new Stopwatch();

            people = new Person[6];

            buttonHasBeenTriggered = false;

            timingInteraction = false;
        }
示例#11
0
        public bool? InUnitTestRunner()
        {
            var testAssemblies = new[] {
                "CSUNIT",
                "NUNIT",
                "XUNIT",
                "MBUNIT",
                "NBEHAVE",
                "VISUALSTUDIO.QUALITYTOOLS",
                "FIXIE",
                "NCRUNCH",
            };

            try {
                return searchForAssembly(testAssemblies);
            } catch (Exception) {
                return null;
            }
        }
示例#12
0
 /// <summary>
 /// Offsets a point in a particular direction by certian length.
 /// </summary>
 /// <param name="p1"></param>
 /// <param name="dir"></param>
 /// <param name="len"></param>
 /// <returns></returns>
 public static Point Offset(Point p1, windows.Vector dir, float len)
 {
     return new Point((int)(p1.X + dir.X * len / dir.Length),
       (int)(p1.Y + dir.Y * len / dir.Length));
 }
示例#13
0
 //Can be more complex later.
 public static WPFMEDIA.LineGeometry Line(WPF.Point StartPoint, WPF.Point EndPoint)
 {
     WPFMEDIA.LineGeometry newLine = new System.Windows.Media.LineGeometry(StartPoint, EndPoint);
     return newLine;
 }
示例#14
0
 public static double DistanceBetweenPoints(WPF.Point StartPoint, WPF.Point EndPoint)
 {
     double length = Math.Sqrt(Math.Pow(StartPoint.X - EndPoint.X, 2) + Math.Pow(StartPoint.Y - EndPoint.Y, 2));
     return length;
 }
示例#15
0
 public static double CurrentAngle(WPF.Point StartPoint, WPF.Point EndPoint)
 {
     double radians = Math.Atan2(StartPoint.Y - EndPoint.Y, StartPoint.X - EndPoint.X);
     double angle = radians * (180 / Math.PI);
     return angle;
 }
示例#16
0
 public void NewFigure(SW.Point p)
 {
     if (Path.Segments.Count > 0) {
         Path = new PathFigure ();
         geometry.Figures.Add (Path);
     }
     LastFigureStart = p;
     EndPoint = p;
     Path.StartPoint = p;
     positionSet = true;
 }
示例#17
0
 public void ConnectToLastFigure(SW.Point p, bool stroke)
 {
     if (EndPoint != p) {
         var pathIsOpen = Path.Segments.Count != 0 || geometry.Figures.Count > 1 || positionSet;
         if (pathIsOpen) {
         //	LastFigureStart = p;
             Path.Segments.Add (new LineSegment (p, stroke));
         }
         else
             NewFigure (p);
     }
     if (!stroke)
         LastFigureStart = p;
 }
示例#18
0
 private NVCFND.Point GetWorldPoint(WIN.Point screenPt)
 {
     var xfPoint = xformGroup_all.Inverse.Transform(screenPt);
      return
     (NVCFND.Point)xfPoint;
 }
示例#19
0
 /// <summary>
 /// Returns the scalar value of the cross product of two vectors.
 /// </summary>
 /// <param name="v1"></param>
 /// <param name="v2"></param>
 /// <returns></returns>
 public static float CrossProduct(windows.Vector v1, windows.Vector v2)
 {
     return (float)(v1.X * v2.Y - v1.Y * v2.X);
 }
示例#20
0
		public static bool ExtendGlassFrame (sw.Window window)
		{
			return ExtendGlassFrame (window, new sw.Thickness (-1));
		}
示例#21
0
        //Draws a polygon with different thiknesses at each end. Traces over a line.
        public static WPFMEDIA.PathGeometry PolygonLine(WPF.Point StartPoint, WPF.Point EndPoint, double StartWidth, double EndWidth)
        {
            //Get Current Angle Don't need the actual angle, radians is fine.
            double angle = CurrentAngle(StartPoint, EndPoint);
            double radians = Math.Atan2(StartPoint.Y - EndPoint.Y, StartPoint.X - EndPoint.X);

            //Take 90 deg
            double newAngle = angle + 90;
            double newRadians = radians + Math.PI / 2;

            //need to determine the shift.

            double shiftStartX = StartWidth * Math.Cos(newRadians);
            double shiftStartY = StartWidth * Math.Sin(newRadians);

            double shiftEndX = EndWidth * Math.Cos(newRadians);
            double shiftEndY = EndWidth * Math.Sin(newRadians);

            double newStartPointX1 = StartPoint.X - shiftStartX;
            double newStartPointY1 = StartPoint.Y - shiftStartY;
            double newStartPointX2 = StartPoint.X + shiftStartX;
            double newStartPointY2 = StartPoint.Y + shiftStartY;

            double newEndPointX1 = EndPoint.X - shiftEndX;
            double newEndPointY1 = EndPoint.Y - shiftEndY;
            double newEndPointX2 = EndPoint.X + shiftEndX;
            double newEndPointY2 = EndPoint.Y + shiftEndY;

            WPF.Point newStartPoint1 = new WPF.Point(newStartPointX1, newStartPointY1);
            WPF.Point newStartPoint2 = new WPF.Point(newStartPointX2, newStartPointY2);
            WPF.Point newEndPoint1 = new WPF.Point(newEndPointX1, newEndPointY1);
            WPF.Point newEndPoint2 = new WPF.Point(newEndPointX2, newEndPointY2);

            //Now we have all the points. Need to build a polygon shape.
            WPFMEDIA.PathGeometry rootPath = new System.Windows.Media.PathGeometry();
            WPFMEDIA.PolyLineSegment poly = new System.Windows.Media.PolyLineSegment();
            //poly.Points.Add(newStartPoint1);
            poly.Points.Add(newStartPoint2);
            poly.Points.Add(newEndPoint2);
            poly.Points.Add(newEndPoint1);

            WPFMEDIA.PathFigure newFigure = new WPFMEDIA.PathFigure();
            newFigure.StartPoint = newStartPoint1;
            newFigure.Segments.Add(poly);
            rootPath.Figures.Add(newFigure);

            return rootPath;
        }
示例#22
0
 public static bool IsAngleClockwise(windows.Vector v1, windows.Vector v2)
 {
     return CrossProduct(v1, v2) < 0;
 }
示例#23
0
 public static float DotProduct(windows.Vector v1, windows.Vector v2)
 {
     return (float)(v1.X * v2.X + v1.Y * v2.Y);
 }
示例#24
0
		public static FontStyle Convert(sw.FontStyle fontStyle, sw.FontWeight fontWeight)
		{
			var style = FontStyle.None;
			if (fontStyle == sw.FontStyles.Italic)
				style |= FontStyle.Italic;
			if (fontStyle == sw.FontStyles.Oblique)
				style |= FontStyle.Italic;

			if (fontWeight == sw.FontWeights.Bold)
				style |= FontStyle.Bold;
			return style;
		}
示例#25
0
		public static bool BlurBehindWindow (sw.Window window)
		{
			if (!DwmIsCompositionEnabled ())
				return false;

			var windowInteropHelper = new sw.Interop.WindowInteropHelper (window);
			IntPtr myHwnd = windowInteropHelper.Handle;
			var mainWindowSrc = System.Windows.Interop.HwndSource.FromHwnd (myHwnd);

			window.Background = swm.Brushes.Transparent;
			mainWindowSrc.CompositionTarget.BackgroundColor = swm.Colors.Transparent;

			var blurBehindParameters = new DWM_BLURBEHIND ();
			blurBehindParameters.dwFlags = DwmBlurBehindFlags.DWM_BB_ENABLE;
			blurBehindParameters.fEnable = true;
			blurBehindParameters.hRgnBlur = IntPtr.Zero;

			DwmEnableBlurBehindWindow (myHwnd, ref blurBehindParameters);
			int val = 1;
			DwmSetWindowAttribute (myHwnd, DwmWindowAttribute.DWMWA_TRANSITIONS_FORCEDISABLED, ref val, sizeof (int));
			return true;
		}
示例#26
0
 public static PointF Offset(PointF p1, windows.Vector dir, float len)
 {
     return new PointF(p1.X + (float)(dir.X * len / dir.Length),
       p1.Y + (float)(dir.Y * len / dir.Length));
 }
示例#27
0
		/// <summary>
		/// Extends the aero glass to the edge of the window
		/// </summary>
		/// <param name="window">
		/// The window to be affected
		/// </param>
		/// <param name="margin">
		/// The window margins
		/// </param>
		/// <returns>
		/// Returns true/false depending on success
		/// </returns>
		public static bool ExtendGlassFrame (sw.Window window, sw.Thickness margin)
		{
			try {
				// desktop window manader must be enabled if it isn't don't bother trying to add glass
				if (!DwmIsCompositionEnabled ())
					return false;

				IntPtr hwnd = new sw.Interop.WindowInteropHelper (window).Handle;

				if (hwnd == IntPtr.Zero) {
					throw new InvalidOperationException ("The Window must be shown before extending glass.");
				}

				// Set the background to transparent from both the WPF and Win32 perspectives
				window.Background = swm.Brushes.Transparent;
				sw.Interop.HwndSource.FromHwnd (hwnd).CompositionTarget.BackgroundColor = swm.Colors.Transparent;

				var margins = new MARGINS (margin);
				DwmExtendFrameIntoClientArea (hwnd, ref margins);
				return true;
			}
			catch {
				return false;
			}
		}
示例#28
0
 /// <summary>
 /// Returns a new vector which is perpendicular to v.
 /// </summary>
 /// <param name="v">The original vector.</param>
 /// <returns>A new vector which is perpendicular to the input vector.</returns>
 public static windows.Vector Perp(windows.Vector v)
 {
     return new windows.Vector(-v.Y, v.X);
 }
示例#29
0
        void GetWidgetDesiredSize(double availableWidth, double availableHeight, out SW.Size minSize, out SW.Size naturalSize)
        {
            // Calculates the desired size of widget.

            if (!Widget.IsMeasureValid) {
                try {
                    calculatingPreferredSize = true;
                    gettingNaturalSize = true;
                    Widget.Measure (new System.Windows.Size (availableWidth, availableHeight));
                    lastNaturalSize = Widget.DesiredSize;
                    gettingNaturalSize = false;

                    Widget.InvalidateMeasure ();
                    Widget.Measure (new System.Windows.Size (availableWidth, availableHeight));
                }
                finally {
                    calculatingPreferredSize = false;
                    gettingNaturalSize = false;
                }
            }
            minSize = Widget.DesiredSize;
            naturalSize = lastNaturalSize;
        }
示例#30
0
 /// <summary>
 /// Angle between two vectors in radians.
 /// </summary>
 /// <param name="v1"></param>
 /// <param name="v2"></param>
 /// <returns></returns>
 public static float Angle(windows.Vector v1, windows.Vector v2)
 {
     if (v1.Length == 0 || v2.Length == 0)
     throw new ArgumentException("Vector lenght cannot be 0.");
       return (float)Math.Acos(DotProduct(v1, v2) / (v1.Length * v2.Length));
 }