예제 #1
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);
        }
예제 #2
0
            // Constructor
            public ChatControlHeader(ChatControl chatControl)
            {
                _chatControl = chatControl;

                this.SetTooltip(tooltipValue);

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

                Height = TopMenuBarHeight + 1;

                // Mousedown
                var mouseDown = false;

                MouseDown += (s, e) =>
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        mouseDown = true;
                        chatControl.Select();
                    }
                };
                MouseUp += (s, e) =>
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        mouseDown = false;
                    }
                };

                // Drag + Drop
                MouseMove += (s, e) =>
                {
                    if (mouseDown)
                    {
                        if (e.X < 0 || e.Y < 0 || e.X > Width || e.Y > Height)
                        {
                            var layout = chatControl.Parent as ColumnTabPage;
                            if (layout != null)
                            {
                                var position = layout.RemoveWidget(chatControl);
                                if (
                                    DoDragDrop(new ColumnLayoutDragDropContainer {
                                    Control = chatControl
                                },
                                               DragDropEffects.Move) == DragDropEffects.None)
                                {
                                    layout.AddWidget(chatControl, position.Item1, position.Item2);
                                }
                            }
                        }
                    }
                };

                // Buttons
                var button = DropDownButton = new FlatButton
                {
                    Height   = Height - 2,
                    Width    = Height - 2,
                    Location = new Point(1, 1),
                    Image    = Properties.Resources.tool_moreCollapser_off16
                };

                button.MouseDown += (s, e) =>
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        chatControl.Select();
                    }
                };
                button.Click += (s, e) =>
                {
                    _selected = chatControl;
                    _contextMenu.Show(this, new Point(Location.X, Location.Y + Height));
                };

                Controls.Add(button);

                RoomstateButton = button = new FlatButton
                {
                    Height      = Height - 2,
                    Width       = Height - 2,
                    MinimumSize = new Size(Height - 2, Height - 2),
                    Location    = new Point(Width - Height, 1),
                    Anchor      = AnchorStyles.Top | AnchorStyles.Right
                };
                button.Text       = "-";
                button.MouseDown += (s, e) =>
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        chatControl.Select();
                    }
                };
                button.Click += (s, e) =>
                {
                    _selected = chatControl;
                    _roomstateContextMenu.Show(this, new Point(Location.X + Width, Location.Y + Height),
                                               LeftRightAlignment.Left);
                };

                Controls.Add(button);
            }