Exemplo n.º 1
0
        static public async Task <Bitmap> CreateLineOrMarkerPlot(LineOrMarkerAttributes attributes)
        {
            await FlaskApi.PutRequest(ApiEndpointConfigurations.lineOrMarkerPlotterApiEndPoint, attributes.PlotToKeyAndArguments());

            Dictionary <string, object> result = await FlaskApi.GetRequest(ApiEndpointConfigurations.lineOrMarkerPlotterApiEndPoint, printResponse : false);



            string imageDataInString      = result[ApiEndpointConfigurations.plotImageData_key] as string;
            string imageDimensionInString = result[ApiEndpointConfigurations.plotImageShape_key] as string;

            #region getting image Shape
            //(height,width ,3)
            int[] imageShape = DataStructureConverter.ConvertArrayInStringToArrayOfInt(imageDimensionInString);
            int   height     = imageShape[0];
            int   width      = imageShape[1];

            #endregion

            #region getting bitmap

            byte[] imageData = DataStructureConverter.ConvertArrayInStringToArrayOfByte(imageDataInString);

            //make bitmap
            Bitmap bitmap = MyImageLibrary.CreateImageFromRGB(width, height, imageData);
            #endregion


            return(bitmap);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Start plotting
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnPlotGraph_Click(object sender, EventArgs e)
        {
            //draw respective plot
            string exceptionMessage="";
            switch (this.plotType)
            {
                case CsvPlotter.PlotTypes.Histogram:
                    {
                        HistogramAttributes attributes = this.pgPlotProperty.SelectedObject as HistogramAttributes;
                        if (attributes.ColumnsNamesAreValid(ref exceptionMessage))
                        {
                            Bitmap image = await CsvPlotter.CreateHistogram(attributes);
                            using (ShowPlotForm showPlotForm = new ShowPlotForm(image))
                            {
                                showPlotForm.ShowDialog();
                            }
                        }
                        else
                        {
                            MessageBox.Show(exceptionMessage, "Exception Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        }
                    }

                    break;
                case CsvPlotter.PlotTypes.Scatter:
                    {
                        ScatterAttributes attributes = this.pgPlotProperty.SelectedObject as ScatterAttributes;
                        if (attributes.ColumnsNamesAreValid(ref exceptionMessage))
                        {
                            Bitmap image = await CsvPlotter.CreateScatterPlot(attributes);
                            using (ShowPlotForm showPlotForm = new ShowPlotForm(image))
                            {
                                showPlotForm.ShowDialog();
                            }
                        }
                        else
                        {
                            MessageBox.Show(exceptionMessage, "Exception Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        }
                    }

                    break;
                case CsvPlotter.PlotTypes.LineOrMarker:
                    {
                        LineOrMarkerAttributes attributes = this.pgPlotProperty.SelectedObject as LineOrMarkerAttributes;
                        if (attributes.ColumnsNamesAreValid(ref exceptionMessage))
                        {
                            Bitmap image = await CsvPlotter.CreateLineOrMarkerPlot(attributes);
                            using (ShowPlotForm showPlotForm = new ShowPlotForm(image))
                            {
                                showPlotForm.ShowDialog();
                            }
                        }
                        else
                        {
                            MessageBox.Show(exceptionMessage, "Exception Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        }
                    }
                    break;
            }
        }