public void Load(IPersistStream stream)
        {
            _useRefScale = (bool)stream.Load("useRefScale", true);

            ScaleRendererPersist persist;

            while ((persist = stream.Load("ScaleRenderer", null, new ScaleRendererPersist(new ScaleRenderer(null))) as ScaleRendererPersist) != null)
            {
                _renderers.Add(persist.ScaleRenderer);
            }
        }
Exemple #2
0
        public IEnumerator TransitioningSprite(Sprite sprite, float speed, bool smooth)
        {
            for (int i = 0; i < RendererList.Count; i++)
            {
                Image image = RendererList[i];
                if (image.sprite == sprite)
                {
                    RenderLayer.CurrentRenderer = image;
                    break;
                }
            }
            if (!IsCurrent(sprite))
            {
                Image image = Object
                              .Instantiate(RenderLayer.CurrentRenderer.gameObject, RenderLayer.CurrentRenderer.transform.parent)
                              .GetComponent <Image>();
                RendererList.Add(image);
                RenderLayer.CurrentRenderer = image;
                image.color  = GraphicHelpers.SetAlpha(image.color, 0f);
                image.sprite = sprite;
            }

            while (TransitionImages(speed, smooth))
            {
                yield return(new WaitForEndOfFrame());
            }

            EndTransition();
        }
Exemple #3
0
        protected override void OnActivate()
        {
            this.toolCursor          = new Cursor(PdnResources.GetResourceStream("Cursors.GenericToolCursor.cur"));
            this.toolMouseDownCursor = new Cursor(PdnResources.GetResourceStream("Cursors.GenericToolCursorMouseDown.cur"));
            this.Cursor   = this.toolCursor;
            this.toolIcon = this.Image;

            this.startNub         = new MoveNubRenderer(RendererList);
            this.startNub.Visible = false;
            this.startNub.Shape   = MoveNubShape.Circle;
            RendererList.Add(this.startNub, false);

            this.endNub         = new MoveNubRenderer(RendererList);
            this.endNub.Visible = false;
            this.endNub.Shape   = MoveNubShape.Circle;
            RendererList.Add(this.endNub, false);

            this.moveNubs =
                new MoveNubRenderer[]
            {
                this.startNub,
                this.endNub
            };

            AppEnvironment.PrimaryColorChanged   += new EventHandler(RenderBecauseOfEvent);
            AppEnvironment.SecondaryColorChanged += new EventHandler(RenderBecauseOfEvent);
            AppEnvironment.GradientInfoChanged   += new EventHandler(RenderBecauseOfEvent);
            AppEnvironment.AlphaBlendingChanged  += new EventHandler(RenderBecauseOfEvent);
            AppWorkspace.UnitsChanged            += new EventHandler(RenderBecauseOfEvent);

            base.OnActivate();
        }
Exemple #4
0
        public void Load(IPersistStream stream)
        {
            ScaleRendererPersist persist;

            while ((persist = stream.Load("ScaleRenderer", null, new ScaleRendererPersist(new ScaleRenderer(null))) as ScaleRendererPersist) != null)
            {
                _renderers.Add(persist.ScaleRenderer);
            }
        }
Exemple #5
0
        protected override void OnActivate()
        {
            // Assume that SetCursors() has been called by now

            Cursor = GetCursor();
            DocumentWorkspace.EnableSelectionTinting = true;

            NewSelection         = new Selection();
            NewSelectionRenderer = new SelectionRenderer(RendererList, NewSelection, DocumentWorkspace)
            {
                EnableSelectionTinting = false,
                EnableOutlineAnimation = false,
                Visible = false
            };
            RendererList.Add(NewSelectionRenderer, true);

            base.OnActivate();
        }
Exemple #6
0
    public void Capture(bool split)
    {
        Vector2 topLeft, bottomRight;

        Vector3[] data;
        topLeft.x = Mathf.Min(Target.GetComponentsInChildren <Node>().Where(x => x.tag == "Block").Min(x => x.GetWidthLimits().x), Target.GetComponentsInChildren <LineRenderer>().Min(
                                  x =>
        {
            data = new Vector3[x.positionCount];
            x.GetPositions(data);
            return(x.transform.position.x + data.Min(q => q.x));
        }));
        topLeft.y     = Target.GetComponentsInChildren <Transform>().Where(x => x.tag == "Block").Max(x => x.position.y);
        bottomRight.x = Mathf.Max(Target.GetComponentsInChildren <Node>().Where(x => x.tag == "Block").Max(x => x.GetWidthLimits().y), Target.GetComponentsInChildren <LineRenderer>().Max(
                                      x =>
        {
            data = new Vector3[x.positionCount];
            x.GetPositions(data);
            return(x.transform.position.x + data.Max(q => q.x));
        }));
        bottomRight.y = Target.GetComponentsInChildren <Transform>().Where(x => x.tag == "Block").Min(x => x.position.y);
        if (!split)
        {
            float ratio = Screen.width / (float)Screen.height;
            float size  = Mathf.Max((bottomRight.x - topLeft.x + Padding) / 2 / ratio, (topLeft.y - bottomRight.y + Padding) / 2);
            Camera.orthographicSize = size;
            Camera.rect             = new Rect(0, 0, (bottomRight.x - topLeft.x + Padding) / (topLeft.y - bottomRight.y + Padding), 1);
            RendererList.Add((topLeft + bottomRight) / 2f);
            Camera.transform.position  = (topLeft + bottomRight) / 2f;
            Camera.transform.position += Vector3.back;
        }
        else
        {
            Camera.rect             = new Rect(0, 0, 1, 1);
            Camera.orthographicSize = 500;
            float height = Camera.orthographicSize;
#if UNITY_EDITOR
            float width = Camera.orthographicSize / Screen.currentResolution.height * Screen.currentResolution.width;
#else
            float width = Camera.orthographicSize / Screen.height * Screen.width;
#endif
            var sPoint = topLeft + new Vector2(width - Padding, -height + Padding);
            Camera.transform.position = sPoint;
            RendererList.Clear();
            do
            {
                do
                {
                    //var g = new GameObject(Camera.transform.position.ToString());
                    //g.transform.position = transform.position;
                    //GameObject.Instantiate(Camera.gameObject,Camera.transform.position, Quaternion.identity);
                    RendererList.Add(transform.position);
                    Camera.transform.Translate(new Vector2(0, -height * 2), Space.World);
                }while (Camera.transform.position.y + height - Padding > bottomRight.y);

                Camera.transform.position = new Vector2(Camera.transform.position.x + width * 2, sPoint.y);
            }while (Camera.transform.position.x - width + Padding < bottomRight.x);
        }

        filePath = GetScreenCapturePath();
    }