コード例 #1
0
 public void Write(RectangleI source)
 {
     Write(source.Minimum.X);
     Write(source.Minimum.Y);
     Write(source.Maximum.X);
     Write(source.Maximum.Y);
 }
コード例 #2
0
ファイル: Rectangle.cs プロジェクト: zwiglm/NeoAxisEngine
 public Rectangle(RectangleI source)
 {
     Left   = source.Left;
     Top    = source.Top;
     Right  = source.Right;
     Bottom = source.Bottom;
 }
コード例 #3
0
 public void Intersection(ref RectangleI v, out RectangleI result)
 {
     result.Left   = (v.Left > Left) ? v.Left : Left;
     result.Top    = (v.Top > Top) ? v.Top : Top;
     result.Right  = (v.Right < Right) ? v.Right : Right;
     result.Bottom = (v.Bottom < Bottom) ? v.Bottom : Bottom;
 }
コード例 #4
0
        public override void CreatedWindow_SetWindowRectangle(RectangleI rectangle)
        {
            //!!!!

            //!!!!
            //EngineApp._CreatedWindow_ProcessResize();
        }
コード例 #5
0
 public static void Subtract(ref RectangleI r, ref Vector2I v, out RectangleI result)
 {
     result.Left   = r.Left - v.X;
     result.Top    = r.Top - v.Y;
     result.Right  = r.Right - v.X;
     result.Bottom = r.Bottom - v.Y;
 }
コード例 #6
0
        //public static RectI Add( RectI r, Vec2I v )
        //{
        //	RectI result;
        //	result.left = r.left + v.X;
        //	result.top = r.top + v.Y;
        //	result.right = r.right + v.X;
        //	result.bottom = r.bottom + v.Y;
        //	return result;
        //}

        //public static RectI Subtract( RectI r, Vec2I v )
        //{
        //	RectI result;
        //	result.left = r.left - v.X;
        //	result.top = r.top - v.Y;
        //	result.right = r.right - v.X;
        //	result.bottom = r.bottom - v.Y;
        //	return result;
        //}

        public static void Add(ref RectangleI r, ref Vector2I v, out RectangleI result)
        {
            result.Left   = r.Left + v.X;
            result.Top    = r.Top + v.Y;
            result.Right  = r.Right + v.X;
            result.Bottom = r.Bottom + v.Y;
        }
コード例 #7
0
 public DisplayInfo(string deviceName, RectangleI bounds, RectangleI workingArea, bool primary)
 {
     this.deviceName  = deviceName;
     this.bounds      = bounds;
     this.workingArea = workingArea;
     this.primary     = primary;
 }
コード例 #8
0
 public bool Contains(ref RectangleI v)
 {
     if (v.Left < Left || v.Top < Top || v.Right > Right || v.Bottom > Bottom)
     {
         return(false);
     }
     return(true);
 }
コード例 #9
0
 public bool Intersects(ref RectangleI v)
 {
     if (v.Right < Left || v.Bottom < Top || v.Left > Right || v.Top > Bottom)
     {
         return(false);
     }
     return(true);
 }
コード例 #10
0
        //!!!!было
        //public delegate void RenderBackgroundEventDelegate( Component_FlowchartStyle sender, Component_Flowchart_DocumentWindow window, ref bool processed );
        //public event RenderBackgroundEventDelegate RenderBackgroundEvent;

        public virtual void RenderBackgroundGrid(Component_FlowGraph_DocumentWindow window)
        {
            var viewport = window.ViewportControl.Viewport;
            var renderer = viewport.CanvasRenderer;

            RectangleI visibleCells = window.GetVisibleCells();

            //draw background
            renderer.AddQuad(new Rectangle(0, 0, 1, 1), new ColorValue(.17f, .17f, .17f));

            //draw grid
            if (window.GetZoom() > .5f)
            {
                var lines = new List <CanvasRenderer.LineItem>(256);

                {
                    ColorValue color = new ColorValue(.2f, .2f, .2f);
                    for (int x = visibleCells.Left; x <= visibleCells.Right; x++)
                    {
                        if (x % 10 != 0)
                        {
                            var floatX = (float)window.ConvertUnitToScreenX(x);
                            lines.Add(new CanvasRenderer.LineItem(new Vector2F(floatX, 0), new Vector2F(floatX, 1), color));
                        }
                    }
                    for (int y = visibleCells.Top; y <= visibleCells.Bottom; y++)
                    {
                        if (y % 10 != 0)
                        {
                            var floatY = (float)window.ConvertUnitToScreenY(y);
                            lines.Add(new CanvasRenderer.LineItem(new Vector2F(0, floatY), new Vector2F(1, floatY), color));
                        }
                    }
                }

                {
                    ColorValue color = new ColorValue(.1f, .1f, .1f);
                    for (int x = visibleCells.Left; x <= visibleCells.Right; x++)
                    {
                        if (x % 10 == 0)
                        {
                            var floatX = (float)window.ConvertUnitToScreenX(x);
                            lines.Add(new CanvasRenderer.LineItem(new Vector2F(floatX, 0), new Vector2F(floatX, 1), color));
                        }
                    }
                    for (int y = visibleCells.Top; y <= visibleCells.Bottom; y++)
                    {
                        if (y % 10 == 0)
                        {
                            var floatY = (float)window.ConvertUnitToScreenY(y);
                            lines.Add(new CanvasRenderer.LineItem(new Vector2F(0, floatY), new Vector2F(1, floatY), color));
                        }
                    }
                }

                viewport.CanvasRenderer.AddLines(lines);
            }
        }
コード例 #11
0
        public RectangleI Intersection(RectangleI v)
        {
            RectangleI result;

            result.Left   = (v.Left > Left) ? v.Left : Left;
            result.Top    = (v.Top > Top) ? v.Top : Top;
            result.Right  = (v.Right < Right) ? v.Right : Right;
            result.Bottom = (v.Bottom < Bottom) ? v.Bottom : Bottom;
            return(result);
        }
コード例 #12
0
        public override IList <SystemSettings.DisplayInfo> GetAllDisplays()
        {
            var result = new List <SystemSettings.DisplayInfo>();

            RectangleI area = new RectangleI(Vector2I.Zero, GetScreenSize());

            SystemSettings.DisplayInfo info = new SystemSettings.DisplayInfo("Primary", area, area, true);
            result.Add(info);

            return(result);
        }
コード例 #13
0
        public override void CreatedWindow_SetWindowRectangle(RectangleI rectangle)
        {
            //TODO: implement it.

            var scaleFactor = displayInfo.RawPixelsPerViewPixel;

            applicationView.TryResizeView(new Size(
                                              (rectangle.Right - rectangle.Left) / scaleFactor,
                                              (rectangle.Bottom - rectangle.Top) / scaleFactor));

            //!!!!!так?
            EngineApp._CreatedWindow_ProcessResize();
        }
コード例 #14
0
        //copy from WindowsPlatformFunctionality
        unsafe static bool MonitorEnumProc(IntPtr hMonitor, IntPtr hdcMonitor, ref RectangleI lprcMonitor, IntPtr dwData)
        {
            MONITORINFOEX info = new MONITORINFOEX();

            info.cbSize = sizeof(MONITORINFOEX);
            if (GetMonitorInfo(hMonitor, ref info))
            {
                SystemSettings.DisplayInfo displayInfo = new SystemSettings.DisplayInfo(new string( info.szDeviceName ), info.rcMonitor,
                                                                                        info.rcWork, (info.dwFlags & MONITORINFOF_PRIMARY) != 0);
                tempScreenList.Add(displayInfo);
            }

            return(true);
        }
コード例 #15
0
 public void Add(RectangleI a)
 {
     if (a.Left < Left)
     {
         Left = a.Left;
     }
     if (a.Top < Top)
     {
         Top = a.Top;
     }
     if (a.Right > Right)
     {
         Right = a.Right;
     }
     if (a.Bottom > Bottom)
     {
         Bottom = a.Bottom;
     }
 }
コード例 #16
0
        public override IList <SystemSettings.DisplayInfo> GetAllDisplays()
        {
            //copy from WindowsPlatformFunctionality

            List <SystemSettings.DisplayInfo> result = new List <SystemSettings.DisplayInfo>();

            lock ( tempScreenList )
            {
                IntPtr hdc = GetDC(IntPtr.Zero);
                if (hdc != IntPtr.Zero)
                {
                    tempScreenList.Clear();

                    EnumDisplayMonitors(hdc, IntPtr.Zero, MonitorEnumProc, IntPtr.Zero);
                    ReleaseDC(IntPtr.Zero, hdc);

                    result.AddRange(tempScreenList);
                    tempScreenList.Clear();
                }
            }

            if (result.Count == 0)
            {
                RectangleI area = new RectangleI(Vector2I.Zero, GetScreenSize());
                SystemSettings.DisplayInfo info = new SystemSettings.DisplayInfo("Primary", area, area, true);
                result.Add(info);
            }

            return(result);

            //// it seems it works, but it's cross-platform?

            //// alternative implementation can be used. see SDL:
            //// IDXGIAdapter1.EnumOutputs, IDXGIOutput::GetDisplayModeList.

            //var wp = new WindowsPlatformFunctionality();
            //return wp.GetAllDisplays();
        }
コード例 #17
0
        public override void RenderNode(Component_FlowGraph_DocumentWindow window, Component_FlowGraphNode node,
                                        EditorRenderSelectionState selectionStateNode, EditorRenderSelectionState selectionStateControlledObject, object mouseOverObject,
                                        Component_FlowGraphNode.Representation.Connector referenceCreationSocketFrom, DragDropSetReferenceData dragDropSetReferenceData)
        {
            var representation = node.GetRepresentation();
            var viewport       = window.ViewportControl.Viewport;
            var mouse          = viewport.MousePosition;
            var renderer       = viewport.CanvasRenderer;

            FlowGraphRepresentationData representationData = new FlowGraphRepresentationData();
            {
                var iRepresentationData = node.ControlledObject.Value as IFlowGraphRepresentationData;
                if (iRepresentationData != null)
                {
                    iRepresentationData.GetFlowGraphRepresentationData(representationData);
                }
            }

            Vector2I   nodeSize = representation.Size;
            RectangleI nodeRectWithOneBorder = new RectangleI(node.Position - new Vector2I(1, 1), node.Position + nodeSize + new Vector2I(1, 1));

            //!!!!slowly
            var visibleCells = window.GetVisibleCells();

            if (!visibleCells.Intersects(nodeRectWithOneBorder))
            {
                return;
            }

            window.GetFontSizes(renderer, out var nodeFontSize, out var nodeFontSizeComment);

            Rectangle nodeRectInUnits = new RectangleI(node.Position, node.Position + nodeSize).ToRectangle();
            Rectangle nodeRect        = window.ConvertUnitToScreen(nodeRectInUnits);
            double    cellHeight      = window.ConvertUnitToScreenY(node.Position.Y + 1) - window.ConvertUnitToScreenY(node.Position.Y);



            //ColorValue totalNodeColorMultiplier = new ColorValue( 1, 1, 1 );
            //{
            //	//if( settings.Error != null )
            //	//	nodeColorMultiplier *= new ColorValue( 1, 0, 0 );

            //	//BlueprintGraphNodeObjectsEvent event_ = node as BlueprintGraphNodeObjectsEvent;
            //	//if( event_ != null && !event_.Enabled )
            //	//	nodeColorMultiplier = new ColorValue( .5f, .5f, .5f );
            //}

            ColorValue nodeColorMultiplierWithSelection = /*totalNodeColorMultiplier*/ GetColorMultiplierSelectionState(selectionStateNode);
            ColorValue objColorMultiplierWithSelection  = /*totalNodeColorMultiplier*/ GetColorMultiplierSelectionState(selectionStateControlledObject);

            //node selection
            if (selectionStateNode != EditorRenderSelectionState.None)
            {
                //node selection rectangle
                Rectangle nodeSelectionRectInUnits = nodeRectInUnits;
                nodeSelectionRectInUnits.Expand(.4);
                Rectangle nodeSelectionRect = window.ConvertUnitToScreen(nodeSelectionRectInUnits);

                renderer.AddQuad(nodeSelectionRect, new ColorValue(.3, .3, .3) * nodeColorMultiplierWithSelection);
                renderer.AddRectangle(nodeSelectionRect, new ColorValue(.6, .6, .6) * nodeColorMultiplierWithSelection);
            }

            //window
            {
                double titleHeight = cellHeight;
                //float titleHeight = ConvertUnitToScreenY( node.NodePosition.Y + 1 ) - ConvertUnitToScreenY( node.NodePosition.Y );
                Rectangle titleRect = new Rectangle(nodeRect.Left, nodeRect.Top, nodeRect.Right, nodeRect.Top + titleHeight);
                Rectangle bodyRect  = new Rectangle(nodeRect.Left, nodeRect.Top + titleHeight, nodeRect.Right, nodeRect.Bottom);

                //!!!!
                ColorValue contentTypeColor;
                ColorValue?titleColor = null;
                switch (representationData.NodeContentType)
                {
                case FlowGraphNodeContentType.Flow: contentTypeColor = new ColorValue(0.16 / 1.2, 0.34 / 1.2, 0.6 / 1.2); break;

                case FlowGraphNodeContentType.MethodBody: contentTypeColor = new ColorValue(0.45, 0.1, 0.1); break;

                case FlowGraphNodeContentType.FlowStart: contentTypeColor = new ColorValue(0.45, 0.1, 0.1); break;
                //case FlowchartNodeContentType.Flow: contentTypeColor = new ColorValue( 0.15, 0.15, 0.4 ); break;
                //case FlowchartNodeContentType.MethodBody: contentTypeColor = new ColorValue( 0.4, 0.1, 0.1 ); break;

                //!!!!
                default:
                    //contentTypeColor = new ColorValue( 0.3, 0.3, 0.3 );
                    //titleColor = new ColorValue( 0.36, 0.36, 0.36 );
                    contentTypeColor = new ColorValue(0.26, 0.26, 0.26);
                    //contentTypeColor = new ColorValue( 0.24, 0.24, 0.24 );
                    titleColor = new ColorValue(0.3, 0.3, 0.3);
                    break;
                    //default: contentTypeColor = new ColorValue( 0.3, 0.3, 0.3 ); break;
                }

                if (titleColor == null)
                {
                    titleColor = contentTypeColor;
                }

                //!!!!
                //object is disabled
                {
                    var c = node.ControlledObject.Value;
                    if (c != null && !c.EnabledInHierarchy)
                    {
                        contentTypeColor *= new ColorValue(0.5, 0.5, 0.5, 1);
                    }
                }

                if (selectionStateControlledObject != EditorRenderSelectionState.None)
                {
                    titleColor = new ColorValue(0.3, 0.3, 0.3) * objColorMultiplierWithSelection;
                }

                //ColorValue titleColor;
                //if( selectionStateControlledObject == EditorRenderSelectionState.None )
                //	titleColor = contentTypeColor;
                //else
                //	titleColor = new ColorValue( 0.3, 0.3, 0.3 ) * objColorMultiplierWithSelection;

                renderer.AddQuad(titleRect, titleColor.Value);
                //renderer.AddQuad( titleRect, new ColorValue( .3, .3, .3 ) * objColorMultiplierWithSelection );

                renderer.AddQuad(bodyRect, contentTypeColor /* totalNodeColorMultiplier*/);
                //renderer.AddQuad( bodyRect, new ColorValue( .3, .3, .3 ) * totalNodeColorMultiplier );

                //renderer.AddQuad( bodyRect, new ColorValue( 1, 1, 1 ) /*new ColorValue( .3, .3, .3 )*/ * nodeColorMultiplier );
                //renderer.AddQuad( bodyRect, settings.BodyColor /*new ColorValue( .3, .3, .3 )*/ * nodeColorMultiplier );

                //renderer.AddQuad( rect, new ColorValue( .3, .3, .3 ) * nodeColorMultiplierWithSelection );
                renderer.AddRectangle(nodeRect, new ColorValue(.6, .6, .6) * objColorMultiplierWithSelection);
                renderer.AddLine(
                    window.ConvertUnitToScreen(node.Position.ToVector2() + new Vector2(0, 1)),
                    window.ConvertUnitToScreen(node.Position.ToVector2() + new Vector2(nodeSize.X, 1)),
                    new ColorValue(.6, .6, .6) * objColorMultiplierWithSelection);

                //if( titleRect.IsContainsPoint( mouse ) )
                //	mouseOverObjects.AddWithCheckAlreadyContained( node );
            }

            //!!!!было
            ////BlueprintGraphNodeComment: draw comment
            //if( node is BlueprintGraphNodeComment && !string.IsNullOrEmpty( node.NodeComment ) )
            //{
            //	renderer.AddText( fontComment, node.NodeComment, rectNode.LeftTop, HorizontalAlign.Left, VerticalAlign.Bottom,
            //		settings.CommentColor );
            //}

            if (window.GetZoom() > .25f)
            {
                //Comment
                if (!string.IsNullOrEmpty(node.Comment))                   //!!!!было && !( node is BlueprintGraphNodeComment ) )
                {
                    //!!!!style
                    var color = new ColorValue(1, 1, 1);                      //settings.CommentColor
                    renderer.AddText(window.NodeFontComment, nodeFontSizeComment, node.Comment, nodeRect.LeftTop, EHorizontalAlignment.Left, EVerticalAlignment.Bottom,
                                     color);
                }

                //title, texts
                {
                    renderer.PushClipRectangle(nodeRect);

                    //title
                    {
                        ColorValue titleColorMultiplier = new ColorValue(1, 1, 1);

                        //!!!!было
                        //if( node.IsFlowEntry() && !IsObjectSelected( node ) )
                        //	titleColorMultiplier = new ColorValue( 1, 0, 0 );

                        Vector2 pos = window.ConvertUnitToScreen(node.Position.ToVector2() + new Vector2(.1f, 0));

                        renderer.AddText(window.NodeFont, nodeFontSize, representation.Title, pos, EHorizontalAlignment.Left, EVerticalAlignment.Top,
                                         titleColorMultiplier * objColorMultiplierWithSelection);
                    }

                    //!!!!
                    ////texts
                    //if( settings.Texts != null )
                    //{
                    //	for( int n = 0; n < settings.Texts.Length; n++ )
                    //	{
                    //		string text = settings.Texts[ n ];
                    //		Vec2 pos2 = ConvertUnitToScreen( node.NodePosition.ToVec2() + new Vec2( .3, (float)n + 1 ) );
                    //		renderer.AddText( fontValue, text, pos2 + new Vec2( 0, cellHeight * .05f ), EHorizontalAlign.Left,
                    //			EVerticalAlign.Top, new ColorValue( .7f, .7f, .7f ) * nodeColorMultiplierWithSelection );
                    //	}
                    //}

                    renderer.PopClipRectangle();
                }

                //client area
                {
                    //!!!!

                    var texture = representationData.NodeImage;
                    if (texture != null)
                    {
                        Rectangle rect;
                        if (representationData.NodeImageView == FlowGraphRepresentationData.NodeImageViewEnum.WideScaled)
                        {
                            double size = 6;
                            rect = new Rectangle(
                                node.Position.ToVector2() + new Vector2(0, representation.Size.Y - size),
                                node.Position.ToVector2() + new Vector2(representation.Size.X, representation.Size.Y));

                            double border = 0.2;
                            rect.Expand(-border);

                            Rectangle rectInScreen = window.ConvertUnitToScreen(rect);
                            var       texCoords    = new Rectangle(0, 0, 1, 1);

                            var textureSize = texture.Result.ResultSize;
                            var s           = textureSize.ToVector2() / viewport.SizeInPixels.ToVector2();
                            var rect2       = new Rectangle(rectInScreen.Left, rectInScreen.Top, rectInScreen.Left + s.X, rectInScreen.Top + s.Y);

                            renderer.PushClipRectangle(rectInScreen);
                            renderer.PushTextureFilteringMode(CanvasRenderer.TextureFilteringMode.Point);
                            renderer.AddQuad(rect2, new Rectangle(0, 0, 1, 1), texture);
                            renderer.PopTextureFilteringMode();
                            renderer.PopClipRectangle();
                        }
                        else
                        {
                            double size = 5;
                            rect = new Rectangle(
                                node.Position.ToVector2() + new Vector2(0, representation.Size.Y - size),
                                node.Position.ToVector2() + new Vector2(size, representation.Size.Y));

                            double border = 0.2;
                            rect.Expand(-border);

                            Rectangle rectInScreen = window.ConvertUnitToScreen(rect);
                            renderer.AddQuad(rectInScreen, new Rectangle(0, 0, 1, 1), texture);
                        }

                        //double size = 5;
                        //double border = 0.2;
                        //Rectangle rect = new Rectangle(
                        //	node.Position.ToVector2() + new Vector2( 0, representation.Size.Y - size ),
                        //	node.Position.ToVector2() + new Vector2( size, representation.Size.Y ) );
                        //rect.Expand( -border );
                        //Rectangle rectInScreen = window.ConvertUnitToScreen( rect );

                        //renderer.AddQuad( rectInScreen, new Rectangle( 0, 0, 1, 1 ), texture );
                    }
                }

                var mouseOverSocket = mouseOverObject as Component_FlowGraphNode.Representation.Connector;

                //items
                for (int nItem = 0; nItem < representation.Items.Count; nItem++)
                {
                    var item = representation.Items[nItem];

                    ColorValue circleColorNotSpecified = new ColorValue(0.6, 0.6, 0.6);
                    ColorValue circleColorSpecified    = new ColorValue(1, 1, 1);
                    ColorValue circleColorMouseOver    = new ColorValue(1, 1, 0);
                    ColorValue circleColorCanConnect   = new ColorValue(1, 1, 0);

                    bool isFlow = false;
                    {
                        var item2 = item as Component_FlowGraphNode.Representation.ItemProperty;
                        //!!!!может кешировать, часто бывает
                        if (item2 != null && MetadataManager.GetTypeOfNetType(typeof(FlowInput)).IsAssignableFrom(item2.Property.TypeUnreferenced))
                        {
                            isFlow = true;
                        }
                    }

                    //draw input circle
                    if (item.Input != null)
                    {
                        Vector2   center = GetSocketPositionInUnits(item, true);
                        Rectangle rect   = window.ConvertUnitToScreen(new Rectangle(center - new Vector2(.25, .25), center + new Vector2(.25, .25)));

                        ColorValue circleColor = circleColorNotSpecified;

                        //check reference specified
                        var itemProperty = item as Component_FlowGraphNode.Representation.ItemProperty;
                        if (itemProperty != null && ReferenceUtility.IsReferenceType(itemProperty.Property.Type.GetNetType()))
                        {
                            Component obj = itemProperty.Owner.Owner.ControlledObject;
                            if (obj != null)
                            {
                                var v          = itemProperty.Property.GetValue(obj, null);
                                var iReference = v as IReference;
                                if (iReference != null && !string.IsNullOrEmpty(iReference.GetByReference))
                                {
                                    //!!!!инвалидная может быть

                                    circleColor = circleColorSpecified;
                                }
                            }
                        }

                        if (mouseOverSocket != null && mouseOverSocket.item == item && mouseOverSocket.input && referenceCreationSocketFrom == null &&
                            dragDropSetReferenceData == null)
                        {
                            circleColor = circleColorMouseOver;
                        }
                        if (referenceCreationSocketFrom != null && window.CanCreateReference(item.Input, referenceCreationSocketFrom))
                        {
                            circleColor = circleColorCanConnect;
                        }
                        if (isFlow && dragDropSetReferenceData != null && window.CanCreateReferenceDragDropSetReference(dragDropSetReferenceData, item.Input, out string[] dummy))
コード例 #18
0
        public unsafe override void CreatedWindow_UpdateInputDevices()
        {
            //!!!!!всё тут проверить

            //!!!!//ничего не обновлять, если отрублены?

            Viewport viewport = RenderingSystem.ApplicationRenderTarget.Viewports[0];              //App.CreatedInsideEngineWindow.Viewport;

            //!!!!new
            if (EngineApp.CreatedInsideEngineWindow != null && IsFocused())
            {
                CreatedWindow_UpdateShowSystemCursor(false);
            }

            //mouse buttons
            {
                //!!!!

                //List<ValueTuple<EMouseButtons, int>> buttons = new List<(EMouseButtons, int)>();
                //buttons.Add( (EMouseButtons.Left, VK_LBUTTON) );
                //buttons.Add( (EMouseButtons.Right, VK_RBUTTON) );
                //buttons.Add( (EMouseButtons.Middle, VK_MBUTTON) );
                //buttons.Add( (EMouseButtons.XButton1, VK_XBUTTON1) );
                //buttons.Add( (EMouseButtons.XButton2, VK_XBUTTON2) );
                //foreach( var tuple in buttons )
                //{
                //	if( viewport.IsMouseButtonPressed( tuple.Item1 ) && GetKeyState( tuple.Item2 ) >= 0 )
                //	{
                //		bool handled = false;
                //		viewport.PerformMouseUp( tuple.Item1, ref handled );
                //	}
                //}


                if (viewport.IsMouseButtonPressed(EMouseButtons.Left) && GetKeyState(VK_LBUTTON) >= 0)
                {
                    bool handled = false;
                    viewport.PerformMouseUp(EMouseButtons.Left, ref handled);
                }
                if (viewport.IsMouseButtonPressed(EMouseButtons.Right) && GetKeyState(VK_RBUTTON) >= 0)
                {
                    bool handled = false;
                    viewport.PerformMouseUp(EMouseButtons.Right, ref handled);
                }
                if (viewport.IsMouseButtonPressed(EMouseButtons.Middle) && GetKeyState(VK_MBUTTON) >= 0)
                {
                    bool handled = false;
                    viewport.PerformMouseUp(EMouseButtons.Middle, ref handled);
                }
                if (viewport.IsMouseButtonPressed(EMouseButtons.XButton1) && GetKeyState(VK_XBUTTON1) >= 0)
                {
                    bool handled = false;
                    viewport.PerformMouseUp(EMouseButtons.XButton1, ref handled);
                }
                if (viewport.IsMouseButtonPressed(EMouseButtons.XButton2) && GetKeyState(VK_XBUTTON2) >= 0)
                {
                    bool handled = false;
                    viewport.PerformMouseUp(EMouseButtons.XButton2, ref handled);
                }
            }

            //keys
            foreach (EKeys eKey in Viewport.AllKeys)
            {
                if (viewport.IsKeyPressed(eKey))
                {
                    KeyInfo keyInfo = keysInfo[(int)eKey];

                    if (keyInfo.keyCode != 0)
                    {
                        if (GetKeyState(keyInfo.keyCode) >= 0)
                        {
                            KeyEvent keyEvent = new KeyEvent(eKey);
                            bool     handled  = false;
                            viewport.PerformKeyUp(keyEvent, ref handled);
                        }
                    }
                }
            }

            //mouse outside window client rectangle
            if (!viewport.MouseRelativeMode)
            {
                Vector2 mouse = viewport.MousePosition;

                if (mouse.X < 0 || mouse.X >= 1 || mouse.Y < 0 || mouse.Y >= 1)
                {
                    if (!mouse.Equals(lastMousePositionForCheckMouseOutsideWindow, .0001f))
                    {
                        lastMousePositionForCheckMouseOutsideWindow = mouse;
                        EngineApp.CreatedInsideEngineWindow._ProcessMouseMoveEvent();
                    }
                }
            }

            //mouse relative mode
            if (viewport.MouseRelativeMode)
            {
                //!!!!в EngineViewportControl тоже?
                //clip cursor by window rectangle
                if (IsFocused())
                {
                    SetCapture(EngineApp.ApplicationWindowHandle);

                    RectangleI rectangle = CreatedWindow_GetWindowRectangle();
                    rectangle.Left   += 1;
                    rectangle.Top    += 1;
                    rectangle.Right  -= 1;
                    rectangle.Bottom -= 1;
                    ClipCursor((IntPtr)(&rectangle));
                }

                //!!!!
                //if( DirectInputMouseDevice.Instance != null )
                //{
                //	////!!!!!
                //	//Log.Warning( "temp" );

                //	DirectInputMouseDevice.State state = DirectInputMouseDevice.Instance.GetState();
                //	if( state.Position.X != 0 || state.Position.Y != 0 )
                //	{
                //		//!!!!wrong
                //		Vector2F offset = new Vector2F(
                //			(float)(int)state.Position.X / viewport.SizeInPixels.X,
                //			(float)(int)state.Position.Y / viewport.SizeInPixels.Y );

                //		//!!!!
                //		viewport.PerformMouseMove( offset );

                //		if( !EngineApp.Closing && IsFocused() )
                //			CreatedWindow_SetMousePosition( new Vector2F( .5f, .5f ) );
                //		//App.MousePosition = new Vec2( .5f, .5f );
                //	}
                //}
                //else
                {
                    //!!!!надо ли

                    if (!EngineApp.Closing && IsFocused())
                    {
                        CreatedWindow_SetMousePosition(new Vector2F(.5f, .5f));
                    }
                    //App.MousePosition = new Vec2( .5f, .5f );
                }
            }
        }
コード例 #19
0
 public abstract void CreatedWindow_SetWindowRectangle(RectangleI rectangle);
コード例 #20
0
        //

        static SimpleTypes()
        {
            //string
            RegisterType(typeof(string), delegate(string value)
            {
                if (value == null)
                {
                    return("");
                    //throw new Exception( "GetSimpleTypeValue: string type, value = null" );
                }
                return(value);
            }, "");

            //bool
            RegisterType(typeof(bool), delegate(string value)
            {
                string lower = value.ToLower();
                if (value == "1" || lower == "yes" || lower == "true")
                {
                    return(true);
                }
                else if (value == "0" || lower == "no" || lower == "false")
                {
                    return(false);
                }
                else
                {
                    return(bool.Parse(value));
                }
            }, false);

            //sbyte
            RegisterType(typeof(sbyte), delegate(string value) { return(sbyte.Parse(value)); }, 0);

            //byte
            RegisterType(typeof(byte), delegate(string value) { return(byte.Parse(value)); }, 0);

            //char
            RegisterType(typeof(char), delegate(string value) { return(char.Parse(value)); }, 0);

            //short
            RegisterType(typeof(short), delegate(string value) { return(short.Parse(value)); }, 0);

            //ushort
            RegisterType(typeof(ushort), delegate(string value) { return(ushort.Parse(value)); }, 0);

            //int
            RegisterType(typeof(int), delegate(string value) { return(int.Parse(value)); }, 0);

            //uint
            RegisterType(typeof(uint), delegate(string value) { return(uint.Parse(value)); }, (uint)0);

            //long
            RegisterType(typeof(long), delegate(string value) { return(long.Parse(value)); }, (long)0);

            //ulong
            RegisterType(typeof(ulong), delegate(string value) { return(ulong.Parse(value)); }, (ulong)0);

            //float
            RegisterType(typeof(float), delegate(string value) { return(float.Parse(value)); }, 0.0f);

            //double
            RegisterType(typeof(double), delegate(string value) { return(double.Parse(value)); }, 0.0);

            //decimal
            RegisterType(typeof(decimal), delegate(string value) { return(decimal.Parse(value)); }, (decimal)0.0);

            //Vec2
            RegisterType(typeof(Vector2F), delegate(string value) { return(Vector2F.Parse(value)); }, Vector2F.Zero);

            //Range
            RegisterType(typeof(RangeF), delegate(string value) { return(RangeF.Parse(value)); }, RangeF.Zero);

            //Vec3
            RegisterType(typeof(Vector3F), delegate(string value) { return(Vector3F.Parse(value)); }, Vector3F.Zero);

            //Vec4
            RegisterType(typeof(Vector4F), delegate(string value) { return(Vector4F.Parse(value)); }, Vector4F.Zero);

            //Bounds
            RegisterType(typeof(BoundsF), delegate(string value) { return(BoundsF.Parse(value)); }, BoundsF.Zero);

            //Quat
            RegisterType(typeof(QuaternionF), delegate(string value) { return(QuaternionF.Parse(value)); }, QuaternionF.Identity);

            //ColorValue
            RegisterType(typeof(ColorValue), delegate(string value) { return(ColorValue.Parse(value)); }, ColorValue.Zero);

            //ColorValuePowered
            RegisterType(typeof(ColorValuePowered), delegate(string value) { return(ColorValuePowered.Parse(value)); }, ColorValuePowered.Zero);

            //ColorPacked
            RegisterType(typeof(ColorByte), delegate(string value) { return(ColorByte.Parse(value)); }, ColorByte.Zero);

            //SphereDir
            RegisterType(typeof(SphericalDirectionF), delegate(string value) { return(SphericalDirectionF.Parse(value)); }, SphericalDirectionF.Zero);

            //Vec2I
            RegisterType(typeof(Vector2I), delegate(string value) { return(Vector2I.Parse(value)); }, Vector2I.Zero);

            //Vec3I
            RegisterType(typeof(Vector3I), delegate(string value) { return(Vector3I.Parse(value)); }, Vector3I.Zero);

            //Vec4I
            RegisterType(typeof(Vector4I), delegate(string value) { return(Vector4I.Parse(value)); }, Vector4I.Zero);

            //Rect
            RegisterType(typeof(RectangleF), delegate(string value) { return(RectangleF.Parse(value)); }, RectangleF.Zero);

            //RectI
            RegisterType(typeof(RectangleI), delegate(string value) { return(RectangleI.Parse(value)); }, RectangleI.Zero);

            //Degree
            RegisterType(typeof(DegreeF), delegate(string value) { return(DegreeF.Parse(value)); }, DegreeF.Zero);

            //Radian
            RegisterType(typeof(RadianF), delegate(string value) { return(RadianF.Parse(value)); }, RadianF.Zero);

            //Vec2D
            RegisterType(typeof(Vector2), delegate(string value) { return(Vector2.Parse(value)); }, Vector2.Zero);

            //RangeD
            RegisterType(typeof(Range), delegate(string value) { return(Range.Parse(value)); }, Range.Zero);

            //RangeI
            RegisterType(typeof(RangeI), delegate(string value) { return(RangeI.Parse(value)); }, RangeI.Zero);

            //Vec3D
            RegisterType(typeof(Vector3), delegate(string value) { return(Vector3.Parse(value)); }, Vector3.Zero);

            //Vec4D
            RegisterType(typeof(Vector4), delegate(string value) { return(Vector4.Parse(value)); }, Vector4.Zero);

            //BoundsD
            RegisterType(typeof(Bounds), delegate(string value) { return(Bounds.Parse(value)); }, Bounds.Zero);

            //QuatD
            RegisterType(typeof(Quaternion), delegate(string value) { return(Quaternion.Parse(value)); }, Quaternion.Identity);

            //SphereDirD
            RegisterType(typeof(SphericalDirection), delegate(string value) { return(SphericalDirection.Parse(value)); }, SphericalDirection.Zero);

            //RectD
            RegisterType(typeof(Rectangle), delegate(string value) { return(Rectangle.Parse(value)); }, Rectangle.Zero);

            //DegreeD
            RegisterType(typeof(Degree), delegate(string value) { return(Degree.Parse(value)); }, Degree.Zero);

            //RadianD
            RegisterType(typeof(Radian), delegate(string value) { return(Radian.Parse(value)); }, Radian.Zero);

            //Angles
            RegisterType(typeof(AnglesF), delegate(string value) { return(AnglesF.Parse(value)); }, AnglesF.Zero);

            //AnglesD
            RegisterType(typeof(Angles), delegate(string value) { return(Angles.Parse(value)); }, Angles.Zero);

            //Mat2F
            RegisterType(typeof(Matrix2F), delegate(string value) { return(Matrix2F.Parse(value)); }, Matrix2F.Zero);

            //Mat2D
            RegisterType(typeof(Matrix2), delegate(string value) { return(Matrix2.Parse(value)); }, Matrix2.Zero);

            //Mat3F
            RegisterType(typeof(Matrix3F), delegate(string value) { return(Matrix3F.Parse(value)); }, Matrix3F.Zero);

            //Mat3D
            RegisterType(typeof(Matrix3), delegate(string value) { return(Matrix3.Parse(value)); }, Matrix3.Zero);

            //Mat4F
            RegisterType(typeof(Matrix4F), delegate(string value) { return(Matrix4F.Parse(value)); }, Matrix4F.Zero);

            //Mat4D
            RegisterType(typeof(Matrix4), delegate(string value) { return(Matrix4.Parse(value)); }, Matrix4.Zero);

            //PlaneF
            RegisterType(typeof(PlaneF), delegate(string value) { return(PlaneF.Parse(value)); }, PlaneF.Zero);

            //PlaneD
            RegisterType(typeof(Plane), delegate(string value) { return(Plane.Parse(value)); }, Plane.Zero);

            //Transform
            RegisterType(typeof(Transform), delegate(string value) { return(Transform.Parse(value)); }, Transform.Identity);

            //UIMeasureValueDouble
            RegisterType(typeof(UIMeasureValueDouble), delegate(string value) { return(UIMeasureValueDouble.Parse(value)); }, new UIMeasureValueDouble());

            //UIMeasureValueVec2
            RegisterType(typeof(UIMeasureValueVector2), delegate(string value) { return(UIMeasureValueVector2.Parse(value)); }, new UIMeasureValueVector2());

            //UIMeasureValueRect
            RegisterType(typeof(UIMeasureValueRectangle), delegate(string value) { return(UIMeasureValueRectangle.Parse(value)); }, new UIMeasureValueRectangle());

            RegisterType(typeof(RangeVector3F), delegate(string value) { return(RangeVector3F.Parse(value)); }, RangeVector3F.Zero);
            RegisterType(typeof(RangeColorValue), delegate(string value) { return(RangeColorValue.Parse(value)); }, RangeColorValue.Zero);

            //no Parse methods. This is complex structures. This is not simple types? or just can't parse?
            //Box
            //Capsule
            //Cone
            //Line3
            //Line2
            //Ray
            //Frustum?

            RegisterConvertDoubleToFloatTypes();
        }