void Awake()
    {
        if (BaseInstance != null && this != BaseInstance)
        {
            //There is already a copy of this script running
            Destroy(this);
            return;
        }

        BaseInstance = this;

        // Init();
    }
Esempio n. 2
0
        public void Show(int x, int y, int width, int height)
        {
            if (GlobalManager.Renderer is Office2007Renderer)
            {
                Office2007ColorTable table = ((Office2007Renderer)GlobalManager.Renderer).ColorTable;
                _ResizeGripColors = new ResizeGripColors(table.Form.BackColor, table.LegacyColors.SplitterBackground2, table.LegacyColors.BarStripeColor);
            }
            else
                _ResizeGripColors = new ResizeGripColors(SystemColors.ButtonFace, Color.White, SystemColors.ControlDark);

            Control hostControl = GetHostedControl();
            if (hostControl == null)
                return;

            _CanResizeHostControl = true;
            _CanResizePopup = true;

            this.Size = new Size(1, 1);
            base.Show(x, y);

            _CanResizeHostControl = false;
            _CanResizePopup = false;

            UpdateContentBasedSize(width);

            if (_CloseButtonVisible && IsResizeGripShown)
            {
                if (_CloseButtonController == null)
                {
                    ButtonItem button = new ButtonItem();
                    button.Symbol = "\uf00d";
                    button.SymbolSize = 8;
                    button.Style = eDotNetBarStyle.StyleManagerControlled;
                    button.ButtonStyle = eButtonStyle.ImageAndText;
                    button.LeftInternal = 1;
                    button.Click += new EventHandler(ClosePopupButtonClick);
                    _CloseButtonController = new BaseItemController(button, this);
                    button.RecalcSize();
                    button.TopInternal = this.Height - button.HeightInternal - 1;
                }
            }
            else if (_CloseButtonController != null)
            {
                _CloseButtonController.Dispose();
                _CloseButtonController = null;
            }

            if (_RefreshSize)
                UpdateHostControlSize();

            if (y > Top && y <= Bottom)
            {
                Top = y - Height - (height != -1 ? height : 0);

                ePopupResizeEdge previous = ResizeEdge;
                if (ResizeEdge == ePopupResizeEdge.BottomLeft)
                    ResizeEdge = ePopupResizeEdge.TopLeft;
                else if (ResizeEdge == ePopupResizeEdge.BottomRight)
                    ResizeEdge = ePopupResizeEdge.TopRight;

                if (ResizeEdge != previous)
                    UpdateHostControlSize();
            }

            hostControl.SizeChanged += HostControlSizeChanged;
        }