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


C# Rect.Contains方法代码示例

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


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

示例1: ContainsPointTest2

        public void ContainsPointTest2()
        {
            Action test = () => {
                var rect = new Rect (0, 0, TestHelper.NextDouble(double.MaxValue), TestHelper.NextDouble(double.MaxValue));
                var point = new Point (TestHelper.NextDouble(double.MaxValue), TestHelper.NextDouble(double.MaxValue));
                if(rect.Contains(point)){
                    Assert.True(point.X >= rect.Left);
                    Assert.True(point.X <= rect.Right);
                    Assert.True(point.Y >= rect.Top);
                    Assert.True(point.Y <= rect.Bottom);
                }
            };

            test.RunBatch (batchCount);
        }
开发者ID:magerate,项目名称:Geometries,代码行数:15,代码来源:RectTests.cs

示例2: InflateTest2

        public void InflateTest2()
        {
            Action test = () => {
                double x = TestHelper.NextDouble(double.MinValue + 100);
                double y = TestHelper.NextDouble(double.MinValue + 100);
                double width = TestHelper.NextDouble(double.MaxValue - 100);
                double height = TestHelper.NextDouble(double.MaxValue - 100);

                var rect = new Rect(x,y,width,height);

                double fWidth = TestHelper.NextDouble(100);
                double fHeight = TestHelper.NextDouble(100);

                rect.Inflate (fWidth, fHeight);

                Assert.AreEqual (x, rect.X + fWidth);
                Assert.AreEqual (y, rect.Y + fHeight);
                Assert.AreEqual (width, rect.Width - 2 * fWidth);
                Assert.AreEqual (height, rect.Height - 2 * fHeight);

                Assert.True(rect.Contains(new Rect(x,y,width,height)));
            };
            test.RunBatch (batchCount);
        }
开发者ID:magerate,项目名称:Geometries,代码行数:24,代码来源:RectTests.cs

示例3: drawVariablePhaseBase

    // VARIABLE BASE
    private Rect drawVariablePhaseBase(DialogueEditorPhaseObject phase, int height)
    {
        int width = 300;
        Rect baseRect = drawPhaseBase(phase, width, height);

        DialogueEditorVariablesContainer variables;

        if(phase.variableScope == VariableEditorScopes.Global){
            if(phase.variableType == VariableEditorTypes.Float){
                variables = DialogueEditorDataManager.data.globals.floats;
            }else if(phase.variableType == VariableEditorTypes.String){
                variables = DialogueEditorDataManager.data.globals.strings;
            } else{
                variables = DialogueEditorDataManager.data.globals.booleans;
            }
        }else{
            if(phase.variableType == VariableEditorTypes.Float){
                variables = DialogueEditorDataManager.data.dialogues[DialogueEditorDataManager.data.currentDialogueId].floats;
            }else if(phase.variableType == VariableEditorTypes.String){
                variables = DialogueEditorDataManager.data.dialogues[DialogueEditorDataManager.data.currentDialogueId].strings;
            } else{
                variables = DialogueEditorDataManager.data.dialogues[DialogueEditorDataManager.data.currentDialogueId].booleans;
            }
        }

        Rect topRowRect = new Rect(baseRect.x + 5,baseRect.yMax,width - 10, 25);
        if(GUI.Toggle(new Rect(topRowRect.x,topRowRect.y,(width - 10)*0.5f, 25), (phase.variableScope == VariableEditorScopes.Global), "Global", DialogueEditorGUI.gui.GetStyle("toolbar_left"))){
            phase.variableScope = VariableEditorScopes.Global;
            if(phase.variableId >= variables.variables.Count) phase.variableId = 0;
        }
        if(GUI.Toggle(new Rect(topRowRect.x + (topRowRect.width*0.5f),topRowRect.y,(width - 10)*0.5f, 25), (phase.variableScope == VariableEditorScopes.Local), "Local", DialogueEditorGUI.gui.GetStyle("toolbar_right"))){
            phase.variableScope = VariableEditorScopes.Local;
            if(phase.variableId >= variables.variables.Count) phase.variableId = 0;
        }

        Rect typesRect = new Rect(topRowRect.x, topRowRect.yMax + 5, width - 10, 25);
        Rect typeBooleanToggleRect = new Rect(typesRect.x, typesRect.y, typesRect.width * 0.33333f, typesRect.height);
        Rect typeFloatToggleRect = new Rect(typesRect.x + (typesRect.width * 0.33333f), typesRect.y, typesRect.width * 0.33333f, typesRect.height);
        Rect typeStringToggleRect = new Rect(typesRect.x + ((typesRect.width * 0.33333f)*2), typesRect.y, typesRect.width * 0.33333f, typesRect.height);

        if(GUI.Toggle(typeBooleanToggleRect, (phase.variableType == VariableEditorTypes.Boolean), "Booleans", DialogueEditorGUI.gui.GetStyle("toolbar_left"))){
            phase.variableType = VariableEditorTypes.Boolean;
            if(phase.variableId >= variables.variables.Count) phase.variableId = 0;
        }
        if(GUI.Toggle(typeFloatToggleRect, (phase.variableType == VariableEditorTypes.Float), "Floats", DialogueEditorGUI.gui.GetStyle("toolbar_center"))){
            phase.variableType = VariableEditorTypes.Float;
            if(phase.variableId >= variables.variables.Count) phase.variableId = 0;
        }
        if(GUI.Toggle(typeStringToggleRect, (phase.variableType == VariableEditorTypes.String), "Strings", DialogueEditorGUI.gui.GetStyle("toolbar_right"))){
            phase.variableType = VariableEditorTypes.String;
            if(phase.variableId >= variables.variables.Count) phase.variableId = 0;
        }

        // ------------------ SCROLL BOX
        // VISUALS
        Rect scrollRect = new Rect(typesRect.x + 2,typesRect.yMax + 7,width - 14, 100);
        if(isPro){
            GUI.color = GUI.contentColor;
            GUI.Box(new Rect(scrollRect.x - 2, scrollRect.y - 2, scrollRect.width + 4, scrollRect.height + 4), string.Empty);
            GUI.color = Color.black;
            GUI.Box(new Rect(scrollRect.x - 1, scrollRect.y - 1, scrollRect.width +2, scrollRect.height + 2), string.Empty);
            GUI.Box(new Rect(scrollRect.x - 1, scrollRect.y - 1, scrollRect.width +2, scrollRect.height + 2), string.Empty);
            GUI.Box(new Rect(scrollRect.x - 1, scrollRect.y - 1, scrollRect.width +2, scrollRect.height + 2), string.Empty);
            GUI.Box(new Rect(scrollRect.x - 1, scrollRect.y - 1, scrollRect.width +2, scrollRect.height + 2), string.Empty);
            GUI.color = GUI.contentColor;
        }else{
            GUI.Box(DialogueEditorGUI.getOutlineRect(scrollRect, 1), string.Empty, DialogueEditorGUI.gui.GetStyle("box_inset"));
        }
        // MOUSE HANDLING
        int rowHeight = 20;
        int rowSpacing = (EditorGUIUtility.isProSkin) ? 1 : -1;
        int newScrollHeight = (scrollRect.height > ((rowHeight + rowSpacing)*variables.variables.Count)) ? (int)scrollRect.height : (rowHeight + rowSpacing)*variables.variables.Count;
        Rect scrollContentRect = new Rect(0, 0, scrollRect.width - 15, newScrollHeight);
        Vector2 mouseClickPosition = Vector2.zero;
        if(Event.current.type == EventType.MouseDown && Event.current.button == 0 && scrollRect.Contains(Event.current.mousePosition)){
            mouseClickPosition = new Vector2(Event.current.mousePosition.x - scrollRect.x - 3, Event.current.mousePosition.y - scrollRect.y - 3 + phase.variableScrollPosition.y);
        }
        //START SCROLL VIEW
        phase.variableScrollPosition = GUI.BeginScrollView(scrollRect, phase.variableScrollPosition, scrollContentRect, false, true);

        GUI.color = (isPro)? new Color(1,1,1,0.25f) : new Color(1,1,1,0.1f);
        GUI.DrawTextureWithTexCoords(
            scrollContentRect,
            DialogueEditorGUI.scrollboxBgTexture,
            new Rect(0, 0, scrollContentRect.width / DialogueEditorGUI.scrollboxBgTexture.width, scrollContentRect.height / DialogueEditorGUI.scrollboxBgTexture.height)
        );
        GUI.color = GUI.contentColor;

        for(int i = 0; i<variables.variables.Count; i+=1){
            Rect row = new Rect(0,0+((rowHeight + rowSpacing)*i),scrollRect.width - 15,20);
            if(mouseClickPosition != Vector2.zero && row.Contains(mouseClickPosition)){
                phase.variableId = i;
            }
            GUI.color = new Color(1,1,1,0.5f);
            GUI.Box(row, string.Empty);
            if(i == phase.variableId){
                if(isPro){
                    GUI.color = GUI.contentColor;
                    GUI.Box(row, string.Empty);
//.........这里部分代码省略.........
开发者ID:Avatarchik,项目名称:school_simulation,代码行数:101,代码来源:DialogueEditorWindow.cs

示例4: OnGUI

            public void OnGUI(Rect position)
            {
                Event current = Event.current;
                Vector2 mousePosition = current.mousePosition;
                int controlID = s_RectSelectionID;
                switch (current.GetTypeForControl(controlID))
                {
                    case EventType.MouseDown:
                        if ((current.button == 0) && position.Contains(mousePosition))
                        {
                            GUIUtility.hotControl = controlID;
                            this.m_SelectStartPoint = mousePosition;
                            this.m_ValidRect = false;
                            current.Use();
                        }
                        return;

                    case EventType.MouseUp:
                    {
                        if ((GUIUtility.hotControl != controlID) || (current.button != 0))
                        {
                            return;
                        }
                        if (!this.m_ValidRect)
                        {
                            this.owner.state.ClearSelections();
                            break;
                        }
                        if (!EditorGUI.actionKey)
                        {
                            this.owner.state.ClearSelections();
                        }
                        float frameRate = this.owner.state.frameRate;
                        Rect currentTimeRect = this.GetCurrentTimeRect();
                        AnimationKeyTime time = AnimationKeyTime.Time(currentTimeRect.xMin, frameRate);
                        AnimationKeyTime time2 = AnimationKeyTime.Time(currentTimeRect.xMax, frameRate);
                        GUI.changed = true;
                        this.owner.state.ClearHierarchySelection();
                        List<AnimationWindowKeyframe> list = new List<AnimationWindowKeyframe>();
                        List<AnimationWindowKeyframe> list2 = new List<AnimationWindowKeyframe>();
                        foreach (DopeLine line in this.owner.state.dopelines)
                        {
                            if ((line.position.yMin >= currentTimeRect.yMin) && (line.position.yMax <= currentTimeRect.yMax))
                            {
                                foreach (AnimationWindowKeyframe keyframe in line.keys)
                                {
                                    AnimationKeyTime time3 = AnimationKeyTime.Time(keyframe.time, frameRate);
                                    if ((((!line.tallMode && (time3.frame >= time.frame)) && (time3.frame <= time2.frame)) || ((line.tallMode && (time3.frame >= time.frame)) && (time3.frame < time2.frame))) && (!list2.Contains(keyframe) && !list.Contains(keyframe)))
                                    {
                                        if (!this.owner.state.KeyIsSelected(keyframe))
                                        {
                                            list2.Add(keyframe);
                                        }
                                        else if (this.owner.state.KeyIsSelected(keyframe))
                                        {
                                            list.Add(keyframe);
                                        }
                                    }
                                }
                            }
                        }
                        if (list2.Count == 0)
                        {
                            foreach (AnimationWindowKeyframe keyframe2 in list)
                            {
                                this.owner.state.UnselectKey(keyframe2);
                            }
                        }
                        foreach (AnimationWindowKeyframe keyframe3 in list2)
                        {
                            this.owner.state.SelectKey(keyframe3);
                        }
                        foreach (DopeLine line2 in this.owner.state.dopelines)
                        {
                            if (this.owner.state.AnyKeyIsSelected(line2))
                            {
                                this.owner.state.SelectHierarchyItem(line2, true, false);
                            }
                        }
                        break;
                    }
                    case EventType.MouseMove:
                    case EventType.KeyDown:
                    case EventType.KeyUp:
                    case EventType.ScrollWheel:
                        return;

                    case EventType.MouseDrag:
                        if (GUIUtility.hotControl == controlID)
                        {
                            Vector2 vector2 = mousePosition - this.m_SelectStartPoint;
                            this.m_ValidRect = Mathf.Abs(vector2.x) > 1f;
                            if (this.m_ValidRect)
                            {
                                this.m_SelectMousePoint = new Vector2(mousePosition.x, mousePosition.y);
                            }
                            current.Use();
                        }
                        return;

//.........这里部分代码省略.........
开发者ID:demelev,项目名称:projectHL,代码行数:101,代码来源:DopeSheetEditor.cs

示例5: DrawGuiPost

    void DrawGuiPost(int id)
    {
        Vector2 mousePos = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);

        // その3>>84 より
        {
            bool enableGameGui = true;
            bool m = Input.GetAxis("Mouse ScrollWheel") != 0;
            for (int i = 0; i < 3; i++)
            {
                m |= Input.GetMouseButtonDown(i);
            }
            if (m)
            {
                enableGameGui = !WindowRect.Contains(mousePos);
            }
            GameMain.Instance.MainCamera.SetControl(enableGameGui);
            UICamera.InputEnable = enableGameGui;
        }

        // 右下をつかんでリサイズ
        // http://forum.unity3d.com/threads/is-there-a-resize-equivalent-to-gui-dragwindow.10144/#post-72530
        if (!Input.GetMouseButton(0))
        {
            handleClicked = false;
        }
        else if (handleClicked)
        {
            WindowRect.width = Mathf.Clamp(originalWindow.width + (mousePos.x - clickedPosition.x), MinWidth, MaxWidth);
            WindowRect.height = Mathf.Clamp(originalWindow.height + (mousePos.y - clickedPosition.y), MinHeight, MaxHeight);
        }
        else if (Input.GetMouseButtonDown(0))
        {
            Rect windowHandle = new Rect(
                WindowRect.x + WindowRect.width - HandleSize,
                WindowRect.y + WindowRect.height - HandleSize,
                HandleSize, HandleSize);
            if (windowHandle.Contains(mousePos))
            {
                handleClicked = true;
                clickedPosition = mousePos;
                originalWindow = WindowRect;
            }
        }
    }
开发者ID:nnnna,项目名称:cm3d2_plugins_okiba,代码行数:45,代码来源:LogWindowPlugin.cs

示例6: OnGUI

    void OnGUI()
    {
        bool isPro = EditorGUIUtility.isProSkin;

        DialogueEditorGUI.drawBackground();

        DialogueEditorVariablesContainer variables = getVariables();

        Rect titleRect = new Rect(5,5,Screen.width-10, 22);
        if(isPro){
            DialogueEditorGUI.drawShadowedRect(titleRect,2);
        }else{
            GUI.Box(titleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset"));
            GUI.Box(titleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset"));
            GUI.Box(titleRect, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset"));
        }

        int globalFloatsCount = DialogueEditorDataManager.data.globals.floats.variables.Count;
        int globalBooleansCount = DialogueEditorDataManager.data.globals.booleans.variables.Count;
        int globalStringsCount = DialogueEditorDataManager.data.globals.strings.variables.Count;

        int localFloatsCount = DialogueEditorDataManager.data.dialogues[DialogueEditorDataManager.data.currentDialogueId].floats.variables.Count;
        int localBooleansCount = DialogueEditorDataManager.data.dialogues[DialogueEditorDataManager.data.currentDialogueId].booleans.variables.Count;
        int localStringsCount = DialogueEditorDataManager.data.dialogues[DialogueEditorDataManager.data.currentDialogueId].strings.variables.Count;

        int globalVarsCount = globalFloatsCount + globalBooleansCount + globalStringsCount;
        int localVarsCount = localFloatsCount + localBooleansCount + localStringsCount;

        int currentFloatsCount = (__scope == VariableEditorScopes.Local)? localFloatsCount : globalFloatsCount;
        int currentBooleansCount = (__scope == VariableEditorScopes.Local)? localBooleansCount : globalBooleansCount;
        int currentStringsCount = (__scope == VariableEditorScopes.Local)? localStringsCount : globalStringsCount;

        string titleText = "Variable Editor: "+__scope.ToString()+" "+__type.ToString();
        GUI.Label(new Rect(titleRect.x + 5, titleRect.y + 3, Screen.width, 20), titleText, EditorStyles.boldLabel);

        if(GUI.Toggle(new Rect(5,30,(Screen.width - 10)*0.5f, 25), (__scope == VariableEditorScopes.Global), "Globals ("+globalVarsCount+")", DialogueEditorGUI.gui.GetStyle("toolbar_left"))) setTarget(VariableEditorScopes.Global, __type);
        if(GUI.Toggle(new Rect((Screen.width - 20)*0.5f + 10,30,(Screen.width - 10)*0.5f, 25), (__scope == VariableEditorScopes.Local), "Locals ("+localVarsCount+")", DialogueEditorGUI.gui.GetStyle("toolbar_right"))) setTarget(VariableEditorScopes.Local, __type);

        Rect typesRect = new Rect(5, 60, Screen.width - 10, 25);
        Rect typeBooleanToggleRect = new Rect(typesRect.x, typesRect.y, typesRect.width * 0.33333f, typesRect.height);
        Rect typeFloatToggleRect = new Rect(typesRect.x + (typesRect.width * 0.33333f), typesRect.y, typesRect.width * 0.33333f, typesRect.height);
        Rect typeStringToggleRect = new Rect(typesRect.x + ((typesRect.width * 0.33333f)*2), typesRect.y, typesRect.width * 0.33333f, typesRect.height);
        if(GUI.Toggle(typeBooleanToggleRect, (__type == VariableEditorTypes.Boolean), "Booleans ("+currentBooleansCount+")", DialogueEditorGUI.gui.GetStyle("toolbar_left"))) setTarget(__scope, VariableEditorTypes.Boolean);
        if(GUI.Toggle(typeFloatToggleRect, (__type == VariableEditorTypes.Float), "Floats ("+currentFloatsCount+")", DialogueEditorGUI.gui.GetStyle("toolbar_center"))) setTarget(__scope, VariableEditorTypes.Float);
        if(GUI.Toggle(typeStringToggleRect, (__type == VariableEditorTypes.String), "Strings ("+currentStringsCount+")", DialogueEditorGUI.gui.GetStyle("toolbar_right"))) setTarget(__scope, VariableEditorTypes.String);

        // Editor Box
        Rect editorRect = new Rect(5, typeBooleanToggleRect.y + typeBooleanToggleRect.height + 5, Screen.width - 10, 130);
        drawEditorGui(editorRect);

        // ------------------ SCROLL BOX
        // VISUALS
        Rect scrollRect = new Rect(8,editorRect.y + editorRect.height + 8,Screen.width - 16, Screen.height - (editorRect.y + editorRect.height + 70));
        if(isPro){
            GUI.color = GUI.contentColor;
            GUI.Box(new Rect(scrollRect.x - 2, scrollRect.y - 2, scrollRect.width + 4, scrollRect.height + 4), string.Empty);
            GUI.color = Color.black;
            GUI.Box(new Rect(scrollRect.x - 1, scrollRect.y - 1, scrollRect.width +2, scrollRect.height + 2), string.Empty);
            GUI.Box(new Rect(scrollRect.x - 1, scrollRect.y - 1, scrollRect.width +2, scrollRect.height + 2), string.Empty);
            GUI.Box(new Rect(scrollRect.x - 1, scrollRect.y - 1, scrollRect.width +2, scrollRect.height + 2), string.Empty);
            GUI.Box(new Rect(scrollRect.x - 1, scrollRect.y - 1, scrollRect.width +2, scrollRect.height + 2), string.Empty);
            GUI.color = GUI.contentColor;
        }else{
            GUI.Box(DialogueEditorGUI.getOutlineRect(scrollRect, 1), string.Empty, DialogueEditorGUI.gui.GetStyle("box_inset"));
        }
        // MOUSE HANDLING
        int rowHeight = 20;
        int rowSpacing = (EditorGUIUtility.isProSkin) ? 1 : -1;
        int newScrollHeight = (scrollRect.height > ((rowHeight + rowSpacing)*variables.variables.Count)) ? (int)scrollRect.height : (rowHeight + rowSpacing)*variables.variables.Count;
        Rect scrollContentRect = new Rect(0, 0, scrollRect.width - 15, newScrollHeight);
        Vector2 mouseClickPosition = Vector2.zero;
        if(Event.current.type == EventType.MouseDown && Event.current.button == 0 && scrollRect.Contains(Event.current.mousePosition)){
            mouseClickPosition = new Vector2(Event.current.mousePosition.x - scrollRect.x - 3, Event.current.mousePosition.y - scrollRect.y - 3 + __scrollPosition.y);
        }
        //START SCROLL VIEW
        __scrollPosition = GUI.BeginScrollView(scrollRect, __scrollPosition, scrollContentRect, false, true);

        GUI.color = (isPro) ? new Color(1,1,1,0.25f) : new Color(1,1,1,0.1f);
        GUI.DrawTextureWithTexCoords(
            scrollContentRect,
            DialogueEditorGUI.scrollboxBgTexture,
            new Rect(0, 0, scrollContentRect.width / DialogueEditorGUI.scrollboxBgTexture.width, scrollContentRect.height / DialogueEditorGUI.scrollboxBgTexture.height)
        );
        GUI.color = GUI.contentColor;

        for(int i = 0; i<variables.variables.Count; i+=1){
            Rect row = new Rect(0,0+((rowHeight + rowSpacing)*i),scrollRect.width - 15,20);
            if(mouseClickPosition != Vector2.zero && row.Contains(mouseClickPosition)){
                variables.selection = i;
            }
            GUI.color = new Color(1,1,1,0.5f);
            GUI.Box(row, string.Empty);
            if(i == variables.selection){
                if(isPro){
                    GUI.color = GUI.contentColor;
                    GUI.Box(row, string.Empty);
                    GUI.Box(row, string.Empty);
                }else{
                    GUI.Box(row, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset"));
                    GUI.Box(row, string.Empty, DialogueEditorGUI.gui.GetStyle("box_outset"));
//.........这里部分代码省略.........
开发者ID:Avatarchik,项目名称:school_simulation,代码行数:101,代码来源:VariableEditorWindow.cs

示例7: GetACPFromPoint

        public void GetACPFromPoint(int viewCookie, ref UnsafeNativeMethods.POINT tsfPoint, UnsafeNativeMethods.GetPositionFromPointFlags flags, out int positionCP)
        {
            SecurityHelper.DemandUnmanagedCode();

            PresentationSource source;
            IWin32Window win32Window;
            CompositionTarget compositionTarget;
            ITextView view;
            Point milPoint;
            ITextPointer position;
            NativeMethods.POINT point;

            point = new NativeMethods.POINT(tsfPoint.x, tsfPoint.y);
            GetVisualInfo(out source, out win32Window, out view);
            compositionTarget = source.CompositionTarget;

            // Convert to client coordinates.
            SafeNativeMethods.ScreenToClient(new HandleRef(null,win32Window.Handle), point);

            // Convert to mil measure units.
            milPoint = new Point(point.x, point.y);
            milPoint = compositionTarget.TransformFromDevice.Transform(milPoint);

            // Convert to local coordinates.
            GeneralTransform transform = compositionTarget.RootVisual.TransformToDescendant(RenderScope);
            if (transform != null)
            {
                // 
                transform.TryTransform(milPoint, out milPoint);
            }

            // Validate layout information on TextView
            if (!view.Validate(milPoint))
            {
                throw new COMException(SR.Get(SRID.TextStore_TS_E_NOLAYOUT), UnsafeNativeMethods.TS_E_NOLAYOUT);
            }

            // Do the hittest.
            position = view.GetTextPositionFromPoint(milPoint, (flags & UnsafeNativeMethods.GetPositionFromPointFlags.GXFPF_NEAREST) != 0 /* snapToText */);
            if (position == null)
            {
                // GXFPF_ROUND_NEAREST was clear and we didn't hit a char.
                throw new COMException(SR.Get(SRID.TextStore_TS_E_INVALIDPOINT), UnsafeNativeMethods.TS_E_INVALIDPOINT);
            }

            positionCP = position.CharOffset;
            if ((flags & UnsafeNativeMethods.GetPositionFromPointFlags.GXFPF_ROUND_NEAREST) == 0)
            {
                // Check if the point is on the backward position of the TextPosition.
                Rect rectCur;
                Rect rectPrev;
                Point milPointTopLeft;
                Point milPointBottomRight;

                ITextPointer positionCur = position.CreatePointer(LogicalDirection.Backward);
                ITextPointer positionPrev = position.CreatePointer(LogicalDirection.Forward);
                positionPrev.MoveToNextInsertionPosition(LogicalDirection.Backward);

                rectCur = view.GetRectangleFromTextPosition(positionCur);
                rectPrev = view.GetRectangleFromTextPosition(positionPrev);

                // Take the "extended" union of the previous char's bounding box.
                milPointTopLeft = new Point(Math.Min(rectPrev.Left, rectCur.Left), Math.Min(rectPrev.Top, rectCur.Top));
                milPointBottomRight = new Point(Math.Max(rectPrev.Left, rectCur.Left), Math.Max(rectPrev.Bottom, rectCur.Bottom));

                // The rect of the previous char.
                Rect rectTest = new Rect(milPointTopLeft, milPointBottomRight);
                if (rectTest.Contains(milPoint))
                    positionCP--;
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:71,代码来源:TextStore.cs

示例8: DrawDropZone

    void DrawDropZone()
    {
        GUILayout.BeginVertical(tk2dEditorSkin.SC_ListBoxBG, GUILayout.Width(leftBarWidth), GUILayout.ExpandHeight(true));
        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (DragAndDrop.objectReferences.Length == 0 && !SpriteCollection.Empty)
            GUILayout.Label("Drop sprite here", tk2dEditorSkin.SC_DropBox);
        else
            GUILayout.Label("Drop sprites here", tk2dEditorSkin.SC_DropBox);
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();

        Rect rect = new Rect(0, 0, leftBarWidth, Screen.height);
        if (rect.Contains(Event.current.mousePosition))
        {
            switch (Event.current.type)
            {
            case EventType.DragUpdated:
                if (IsValidDragPayload())
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                else
                    DragAndDrop.visualMode = DragAndDropVisualMode.None;
                break;

            case EventType.DragPerform:
                var droppedObjectsList = new List<Object>();
                for (int i = 0; i < DragAndDrop.objectReferences.Length; ++i)
                {
                    var type = DragAndDrop.objectReferences[i].GetType();
                    if (type == typeof(Texture2D))
                        droppedObjectsList.Add(DragAndDrop.objectReferences[i]);
                    else if (type == typeof(Object) && System.IO.Directory.Exists(DragAndDrop.paths[i]))
                        droppedObjectsList.AddRange(AddTexturesInPath(DragAndDrop.paths[i]));
                }
                deferredDroppedObjects = droppedObjectsList.ToArray();
                Repaint();
                break;
            }
        }
    }
开发者ID:Gahzi,项目名称:BrutalArena,代码行数:43,代码来源:tk2dSpriteCollectionEditorPopup.cs

示例9: drawOutputConnector

    private void drawOutputConnector(DialogueEditorPhaseObject phase, Vector2 position, int outputIndex)
    {
        Rect outputButtonRect = new Rect(position.x, position.y, 16, 16);
        string outputButtonType = (phase.outs[outputIndex] != null) ? "connector_full" : "connector_empty" ;
        if(Event.current.type == EventType.MouseDown && outputButtonRect.Contains(Event.current.mousePosition)){
            if (Event.current.button == 0){
                phase.outs[outputIndex] = null;
                __outputSelection = new DialogueEditorSelectionObject(phase.id, outputIndex	);
            }else if (Event.current.button == 1){
                phase.outs[outputIndex] = null;
                if(__outputSelection != null && __outputSelection.phaseId == phase.id && __outputSelection.outputIndex == outputIndex){
                    __outputSelection = null;
                }
            }

        }
        GUI.Button(outputButtonRect, string.Empty, DialogueEditorGUI.gui.GetStyle(outputButtonType));
    }
开发者ID:Avatarchik,项目名称:school_simulation,代码行数:18,代码来源:DialogueEditorWindow.cs

示例10: DrawDropZone

    void DrawDropZone()
    {
        GUILayout.BeginVertical(tk2dEditorSkin.SC_ListBoxBG, GUILayout.Width(leftBarWidth), GUILayout.ExpandHeight(true));
        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (DragAndDrop.objectReferences.Length == 0 && !SpriteCollection.Empty)
            GUILayout.Label("Drop sprite here", tk2dEditorSkin.SC_DropBox);
        else
            GUILayout.Label("Drop sprites here", tk2dEditorSkin.SC_DropBox);
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();

        Rect rect = new Rect(0, 0, leftBarWidth, Screen.height);
        if (rect.Contains(Event.current.mousePosition))
        {
            switch (Event.current.type)
            {
            case EventType.DragUpdated:
                if (IsValidDragPayload())
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                else
                    DragAndDrop.visualMode = DragAndDropVisualMode.None;
                break;

            case EventType.DragPerform:
                deferredDroppedObjects = new Object[DragAndDrop.objectReferences.Length];
                for (int i = 0; i < DragAndDrop.objectReferences.Length; ++i)
                    deferredDroppedObjects[i] = DragAndDrop.objectReferences[i];
                Repaint();
                break;
            }
        }
    }
开发者ID:GennrichJ,项目名称:GalaxyWars,代码行数:36,代码来源:tk2dSpriteCollectionEditorPopup.cs

示例11: Containment

		[Test] public void Containment()
		{
			Rect rect = new Rect(-5, -10, 10, 20);

			// A rect should contain all the points on its edge
			Assert.IsTrue(rect.Contains(rect.TopLeft));
			Assert.IsTrue(rect.Contains(rect.TopRight));
			Assert.IsTrue(rect.Contains(rect.Center));
			Assert.IsTrue(rect.Contains(rect.BottomLeft));
			Assert.IsTrue(rect.Contains(rect.BottomRight));

			// Points it shouldn't contain
			Assert.IsFalse(rect.Contains(new Vector2(rect.LeftX - 1.0f, rect.CenterY)));
			Assert.IsFalse(rect.Contains(new Vector2(rect.RightX + 1.0f, rect.CenterY)));
			Assert.IsFalse(rect.Contains(new Vector2(rect.CenterX, rect.TopY - 1.0f)));
			Assert.IsFalse(rect.Contains(new Vector2(rect.CenterX, rect.BottomY + 1.0f)));

			// A rect should contain itself, but not any offset variant
			Assert.IsTrue(rect.Contains(rect));
			Assert.IsFalse(rect.Contains(rect.WithOffset(1, 0)));
			Assert.IsFalse(rect.Contains(rect.WithOffset(-1, 0)));
			Assert.IsFalse(rect.Contains(rect.WithOffset(0, 1)));
			Assert.IsFalse(rect.Contains(rect.WithOffset(0, -1)));

			// It can contain a smaller rect, but not a bigger one
			Assert.IsTrue(rect.Contains(1, 2, 3, 4));
			Assert.IsFalse(rect.Contains(-6, -11, 12, 22));
			Assert.IsFalse(rect.Contains(-1, -11, 2, 22));
			Assert.IsFalse(rect.Contains(-6, -1, 12, 2));
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:30,代码来源:RectTest.cs

示例12: HitTest

        public bool HitTest(Point point)
        {
            Vector absoluteOffset = Vector.Zero;
            IElement currentElement = this;

            while (currentElement != null)
            {
                absoluteOffset += currentElement.VisualOffset;
                currentElement = currentElement.VisualParent;
            }

            var hitTestRect = new Rect(absoluteOffset.X, absoluteOffset.Y, this.ActualWidth, this.ActualHeight);
            return hitTestRect.Contains(point);
        }
开发者ID:redbadger,项目名称:XPF,代码行数:14,代码来源:UIElement.cs

示例13: Intersects

		public static bool Intersects(Point p1, Point p2, Rect r)
		{
			return Intersects(p1, p2, new Point(r.X, r.Y), new Point(r.X + r.Width, r.Y)).HasValue ||
				   Intersects(p1, p2, new Point(r.X + r.Width, r.Y), new Point(r.X + r.Width, r.Y + r.Height)).HasValue ||
				   Intersects(p1, p2, new Point(r.X + r.Width, r.Y + r.Height), new Point(r.X, r.Y + r.Height)).HasValue ||
				   Intersects(p1, p2, new Point(r.X, r.Y + r.Height), new Point(r.X, r.Y)).HasValue ||
				   (r.Contains(p1) && r.Contains(p2));
		}
开发者ID:RareNCool,项目名称:MyToolkit,代码行数:8,代码来源:VectorMath.cs

示例14: DrawCharacter


//.........这里部分代码省略.........
                    rect.x += (Screen.width / 40 + Screen.width / 20);

                    if (GUI.Button(rect, Resources.Load<Texture2D>("Sprites/Cosmetics/HatIcon"), skin.GetStyle("Square")))
                    {
                        this.smoothAparition = 0;
                        typeCloth = (int)Hat.TypeHat.TopHat;
                    }
                    rect.x += (Screen.width / 40 + Screen.width / 20);

                    if (GUI.Button(rect, Resources.Load<Texture2D>("Sprites/Cosmetics/StrawHatIcon"), skin.GetStyle("Square")))
                    {
                        this.smoothAparition = 0;
                        typeCloth = (int)Hat.TypeHat.StrawHat;
                    }
                    rect.x += (Screen.width / 40 + Screen.width / 20);

                    if (GUI.Button(rect, Resources.Load<Texture2D>("Sprites/Cosmetics/CowBoyIcon"), skin.GetStyle("Square")))
                    {
                        this.smoothAparition = 0;
                        typeCloth = (int)Hat.TypeHat.CowBoy;
                    }

                    foreach (Hat h in Clothing.Hats)
                        if (this.typeCloth == (int)h.GetTypeHat)
                        {
                            x = this.typeCloth;
                            Color fillcolor = h.Color;
                            fillcolor.a = Mathf.Clamp01(this.smoothAparition - y * TransitionDelay);
                            for (int i = 0; i < this.width / 3; i++)
                                for (int j = 0; j < this.width / 3; j++)
                                    fill.SetPixel(i, j, fillcolor);
                            fill.Apply();
                            rect = new Rect((Screen.width / 40 + Screen.width / 20) * x + Screen.width / 25f, y * (Screen.height / 10) + Screen.height / 2.6f, Screen.height / 11, Screen.height / 11);
                            if (rect.Contains(Event.current.mousePosition))
                                tooltip = h.Description;
                            if (this.smoothAparition > y * TransitionDelay && GUI.Button(rect, fill, skin.GetStyle("Square")))
                            {
                                this.skinCharacter.Hat = h;
                                this.skinCharacter.Apply(this.character);
                            }
                            y += 1;
                        }
                    break;
                #endregion
                #region Beard
                case (CategoryCloth.Beard):
                    y = 0;
                    x = 0;
                    rect = new Rect(Screen.width / 25f, this.posY - this.spacing * 1.5f, Screen.height / 11, Screen.height / 11);
                    if (GUI.Button(rect, Resources.Load<Texture2D>("Sprites/Cosmetics/NoneIcon"), skin.GetStyle("Square")))
                    {
                        this.smoothAparition = 0;
                        typeCloth = (int)Beard.TypeBeard.None;
                    }
                    rect.x += (Screen.width / 50 + Screen.width / 20);

                    if (GUI.Button(rect, Resources.Load<Texture2D>("Sprites/Cosmetics/BeardIcon"), skin.GetStyle("Square")))
                    {
                        this.smoothAparition = 0;
                        typeCloth = (int)Beard.TypeBeard.Beard;
                    }
                    rect.x += (Screen.width / 50 + Screen.width / 20);

                    if (GUI.Button(rect, Resources.Load<Texture2D>("Sprites/Cosmetics/BeardOnlyIcon"), skin.GetStyle("Square")))
                    {
                        this.smoothAparition = 0;
开发者ID:JMounier,项目名称:Aegina,代码行数:67,代码来源:NetworkManagerHUD.cs

示例15: CheckRectLine

 /// <summary>
 /// Checks intersection of line with rectangular area
 /// </summary>
 /// <param name="start">Line start point</param>
 /// <param name="end">Line end point</param>
 /// <param name="rect">Rectangular area</param>
 /// <returns>
 /// Returns true if line intersects with rectangle otherwise - false
 /// </returns>
 private static bool CheckRectLine(Vector2 start, Vector2 end, Rect rect)
 {
     bool result = false;
     if (rect.Contains(start) || rect.Contains(end))
         result = true;
     else
     {
         result |= CheckRectLineH(start, end, rect.LeftTop.Y, rect.LeftTop.X, rect.RightBottom.X);
         result |= CheckRectLineH(start, end, rect.RightBottom.Y, rect.LeftTop.X, rect.RightBottom.X);
         result |= CheckRectLineV(start, end, rect.LeftTop.X, rect.LeftTop.Y, rect.RightBottom.Y);
         result |= CheckRectLineV(start, end, rect.RightBottom.X, rect.LeftTop.Y, rect.RightBottom.Y);
     }
     return result;
 }
开发者ID:Neio,项目名称:MonoGame2D,代码行数:23,代码来源:GeometryHelper.cs


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