Ejemplo n.º 1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            var g = App.UseDirectX ? null : CreateGraphics();

            if (e.Button == MouseButtons.Left)
            {
                mdown = true;

                if (Logic.Message != null)
                {
                    Logic.SetSelectionEnd(Logic.SelectionStart = getIndexFromMessagePosition(Logic.Message.MessagePositionAtPoint(g, new CommonPoint(e.X - messagePadding.Left, e.Y - messagePadding.Top), 0)));
                }
            }

            g?.Dispose();

            chatControl.Focus();

            base.OnMouseClick(e);
        }
Ejemplo n.º 2
0
        public ChatInputControl(ChatControl chatControl)
        {
            Size = new Size(100, 100);

            var caretBlinkInterval = SystemInformation.CaretBlinkTime;

            if (caretBlinkInterval > 0)
            {
                caretBlinkTimer = new Timer {
                    Interval = SystemInformation.CaretBlinkTime
                };

                caretBlinkTimer.Tick += (s, e) =>
                {
                    if (caretRect != null)
                    {
                        using (var g = CreateGraphics())
                        {
                            caretBlinkState = !caretBlinkState;
                        }
                    }
                };
            }

            Cursor = Cursors.IBeam;

            SetStyle(ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);

            this.chatControl = chatControl;

            {
                var g = App.UseDirectX ? null : CreateGraphics();

                Height = minHeight = GuiEngine.Current.MeasureStringSize(g, FontType.Medium, "X").Height + 8 + messagePadding.Top + messagePadding.Bottom;

                g?.Dispose();
            }

            if (AppSettings.ChatHideInputIfEmpty && Logic.Text.Length == 0)
            {
                Visible = false;
            }

            Logic.Changed += (sender, e) =>
            {
                if (Logic.Text.StartsWith("/r "))
                {
                    if (IrcManager.LastReceivedWhisperUser != null)
                    {
                        var s = "/w " + IrcManager.LastReceivedWhisperUser + Logic.Text.Substring(2);
                        Logic.SetText(s);
                        Logic.SetCaretPosition(s.Length - 1);
                        return;
                    }
                }

                if (AppSettings.ChatHideInputIfEmpty && Logic.Text.Length == 0)
                {
                    Visible = false;
                }
                else
                {
                    Visible = true;
                }

                if (Logic.SelectionLength != 0)
                {
                    chatControl.ClearSelection();
                }

                if (caretBlinkTimer != null)
                {
                    caretBlinkTimer.Stop();
                    caretBlinkTimer.Start();
                }

                caretBlinkState = true;

                calculateBounds();
                Invalidate();
            };

            // emote button
            emoteListButton = new FlatButton
            {
                Image  = (Image)GuiEngine.Current.ScaleImage(Properties.Resources.Emoji_Color_1F607_19, 0.85),
                Anchor = AnchorStyles.Right | AnchorStyles.Bottom,
                Size   = new Size(16, 16),
                Cursor = Cursors.Default
            };
            emoteListButton.Location = new Point(Width - emoteListButton.Width - 1, Height - emoteListButton.Height - 1);

            emoteListButton.Click += (s, e) =>
            {
                chatControl.Focus();
                App.ShowEmoteList(chatControl.Channel);
                App.EmoteList.BringToFront();
            };

            Controls.Add(emoteListButton);
        }