Esempio n. 1
0
        public void ChangedEvent(object o, EventArgs e)
        {
            backColor    = chatFormSettings.BackgroundColor;
            BackColor    = backColor;
            textColor    = chatFormSettings.ForegroundColor;
            font         = chatFormSettings.Font;
            doAnimations = chatFormSettings.Animations;
            panelBorder  = chatFormSettings.PanelBorder;
            emoteSpacing = chatFormSettings.EmoteSpacing;

            if (FormBorderStyle != chatFormSettings.BorderStyle)
            {
                if (IsHandleCreated)
                {
                    Invoke((MethodInvoker)(() =>
                    {
                        FormBorderStyle = chatFormSettings.BorderStyle;
                    }));
                }
            }

            var differences = new Size[currentChatMessages.Count];

            if (IsHandleCreated)
            {
                Invoke((MethodInvoker)(() =>
                {
                    if (doSplitter != chatFormSettings.Splitter)
                    {
                        doSplitter = chatFormSettings.Splitter;
                    }
                    for (int i = differences.Length - 1; i >= 0; i--)
                    {
                        bool should = false;
                        MessageControl m = currentChatMessages[i];
                        Size oldSize = m.Size;
                        differences[i] = oldSize;
                        if (m is TwitchUserMessage u)
                        {
                            u.DoSplitter = doSplitter;
                            u.ForeColor = textColor;
                            u.BackColor = backColor;
                            u.PanelBorder = panelBorder;
                            if (u.EmoteSpacing != emoteSpacing)
                            {
                                u.EmoteSpacing = emoteSpacing;
                                should = true;
                            }
                            if (m.Font != font)
                            {
                                m.Font = font;
                                should = true;
                            }
                            if (should)
                            {
                                u.CalculateTextAndEmotes();
                            }
                            u.DrawContent(m.CreateGraphics());
                        }
                    }
                }));
            }
            Application.DoEvents();
            if (IsHandleCreated)
            {
                Invoke((MethodInvoker)(() =>
                {
                    for (int i = differences.Length - 1; i >= 0; i--)
                    {
                        var m = currentChatMessages[i];
                        int heightDifference = m.Size.Height - differences[i].Height;
                        for (int x = i; x >= 0; x--)
                        {
                            currentChatMessages[x].Location = new Point(currentChatMessages[x].Location.X, currentChatMessages[x].Location.Y - heightDifference);
                        }
                    }
                }));
            }
        }