Inheritance: IVisible, IRenderableIpso
        public void HandleXnaInitialize(SystemManagers managers)
        {
            mManagers = managers;

            mSprite = new Sprite(null);
            mSprite.Visible = false;
            mManagers.SpriteManager.Add(mSprite);

            mOutlineRectangle = new RenderingLibrary.Math.Geometry.LineRectangle(mManagers);
            mOutlineRectangle.Visible = false;
            mManagers.ShapeManager.Add(mOutlineRectangle);
            mOutlineRectangle.Color = new Microsoft.Xna.Framework.Color(
                1.0f, 1.0f, 1.0f, .5f);

            mHighlightRectangle = new RenderingLibrary.Math.Geometry.LineRectangle(mManagers);
            mHighlightRectangle.Visible = false;
            mManagers.ShapeManager.Add(mHighlightRectangle);
            mHighlightRectangle.Color = new Microsoft.Xna.Framework.Color(
                1.0f, 1.0f, 1.0f, 1.0f);

            HandleWindowResize();
            mCursor = new InputLibrary.Cursor();
            mCursor.Initialize(mControl);
            mCameraPanningLogic = new CameraPanningLogic(mControl, managers, mCursor, mKeyboard);
            mCameraPanningLogic.Panning += delegate
            {
                ApplicationEvents.Self.CallAfterWireframePanning();
            };

            mManagers.Renderer.Camera.CameraCenterOnScreen = CameraCenterOnScreen.TopLeft;
            mManagers.Renderer.SamplerState = Microsoft.Xna.Framework.Graphics.SamplerState.PointClamp;

            mControl.KeyDown += HandleXnaControlKeyDown;
            mControl.KeyPress += HandleXnaControlKeyPress;
        }
        public void HandleXnaInitialize(SystemManagers managers)
        {
            mManagers = managers;

            mSprite = new Sprite(null);
            mSprite.Visible = false;
            mManagers.SpriteManager.Add(mSprite);

            mOutlineRectangle = new RenderingLibrary.Math.Geometry.LineRectangle(mManagers);
            mOutlineRectangle.Visible = false;
            mManagers.ShapeManager.Add(mOutlineRectangle);
            mOutlineRectangle.Color = new Microsoft.Xna.Framework.Color(
                1.0f, 1.0f, 1.0f, .5f);

            mHighlightRectangle = new RenderingLibrary.Math.Geometry.LineRectangle(mManagers);
            mHighlightRectangle.Visible = false;
            mManagers.ShapeManager.Add(mHighlightRectangle);
            mHighlightRectangle.Color = new Microsoft.Xna.Framework.Color(
                1.0f, 1.0f, 1.0f, 1.0f);

            HandleWindowResize();
            mCursor = new InputLibrary.Cursor();
            mCursor.Initialize(mControl);
            mCameraPanningLogic = new CameraPanningLogic(mControl, managers, mCursor, mKeyboard);
            mManagers.Renderer.SamplerState = Microsoft.Xna.Framework.Graphics.SamplerState.PointClamp;
        }
        internal static bool TryHandleAsBaseType(string baseType, SystemManagers systemManagers, out IRenderable containedObject)
        {
            bool handledAsBaseType = true;
            containedObject = null;

            switch (baseType)
            {

                case "Container":

                    LineRectangle lineRectangle = new LineRectangle(systemManagers);
                    containedObject = lineRectangle;
                    break;

                case "Rectangle":
                    LineRectangle rectangle = new LineRectangle();
                    rectangle.IsDotted = false;
                    containedObject = rectangle;
                    break;
                case "Circle":
                    LineCircle circle = new LineCircle();
                    circle.CircleOrigin = CircleOrigin.TopLeft;
                    containedObject = circle;
                    break;

                case "ColoredRectangle":
                    SolidRectangle solidRectangle = new SolidRectangle();
                    containedObject = solidRectangle;
                    break;
                case "Sprite":
                    Texture2D texture = null;

                    Sprite sprite = new Sprite(texture);
                    containedObject = sprite;

                    break;
                case "NineSlice":
                    {
                        NineSlice nineSlice = new NineSlice();
                        containedObject = nineSlice;
                    }
                    break;
                case "Text":
                    {
                        Text text = new Text(systemManagers, "");
                        containedObject = text;
                    }
                    break;
                default:
                    handledAsBaseType = false;
                    break;
            }

            return handledAsBaseType;
        }
Exemple #4
0
        public void Add(LineRectangle lineRectangle, Layer layer)
        {
            if (layer == null)
            {
                layer = Renderer.LayersWritable[0];
            }

            mRectangles.Add(lineRectangle);

            layer.Add(lineRectangle);
        }
Exemple #5
0
        public void Add(LineRectangle lineRectangle, Layer layer)
        {
            if (layer == null)
            {
                layer = Renderer.LayersWritable[0];
            }

            mRectangles.Add(lineRectangle);

            layer.Add(lineRectangle);
        }
        public TilePropertyHighlight(SystemManagers managers)
        {
            Children = new List<IRenderableIpso>();
            mManagers = managers;
            mLineRectangle = new LineRectangle(mManagers);
            mLineRectangle.Width = 16;
            mLineRectangle.Height = 16;
            mLineRectangle.Z = 1;
            mLineRectangle.Parent = this;

            mLineRectangle.Color = new Microsoft.Xna.Framework.Color(1, 1, 1, .3f);

            mCountDisplay = new Text(mManagers, "99");
            mCountDisplay.HorizontalAlignment = HorizontalAlignment.Left;
            mCountDisplay.VerticalAlignment = VerticalAlignment.Top;
            mCountDisplay.Z = 1;
            mCountDisplay.Parent = this;
        }
Exemple #7
0
        LineRectangle GetOrMakeRectangleAtIndex(int i)
        {
            if (i < mHighlightRectangles.Count)
            {
                mHighlightRectangles[i].Visible = true;
                return mHighlightRectangles[i];
            }
            else
            {

                LineRectangle newRect = new LineRectangle();
                newRect.Color = Color.Yellow;
                newRect.Visible = true;
                mHighlightRectangles.Add(newRect);
                ShapeManager.Self.Add(newRect, mUiLayer);

                return newRect;
            }
        }
Exemple #8
0
 public void Remove(LineRectangle linePrimitive)
 {
     // todo:  Need to make this remove from whatever Layer the line rectangle is on
     mRectangles.Remove(linePrimitive);
     Renderer.RemoveRenderable(linePrimitive);
 }
Exemple #9
0
        public void Initialize(WireframeEditControl wireframeEditControl)
        {
            try
            {
                mWireframeEditControl = wireframeEditControl;

                mWireframeEditControl.ZoomChanged += HandleZoomChanged;

                Renderer.Self.Initialize(GraphicsDevice, null);

                Renderer.Self.SamplerState = SamplerState.PointWrap;

                LoaderManager.Self.ContentLoader = new ContentLoader();

                LoaderManager.Self.Initialize(null, "content/TestFont.fnt", Services, null);
                CameraController.Self.Initialize(Camera, mWireframeEditControl, Width, Height);

                InputLibrary.Cursor.Self.Initialize(this);
                InputLibrary.Keyboard.Self.Initialize(this);

                mScreenBounds = new LineRectangle();
                mScreenBounds.Width = 800;
                mScreenBounds.Height = 600;
                mScreenBounds.Color = ScreenBoundsColor;
                ShapeManager.Self.Add(mScreenBounds, SelectionManager.Self.UiLayer);

                this.KeyDown += OnKeyDown;
                this.KeyPress += OnKeyPress;
                this.MouseDown += CameraController.Self.HandleMouseDown;
                this.MouseMove += CameraController.Self.HandleMouseMove;
                this.MouseWheel += CameraController.Self.HandleMouseWheel;
                this.mTopRuler = new Ruler(this, null, InputLibrary.Cursor.Self);
                mLeftRuler = new Ruler(this, null, InputLibrary.Cursor.Self);
                mLeftRuler.RulerSide = RulerSide.Left;

                if (AfterXnaInitialize != null)
                {
                    AfterXnaInitialize(this, null);
                }

                UpdateToProject();

                mHasInitialized = true;

                SystemManagers.Default = SystemManagers.CreateFromSingletons();
            }
            catch(Exception exception)
            {
                MessageBox.Show("Error initializing the wireframe control\n\n" + exception);
            }
        }
Exemple #10
0
        private void RenderUsingBitmapFont(SpriteRenderer spriteRenderer, SystemManagers managers)
        {
            if (mTempForRendering == null)
            {
                mTempForRendering = new LineRectangle(managers);
            }

            mTempForRendering.X = this.X;
            mTempForRendering.Y = this.Y;
            mTempForRendering.Width = this.mTextureToRender.Width * mFontScale;
            mTempForRendering.Height = this.mTextureToRender.Height * mFontScale;

            //mTempForRendering.Parent = this.Parent;

            float widthDifference = this.EffectiveWidth - mTempForRendering.Width;

            if (this.HorizontalAlignment == Graphics.HorizontalAlignment.Center)
            {
                mTempForRendering.X += widthDifference / 2.0f;
            }
            else if (this.HorizontalAlignment == Graphics.HorizontalAlignment.Right)
            {
                mTempForRendering.X += widthDifference;
            }

            if (this.VerticalAlignment == Graphics.VerticalAlignment.Center)
            {
                mTempForRendering.Y += (this.EffectiveHeight - mTextureToRender.Height) / 2.0f;
            }
            else if (this.VerticalAlignment == Graphics.VerticalAlignment.Bottom)
            {
                mTempForRendering.Y += this.EffectiveHeight - mTempForRendering.Height;
            }

            if(this.Parent != null)
            {
                mTempForRendering.X += Parent.GetAbsoluteX();
                mTempForRendering.Y += Parent.GetAbsoluteY();

            }

            if (mBitmapFont?.AtlasedTexture != null)
            {
                mBitmapFont.RenderAtlasedTextureToScreen(mWrappedText, this.HorizontalAlignment, mTextureToRender.Height,
                    new Color(mRed, mGreen, mBlue, mAlpha), Rotation, mFontScale, managers,spriteRenderer, this);
            }
            else
            {
                Sprite.Render(managers, spriteRenderer, mTempForRendering, mTextureToRender,
                    new Color(mRed, mGreen, mBlue, mAlpha), null, false, false, Rotation, treat0AsFullDimensions: false,
                    objectCausingRenering: this);
                
            }
        }
Exemple #11
0
 public void Remove(LineRectangle linePrimitive)
 {
     // todo:  Need to make this remove from whatever Layer the line rectangle is on
     mRectangles.Remove(linePrimitive);
     Renderer.RemoveRenderable(linePrimitive);
 }
Exemple #12
0
        private void SetLineRectangleAroundIpso(LineRectangle rectangle, IPositionedSizedObject pso)
        {
            float adjustedSelectionBorder = SelectionBorder / Renderer.Self.Camera.Zoom;

            rectangle.Visible = true;
            rectangle.X = pso.GetAbsoluteX() - adjustedSelectionBorder;
            rectangle.Y = pso.GetAbsoluteY() - adjustedSelectionBorder;

            rectangle.Width = pso.Width + adjustedSelectionBorder * 2;
            rectangle.Height = pso.Height + adjustedSelectionBorder * 2;
        }
        public void Initialize(ImageRegionSelectionControl control, SystemManagers managers, WireframeEditControls wireframeControl)
        {
            mManagers = managers;
            mManagers.Renderer.SamplerState = SamplerState.PointClamp;


            mControl = control;


            mManagers.Renderer.Camera.CameraCenterOnScreen = CameraCenterOnScreen.TopLeft;

            mWireframeControl = wireframeControl;
            mWireframeControl.WandSelectionChanged += ReactToMagicWandChange;

            mControl.RegionChanged += new EventHandler(HandleRegionChanged);

            mControl.MouseWheelZoom += new EventHandler(HandleMouseWheelZoom);
            mControl.AvailableZoomLevels = mWireframeControl.AvailableZoomLevels;

            mControl.XnaUpdate += new Action(HandleXnaUpdate);
            mControl.Panning += HandlePanning;

            mSpriteOutline = new LineRectangle(managers);
            managers.ShapeManager.Add(mSpriteOutline);
            mSpriteOutline.Visible = false;
            mSpriteOutline.Color = OutlineColor;

            mLineGrid = new LineGrid(managers);
            managers.ShapeManager.Add(mLineGrid);
            mLineGrid.Visible = false;
            mLineGrid.Color = OutlineColor;

            mControl.Click += new EventHandler(HandleClick);

            mStatusText = new StatusTextController(managers);
            mControl_XnaInitialize();
        }
Exemple #14
0
 public void Add(LineRectangle lineRectangle)
 {
     Add(lineRectangle, Renderer.LayersWritable[0]);
 }
Exemple #15
0
 public void Add(LineRectangle lineRectangle)
 {
     Add(lineRectangle, Renderer.LayersWritable[0]);
 }
Exemple #16
0
 public void Remove(LineRectangle linePrimitive)
 {
     mRectangles.Remove(linePrimitive);
     Renderer.RemoveRenderable(linePrimitive);
 }
        public RectangleSelector(SystemManagers managers)
        {
            HandleSize = 4;
            ResetsCursorIfNotOver = true;
            mShowHandles = true;
            mHandles = new List<LineCircle>();
            mLineRectangle = new LineRectangle(managers);

            for (int i = 0; i < 8; i++)
            {
                LineCircle lineCircle = new LineCircle(managers);
                lineCircle.Radius = HandleSize;
                mHandles.Add(lineCircle);
            }

            Width = 34;
            Height = 34;
        }
Exemple #18
0
        /// <summary>
        /// Used for rendering directly to screen with an atlased texture.
        /// </summary>
        public void RenderAtlasedTextureToScreen(List<string> lines, HorizontalAlignment horizontalAlignment,
            float textureToRenderHeight, Color color, float rotation, float fontScale, SystemManagers managers, SpriteRenderer spriteRenderer,
            object objectRequestingChange)
        {
            var textObject = (Text)objectRequestingChange;
            var point = new Point();
            int requiredWidth;
            int requiredHeight;
            List<int> widths;
            GetRequiredWithAndHeight(lines, out requiredWidth, out requiredHeight, out widths);

            int lineNumber = 0;

            if (mCharRect == null) mCharRect = new LineRectangle(managers);

            var yoffset = 0f;
            if (textObject.VerticalAlignment == Graphics.VerticalAlignment.Center)
            {
                yoffset = (textObject.EffectiveHeight - textureToRenderHeight) / 2.0f;
            }
            else if (textObject.VerticalAlignment == Graphics.VerticalAlignment.Bottom)
            {
                yoffset = textObject.EffectiveHeight - textureToRenderHeight * fontScale;
            }

            foreach (string line in lines)
            {
                // scoot over to leave room for the outline
                point.X = mOutlineThickness;

                if (horizontalAlignment == HorizontalAlignment.Right)
                {
                    point.X = (int)(textObject.Width - widths[lineNumber] * fontScale);
                }
                else if (horizontalAlignment == HorizontalAlignment.Center)
                {
                    point.X = (int)(textObject.Width - widths[lineNumber] * fontScale) / 2;
                }

                foreach (char c in line)
                {
                    Rectangle destRect;
                    int pageIndex;
                    var sourceRect = GetCharacterRect(c, lineNumber, ref point, out destRect, out pageIndex, textObject.FontScale);

                    var origin = new Point((int)textObject.X, (int)(textObject.Y + yoffset));
                    var rotate = (float)-(textObject.Rotation * System.Math.PI / 180f);

                    var rotatingPoint = new Point(origin.X + destRect.X, origin.Y + destRect.Y);
                    MathFunctions.RotatePointAroundPoint(new Point(origin.X, origin.Y), ref rotatingPoint, rotate);

                    mCharRect.X = rotatingPoint.X;
                    mCharRect.Y = rotatingPoint.Y;
                    mCharRect.Width = destRect.Width;
                    mCharRect.Height = destRect.Height;

                    if(textObject.Parent != null)
                    {
                        mCharRect.X += textObject.Parent.GetAbsoluteX();
                        mCharRect.Y += textObject.Parent.GetAbsoluteY();
                    }

                    Sprite.Render(managers, spriteRenderer, mCharRect, mTextures[0], color, sourceRect, false, false, rotation,
                        treat0AsFullDimensions: false, objectCausingRenering: objectRequestingChange);
                }
                point.X = 0;
                lineNumber++;
            }
        }
        void HandleXnaInitialize()
        {
            mManagers = new SystemManagers();
            mManagers.Initialize(mControl.GraphicsDevice);

            mManagers.Renderer.SamplerState = SamplerState.PointClamp;

            mManagers.Name = "Preview Window Managers";
            ShapeManager shapeManager = mManagers.ShapeManager;

            mSprite = new RenderingLibrary.Graphics.Sprite(null);


            mRectangle = new LineRectangle(mManagers);
            mManagers.ShapeManager.Add(mRectangle);
            // Move it in front of the Sprite
            mRectangle.Z = 1;

            mManagers.SpriteManager.Add(mSprite);

            mControl.Resize += new EventHandler(HandleResize);
            mControl.XnaUpdate += new Action(HandleXnaUpdate);
            MoveCameraToProperLocation();

            // We'll use Cursor.Self which is initialized and updated elsewhere
            // Actually looks like that's not the case.  We'll make a new one.
            mCursor = new Cursor();
            mCursor.Initialize(mControl);

            mKeyboard = new Keyboard();
            mKeyboard.Initialize(mControl);

            mLeftRuler = new Ruler(mControl, mManagers, mCursor);
            mLeftRuler.RulerSide = RulerSide.Left;

            mTopRuler = new Ruler(mControl, mManagers, mCursor);
            mTopRuler.RulerSide = RulerSide.Top;

            mManagers.Renderer.Camera.CameraCenterOnScreen = CameraCenterOnScreen.TopLeft;
            mManagers.Renderer.Camera.X = -50;
            mManagers.Renderer.Camera.Y = -50;

            cameraController = new CameraController(Camera, mManagers, mCursor, mControl, mTopRuler, mLeftRuler);

        }