예제 #1
0
        public AutoComplete(ChatControl chatControl)
        {
            //Font = Fonts.GetFont(Common.FontType.Small);

            //Fonts.FontChanged += (s, e) => Font = Fonts.GetFont(Common.FontType.Small);

            FormBorderStyle = FormBorderStyle.None;

            Padding       = new Padding(8, 4, 8, 4);
            ShowInTaskbar = false;

            StartPosition = FormStartPosition.Manual;
            SetStyle(ControlStyles.Selectable, false);
            this.DoubleBuffered = true;

            //AutoCompleteListBox.Location = new Point(81, 69);
            AutoCompleteListBox.Size = new Size(chatControl.Width < 300?chatControl.Width:300, 95);
            Size = AutoCompleteListBox.Size;
            AutoCompleteListBox.DrawMode  = DrawMode.OwnerDrawFixed;
            AutoCompleteListBox.DrawItem += new DrawItemEventHandler(ListBox_DrawItem);
            AutoCompleteListBox.Enabled   = false;
            this.Enabled = false;
            Controls.Add(AutoCompleteListBox);
            this._chatControl         = chatControl;
            AppSettings.ThemeChanged += (s, e) => setColors();
            setColors();
        }
예제 #2
0
 public void UpdateLocation(int left, int top)
 {
     this.Location            = new Point(left, top - this.Height);
     this._chatControl        = App.MainForm.Selected as ChatControl;
     AutoCompleteListBox.Size = new Size(_chatControl.Width < 300?_chatControl.Width:300, 95);
     Size = AutoCompleteListBox.Size;
 }
예제 #3
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            int index;

            index = AutoCompleteListBox.IndexFromPoint(e.X, e.Y);
            if (index != -1)
            {
                selected = index;
                AutoCompleteListBox.SetSelected(selected, true);
                this._chatControl = App.MainForm.Selected as ChatControl;
                _chatControl.SelectAutoComplete();
            }
            base.OnMouseClick(e);
        }
예제 #4
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);
            }
예제 #5
0
        //static Image getImage(string name)
        //{
        //    try
        //    {
        //        return Image.FromResource("Chatterino.Desktop.Assets." + name);
        //    }
        //    catch { }

        //    return null;
        //}

        // CONSTRUCTOR
        public ColumnTabPage()
        {
            AllowDrop = true;

            LayoutPreviewItem = new ColumnLayoutPreviewItem
            {
                Visible = false
            };
            LayoutPreviewItem.SetBounds(25, 25, 100, 100);
            Controls.Add(LayoutPreviewItem);

            // layout on item added/removed/bounds changed
            ColumnAdded += (s, e) =>
            {
                foreach (var w in e.Value.Widgets)
                {
                    Controls.Add(w);

                    //w.MouseUp += W_ButtonReleased;
                }

                layout();

                e.Value.WidgetAdded   += Value_WidgetAdded;
                e.Value.WidgetRemoved += Value_WidgetRemoved;
            };

            ColumnRemoved += (s, e) =>
            {
                foreach (var w in e.Value.Widgets)
                {
                    Controls.Remove(w);

                    //w.MouseUp -= W_ButtonReleased;
                }

                layout();

                e.Value.WidgetAdded   -= Value_WidgetAdded;
                e.Value.WidgetRemoved -= Value_WidgetRemoved;
            };

            SizeChanged += (s, e) =>
            {
                layout();

                Invalidate();
            };

            // Drag drop
            var lastDragPoint = new Point(10000, 10000);

            var dragColumn = -1;
            var dragRow    = -1;

            var MaxColumns = 10;
            var MaxRows    = 10;

            DragEnter += (s, e) =>
            {
                try
                {
                    var control = (ColumnLayoutDragDropContainer)e.Data.GetData(typeof(ColumnLayoutDragDropContainer));

                    if (control != null)
                    {
                        dragging = true;

                        lastDragPoint = new Point(10000, 10000);

                        e.Effect = e.AllowedEffect;
                        LayoutPreviewItem.Visible = true;
                    }
                }
                catch
                {
                }
            };
            DragLeave += (s, e) =>
            {
                if (dragging)
                {
                    dragging = false;
                    LayoutPreviewItem.Visible = false;
                }
            };
            DragDrop += (s, e) =>
            {
                if (dragging)
                {
                    dragging = false;
                    LayoutPreviewItem.Visible = false;

                    var container = (ColumnLayoutDragDropContainer)e.Data.GetData(typeof(ColumnLayoutDragDropContainer));

                    if (container != null /* && dragColumn != -1*/)
                    {
                        var control = container.Control;

                        AddWidget(control, dragColumn, dragRow);

                        //if (dragRow == -1)
                        //{
                        //    InsertColumn(dragColumn, new ChatColumn(control));
                        //}
                        //else
                        //{
                        //    ChatColumn row = Columns.ElementAt(dragColumn);
                        //    row.InsertWidget(dragRow, control);
                        //}
                    }
                }
            };

            DragOver += (s, e) =>
            {
                if (dragging)
                {
                    var mouse = PointToClient(new Point(e.X, e.Y));

                    if (lastDragPoint != mouse)
                    {
                        lastDragPoint = mouse;
                        var totalWidth = Width;

                        if (ColumnCount == 0)
                        {
                            LayoutPreviewItem.Bounds  = new Rectangle(8, 8, Width - 16, Height - 16);
                            LayoutPreviewItem.Visible = true;

                            dragColumn = -1;
                            dragRow    = -1;

                            e.Effect = DragDropEffects.Move;
                            LayoutPreviewItem.IsError = false;
                        }
                        else
                        {
                            var columnWidth = (double)totalWidth / ColumnCount;

                            dragColumn = -1;
                            dragRow    = -1;

                            // insert new column
                            for (var i = (ColumnCount >= MaxColumns ? 1 : 0); i < (ColumnCount >= MaxColumns ? ColumnCount : ColumnCount + 1); i++)
                            {
                                if (mouse.X > i * columnWidth - columnWidth / 4 &&
                                    mouse.X < i * columnWidth + columnWidth / 4)
                                {
                                    dragColumn = i;

                                    var bounds = new Rectangle((int)(i * columnWidth - columnWidth / 4), 0, (int)(columnWidth / 2), Height);

                                    if (LayoutPreviewItem.Bounds != bounds)
                                    {
                                        LayoutPreviewItem.Bounds = bounds;
                                        LayoutPreviewItem.Invalidate();
                                    }
                                    break;
                                }
                            }

                            // insert new row
                            if (dragColumn == -1)
                            {
                                for (var i = 0; i < ColumnCount; i++)
                                {
                                    if (mouse.X < (i + 1) * columnWidth)
                                    {
                                        var rows      = Columns.ElementAt(i);
                                        var rowHeight = (double)Height / rows.WidgetCount;

                                        for (var j = 0; j < rows.WidgetCount + 1; j++)
                                        {
                                            if (mouse.Y > j * rowHeight - rowHeight / 2 &&
                                                mouse.Y < j * rowHeight + rowHeight / 2)
                                            {
                                                if (rows.WidgetCount < MaxRows)
                                                {
                                                    dragColumn = i;
                                                    dragRow    = j;
                                                }

                                                var bounds = new Rectangle((int)(i * columnWidth), (int)(j * rowHeight - rowHeight / 2), (int)columnWidth, (int)(rowHeight));
                                                if (LayoutPreviewItem.Bounds != bounds)
                                                {
                                                    LayoutPreviewItem.Bounds = bounds;
                                                    LayoutPreviewItem.Invalidate();
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }

                            LayoutPreviewItem.IsError = dragColumn == -1;
                            e.Effect = dragColumn == -1 ? DragDropEffects.None : DragDropEffects.Move;
                        }
                    }
                }
            };

            // Add chat control
            checkAddChatControl();

            addChatControl.Click += (s, e) =>
            {
                var chatControl = new ChatControl();

                using (var dialog = new InputDialogForm("channel name")
                {
                    Value = ""
                })
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        chatControl.ChannelName = dialog.Value;
                    }
                }

                AddColumn(new ChatColumn(chatControl));
            };
        }
예제 #6
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);
        }