Esempio n. 1
0
        //when a button to change the stock is actually pressed
        private void SidebarButton_Clicked(object sender, EventArgs e)
        {
            string[] senderText = sender.ToString().Split(' ');
            string   ticker     = senderText.Last();

            ChartHandler.loadStock(ticker);
        }
        public static void openAnnotatedGraph()
        {
            string path     = @"C:\Users\Public\Documents\SavedAnnotations";
            string fileName = null;

            using (OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.InitialDirectory = Path.GetFullPath(path);
                dialog.Filter           = "annotation files (*.an)|*.an";
                dialog.FilterIndex      = 2;
                dialog.RestoreDirectory = true;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    fileName = dialog.FileName;
                }
            }

            if (fileName != null)
            {
                //here is where we read the file data:
                using (var reader = new StreamReader(fileName))
                {
                    bool isFirstLine = true;
                    while (!reader.EndOfStream)
                    {
                        if (isFirstLine)
                        {
                            //first line is the ticker of the graph annotated
                            string firstLine = reader.ReadLine();
                            ChartHandler.loadStock(firstLine);

                            isFirstLine = false;
                        }

                        //read the next line, the first word of that next line is the kind of annotation that the line is
                        string   line      = reader.ReadLine();
                        string[] splitLine = line.Split(' ');

                        switch (splitLine[0])
                        {
                        case "Plot":
                            //for a plot line, the next 4 elements in "splitLine" are the 2 start/end points of the line
                            double startX = Convert.ToDouble(splitLine[1]);
                            double startY = Convert.ToDouble(splitLine[2]);
                            double endX   = Convert.ToDouble(splitLine[3]);
                            double endY   = Convert.ToDouble(splitLine[4]);
                            LinePlotter.addLine(startX, startY, endX, endY);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public aMainForm()
        {
            //setting up files in the public documents if there are no files already there:
            //raw data
            if (!File.Exists(@"C:\Users\Public\Documents\RawData"))
            {
                Directory.CreateDirectory(@"C:\Users\Public\Documents\RawData");
            }
            //annotations
            if (!File.Exists(@"C:\Users\Public\Documents\SavedAnnotations"))
            {
                Directory.CreateDirectory(@"C:\Users\Public\Documents\SavedAnnotations");
            }
            //strategies
            if (!File.Exists(@"C:\Users\Public\Documents\Strategies"))
            {
                Directory.CreateDirectory(@"C:\Users\Public\Documents\Strategies");
            }

            InitializeComponent();

            graphicsProcessor = new GraphicsProcessor(ChartHandler.chart, linePlotter);

            //chart events

            aChartPanel.Controls.Add(ChartHandler.chart);
            ChartHandler.chart.MouseClick += new MouseEventHandler(aMainChart_MouseClick);

            ChartHandler.chart.Paint += new PaintEventHandler(graphicsProcessor.paint);

            ChartHandler.chart.MouseMove += new MouseEventHandler(graphicsProcessor.mouseMove);
            ChartHandler.chart.MouseMove += new MouseEventHandler(chartZoom.mouseMove);

            ChartHandler.chart.MouseLeave += new EventHandler(graphicsProcessor.exit);
            ChartHandler.chart.MouseLeave += new EventHandler(chartZoom.mouseLeave);
            ChartHandler.chart.MouseEnter += new EventHandler(graphicsProcessor.enter);

            ChartHandler.chart.MouseWheel += new MouseEventHandler(chartZoom.mouseScroll);

            ChartHandler.chart.MouseDown += new MouseEventHandler(chartZoom.mouseDown);
            ChartHandler.chart.MouseUp   += new MouseEventHandler(chartZoom.mouseUp);


            //sidebar
            Controls.Add(sideMenu.flowLayoutPanel);
            sideMenu.scanForStockData("C:/Users/Public/Documents/RawData");


            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            //for debugging (so we don't have to click button every time)
            ChartHandler.loadStock("MSFT");
            linePlotter.updateGaps();
        }
Esempio n. 4
0
 private void aGetHistoricalData_Click(object sender, EventArgs e)
 {
     ChartHandler.loadStock(aTickerTextInput.Text);
     linePlotter.updateGaps();
     sideMenu.scanForStockData("C:/Users/Public/Documents/RawData");
 }