예제 #1
0
        public void ResizeChatDialogByDelta(int delta)
        {
            if (chatSize + delta < 7 || chatSize + delta > 11)
            {
                return;
            }
            chatSize += delta;

            var updatedSize = delta * 30; //Incease or decrease by 30px

            var histStyle = ChatHistoryText.TextStyle.Clone();

            histStyle.Size            = chatSize;
            ChatHistoryText.TextStyle = histStyle;

            this.SetSize((int)Math.Round(this.Size.X) + updatedSize, (int)Math.Round(this.Size.Y) + updatedSize);

            ChatHistoryBackground.SetSize(ChatHistoryBackground.Size.X + updatedSize, ChatHistoryBackground.Size.Y + updatedSize);
            ChatHistoryText.SetSize(ChatHistoryBackground.Size.X - 19, ChatHistoryBackground.Size.Y - 16);

            ChatHistorySlider.Position = new Vector2(ChatHistorySlider.Position.X + updatedSize, ChatHistorySlider.Position.Y);
            ChatHistorySlider.SetSize(ChatHistorySlider.Size.X, ChatHistoryBackground.Size.Y - 26);
            ChatHistoryScrollUpButton.Position   = new Vector2(ChatHistoryScrollUpButton.Position.X + updatedSize, ChatHistoryScrollUpButton.Position.Y);
            ChatHistoryScrollDownButton.Position = new Vector2(ChatHistoryScrollDownButton.Position.X + updatedSize, ChatHistoryScrollDownButton.Position.Y + updatedSize);

            ChatEntryTextEdit.Position = new Vector2(ChatEntryTextEdit.Position.X, ChatEntryTextEdit.Position.Y + updatedSize);
            ChatEntryTextEdit.SetSize(ChatEntryTextEdit.Size.X, ChatEntryTextEdit.Size.Y);
            ChatEntryBackground.Position = new Vector2(ChatEntryBackground.Position.X, ChatEntryBackground.Position.Y + updatedSize);
            ChatEntryBackground.SetSize(ChatEntryBackground.Size.X + updatedSize, ChatEntryBackground.Size.Y);

            ChatEntryTextEdit.ComputeDrawingCommands();
            ChatHistoryText.ComputeDrawingCommands();
        }
예제 #2
0
        private void ChangeSizeTo(Vector2 size)
        {
            if (Size == size && LastCategories == Categories.HasButtons)
            {
                return;
            }

            var wasAtBottom = ChatHistoryText.VerticalScrollPosition == ChatHistoryText.VerticalScrollMax;

            var delta = size.ToPoint().ToVector2() - Size;

            if (LastCategories != Categories.HasButtons)
            {
                var yDelta = Categories.HasButtons ? 10 : -10;
                foreach (var child in Children)
                {
                    if (child != Categories && child != Background)
                    {
                        child.Y += yDelta;
                    }
                }
                LastCategories = Categories.HasButtons;
                delta.Y       -= yDelta;
            }

            this.SetSize((int)size.X, (int)size.Y);

            ChatHistoryBackground.SetSize(ChatHistoryBackground.Size.X + delta.X, ChatHistoryBackground.Size.Y + delta.Y);
            ChatHistoryText.SetSize(ChatHistoryBackground.Size.X - 19, ChatHistoryBackground.Size.Y - 16);

            ChatHistorySlider.Position = new Vector2(ChatHistorySlider.Position.X + delta.X, ChatHistorySlider.Position.Y);
            ChatHistorySlider.SetSize(ChatHistorySlider.Size.X, ChatHistoryBackground.Size.Y - 26);
            ChatHistoryScrollUpButton.Position   = new Vector2(ChatHistoryScrollUpButton.Position.X + delta.X, ChatHistoryScrollUpButton.Position.Y);
            ChatHistoryScrollDownButton.Position = new Vector2(ChatHistoryScrollDownButton.Position.X + delta.X, ChatHistoryScrollDownButton.Position.Y + delta.Y);

            ChatEntryTextEdit.Position = new Vector2(ChatEntryTextEdit.Position.X, ChatEntryTextEdit.Position.Y + delta.Y);
            ChatEntryTextEdit.SetSize(ChatEntryTextEdit.Size.X + delta.X, ChatEntryTextEdit.Size.Y);
            ChatEntryBackground.Position = new Vector2(ChatEntryBackground.Position.X, ChatEntryBackground.Position.Y + delta.Y);
            ChatEntryBackground.SetSize(ChatEntryBackground.Size.X + delta.X, ChatEntryBackground.Size.Y);

            ChatEntryTextEdit.ComputeDrawingCommands();
            ChatHistoryText.ComputeDrawingCommands();

            if (wasAtBottom)
            {
                ChatHistoryText.VerticalScrollPosition = ChatHistoryText.VerticalScrollMax;
            }
        }