Ejemplo n.º 1
0
        /// <summary>
        /// Updates the combobox select
        /// </summary>
        private async void getAllLinesAsync()
        {
            var model = new UserlineModel(stock);
            Task <List <UserLines> > task = Task.Run(() => model.getAllUserlines());
            var userlines = await task;

            this.userlines = userlines;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deletes all lines drawn by the user
        /// </summary>
        private void btnLinesDeleteAll_Click(object sender, EventArgs e)
        {
            UserlineModel model = new UserlineModel(stock);

            model.deleteAllUserlines();
            refreshChartAsync(stock.symbol);
            pointNr   = 1;
            lastPoint = null;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deletes all trend lines
        /// </summary>
        private void deleteLinesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.AppStarting;
            UserlineModel model = new UserlineModel(stock);

            model.deleteAllUserlines();
            refreshChartAsync(stock.symbol);
            pointNr   = 1;
            lastPoint = null;
            resetAttributes();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Deletes selected user line asynchronously
 /// </summary>
 private async void btnDeleteLine_Click(object sender, EventArgs e)
 {
     if (selectedLine != null)
     {
         mainForm.notifyUser(FrmMain.NotifyType.PrepareMessage, "Linie wird gelöscht...");
         var   model = new UserlineModel(stock);
         Task  task  = Task.Run(() => model.deleteUserline(selectedLine));
         await task;
         refreshChartAsync(stock.symbol);
         mainForm.notifyUser(FrmMain.NotifyType.StatusMessage, "Bereit");
         btnLineSubmitChanges.Visible = false;
     }
     selectedLine = null;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Draws single line
        /// </summary>
        private async void drawSingleLineAsync(MouseEventArgs e)
        {
            mousePosX = chartStock.ChartAreas[0].AxisX.PixelPositionToValue(e.Location.X);
            mousePosY = chartStock.ChartAreas[0].AxisY.PixelPositionToValue(e.Location.Y);

            currentPoint = new DataPoint(mousePosX, mousePosY);

            chartStock.Series.Add("Point_" + pointNr);
            chartStock.Series["Point_" + pointNr].Points.Add(currentPoint);
            chartStock.Series["Point_" + pointNr].ChartType = SeriesChartType.Point;
            chartStock.Series["Point_" + pointNr].Color     = lineColor;

            if (pointNr % 2 == 0 && (currentPoint != null && lastPoint != null))
            {
                chartStock.Series.Add("Line" + pointNr);
                chartStock.Series["Line" + pointNr].Points.Add(lastPoint);
                chartStock.Series["Line" + pointNr].Points[0].MarkerSize  = (int)(lineThickness * 2);
                chartStock.Series["Line" + pointNr].Points[0].MarkerStyle = MarkerStyle.Circle;
                chartStock.Series["Line" + pointNr].Points.Add(currentPoint);
                chartStock.Series["Line" + pointNr].Points[1].MarkerSize  = (int)(lineThickness * 2);
                chartStock.Series["Line" + pointNr].Points[1].MarkerStyle = MarkerStyle.Circle;
                chartStock.Series["Line" + pointNr].ChartType             = SeriesChartType.Line;
                chartStock.Series["Line" + pointNr].Color       = lineColor;
                chartStock.Series["Line" + pointNr].BorderWidth = lineThickness;

                UserlineModel    ulModel = new UserlineModel(stock, lineColor, lineThickness);
                Task <UserLines> task    = Task.Run(() => ulModel.insertUserline(lastPoint, currentPoint));
                var line = await task;

                if (line != null)
                {
                    chartStock.Series["Line" + pointNr].Tag = line;

                    createNewTrendlineToolStripMenuItem.Checked = false;
                    splitMain.Panel2Collapsed    = true;
                    DrawingAllowed               = false;
                    btnLineSubmitChanges.Visible = false;
                    resetAttributes();
                }


                getAllLinesAsync();
            }

            lastPoint = currentPoint;

            pointNr++;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Updates selected user line asynchronously
        /// </summary>
        private async void btnLineSubmitChanges_Click(object sender, EventArgs e)
        {
            if (selectedLine != null)
            {
                mainForm.notifyUser(FrmMain.NotifyType.PrepareMessage, "Linie wird aktualisiert...");
                selectedLine.Thickness = (short)lineThickness;
                selectedLine.LineColor = ColorTranslator.ToHtml(lineColor);

                var   model = new UserlineModel(stock);
                Task  task  = Task.Run(() => model.updateUserline(selectedLine));
                await task;
                refreshChartAsync(stock.symbol);
                mainForm.notifyUser(FrmMain.NotifyType.StatusMessage, "Bereit");
                btnLineSubmitChanges.Visible = false;
            }
            selectedLine = null;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Draws trend lines asynchronously
        /// </summary>
        private async void drawLinesAsync()
        {
            mainForm.notifyUser(FrmMain.NotifyType.PrepareMessage, "Userlines werden geladen...");

            var model = new UserlineModel(stock);
            Task <List <UserLines> > task = Task.Run(() => model.getAllUserlines());
            var userlines = await task;

            if (userlines != null)
            {
                foreach (var userline in userlines)
                {
                    var pointStart = new DataPoint(userline.TimePoint1, userline.PricePoint1);
                    var pointEnd   = new DataPoint(userline.TimePoint2, userline.PricePoint2);
                    var color      = ColorTranslator.FromHtml(userline.LineColor);

                    var line = new Series("Line_" + pointNr);
                    line.ChartType   = SeriesChartType.Line;
                    line.BorderWidth = (int)userline.Thickness;
                    line.Color       = color;
                    line.Tag         = userline;

                    line.Points.Add(pointStart);
                    line.Points[0].MarkerSize  = (int)(userline.Thickness * 2);
                    line.Points[0].MarkerStyle = MarkerStyle.Circle;
                    line.Points.Add(pointEnd);
                    line.Points[1].MarkerSize  = (int)(userline.Thickness * 2);
                    line.Points[1].MarkerStyle = MarkerStyle.Circle;

                    chartStock.Series.Add(line);

                    pointNr += 2;
                }
            }

            mainForm.notifyUser(FrmMain.NotifyType.StatusMessage, "Bereit");
        }