コード例 #1
0
 private void SwichEnterTypeInSceneGUI()
 {
     for (int i = 0; i < Monsterpoint.MonsterPointdataList.Count; i++)
     {
         Handles.CubeCap(0, Monsterpoint.MonsterPointdataList[i].Effpos, Quaternion.identity, 0.3f);
         switch (Monsterpoint.MonsterPointdataList[i].Entertype)
         {
             case MonsterEnterType.StayIdle:
                 //Handles.CircleCap(0, Monsterpoint.transform.position, Quaternion.EulerRotation(20.45f,0,0), Monsterpoint.MonsterPointdataList[i].StayIdleSize);
                 break;
             case MonsterEnterType.RunAround:
                 for (int j = 0; j < Monsterpoint.MonsterPointdataList[i].RunAroundCount; j++)
                 {
                     Handles.SphereCap(0,Monsterpoint.MonsterPointdataList[i].RunAroundPoints[j], Quaternion.identity, 0.3f);
                 }
                 break;
         }
     }
 }
コード例 #2
0
    static void DrawPointSceneGUI(BezierPoint point)
    {
        Handles.Label(point.position + new Vector3(0, HandleUtility.GetHandleSize(point.position) * 0.4f, 0), point.gameObject.name);

        Handles.color = Color.green;
        Vector3 newPosition = Handles.FreeMoveHandle(point.position, point.transform.rotation, HandleUtility.GetHandleSize(point.position) * 0.1f, Vector3.zero, Handles.RectangleHandleCap);

        if (newPosition != point.position)
        {
            Undo.RegisterCompleteObjectUndo(point.transform, "Move Point");
            point.transform.position = newPosition;
        }

        if (point.handleStyle != BezierPoint.HandleStyle.None)
        {
            Handles.color = Color.cyan;
            Vector3 newGlobal1 = Handles.FreeMoveHandle(point.globalHandle1, point.transform.rotation, HandleUtility.GetHandleSize(point.globalHandle1) * 0.075f, Vector3.zero, Handles.CircleHandleCap);
            if (point.globalHandle1 != newGlobal1)
            {
                Undo.RegisterCompleteObjectUndo(point, "Move Handle");
                point.globalHandle1 = newGlobal1;
                if (point.handleStyle == BezierPoint.HandleStyle.Connected)
                {
                    point.globalHandle2 = -(newGlobal1 - point.position) + point.position;
                }
            }

            Vector3 newGlobal2 = Handles.FreeMoveHandle(point.globalHandle2, point.transform.rotation, HandleUtility.GetHandleSize(point.globalHandle2) * 0.075f, Vector3.zero, Handles.CircleHandleCap);
            if (point.globalHandle2 != newGlobal2)
            {
                Undo.RegisterCompleteObjectUndo(point, "Move Handle");
                point.globalHandle2 = newGlobal2;
                if (point.handleStyle == BezierPoint.HandleStyle.Connected)
                {
                    point.globalHandle1 = -(newGlobal2 - point.position) + point.position;
                }
            }

            Handles.color = Color.yellow;
            Handles.DrawLine(point.position, point.globalHandle1);
            Handles.DrawLine(point.position, point.globalHandle2);
        }
    }
コード例 #3
0
        public static void DrawSpline(CatmullRomUniform spline, Transform owner)
        {
            List <Vector3> interPts = spline.InterPoints;
            List <Vector3> tangents = spline.InterTangents;
            List <Vector3> ups = spline.InterUps;
            Vector3        p0, p1;

            Vector3 prevBino = Vector3.right;

            p0 = owner.TransformPoint(interPts[0]);
            for (int i = 0; i < interPts.Count; ++i)
            {
                Vector3 tan  = owner.TransformDirection(tangents[i]).normalized;
                Vector3 up   = owner.TransformDirection(ups[i]).normalized;
                Vector3 bino = Vector3.Cross(up, tan).normalized;

                if (bino == Vector3.zero)
                {
                    bino = prevBino;
                }
                else
                {
                    prevBino = bino;
                }

                if (ms_drawArrow)
                {
                    Handles.DrawLine(p0, p0 + (bino - tan) * ms_arrowLineLen);
                    Handles.DrawLine(p0, p0 - (bino + tan) * ms_arrowLineLen);
                }
                if (ms_drawUp)
                {
                    Handles.DrawLine(p0, p0 + up * ms_arrowLineLen);
                }

                if (i + 1 < interPts.Count)
                {
                    p1 = owner.TransformPoint(interPts[i + 1]);
                    Handles.DrawLine(p0, p1);
                    p0 = p1;
                }
            }
        }
コード例 #4
0
    public static void DrawCatmullPath(List<Transform> points, InterpolationFunc sampler, int samples)
    {
        if (!PreDrawPath(points, 4))
            return;

        float sampleInterval = 1.0f / (float)samples;

        int p0, p1, p2, p3;

        for (int i = 0; i < points.Count; ++i)
        {
            p1 = i;

            p0 = p1 - 1;
            if (p0 < 0)
                p0 = points.Count - 1;

            p2 = p1 + 1;
            if (p2 >= points.Count)
                p2 = 0;

            p3 = p2 + 1;
            if (p3 >= points.Count)
                p3 = 0;

            Vector3 sample, prevSample;

            prevSample = points[p1].position;

            for (int j = 1; j <= samples; ++j)
            {
                float t = j * sampleInterval;
                sample = sampler(points[p0].position,
                                 points[p1].position,
                                 points[p2].position,
                                 points[p3].position, t);

                Handles.DrawLine(prevSample, sample);

                prevSample = sample;
            }
        }
    }
コード例 #5
0
    public static void DrawSelector(ColorKeyframe keyframe)
    {
        int     hint           = (ControlHint * keyframe.MarkerIndex) + keyframe.MarkerIndex;
        int     controlId      = GUIUtility.GetControlID(hint, FocusType.Passive);
        Vector3 offsetPosition = keyframe.Position + new Vector3(0, keyframe.Offset, 0);

        float size       = 0.0175f;
        float hitboxSize = 1.5f * size;

        // -- DOT & LINE -- //
        Handles.color = Palette.Translucent;
        Handles.DrawLine(keyframe.Position, offsetPosition);
        CustomHandles.DrawDisc(offsetPosition, size * 0.5f, keyframe.LightColor);

        // -- SELECTION -- //
        if (CustomHandles.SelectableButton(offsetPosition, hitboxSize, keyframe.LightColor))
        {
            Selection.activeObject = keyframe;
        }

        bool selected = Selection.activeObject == keyframe;

        if (selected)
        {
            CustomHandles.DrawCircle(offsetPosition, hitboxSize, keyframe.LightColor);
        }


        /// -- MOVEMENT -- //
        EditorGUI.BeginChangeCheck();
        Vector3 newPosition = Handles.FreeMoveHandle(controlId, offsetPosition, Quaternion.identity, size, DefaultSnap, CustomHandles.NullCap);

        if (EditorGUI.EndChangeCheck() && selected)
        {
            Undo.RecordObject(keyframe, "Change Color Keyframe");

            Vector3 delta = (newPosition - offsetPosition);
            ApplyDelta(keyframe, keyframe.Tangent, delta);

            keyframe.Drone.UpdateView();
            TimelineEditor.Refresh(RefreshReason.ContentsModified);
        }
    }
コード例 #6
0
    private static void RenderCustomGizmo(Transform objectTransform, GizmoType gizmoType)
    {
        var path = objectTransform.GetComponent <UnitPath>();

        if (path != null)
        {
            var p0 = objectTransform.TransformPoint(path[0]);

            for (var i = 1; i < path.Count; i += 3)
            {
                var p1 = objectTransform.TransformPoint(path[i]);
                var p2 = objectTransform.TransformPoint(path[i + 1]);
                var p3 = objectTransform.TransformPoint(path[i + 2]);

                Handles.DrawBezier(p0, p3, p1, p2, Color.white, null, 2.0f);
                p0 = p3;
            }
        }
    }
コード例 #7
0
    private void OnSceneGUI()
    {
        curve           = target as BezierCurve;
        handleTransform = curve.transform;
        handleRotation  = Tools.pivotRotation == PivotRotation.Local ? handleTransform.rotation : Quaternion.identity;


        Vector3 p0 = ShowPoint(0);
        Vector3 p1 = ShowPoint(1);
        Vector3 p2 = ShowPoint(2);
        Vector3 p3 = ShowPoint(3);

        Handles.color = Color.gray;
        Handles.DrawLine(p0, p1);
        Handles.DrawLine(p2, p3);

        ShowDirections();
        Handles.DrawBezier(p0, p3, p1, p2, Color.white, null, 5f);
    }
コード例 #8
0
    void OnDrawGizmosSelected()
    {
        Gizmos.color = Color.white;
        Gizmos.DrawSphere(StartNode.RootNode.transform.position, 0.25f);
        Handles.Label(StartNode.RootNode.transform.position + Vector3.up, "0");

        Gizmos.color = Color.red;
        Gizmos.DrawSphere(StartNode.AfterNode.transform.position, 0.1f);
        Handles.Label(StartNode.AfterNode.transform.position + Vector3.up, "0_");

        Gizmos.DrawLine(StartNode.RootNode.position, StartNode.AfterNode.position);

        Gizmos.color = Color.black;
        Gizmos.DrawSphere(EndNode.RootNode.transform.position, 0.25f);
        Handles.Label(EndNode.RootNode.transform.position + Vector3.up, (MidNodes.Count + 1).ToString());

        Gizmos.color = Color.cyan;
        Gizmos.DrawSphere(EndNode.BeforeNode.transform.position, 0.1f);
        Handles.Label(EndNode.BeforeNode.transform.position + Vector3.up, "_" + (MidNodes.Count + 1));

        Gizmos.DrawLine(EndNode.RootNode.position, EndNode.BeforeNode.position);

        for (int i = 0; i < MidNodes.Count; i++)
        {
            Gizmos.color = Color.cyan;
            Gizmos.DrawSphere(MidNodes[i].BeforeNode.transform.position, 0.1f);
            Handles.Label(MidNodes[i].BeforeNode.transform.position + Vector3.up, "_" + (i + 1));

            Gizmos.DrawLine(MidNodes[i].RootNode.transform.position, MidNodes[i].BeforeNode.transform.position);


            Gizmos.color = Color.Lerp(Color.white, Color.black, (float)(i + 1) / (MidNodes.Count + 1));
            Gizmos.DrawSphere(MidNodes[i].RootNode.transform.position, 0.25f);
            Handles.Label(MidNodes[i].RootNode.transform.position + Vector3.up, (i + 1).ToString());


            Gizmos.color = Color.red;
            Gizmos.DrawSphere(MidNodes[i].AfterNode.transform.position, 0.1f);
            Handles.Label(MidNodes[i].AfterNode.transform.position + Vector3.up, (i + 1) + "_");

            Gizmos.DrawLine(MidNodes[i].RootNode.transform.position, MidNodes[i].AfterNode.transform.position);
        }
    }
コード例 #9
0
    private void OnSceneGUI()
    {
        FieldOfView fov = (FieldOfView)target;

        Handles.color = Color.white;
        Handles.DrawWireArc(fov.transform.position, Vector3.forward, Vector2.up, 360, fov.viewRadius);

        Vector2 viewAngleA = fov.DirectionFromAngle(-fov.viewAngle / 2, false);
        Vector2 viewAngleB = fov.DirectionFromAngle(fov.viewAngle / 2, false);

        Handles.DrawLine(fov.transform.position, fov.transform.position + (Vector3)viewAngleA * fov.viewRadius);
        Handles.DrawLine(fov.transform.position, fov.transform.position + (Vector3)viewAngleB * fov.viewRadius);

        Handles.color = Color.red;
        foreach (Transform visibleTarget in fov.visibleTargets)
        {
            Handles.DrawLine(fov.transform.position, visibleTarget.position);
        }
    }
コード例 #10
0
    public virtual void OnSceneGUI()
    {
        if (!SceneEditor.ShowGizmos)
        {
            return;
        }

        Waypoint _waypoint = (Waypoint)target;

        Handles.color = Color.yellow;

        _waypoint.transform.position = Handles.FreeMoveHandle(_waypoint.transform.position,
                                                              Quaternion.identity,
                                                              0.4f,
                                                              Vector3.zero,
                                                              Handles.CylinderHandleCap);

        Undo.RecordObject(_waypoint.transform, "Waypoint Position");
    }
コード例 #11
0
    private void DrawPlane()
    {
        Handles.zTest = UnityEngine.Rendering.CompareFunction.LessEqual;
        Vector3 tangent1 = PlaneTangent * planePreviewSize.x;
        Vector3 tangent2 = Vector3.Cross(PlaneTangent, PlaneNormal) * planePreviewSize.y;

        Handles.DrawSolidRectangleWithOutline
        (
            new Vector3[]
        {
            tangent1 + tangent2 + PlanePoint,
            tangent1 - tangent2 + PlanePoint,
            -tangent1 - tangent2 + PlanePoint,
            -tangent1 + tangent2 + PlanePoint
        },
            planeColor,
            planeColor
        );
    }
コード例 #12
0
        internal virtual void OnSceneGUI()
        {
            Tools.current = Tool.Custom;
            Bezier t = target as Bezier;

            EditorGUI.BeginChangeCheck();
            t.StartPosition = Handles.PositionHandle(t.startPosition, Quaternion.identity);
            t.EndPosition   = Handles.PositionHandle(t.endPosition, Quaternion.identity);
            t.startTangent  = Handles.PositionHandle(t.startTangent, Quaternion.identity);
            t.endTangent    = Handles.PositionHandle(t.endTangent, Quaternion.identity);
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(t);
                if (!t.startPosition.Equals(t.endPosition))
                {
                    t.Points = Handles.MakeBezierPoints(t.startPosition, t.endPosition, t.startTangent, t.endTangent, Mathf.CeilToInt(Vector3.Distance(t.startPosition, t.endPosition)));
                }
            }
        }
コード例 #13
0
    // Can be used to draw graphics in the scene view of our component
    private void OnSceneGUI()
    {
        // target is an Object type inherited from Editor class
        // that is the object we inspect in the scene and is being casted
        // as a Line during runtime
        Line line = target as Line;

        // Handles operates in world space while points
        // are in local space of line
        // need to convert from local to world space
        Transform handleTransform = line.transform;
        Vector3   p0 = handleTransform.TransformPoint(line.p0);
        Vector3   p1 = handleTransform.TransformPoint(line.p1);

        // Rotation handle
        Quaternion handleRotation = Tools.pivotRotation == PivotRotation.Local ?
                                    handleTransform.rotation : Quaternion.identity;

        Handles.color = Color.white;
        Handles.DrawLine(p0, p1);

        // Add rotation handles
        // Update handle positions
        EditorGUI.BeginChangeCheck();
        p0 = Handles.DoPositionHandle(p0, handleRotation);
        if (EditorGUI.EndChangeCheck())
        {
            // Enables Undo Operation in Unity Editor
            Undo.RecordObject(line, "Move Point");
            EditorUtility.SetDirty(line);
            line.p0 = handleTransform.InverseTransformPoint(p0);
        }

        EditorGUI.BeginChangeCheck();
        p1 = Handles.DoPositionHandle(p1, handleRotation);
        if (EditorGUI.EndChangeCheck())
        {
            // Enables Undo Operation in Unity Editor
            Undo.RecordObject(line, "Move Point");
            EditorUtility.SetDirty(line);
            line.p1 = handleTransform.InverseTransformPoint(p1);
        }
    }
コード例 #14
0
 static void DrawGizmoForMyScript(MapBehaviour mapBehaviour, GizmoType gizmoType)
 {
     if (!mapBehaviour.VisualizeSlots)
     {
         return;
     }
     if (mapBehaviour.Map == null)
     {
         return;
     }
     foreach (var slot in mapBehaviour.Map.GetAllSlots())
     {
         if (slot.Collapsed || slot.Modules.Count == Module.All.Length)
         {
             continue;
         }
         Handles.Label(mapBehaviour.GetWorldspacePosition(slot.Position), slot.Modules.Count.ToString());
     }
 }
コード例 #15
0
    void OnSceneGUI()
    {
        Light2D l = (Light2D)target;

        EditorUtility.SetSelectedWireframeHidden(l.renderer, true);

        Handles.color = Color.green;
        float widgetSize = Vector3.Distance(l.transform.position, SceneView.lastActiveSceneView.camera.transform.position) * 0.05f;
        float rad        = (l.LightRadius / 2f);

        Handles.DrawWireDisc(l.transform.position, l.transform.forward, rad);
        l.LightRadius = Handles.ScaleValueHandle(l.LightRadius, l.transform.TransformPoint(Vector3.right * rad), Quaternion.identity, widgetSize, Handles.CubeCap, 1);

        Handles.color = Color.red;
        Vector3 sPos = l.transform.TransformDirection(Mathf.Cos(Mathf.Deg2Rad * l.SweepStart), Mathf.Sin(Mathf.Deg2Rad * l.SweepStart), 0);

        Handles.DrawWireArc(l.transform.position, l.transform.forward, sPos, l.SweepSize, (rad * 0.8f));
        l.SweepSize = Mathf.Clamp((int)Handles.ScaleValueHandle(l.SweepSize, l.transform.position + sPos * (rad * 0.8f), Quaternion.identity, widgetSize, Handles.SphereCap, 1), 0, 360);
    }
コード例 #16
0
        public override void OnSceneGui()
        {
            float radius        = PropertyValue;
            var   monoTransform = mono.transform;

            bool relativeSpace = attribute.Space == Space.Self;

            if (relativeSpace)
            {
                radius *= monoTransform.localScale.magnitude;
            }

            var pos = monoTransform.position;

            Handles.color = attribute.Color;
            Handles.DrawWireDisc(pos, relativeSpace ? monoTransform.forward : Vector3.forward, radius);
            Handles.DrawWireDisc(pos, relativeSpace ? monoTransform.up      : Vector3.up, radius);
            Handles.DrawWireDisc(pos, relativeSpace ? monoTransform.right   : Vector3.right, radius);
        }
コード例 #17
0
        public override void OnPaintSceneGUI(GridLayout grid, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing)
        {
            base.OnPaintSceneGUI(grid, brushTarget, position, tool, executing);
            if (lineBrush.lineStartActive)
            {
                Tilemap tilemap = brushTarget.GetComponent<Tilemap>();
                if (tilemap != null)
                    lastTilemap = tilemap;

                // Draw preview tiles for tilemap
                Vector2Int startPos = new Vector2Int(lineBrush.lineStart.x, lineBrush.lineStart.y);
                Vector2Int endPos = new Vector2Int(position.x, position.y);
                if (startPos == endPos)
                    PaintPreview(grid, brushTarget, position.min);
                else
                {
                    foreach (var point in LineBrush.GetPointsOnLine(startPos, endPos, lineBrush.fillGaps))
                    {
                        Vector3Int paintPos = new Vector3Int(point.x, point.y, position.z);
                        PaintPreview(grid, brushTarget, paintPos);
                    }
                }

                if (Event.current.type == EventType.Repaint)
                {
                    var min = lineBrush.lineStart;
                    var max = lineBrush.lineStart + position.size;

                    // Draws a box on the picked starting position
                    GL.PushMatrix();
                    GL.MultMatrix(GUI.matrix);
                    GL.Begin(GL.LINES);
                    Handles.color = Color.blue;
                    Handles.DrawLine(new Vector3(min.x, min.y, min.z), new Vector3(max.x, min.y, min.z));
                    Handles.DrawLine(new Vector3(max.x, min.y, min.z), new Vector3(max.x, max.y, min.z));
                    Handles.DrawLine(new Vector3(max.x, max.y, min.z), new Vector3(min.x, max.y, min.z));
                    Handles.DrawLine(new Vector3(min.x, max.y, min.z), new Vector3(min.x, min.y, min.z));
                    GL.End();
                    GL.PopMatrix();
                }
            }
        }
コード例 #18
0
        static void Gizmos_CapturePoint(ReflectionProbe target)
        {
            if (sphere == null)
            {
                sphere = Resources.GetBuiltinResource <Mesh>("New-Sphere.fbx");
            }
            if (material == null)
            {
                material = new Material(Shader.Find("Debug/ReflectionProbePreview"));
            }
            var probe = target.GetComponent <HDAdditionalReflectionData>();
            var probePositionSettings = ProbeCapturePositionSettings.ComputeFrom(probe, null);

            HDRenderUtilities.ComputeCameraSettingsFromProbeSettings(
                probe.settings, probePositionSettings, probe.texture,
                out CameraSettings cameraSettings, out CameraPositionSettings cameraPositionSettings
                );
            var capturePosition = cameraPositionSettings.position;

            material.SetTexture("_Cubemap", probe.texture);
            material.SetPass(0);
            Graphics.DrawMeshNow(sphere, Matrix4x4.TRS(capturePosition, Quaternion.identity, Vector3.one * capturePointPreviewSize));

            var ray = new Ray(capturePosition, Vector3.down);

            if (Physics.Raycast(ray, out RaycastHit hit))
            {
                var startPoint = capturePosition - Vector3.up * 0.5f * capturePointPreviewSize;
                var c          = InfluenceVolumeUI.k_GizmoThemeColorBase;
                c.a           = 0.8f;
                Handles.color = c;
                Handles.zTest = UnityEngine.Rendering.CompareFunction.LessEqual;
                Handles.DrawLine(startPoint, hit.point);
                Handles.DrawWireDisc(hit.point, hit.normal, 0.5f);

                c.a           = 0.25f;
                Handles.color = c;
                Handles.zTest = UnityEngine.Rendering.CompareFunction.Greater;
                Handles.DrawLine(capturePosition, hit.point);
                Handles.DrawWireDisc(hit.point, hit.normal, 0.5f);
            }
        }
コード例 #19
0
ファイル: PathEditor.cs プロジェクト: jv-albuquerque/TD
        void DrawVertexPathSceneEditor()
        {
            Color bezierCol = globalDisplaySettings.bezierPath;

            bezierCol.a *= .5f;

            if (data.showBezierPathInVertexMode)
            {
                for (int i = 0; i < bezierPath.NumSegments; i++)
                {
                    Vector3[] points = bezierPath.GetPointsInSegment(i);
                    for (int j = 0; j < points.Length; j++)
                    {
                        points[j] = MathUtility.TransformPoint(points[j], creator.transform, bezierPath.Space);
                    }
                    Handles.DrawBezier(points[0], points[3], points[1], points[2], bezierCol, null, 2);
                }
            }

            Handles.color = globalDisplaySettings.vertexPath;

            for (int i = 0; i < creator.path.NumPoints; i++)
            {
                int nextIndex = (i + 1) % creator.path.NumPoints;
                if (nextIndex != 0 || bezierPath.IsClosed)
                {
                    Handles.DrawLine(creator.path.GetPoint(i), creator.path.GetPoint(nextIndex));
                }
            }

            if (data.showNormalsInVertexMode)
            {
                Handles.color = globalDisplaySettings.normals;
                Vector3[] normalLines = new Vector3[creator.path.NumPoints * 2];
                for (int i = 0; i < creator.path.NumPoints; i++)
                {
                    normalLines[i * 2]     = creator.path.GetPoint(i);
                    normalLines[i * 2 + 1] = creator.path.GetPoint(i) + creator.path.localNormals[i] * globalDisplaySettings.normalsLength;
                }
                Handles.DrawLines(normalLines);
            }
        }
コード例 #20
0
		private static void OnSceneGUI(SceneView sceneView) {
			if (cachedValidationErrors_ == null) {
				return;
			}

			Handles.BeginGUI();

			// BEGIN SCENE GUI
			float yPosition = 0.0f;
			foreach (IValidationError error in cachedValidationErrors_) {
				var componentError = error as IComponentValidationError;

				// NOTE (darren): it's possible that OnSceneGUI gets called after
				// the prefab is destroyed - don't do anything in that case
				if (componentError == null || componentError.Component == null) {
					continue;
				}

				var linkRect = new Rect(kErrorWidth - kLinkWidth - kLinkPadding, yPosition + kLinkPadding, kLinkWidth, kErrorHeight - kLinkPadding);
				if (GUI.Button(linkRect, "Link")) {
					LinkValidationError(componentError);
				}

				var rect = new Rect(0.0f, yPosition, kErrorWidth, kErrorHeight);
				var errorDescription = string.Format("{0}->{1}.{2}", componentError.Component.gameObject.name, error.ObjectType.Name, error.MemberInfo.Name);

				if (GUI.Button(rect, errorDescription, kButtonStyle)) {
					Selection.activeGameObject = componentError.Component.gameObject;
				}

				if (GUI.Button(linkRect, "Link")) {
					// empty (no-action) button for the visual look
					// NOTE (darren): it appears the order in which GUI.button is
					// called determines the ordering for which button consumes the touch
					// but also the order is used to render :)
				}

				yPosition += kErrorHeight + kErrorSpacingHeight;
			}
			// END SCENE GUI
			Handles.EndGUI();
		}
コード例 #21
0
        private void ShowTangentPoint(int index)
        {
            if (m_selectedIndex != index)
            {
                return;
            }
            Vector3 point = SelectSpline.GetLocationAtSplineInputKey(index, ESplineCoordinateSpace.World);
            float   size  = HandleUtility.GetHandleSize(point);

            Vector3 Location      = SelectSpline.GetLocationAtSplinePoint(index, ESplineCoordinateSpace.World);
            Vector3 LeaveTangent  = SelectSpline.GetLeaveTangentAtSplinePoint(index, ESplineCoordinateSpace.World);
            Vector3 ArriveTangent = SelectSpline.GetArriveTangentAtSplinePoint(index, ESplineCoordinateSpace.World);

            DrawTangent(index, Location, ArriveTangent, -1, size);
            DrawTangent(index, Location, LeaveTangent, 1, size);

            //Arrive:-1,Leave:1
            if (m_selectedTangentIndex == 1)
            {
                EditorGUI.BeginChangeCheck();
                LeaveTangent = Handles.DoPositionHandle(Location + LeaveTangent, handleRotation);

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(SelectSpline, "移动离开切线点");
                    EditorUtility.SetDirty(SelectSpline);
                    SelectSpline.SetTangentsAtSplinePoint(index, ArriveTangent, LeaveTangent - Location, ESplineCoordinateSpace.World);
                }
            }
            //Arrive:-1,Leave:1
            if (m_selectedTangentIndex == -1)
            {
                EditorGUI.BeginChangeCheck();
                ArriveTangent = Handles.DoPositionHandle(Location - ArriveTangent, handleRotation);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(SelectSpline, "移动进入切线点");
                    EditorUtility.SetDirty(SelectSpline);
                    SelectSpline.SetTangentsAtSplinePoint(index, -1 * (ArriveTangent - Location), LeaveTangent, ESplineCoordinateSpace.World);
                }
            }
        }
コード例 #22
0
        protected override void OnSceneGUI()
        {
            base.OnSceneGUI();

            if (Event.current.type == EventType.Repaint)
            {
                if (m_LookAtAction.IsPlacedOnBrick())
                {
                    var start     = m_LookAtAction.GetBrickCenter();
                    var direction = m_LookAtAction.GetBrickRotation() * Vector3.right;
                    var end       = start + direction * 3.2f;
                    Handles.color = Color.green;
                    Handles.DrawDottedLine(start, end, 5.0f);

                    var angleRange = m_SpeedProp.intValue * m_TimeProp.floatValue;
                    var rotate     = (LookAtAction.Rotate)m_RotateProp.enumValueIndex;
                    switch (rotate)
                    {
                    case LookAtAction.Rotate.Horizontally:
                    {
                        DrawRange(start, direction, Vector3.up, angleRange, m_LookAtAction.GetHorizontalRotatedAngle());
                        break;
                    }

                    case LookAtAction.Rotate.Vertically:
                    {
                        var rotationAxis = Vector3.Cross(direction, Vector3.up);
                        DrawRange(start, direction, rotationAxis, angleRange, m_LookAtAction.GetVerticalRotatedAngle());
                        break;
                    }

                    case LookAtAction.Rotate.Freely:
                    {
                        DrawRange(start, direction, Vector3.up, angleRange, m_LookAtAction.GetHorizontalRotatedAngle());
                        var rotationAxis = Vector3.Cross(direction, Vector3.up);
                        DrawRange(start, direction, rotationAxis, angleRange, m_LookAtAction.GetVerticalRotatedAngle());
                        break;
                    }
                    }
                }
            }
        }
コード例 #23
0
        void OnSceneGUI()
        {
            Undo.SetSnapshotTarget(_target, "distance tool undo");
            //lables and handles:
            float distance      = Vector3.Distance(_target.startPoint, _target.endPoint);
            float scalePerPixel = distance * _target.pixelPerUnit;

            if (_target.scaleToPixels)
            {
                Handles.Label(_target.endPoint, "       Distance from Start point: " + distance + " - Scale per pixel: " + scalePerPixel + "px", style);
            }
            else
            {
                Handles.Label(_target.endPoint, "        Distance from Start point: " + distance, style);
            }

            //allow adjustment undo:
            _target.startPoint = Handles.PositionHandle(_target.startPoint, Quaternion.identity);
            _target.endPoint   = Handles.PositionHandle(_target.endPoint, Quaternion.identity);
        }
        protected override void DrawHandles(SerializedPlanarReflectionProbe serialized, Editor owner)
        {
            base.DrawHandles(serialized, owner);

            SceneViewOverlay_Window(EditorGUIUtility.TrTextContent(target.name), OnOverlayGUI, -100, target);

            if (serialized.probeSettings.mode.intValue != (int)ProbeSettings.Mode.Realtime)
            {
                using (new Handles.DrawingScope(Matrix4x4.TRS(serialized.target.transform.position, serialized.target.transform.rotation, Vector3.one)))
                {
                    var referencePosition = serialized.localReferencePosition.vector3Value;
                    EditorGUI.BeginChangeCheck();
                    referencePosition = Handles.PositionHandle(referencePosition, Quaternion.identity);
                    if (EditorGUI.EndChangeCheck())
                    {
                        serialized.localReferencePosition.vector3Value = referencePosition;
                    }
                }
            }
        }
コード例 #25
0
    public void Draw()
    {
        Handles.DrawBezier(
            m_InPoint.GetGlobalCenter(),
            m_OutPoint.GetGlobalCenter(),
            m_InPoint.GetGlobalCenter() + Vector2.left * 50f,
            m_OutPoint.GetGlobalCenter() - Vector2.left * 50f,
            Color.white,
            null,
            2f
            );

        if (Handles.Button((m_InPoint.GetGlobalCenter() + m_OutPoint.GetGlobalCenter()) * 0.5f, Quaternion.identity, 4, 8, Handles.RectangleHandleCap))
        {
            if (m_OnClickRemoveConnection != null)
            {
                m_OnClickRemoveConnection(this);
            }
        }
    }
コード例 #26
0
        void OnSceneGUI()
        {
            var component = target as VRMFirstPerson;

            var head = component.FirstPersonBone;

            if (head == null)
            {
                return;
            }


            var worldOffset = head.localToWorldMatrix.MultiplyPoint(component.FirstPersonOffset);

            worldOffset = Handles.PositionHandle(worldOffset, head.rotation);

            Handles.Label(worldOffset, "FirstPersonOffset");

            component.FirstPersonOffset = head.worldToLocalMatrix.MultiplyPoint(worldOffset);
        }
コード例 #27
0
ファイル: GridAxisDrawer.cs プロジェクト: UnMapache/VT_DEMO
            private void DrawSelectionAxisReferenceLines(Transform transform)
            {
                Color originalColor = Handles.color;
                Color lineColor     = GridSettings.instance.axisReferenceStyle == ReferenceLineStyle.SingleColor ?
                                      GridSettings.instance.axisReferenceColor : GetAxisColor(m_axis);

                lineColor.a   = 1f;
                Handles.color = lineColor;

                Vector3 gridPosition  = m_gridData.WorldToGridPosition(transform.position);
                Vector3 planePosition = Vector3.Scale(gridPosition, Vector3.one - AxisUtil.GetVector(m_axis));

                if (!Mathf.Approximately(gridPosition.GetComponent(aAxis), 0f) &&
                    !Mathf.Approximately(gridPosition.GetComponent(bAxis), 0f))
                {
                    Handles.DrawLine(gridPosition, planePosition);
                }

                Handles.color = originalColor;
            }
コード例 #28
0
        public static void DrawString(string text, Vector3 worldPos, Color?colour = null)
        {
#if UNITY_EDITOR
            var defaultColor = GUI.color;

            Handles.BeginGUI();
            if (colour.HasValue)
            {
                GUI.color = colour.Value;
            }
            var     view      = SceneView.currentDrawingSceneView;
            Vector3 screenPos = view.camera.WorldToScreenPoint(worldPos);
            Vector2 size      = GUI.skin.label.CalcSize(new GUIContent(text));
            GUI.Label(new Rect(screenPos.x - (size.x / 2), -screenPos.y + view.position.height + 4, size.x, size.y), text);

            Handles.EndGUI();

            GUI.color = defaultColor;
#endif
        }
コード例 #29
0
    private void DrawPrefabPalette(SokobanEditorSetup target)
    {
        Handles.BeginGUI();

        GUILayout.BeginArea(new Rect(target.Position.x, target.Position.y, target.Width, target.Height), EditorStyles.helpBox);

        if (GUILayout.Button("Загрузить список префабов"))
        {
            target.LoadResources();
        }

        GUILayout.TextArea("установить выбранный префаб ЛКМ, убрать префаб Shift+ЛКМ");
        GUILayout.BeginHorizontal();
        GUILayout.TextField("Выбор префаба: ");
        target.Index = EditorGUILayout.Popup(target.Index, target.PrefabNames);
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        Handles.EndGUI();
    }
コード例 #30
0
        private void SetPositionHandle(int index, Quaternion handleRotation)
        {
            var point = _spline.GetPointTransformed(index, _self.transform);

            if (EditorApplication.isPlaying)
            {
                point = _spline.GetPoint(index);
            }

            EditorGUI.BeginChangeCheck();
            var p = Handles.PositionHandle(point, handleRotation);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(_self, "Move Point");
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                EditorUtility.SetDirty(_self);
                _spline.SetTransformedPoint(index, p, _self.transform);
            }
        }
コード例 #31
0
        public MonoDebugSession()
            : base(true)
        {
            _variableHandles = new Handles<ObjectValue[]>();
            _frameHandles = new Handles<Mono.Debugging.Client.StackFrame>();
            _seenThreads = new Dictionary<int, Thread>();

            Configuration.Current.MaxConnectionAttempts = 10;
            Configuration.Current.ConnectionAttemptInterval = 500;

            // install an event handler in SDB
            Debugger.Callback = (type, threadinfo, text) => {
                int tid;
                switch (type) {
                case "TargetStopped":
                    Stopped();
                    SendEvent(CreateStoppedEvent("step", threadinfo));
                    break;

                case "TargetHitBreakpoint":
                    Stopped();
                    SendEvent(CreateStoppedEvent("breakpoint", threadinfo));
                    break;

                case "TargetExceptionThrown":
                case "TargetUnhandledException":
                    Stopped();
                    ExceptionInfo ex = Debugger.ActiveException;
                    if (ex != null) {
                        _exception = ex.Instance;
                    }
                    SendEvent(CreateStoppedEvent("exception", threadinfo, Debugger.ActiveException.Message));
                    break;

                case "TargetExited":
                    Terminate("target exited");
                    break;

                case "TargetThreadStarted":
                    tid = (int)threadinfo.Id;
                    lock (_seenThreads) {
                        _seenThreads[tid] = new Thread(tid, threadinfo.Name);
                    }
                    SendEvent(new ThreadEvent("started", tid));
                    break;

                case "TargetThreadStopped":
                    tid = (int)threadinfo.Id;
                    lock (_seenThreads) {
                        _seenThreads.Remove(tid);
                    }
                    SendEvent(new ThreadEvent("exited", tid));
                    break;

                case "Output":
                    SendOutput("stdout", text);
                    break;

                case "ErrorOutput":
                    SendOutput("stderr", text);
                    break;

                default:
                    SendEvent(new Event(type));
                    break;
                }
            };
        }
コード例 #32
0
		extern static IntPtr GetStdHandle (Handles handle);
コード例 #33
0
 public void when_a_ClaimDisbursedEvent_is_received()
 {
     var mongoServer = MongoServer.Create("mongodb://localhost/wf1_read_model?safe=true");
     var mongoDb = mongoServer.GetDatabase("wf1_read_model", SafeMode.True);
     _eventHandler = new ClaimDisbursedEventHandler(mongoDb);
 }
コード例 #34
0
ファイル: Utilities.cs プロジェクト: ChrisMoreton/Test3
		internal static void drawRotationHandle(
			Graphics g, Color rgb, Color rgbDis,
			RectangleF rc, float rotationAngle,
			Handles mask, bool showDsbl, float size)
		{
			bool draw = true;
			System.Drawing.Pen pen = new System.Drawing.Pen(Color.Black, 0);
			System.Drawing.Brush enbBrush = new System.Drawing.SolidBrush(rgb);
			System.Drawing.Brush dsbBrush = new System.Drawing.SolidBrush(rgbDis);
			System.Drawing.Brush brush;

			// determine whether this handle should be drawn
			if ((mask & Handles.Rotate) != 0)
			{
				brush = enbBrush;
			}
			else
			{
				brush = dsbBrush;
				draw = false;
			}
			if (draw)
			{
				PointF center = getCenter(rc);
				PointF[] rotPoints = new PointF[] {
					new PointF(center.X, rc.Top - 6 * Constants.getMillimeter(g.PageUnit)),
					new PointF(center.X, rc.Top) };

				// apply rotation
				if (rotationAngle != 0)
				{
					Matrix rotation = new Matrix();
					rotation.RotateAt(rotationAngle, center);
					rotation.TransformPoints(rotPoints);
					rotation.Dispose();
				}

				PointF point = rotPoints[0];
				g.FillEllipse(brush,
					point.X - 2.8F*size/4, point.Y - 2.8F*size/4, 2.8F*size/2, 2.8F*size/2);
				g.DrawEllipse(pen,
					point.X - 2.8F*size/4, point.Y - 2.8F*size/4, 2.8F*size/2, 2.8F*size/2);

				System.Drawing.Pen rotMarker =
					new System.Drawing.Pen(brush, 0);
				rotMarker.DashStyle = DashStyle.Dot;
				g.DrawLine(rotMarker, point, rotPoints[1]);
				rotMarker.Dispose();
			}

			pen.Dispose();
			enbBrush.Dispose();
			dsbBrush.Dispose();
		}
コード例 #35
0
		static IntPtr GetStdHandle (Handles handle)
		{
			throw new System.NotImplementedException();
		}
コード例 #36
0
ファイル: Node.cs プロジェクト: ChrisMoreton/Test3
		internal override void restoreProperties(ItemProperties props)
		{
			NodeProperties nprops = (NodeProperties)props;
			anchorPattern = nprops.anchorPattern;
			expanded = nprops.expanded;
			expandable = nprops.expandable;
			obstacle = nprops.obstacle;
			Constraints = nprops.contraints == null ?
				null : (NodeConstraints)nprops.contraints.Clone();
			enabledHandles = nprops.enabledHandles;
			boolValues = nprops.boolValues;

			base.restoreProperties(props);
		}
コード例 #37
0
ファイル: Utilities.cs プロジェクト: ChrisMoreton/Test3
		internal static void drawSquareHandles(Graphics g,
			Handles mask, Color rgb, Color rgbDis, bool showDsbl,
			RectangleF rc, float rotationAngle, HandlesStyle st, float size)
		{
			PointF center = getCenter(rc);

			// select pen and brush for drawing the selection handles
			System.Drawing.Pen pen = new System.Drawing.Pen(Color.Black, 0);
			System.Drawing.Brush enbBrush = new System.Drawing.SolidBrush(rgb);
			System.Drawing.Brush dsbBrush = new System.Drawing.SolidBrush(rgbDis);
			System.Drawing.Brush brush;

			// calculate selection handles coordinates
			PointF[] handlePoints = new PointF[10];
			handlePoints[0] = new PointF(rc.Left, rc.Top);
			handlePoints[1] = new PointF(rc.Right, rc.Top);
			handlePoints[2] = new PointF(rc.Right, rc.Bottom);
			handlePoints[3] = new PointF(rc.Left, rc.Bottom);
			handlePoints[4] = new PointF(center.X, rc.Top);
			handlePoints[5] = new PointF(rc.Right, center.Y);
			handlePoints[6] = new PointF(center.X, rc.Bottom);
			handlePoints[7] = new PointF(rc.Left, center.Y);
			handlePoints[8] = center;
			handlePoints[9] = new PointF(
				center.X, rc.Top - 6 * Constants.getMillimeter(g.PageUnit));

			// apply rotation
			if (rotationAngle != 0)
			{
				Matrix rotation = new Matrix();
				rotation.RotateAt(rotationAngle, center);
				rotation.TransformPoints(handlePoints);
				rotation.Dispose();
			}

			// draw the handles
			float hsize = size / 2;
			for (int h = 0; h <= 9; h++)
			{
				bool draw = true;

				// determine whether this handle should be drawn
				if (((long)mask & (1 << h)) != 0)
				{
					brush = enbBrush;
				}
				else
				{
					brush = dsbBrush;
					draw = showDsbl && h != 9;
				}

				if (draw) 
				{
					PointF point = handlePoints[h];

					// the side and corner handles
					if (h < 8)
					{
						g.FillRectangle(brush,
							point.X - hsize, point.Y - hsize, size, size);
						g.DrawRectangle(pen,
							point.X - hsize, point.Y - hsize, size, size);
					}
					// the center handle
					else if (h == 8)
					{
						if (st == HandlesStyle.EasyMove)
						{
							//g.FillEllipse(brush,
							//	point.X - size, point.Y - size, 2*size, 2*size);
							//g.DrawEllipse(pen,
							//	point.X - size, point.Y - size, 2*size, 2*size);
						}
						if (st == HandlesStyle.SquareHandles)
						{
							g.FillRectangle(brush,
								point.X - hsize, point.Y - hsize, size, size);
							g.DrawRectangle(pen,
								point.X - hsize, point.Y - hsize, size, size);
						}
					}
					// the rotation handle
					else if (h == 9)
					{
						g.FillEllipse(brush,
							point.X - 2.8F*size/4, point.Y - 2.8F*size/4, 2.8F*size/2, 2.8F*size/2);
						g.DrawEllipse(pen,
							point.X - 2.8F*size/4, point.Y - 2.8F*size/4, 2.8F*size/2, 2.8F*size/2);

						System.Drawing.Pen rotMarker =
							new System.Drawing.Pen(brush, 0);
						rotMarker.DashStyle = DashStyle.Dot;
						g.DrawLine(rotMarker, point, handlePoints[4]);
						rotMarker.Dispose();
					}
				}
			}

			//cleanup
			pen.Dispose();
			enbBrush.Dispose();
			dsbBrush.Dispose();
		}
コード例 #38
0
		public SDBDebugSession(Action<DebugEvent> callback) : base(true)
		{
			_callback = callback;
			_variableHandles = new Handles<ObjectValue[]>();
			_frameHandles = new Handles<Mono.Debugging.Client.StackFrame>();
			_seenThreads = new Dictionary<int, Thread>();

			Configuration.Current.MaxConnectionAttempts = 10;
			Configuration.Current.ConnectionAttemptInterval = 500;

			Debugger.Callback = (type, sourceLocation, threadinfo, text) => {
				int tid;
				switch (type) {
				case "TargetStopped":
					Stopped();
					callback.Invoke(CreateStoppedEvent("step", sourceLocation, threadinfo));
					break;

				case "TargetHitBreakpoint":
					Stopped();
					callback.Invoke(CreateStoppedEvent("breakpoint", sourceLocation, threadinfo));
					break;

				case "TargetExceptionThrown":
				case "TargetUnhandledException":
					Stopped();
					ExceptionInfo ex = Debugger.ActiveException;
					if (ex != null) {
						_exception = ex.Instance;
					}
					callback.Invoke(CreateStoppedEvent("exception", sourceLocation, threadinfo, Debugger.ActiveException.Message));
					break;

				case "TargetExited":
					Terminate("target exited");
					break;

				case "TargetThreadStarted":
					tid = (int)threadinfo.Id;
					lock (_seenThreads) {
						_seenThreads[tid] = new Thread(tid, threadinfo.Name);
					}
					callback.Invoke(new ThreadEvent("started", tid));
					break;

				case "TargetThreadStopped":
					tid = (int)threadinfo.Id;
					lock (_seenThreads) {
						_seenThreads.Remove(tid);
					}
					callback.Invoke(new ThreadEvent("exited", tid));
					break;

				case "Output":
					SendOutput(OutputEvent.Category.stdout, text);
					break;

				case "ErrorOutput":
					SendOutput(OutputEvent.Category.stderr, text);
					break;

				default:
					callback.Invoke(new DebugEvent(type));
					break;
				}
			};

			// the Soft Debugger is ready to accept breakpoints immediately (so it doesn't have to wait until the target is known)
			callback.Invoke(new InitializedEvent());
		}
コード例 #39
0
ファイル: Utilities.cs プロジェクト: ChrisMoreton/Test3
		internal static bool pointInHandle(PointF pt, ref int handle,
			RectangleF rc, float rotationAngle, Handles mask,
			float ht, HandlesStyle st, float handleSize, GraphicsUnit measureUnit)
		{
			if (rotationAngle != 0)
				pt = rotatePointAt(pt, getCenter(rc), -rotationAngle);

			if (st == HandlesStyle.MoveOnly || st == HandlesStyle.InvisibleMove)
			{
				handle = 8;
				return rc.Contains(pt) && (mask & Handles.Move) != 0;
			}

			if (st == HandlesStyle.SquareHandles || st == HandlesStyle.HatchHandles ||
				st == HandlesStyle.EasyMove)
			{
				PointF[] pts = new PointF[10];

				//the corner points
				pts[0].X = rc.X;
				pts[0].Y = rc.Y;
				pts[1].X = rc.Right;
				pts[1].Y = rc.Y;
				pts[2].X = rc.Right;
				pts[2].Y = rc.Bottom;
				pts[3].X = rc.X;
				pts[3].Y = rc.Bottom;

				//the side points
				pts[4].X = (pts[0].X + pts[1].X) / 2;
				pts[4].Y = pts[0].Y;
				pts[5].X = pts[1].X;
				pts[5].Y = (pts[1].Y + pts[2].Y) / 2;
				pts[6].X = pts[4].X;
				pts[6].Y = pts[2].Y;
				pts[7].X = pts[0].X;
				pts[7].Y = pts[5].Y;

				//the center point
				pts[8].X = pts[4].X;
				pts[8].Y = pts[5].Y;

				// the rotation handle
				pts[9].X = pts[4].X;
				pts[9].Y = pts[4].Y - 6*Constants.getMillimeter(measureUnit);

				//if (st == HandlesStyle.EasyMove && (Distance(pts[8], pt) < 1.5 * handleSize))
				//	return false;

				for (int i = 0; i < 10; ++i)
				{
					if (Math.Abs(pts[i].X - pt.X) <= (handleSize/2) &&
						Math.Abs(pts[i].Y - pt.Y) <= (handleSize/2) &&
						((long)mask & (1 << i)) != 0)
					{
						handle = i;
						return true;
					}
				}

				if (st == HandlesStyle.EasyMove && rc.Contains(pt) && (mask & Handles.Move) != 0)
				{
					handle = 8;
					return true;
				}

				rc.Inflate(handleSize / 2, handleSize / 2);
				if (st == HandlesStyle.HatchHandles && rc.Contains(pt) &&
					(mask & Handles.Move) != 0)
				{
					rc.Inflate(- handleSize, - handleSize);
					handle = 8;
					return !rc.Contains(pt);
				}
			}
			else
			{
				// check the corners
				PointF[] ptCorner = new PointF[4];
				ptCorner[0].X = rc.Left;
				ptCorner[0].Y = rc.Top;
				ptCorner[1].X = rc.Right;
				ptCorner[1].Y = rc.Top;
				ptCorner[2].X = rc.Right;
				ptCorner[2].Y = rc.Bottom;
				ptCorner[3].X = rc.Left;
				ptCorner[3].Y = rc.Bottom;
				for (int i = 0; i < 4; ++i)
				{
					if (Math.Abs(ptCorner[i].X - pt.X) <= (handleSize/2) &&
						Math.Abs(ptCorner[i].Y - pt.Y) <= (handleSize/2) &&
						((long)mask & (1 << i)) != 0)
					{
						handle = i;
						return true;
					}
				}

				//the side points
				rc.Inflate(Constants.getSelPtTest(measureUnit)*2, Constants.getSelPtTest(measureUnit)*2);
				if (Utilities.pointInRect(pt, rc))
				{
					float inflate = -Constants.getSelPtTest(measureUnit)*2;
					rc.Inflate(inflate, inflate);
					if (Math.Abs(rc.Top - pt.Y) <= (handleSize/2) &&
						(mask & Handles.ResizeTopCenter) != 0)
					{
						handle = 4;
						return true;
					}
					if (Math.Abs(rc.Right - pt.X) <= (handleSize/2) &&
						(mask & Handles.ResizeMiddleRight) != 0)
					{
						handle = 5;
						return true;
					}
					if (Math.Abs(rc.Bottom - pt.Y) <= (handleSize/2) &&
						(mask & Handles.ResizeBottomCenter) != 0)
					{
						handle = 6;
						return true;
					}
					if (Math.Abs(rc.Left - pt.X) <= (handleSize/2) &&
						(mask & Handles.ResizeMiddleLeft) != 0)
					{
						handle = 7;
						return true;
					}
				}

				// the rotation handle
				PointF rotHandle = new PointF(
					(ptCorner[0].X + ptCorner[1].X) / 2,
					ptCorner[0].Y - 6*Constants.getMillimeter(measureUnit));
				if (Math.Abs(rotHandle.X - pt.X) <= (handleSize/2) &&
					Math.Abs(rotHandle.Y - pt.Y) <= (handleSize/2) &&
					(mask & Handles.Rotate) != 0)
				{
					handle = 9;
					return true;
				}

				// check if the point is in the title area
				RectangleF rcCpt = rc;
				if (ht != 0)
					rcCpt.Height = ht;
				else
					rcCpt.Inflate(- handleSize * 2, - handleSize * 2);
				if (Utilities.pointInRect(pt, rcCpt) && (mask & Handles.Move) != 0)
				{
					handle = 8;
					return true;
				}
			}

			return false;
		}
コード例 #40
0
ファイル: Utilities.cs プロジェクト: ChrisMoreton/Test3
		internal static void drawSelHandles(
			Graphics g, Color rgb, Color rgbDis,
			RectangleF rc, float rotationAngle,
			Handles mask, bool showDsbl, HandlesStyle st, float size)
		{
			// these styles must not be painted
			if (st == HandlesStyle.Invisible ||
				st == HandlesStyle.InvisibleMove)
				return;

			// draw square selection handles for these styles
			if (st == HandlesStyle.SquareHandles ||
				st == HandlesStyle.SquareHandles2 ||
				st == HandlesStyle.EasyMove)
			{
				drawSquareHandles(g, mask, rgb, rgbDis, showDsbl,
					rc, rotationAngle, st, size);

				return;
			}

			PointF center = getCenter(rc);

			if (st == HandlesStyle.DashFrame)
			{
				try
				{
					// drawing with a dashed pen sometimes throws a generic exception
					// in GDIPLUS.DLL, so catch everything or everyone will blame us;
					System.Drawing.Pen pen = new System.Drawing.Pen(rgb, 0);
					pen.DashStyle = DashStyle.Dash;

					if (rotationAngle == 0)
					{
						g.DrawRectangle(pen, rc.X, rc.Y, rc.Width, rc.Height);
					}
					else
					{
						GraphicsPath path = rotateRectAt(rc, center, rotationAngle);
						g.DrawPath(pen, path);
						path.Dispose();
					}

					pen.Dispose();

					drawRotationHandle(g, rgb, rgbDis,
						rc, rotationAngle, mask, showDsbl, size);
				}
				catch (Exception)
				{
					// sometimes the exception says 'out of memory'
					GC.Collect();
				}

				return;
			}

			if (st == HandlesStyle.HatchFrame)
			{
				rc.Inflate(size / 2, size / 2);

				System.Drawing.Drawing2D.HatchBrush hatchBrush =
					new System.Drawing.Drawing2D.HatchBrush(
					HatchStyle.BackwardDiagonal, Color.Black, Color.White);

				RectangleF[] rects = new RectangleF[] {
					new RectangleF(rc.Left + size, rc.Top, rc.Width - 2 * size, size),
					new RectangleF(rc.Left + size, rc.Bottom - size, rc.Width - 2 * size, size),
					new RectangleF(rc.Left, rc.Top, size, rc.Height),
					new RectangleF(rc.Right - size, rc.Top, size, rc.Height) };

				if (rotationAngle == 0)
				{
					for (int i = 0; i < 4; ++i)
						g.FillRectangle(hatchBrush, rects[i]);
				}
				else
				{
					for (int i = 0; i < 4; ++i)
					{
						GraphicsPath path = rotateRectAt(
							rects[i], center, rotationAngle);
						g.FillPath(hatchBrush, path);
						path.Dispose();
					}
				}

				hatchBrush.Dispose();

				drawRotationHandle(g, rgb, rgbDis,
					rc, rotationAngle, mask, showDsbl, size);

				return;
			}

			if (st == HandlesStyle.HatchHandles || st == HandlesStyle.HatchHandles2 ||
				st == HandlesStyle.HatchHandles3 || st == HandlesStyle.MoveOnly)
			{
				RectangleF rch = rc;
				rch.Inflate(size / 4, size / 4);

				System.Drawing.Drawing2D.HatchBrush hatchBrush = null;

				if (st == HandlesStyle.HatchHandles3 || st == HandlesStyle.MoveOnly)
					hatchBrush = new System.Drawing.Drawing2D.HatchBrush(
						HatchStyle.Percent50, Color.Black, Color.FromArgb(50, Color.Black));
				else
					hatchBrush = new System.Drawing.Drawing2D.HatchBrush(
						HatchStyle.BackwardDiagonal, Color.Black, Color.White);

				RectangleF[] rects = new RectangleF[] {
					new RectangleF(rch.Left + size*2/4, rch.Top, rch.Width - size, size*2/4),
					new RectangleF(rch.Left + size*2/4, rch.Bottom - size*2/4, rch.Width - size, size*2/4),
					new RectangleF(rch.Left, rch.Top, size*2/4, rch.Height),
					new RectangleF(rch.Right - size*2/4, rch.Top, size*2/4, rch.Height) };

				if (rotationAngle == 0)
				{
					for (int i = 0; i < 4; ++i)
						g.FillRectangle(hatchBrush, rects[i]);
				}
				else
				{
					for (int i = 0; i < 4; ++i)
					{
						GraphicsPath path = rotateRectAt(
							rects[i], center, rotationAngle);
						g.FillPath(hatchBrush, path);
						path.Dispose();
					}
				}

				hatchBrush.Dispose();

				if (st == HandlesStyle.MoveOnly)
					return;

				drawSquareHandles(g, mask, rgb, rgbDis, showDsbl,
					rc, rotationAngle, st, size);

				return;
			}
		}