<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RobinhoodDesktop
{
    public class StockChartPanel : Panel
    {
        public StockChartPanel(string symbol)
        {
            this.Symbol = symbol;
            this.Resize += StockChartPanel_Resize;

            // Create the summary bar
            SummaryBarPanel = new Panel();
            SummaryBarPanel.Location = new System.Drawing.Point(0, 0);
            SummaryBarPanel.Size = new System.Drawing.Size(600, 25);
            SummaryBarPanel.BackColor = GuiStyle.BACKGROUND_COLOR;

            BuyButton = new GuiButton("Buy");
            BuyButton.Location = new System.Drawing.Point(0, 5);
            SummaryBarPanel.Controls.Add(BuyButton);

            SellButton = new GuiButton("Sell");
            SellButton.Location = new System.Drawing.Point(0, BuyButton.Location.Y);
            SummaryBarPanel.Controls.Add(SellButton);

            SummaryLabel = new Label();
            SummaryLabel.ForeColor = GuiStyle.TEXT_COLOR;
            SummaryLabel.Size = new System.Drawing.Size(200, 20);
            SummaryLabel.BackColor = System.Drawing.Color.Transparent;
            SummaryLabel.Location = new System.Drawing.Point(10, 5);
            SummaryBarPanel.Controls.Add(SummaryLabel);

            CollapseButton = new PictureBox();
            CollapseButton.Image = System.Drawing.Bitmap.FromFile("Content/GUI/Button_Collapse.png");
            CollapseButton.BackColor = System.Drawing.Color.Transparent;
            CollapseButton.Size = CollapseButton.Image.Size;
            CollapseButton.Location = new System.Drawing.Point(SummaryLabel.Location.X + SummaryLabel.Width, 5);
            CollapseButton.MouseUp += CollapseButton_MouseUp;
            SummaryBarPanel.Controls.Add(CollapseButton);

            CloseButton = new PictureBox();
            CloseButton.Image = System.Drawing.Bitmap.FromFile("Content/GUI/Button_Close.png");
            CloseButton.BackColor = System.Drawing.Color.Transparent;
            CloseButton.Size = CollapseButton.Image.Size;
            CloseButton.Location = new System.Drawing.Point(CollapseButton.Location.X + CollapseButton.Width, 5);
            SummaryBarPanel.Controls.Add(CloseButton);
            this.Controls.Add(SummaryBarPanel);

            // Prevent scroll wheel when not over the scroll bar itself
            this.MouseWheel += (object sender, MouseEventArgs e) =>
            {
                if(e.X < (this.Right - 15))
                {
                    ((HandledMouseEventArgs)e).Handled = true;
                }

            };

            this.Canvas = new Panel();
            this.Chart = new StockChart(symbol);
            Canvas.Controls.Add(Chart.Canvas);

            // Request data to fill the stock chart
            Chart.RequestData(DateTime.Now.Date.AddHours(-48), DateTime.Now.Date.AddHours(16), new TimeSpan(0, 1, 0));
            Chart.SetSubscritpion(DataAccessor.Subscribe(Chart.Symbol, DataAccessor.SUBSCRIBE_FIVE_SEC));

            Canvas.Resize += (sender, e) => { Chart.Canvas.Size = Canvas.Size; };
            Canvas.Location = new System.Drawing.Point(SummaryBarPanel.Location.X - 6, SummaryBarPanel.Location.Y + SummaryBarPanel.Height);
            this.Controls.Add(Canvas);
        }


        #region Types
        public struct StockUIConfig
        {
            public string Symbol;
            public int Height;
<commit_msg>Fix crash in Mono when doing the scroll wheel (again?)<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RobinhoodDesktop
{
    public class StockChartPanel : Panel
    {
        public StockChartPanel(string symbol)
        {
            this.Symbol = symbol;
            this.Resize += StockChartPanel_Resize;

            // Create the summary bar
            SummaryBarPanel = new Panel();
            SummaryBarPanel.Location = new System.Drawing.Point(0, 0);
            SummaryBarPanel.Size = new System.Drawing.Size(600, 25);
            SummaryBarPanel.BackColor = GuiStyle.BACKGROUND_COLOR;

            BuyButton = new GuiButton("Buy");
            BuyButton.Location = new System.Drawing.Point(0, 5);
            SummaryBarPanel.Controls.Add(BuyButton);

            SellButton = new GuiButton("Sell");
            SellButton.Location = new System.Drawing.Point(0, BuyButton.Location.Y);
            SummaryBarPanel.Controls.Add(SellButton);

            SummaryLabel = new Label();
            SummaryLabel.ForeColor = GuiStyle.TEXT_COLOR;
            SummaryLabel.Size = new System.Drawing.Size(200, 20);
            SummaryLabel.BackColor = System.Drawing.Color.Transparent;
            SummaryLabel.Location = new System.Drawing.Point(10, 5);
            SummaryBarPanel.Controls.Add(SummaryLabel);

            CollapseButton = new PictureBox();
            CollapseButton.Image = System.Drawing.Bitmap.FromFile("Content/GUI/Button_Collapse.png");
            CollapseButton.BackColor = System.Drawing.Color.Transparent;
            CollapseButton.Size = CollapseButton.Image.Size;
            CollapseButton.Location = new System.Drawing.Point(SummaryLabel.Location.X + SummaryLabel.Width, 5);
            CollapseButton.MouseUp += CollapseButton_MouseUp;
            SummaryBarPanel.Controls.Add(CollapseButton);

            CloseButton = new PictureBox();
            CloseButton.Image = System.Drawing.Bitmap.FromFile("Content/GUI/Button_Close.png");
            CloseButton.BackColor = System.Drawing.Color.Transparent;
            CloseButton.Size = CollapseButton.Image.Size;
            CloseButton.Location = new System.Drawing.Point(CollapseButton.Location.X + CollapseButton.Width, 5);
            SummaryBarPanel.Controls.Add(CloseButton);
            this.Controls.Add(SummaryBarPanel);

            this.Canvas = new Panel();
            this.Chart = new StockChart(symbol);
            Canvas.Controls.Add(Chart.Canvas);

            // Request data to fill the stock chart
            Chart.RequestData(DateTime.Now.Date.AddHours(-48), DateTime.Now.Date.AddHours(16), new TimeSpan(0, 1, 0));
            Chart.SetSubscritpion(DataAccessor.Subscribe(Chart.Symbol, DataAccessor.SUBSCRIBE_FIVE_SEC));

            Canvas.Resize += (sender, e) => { Chart.Canvas.Size = Canvas.Size; };
            Canvas.Location = new System.Drawing.Point(SummaryBarPanel.Location.X - 6, SummaryBarPanel.Location.Y + SummaryBarPanel.Height);
            this.Controls.Add(Canvas);
        }


        #region Types
        public struct StockUIConfig
        {
            public string Symbol;
            public int Height;

{'fraction_non_alphanumeric': 0.09939625975555882, 'fraction_numerical': 0.00854071565307024, 'mean_word_length': 2.384155455904335, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7386322', 'n_tokens_mistral': 1835, 'n_tokens_neox': 1757, 'n_words': 333}