Exemplo n.º 1
0
        private void LineMarker_PositionChanged(object sender, PositionChangedArgs e)
        {
            var chartPoint   = new Point(LineMarker.X, LineMarker.Y);
            var _hitTestInfo = MainChart.HitTest(chartPoint);

            var hitTestInfo = MainChart.HitTest(chartPoint);
        }
Exemplo n.º 2
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            for (int i = 0; i < m_Y.Count; i++)
            {
                m_GraphCnt[i] = m_Y[i] / 10;
                if (m_GraphSum[i] < m_Y[i])
                {
                    MainChart.Series[0].Points[i].YValues[0] = m_GraphSum[i];
                    MainChart.Invalidate();
                }
                else
                {
                    MainChart.Series[0].Points[i].YValues[0] = m_Y[i];
                    MainChart.Invalidate();
                    m_GraphComplete[i] = true;
                }
                m_GraphSum[i] += m_GraphCnt[i];
            }

            bool End = true;

            for (int i = 0; i < m_GraphComplete.Count; i++)
            {
                End &= m_GraphComplete[i];
            }
            if (m_Y.Count < 1)
            {
                End = true;
            }
            if (End)
            {
                m_TImer.Stop();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// When we click chart
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Clicked dot</param>
        private void MainChart_MouseDown(object sender, MouseEventArgs e)
        {
            //Information abour click result
            var DotWeGot = MainChart.HitTest(e.X, e.Y);

            //If we click one of x dots
            if ((DotWeGot.Series != null) && (DotWeGot.Series.Name == SOURSE_DOTS_SERIES_NAME))
            {
                //capture it
                captured = MainChart.Series[SOURSE_DOTS_SERIES_NAME].Points[DotWeGot.PointIndex].XValue;
            }

            //Els if we click on chart area
            else if (DotWeGot.ChartArea != null)
            {
                //Finde x coordinate of click on chart
                double clickedColumn = MainChart.ChartAreas[0].AxisX.PixelPositionToValue(e.X);

                //If we clicked almost on one of the start dot's column
                if ((Math.Abs(Math.Round(clickedColumn) - clickedColumn) < this.Width * 0.00005) && (Math.Round(clickedColumn) >= FIRST_DOT_X) && (Math.Round(clickedColumn) < (FIRST_DOT_X + NUMBBER_OF_SOURSE_DOTS)))
                {
                    //Move start dot
                    SourseDots[Math.Round(clickedColumn)] = MainChart.ChartAreas[0].AxisY.PixelPositionToValue(e.Y);

                    //Rewrite all functions according to
                    Rewrite();
                }
            }
        }
Exemplo n.º 4
0
 public MainChart GetMainChart()
 {
     return CRUD.ExcuteSql(connection =>
     {
         MainChart chart = new MainChart();
         double awaitOrder = connection.RecordCount<order_model>("WHERE state = 0");
         double orderCount = connection.RecordCount<order_model>("WHERE state != 200 and state != 500");
         double awaitError = connection.RecordCount<equipment_error_model>("WHERE date=@date and state=-1", new { date = DateTime.Now.ToString("yyyy-MM-dd").ToDate() });
         double ErrorCount = connection.RecordCount<equipment_error_model>("WHERE date=@date", new { date = DateTime.Now.ToString("yyyy-MM-dd").ToDate() });
         chart.GetChartpercentOrder =
         new Chartpercent()
         {
             percent = ((awaitOrder / orderCount).ToString("0.0").ToDouble() * 100).ToString(),
             Chartdata =
             new List<Chart>() {
                 new Chart() { name="总订单",value= orderCount.ToInt() },
                 new Chart() { name = "待执行订单", value = awaitOrder.ToInt() }
             }
         };
         chart.GetChartpercentError =
         new Chartpercent()
         {
             percent = ((awaitError / ErrorCount).ToString("0.0").ToDouble() * 100).ToString(),
             Chartdata =
             new List<Chart>() {
                 new Chart() { name="总异常",value= ErrorCount.ToInt()== 0 ? 1: ErrorCount.ToInt() },
                 new Chart() { name = "待处理异常", value = awaitError.ToInt() }
             }
         };
         return chart;
     });
 }
Exemplo n.º 5
0
        internal void RangeSelectorChanged()
        {
            if (MainChart != null)
            {
                MainChart.BeginUpdate();
                UpdateDataRange();

                IEnumerable <QuoteRange> ranges = ViewModel.ChartViewModel.Instance.GetYRange(this.LowerValue, this.UpperValue);
                if (ranges != null && ranges.Any())
                {
                    if (MainChart != null)
                    {
                        MainChart.AxisY.Min = ranges.Min(p => { return(p == null ? int.MaxValue : p.PriceMin); });
                        MainChart.AxisY.Max = ranges.Max(p => { return(p == null ? int.MinValue : p.PriceMax); });
                    }
                    var quote = ranges.First();
                    if (quote != null && VolumeSeries != null)
                    {
                        VolumeSeries.AxisY.Min = quote.VolumeMin;
                        VolumeSeries.AxisY.Max = quote.VolumeMax * 12;
                    }
                }
                MainChart.EndUpdate();

                if (this.RangeSelector != null)
                {
                    DateRangeText = Utilities.FromOADate(RangeSelector.LowerValue).ToString("MMM dd, yyyy")
                                    + " - " + Utilities.FromOADate(RangeSelector.UpperValue).ToString("MMM dd, yyyy");
                }
            }
        }
Exemplo n.º 6
0
        private void startWork()
        {
            SimulationOptionsCurrentExecution = SimulationOptionsForBinding.GetCopy();
            session = new SimulationSession(SimulationOptionsCurrentExecution);

            MainChart.StartDrawData(simulationResultsDictionary);

            threads = null;
            if (!SimulationOptionsCurrentExecution.RemoteExecutionOnly)
            {
                threads = new Thread[threadSlots];
                for (int i = 0; i < threads.Length; i++)
                {
                    threads[i]      = new Thread(this.performWork);
                    threads[i].Name = "Local Thread " + localThreadNumber++;
                    threads[i].Start();
                }
            }

            foreach (TCPSimulatorProxy proxy in TCPConnections)
            {
                if (proxy.Connected)
                {
                    proxy.startNewSession(session);
                }
            }

            btnSimulate.IsEnabled = false;
            btnAbort.IsEnabled    = true;
        }
Exemplo n.º 7
0
 public void ThemeChanged(ITheme visualTheme)
 {
     MainChart.ThemeChanged(visualTheme);
     ButtonPanel.ThemeChanged(visualTheme);
     ButtonPanel.BackColor = visualTheme.Window;
     ChartBanner.ThemeChanged(visualTheme);
     panelMain.BackColor = visualTheme.Window;
 }
Exemplo n.º 8
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            long cnt = m_Sum / 10;

            if (m_Cnt < m_Sum)
            {
                if (cbCountryName.SelectedItem.Equals("한국"))
                {
                    lbSum.Text = m_Cnt.ToString("C0");
                }
                else
                {
                    lbSum.Text = m_Cnt.ToString("C0", new System.Globalization.CultureInfo("en-US"));
                }
                m_Cnt += cnt;
            }
            else
            {
                if (cbCountryName.SelectedItem.Equals("한국"))
                {
                    lbSum.Text = m_Sum.ToString("C0");
                }
                else
                {
                    lbSum.Text = m_Sum.ToString("C0", new System.Globalization.CultureInfo("en-US"));
                }
                m_SumComplete = true;
            }

            for (int i = 0; i < m_Y.Count; i++)
            {
                m_GraphCnt[i] = m_Y[i] / 10;
                if (m_GraphSum[i] < m_Y[i])
                {
                    MainChart.Series[0].Points[i].YValues[0] = m_GraphSum[i];
                    MainChart.Invalidate();
                }
                else
                {
                    MainChart.Series[0].Points[i].YValues[0] = m_Y[i];
                    MainChart.Invalidate();
                    m_GraphComplete[i] = true;
                }
                m_GraphSum[i] += m_GraphCnt[i];
            }

            bool End = m_SumComplete;

            for (int i = 0; i < m_GraphComplete.Count; i++)
            {
                End &= m_GraphComplete[i];
            }
            if (End)
            {
                m_TImer.Stop();
            }
        }
Exemplo n.º 9
0
        protected override void OnPrimaryKeyChangedComplete(Exception error)
        {
            if (error != null)
            {
                throw error;
            }

            MainChart.Width   = DisplayArea.Width;
            MainChart.Height  = DisplayArea.Height;
            DisplayArea.Image = MainChart.GetChartImage();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Pops up the Save Image dialog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveImageButton_Click(object sender, EventArgs e)
        {
            SaveImage dlg = new SaveImage();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                MainChart.SaveImage(dlg.ImageSize, dlg.FileName, dlg.ImageFormat);
            }

            MainChart.Focus();
            dlg.Dispose();
        }
Exemplo n.º 11
0
        private void MainChart_MouseMove(object sender, MouseEventArgs e)
        {
            if (m_isPlacingAnnotation)
            {
                return;
            }

            while (m_isChartUpdating)
            {
            }

            try
            {
                m_isPlacingAnnotation = true;
                var xValueUnderCursor = MainChart.ChartAreas[0].AxisX.PixelPositionToValue(e.X);
                var results           = MainChart.HitTest(e.X, e.Y, false, ChartElementType.DataPoint);
                var point             = results.Where(x => x.ChartElementType == ChartElementType.DataPoint)
                                        .Select(x => x.Object as DataPoint)
                                        .Where(x => x != null && x.Tag != null)
                                        .OrderBy(x => Math.Abs(xValueUnderCursor - x.XValue))
                                        .FirstOrDefault();

                if (point == null)
                {
                    return;
                }
                if (m_pointUnderCursor != null && !m_pointerUnderCursorSelected)
                {
                    m_pointUnderCursor.MarkerSize = ChartMarkerSize;
                }

                m_pointUnderCursor            = point;
                m_pointerUnderCursorSelected  = m_pointUnderCursor.MarkerSize == ChartSelectedMarkerSize;
                m_pointUnderCursor.MarkerSize = ChartSelectedMarkerSize;

                m_valueAnnotation.BeginPlacement();
                {
                    m_valueAnnotation.AnchorX = m_pointUnderCursor.XValue;
                    m_valueAnnotation.AnchorY = m_pointUnderCursor.YValues[0];
                    m_valueAnnotation.Text    = m_pointUnderCursor.Tag.ToString();
                }
                m_valueAnnotation.EndPlacement();
            }
            catch (Exception)
            {
                // Ignore
            }
            finally
            {
                m_isPlacingAnnotation = false;
            }
        }
Exemplo n.º 12
0
 /// <summary>
 ///点击刷新按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void A_Click(object sender, RoutedEventArgs e)
 {
     initTotalChart();
     initMainChart();
     initNumberChart();
     initFuncChart();
     initCtrlChart();
     TotalChart.Update(true);
     MainChart.Update(true);
     NumberChart.Update(true);
     FuncChart.Update(true);
     CtrlChart.Update(true);
 }
Exemplo n.º 13
0
        private void BarGraphAnimations()
        {
            // Set animation on Bar Graph upon loading of the window.

            //Animation for Production and Aanvoer.
            DoubleAnimation moveAnimation = new DoubleAnimation();

            moveAnimation.From     = MainChart.TransformToAncestor(this).Transform(new Point(0, 0)).Y;
            moveAnimation.To       = MainChart.ActualHeight / 1.57;
            moveAnimation.Duration = TimeSpan.FromMilliseconds(4000);
            BarSeriesProductie.BeginAnimation(Canvas.HeightProperty, moveAnimation);
            BarSeriesAanvoer.BeginAnimation(Canvas.HeightProperty, moveAnimation);
        }
Exemplo n.º 14
0
 private void Chart_load(int group)
 {
     if (chartIsinit[group] == false)
     {
         MainChart.AddLineGraph(getDataSourceName(group), getRandomColor(), 1, "Group" + group);
         chartIsinit[group] = true;
         MainChart.Viewport.FitToView();
     }
     else
     {
         MainChart.Viewport.FitToView();
     }
 }
Exemplo n.º 15
0
        private void MainChart_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button.HasFlag(MouseButtons.Left))
            {
                ChartArea     ca = MainChart.ChartAreas[0];
                Axis          ax = ca.AxisX;
                Axis          ay = ca.AxisY;
                int           X = e.X, Y = e.Y;
                HitTestResult hit = MainChart.HitTest(e.X, e.Y);
                if (hit.PointIndex > 0)
                {
                    curPoint = hit.Series.Points[hit.PointIndex];
                }

                //if (curPoint != null)
                //{
                //    if (curPoint.XValue == 255 && curPoint.YValues[0] == 255) curPoint = null;
                //    if (curPoint.XValue == 0 && curPoint.YValues[0] == 0) curPoint = null;
                //    if (MainChart.Series[0].Points[MainChart.Series[0].Points.Count() - 1] == curPoint) curPoint = null;
                //    if (MainChart.Series[0].Points[0] == curPoint) curPoint = null;

                //}
                if (curPoint != null)
                {
                    Series s  = hit.Series;
                    double dx = ax.PixelPositionToValue(e.X);
                    double dy = ay.PixelPositionToValue(e.Y);

                    curPoint.XValue     = dx;
                    curPoint.YValues[0] = dy;
                }


                ObjectAPI pic2 = pic.Clone() as ObjectAPI;
                //pic2.ChangeGist(MainChart,str);
                Gist.Series[str2].Points.Clear();

                if (flag == false)
                {
                    Parallel.Invoke(() => Gist = Curve.loadGist(Gist, pic2, str2), () => pic2.ChangeGist(MainChart, str), () => MainPic.Image = pic2.ShowRGB());
                }
                //MainPic.Image = pic2.ShowRGB();
                else
                {
                    Parallel.Invoke(() => Gist = Curve.loadGist(Gist, pic2, str2), () => pic2.ChangeGist(MainChart, str), () => MainPic.Image = pic2.Show());
                }
                //MainPic.Image = pic2.Show();
                MainPic.Refresh();
                Gist = Curve.loadGist(Gist, pic2, str2);
            }
        }
Exemplo n.º 16
0
        //private void ShowChart_Completed(object sender, EventArgs e)
        //{
        //    MainChart.DataContext = ViewModel.CurrentChartViewModel;
        //    ViewModel.CurrentChartViewModel.RefreshCommand.Execute(3600);
        //}

        //private void HideChart_Completed(object sender, EventArgs e)
        //{
        //    MainChart.DataContext = null;
        //}

        protected override void OnOrientationChanged(OrientationChangedEventArgs e)
        {
            if ((e.Orientation & PageOrientation.Portrait) != 0)
            {
                //NavigationService.Navigate(new Uri("/View/ChartView.xaml", UriKind.Relative));
                VisualStateManager.GoToState(this, "PortraitVisualState", true);
            }
            else
            {
                VisualStateManager.GoToState(this, "LandscapeVisualState", true);
                MainChart.Activate();
            }

            base.OnOrientationChanged(e);
        }
Exemplo n.º 17
0
        private void MainChart_MouseMove(object sender, MouseEventArgs e)
        {
            //If mous left button is clamped and some dot is captured
            if ((MouseButtons == MouseButtons.Left) && (captured != 0))
            {
                //If we still on our chart area
                if (MainChart.HitTest(e.X, e.Y).ChartArea != null)
                {
                    //Move captured dot
                    SourseDots[captured] = MainChart.ChartAreas[0].AxisY.PixelPositionToValue(e.Y);

                    //Rebuid series
                    Rewrite();
                }
            }
        }
Exemplo n.º 18
0
        public override void Plot(double value)
        {
            IsBusy = true;

            var weeklyData = getOxyWeeklyOhlcs(value);

            if (weeklyData == null)
            {
                IsBusy = false;
                return;
            }

            var lineSeries1 = new CandleStickSeries
            {
                XAxisKey = "X",
                YAxisKey = "Y1"
            };

            lineSeries1.Items.AddRange(weeklyData);

            var lineSeries2 = new LineSeries
            {
                XAxisKey = "X",
                YAxisKey = "Y2"
            };

            MainChart.Series.Add(lineSeries1);

            double[] outData = new double[weeklyData.Count];
            var      res     = Core.Roc(weeklyData.Select(d => d.Close).ToArray(), 0, weeklyData.Count - 1, outData, out int begIdx, out int element, 13);

            for (int i = 0; i < weeklyData.Count; i++)
            {
                if (i >= begIdx)
                {
                    lineSeries2.Points.Add(new DataPoint(weeklyData[i].X, outData[i - begIdx]));
                }
            }

            MainChart.Series.Add(lineSeries2);
            MainChart.InvalidatePlot(true);
            IsBusy = false;
        }
Exemplo n.º 19
0
 private async void GraphLog(DSLOGFileEntry file)
 {
     if (MainChart != null && file != null && file.Valid)
     {
         while (LoadingLog)
         {
             Application.DoEvents();
         }
         SeriesViewObserving.Enabled = false;
         LoadingLog = true;
         var   tc = Task.Run(() => { MainChart.LoadLog(file); });
         var   te = Task.Run(() => { EventView.LoadLog(file); });
         await tc;
         await te;
         SeriesViewObserving.Enabled = true;
         EventView.AddEvents();
         LoadingLog = false;
     }
 }
Exemplo n.º 20
0
        public override void Plot(DateTime value)
        {
            if (MainChart.Series.Any(_ => (DateTime)_.Tag == value))
            {
                return;
            }
            IsBusy = true;

            Task.Run(async() =>
            {
                data = await dataManager.GetData(value);

                if (data.DataRow.Count > 0)
                {
                    var lineSeries1 = new LineSeries
                    {
                        MarkerType            = MarkerType.Circle,
                        MarkerStrokeThickness = 2,
                        MarkerSize            = 2,
                        LineStyle             = LineStyle.Solid,
                        StrokeThickness       = 2,
                        Title = value.ToShortDateString(),
                        InterpolationAlgorithm = InterpolationAlgorithms.CanonicalSpline,
                        Tag = value
                    };
                    lineSeries1.MarkerStroke = lineSeries1.Color;

                    data.DataRow.ForEach(item => { lineSeries1.Points.Add(new DataPoint(item.Period, item.Value)); });

                    MainChart.Series.Add(lineSeries1);
                    MainChart.InvalidatePlot(true);
                    dataManager.Status = string.Empty;
                }
                else
                {
                    dataManager.Status = $"No data for {value}";
                }
                IsBusy = false;
            });
        }
Exemplo n.º 21
0
        private void Timer_Tick(object sender, EventArgs e, ref int StopChecker, double[] CurrentPoint)
        {
            SaveHistoryOfWeightsValues();
            CalculationsInsideTheLoop(ref StopChecker, CurrentPoint);

            Iteration++;
            CurrentIterationTextBlock.Text = Iteration.ToString();


            if (Iteration > Convert.ToInt32(MaxIterationsTextBox.Text) || CheckStopCondition(StopChecker))
            {
                MainChart.Visibility = Visibility.Visible;
                MainChart.DrawChart(WeightsList.Count, WeightsList);

                ChartsScrollViewer.Visibility = Visibility.Visible;
                DrawWeightGraphs();

                StartButton.IsEnabled    = true;
                SaveFileButton.IsEnabled = true;

                dispatcherTimer.Stop();
            }
        }
Exemplo n.º 22
0
        private void SetupAxisStripes(IAxis yAxis, LineChartTypes chartType)
        {
            if (yAxis != null && Activity != null)
            {
                yAxis.Stripes.Clear();

                if (Options.Instance.ShowZonesInChart && ShownZones != null)
                {
                    foreach (INamedLowHighZone zone in ShownZones.Zones)
                    {
                        AxisStripe stripe = new AxisStripe(zone.Low, zone.High, Color.FromArgb(16, 0, 0, 0));
                        yAxis.Stripes.Add(stripe);

                        // Setup default parameters
                        stripe.Name      = zone.Name;
                        stripe.LineColor = Color.FromArgb(128, 0, 0, 0);
                        stripe.LineStyle = DashStyle.Dash;
                        stripe.LineWidth = 2;

                        // Some types need to override the low/high values
                        switch (chartType)
                        {
                        case LineChartTypes.HeartRatePercentMax:
                        {
                            IAthleteInfoEntry lastAthleteEntry = PluginMain.GetApplication().Logbook.Athlete.InfoEntries.LastEntryAsOfDate(m_ActivityInfoCache.ActualTrackStart);

                            // Value is in BPM so convert to the % max HR if we have the info
                            if (!float.IsNaN(lastAthleteEntry.MaximumHeartRatePerMinute))
                            {
                                stripe.From = (zone.Low / lastAthleteEntry.MaximumHeartRatePerMinute) * 100;
                                stripe.To   = (zone.High / lastAthleteEntry.MaximumHeartRatePerMinute) * 100;
                            }
                            else
                            {
                                // Cancel the add, we don't have the data
                                yAxis.Stripes.Remove(stripe);
                            }

                            break;
                        }

                        case LineChartTypes.Speed:
                        {
                            stripe.From = Length.Convert(zone.Low, Length.Units.Meter, Utils.Utils.MajorLengthUnit(Activity.Category.DistanceUnits)) * Utils.Constants.SecondsPerHour;
                            stripe.To   = Length.Convert(zone.High, Length.Units.Meter, Utils.Utils.MajorLengthUnit(Activity.Category.DistanceUnits)) * Utils.Constants.SecondsPerHour;;

                            break;
                        }

                        default:
                        {
                            break;
                        }
                        }
                    }

                    if (MainChart != null)
                    {
                        MainChart.Invalidate();
                    }
                }
            }
        }
Exemplo n.º 23
0
        private void CbCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            m_Y.Clear();
            MainChart.Series.Clear();
            MainChart.ChartAreas[0].AxisY.LabelStyle.Format = "{0:C0}";

            if (cbCategory.SelectedItem.Equals("ALL"))
            {
                MainChart.Series.Add("지출금");
                MainChart.Series.Add("월세");
                MainChart.Series.Add("생활비");

                if (m_DataTable.Rows.Count > 3)
                {
                    for (int i = 0; i < MainChart.Series.Count; i++)
                    {
                        MainChart.Series[i].ChartType   = SeriesChartType.Line;
                        MainChart.Series[i].BorderWidth = 3;
                    }
                }
                foreach (DataRow item in m_DataTable.Rows)
                {
                    long   temp1 = Convert.ToInt64(item[1]);
                    long   temp2 = Convert.ToInt64(item[2]);
                    long   temp3 = temp1 - temp2;
                    string X     = item[0].ToString().Substring(2, 2) + "/" + item[0].ToString().Substring(5, 2);
                    MainChart.Series[0].Points.AddXY(X, temp1);
                    MainChart.Series[1].Points.AddXY(X, temp2);
                    MainChart.Series[2].Points.AddXY(X, temp3);
                }
            }
            else if (cbCategory.SelectedItem.Equals("지출금"))
            {
                MainChart.Series.Add("지출금");
                MainChart.Series[0].ChartType = SeriesChartType.Column;
                MainChart.Series[0].Color     = Color.Blue;
                foreach (DataRow item in m_DataTable.Rows)
                {
                    long   temp = Convert.ToInt64(item[1]);
                    string X    = item[0].ToString().Substring(2, 2) + "/" + item[0].ToString().Substring(5, 2);
                    MainChart.Series[0].Points.AddXY(X, temp);

                    m_Y.Add(temp);
                }
            }
            else if (cbCategory.SelectedItem.Equals("월세"))
            {
                MainChart.Series.Add("월세");
                MainChart.Series[0].ChartType = SeriesChartType.Column;
                MainChart.Series[0].Color     = Color.Orange;
                foreach (DataRow item in m_DataTable.Rows)
                {
                    long   temp = Convert.ToInt64(item[2]);
                    string X    = item[0].ToString().Substring(2, 2) + "/" + item[0].ToString().Substring(5, 2);
                    MainChart.Series[0].Points.AddXY(X, temp);

                    m_Y.Add(temp);
                }
            }
            else if (cbCategory.SelectedItem.Equals("생활비"))
            {
                MainChart.Series.Add("생활비");
                MainChart.Series[0].ChartType = SeriesChartType.Column;
                MainChart.Series[0].Color     = Color.Red;
                foreach (DataRow item in m_DataTable.Rows)
                {
                    long   temp = Convert.ToInt64(item[1]) - Convert.ToInt64(item[2]);
                    string X    = item[0].ToString().Substring(2, 2) + "/" + item[0].ToString().Substring(5, 2);
                    MainChart.Series[0].Points.AddXY(X, temp);

                    m_Y.Add(temp);
                }
            }
            MainChart.ChartAreas[0].RecalculateAxesScale();
            MainChart.Invalidate();

            m_GraphSum.Clear();
            m_GraphCnt.Clear();
            m_GraphComplete.Clear();
            for (int i = 0; i < m_Y.Count; i++)
            {
                m_GraphSum.Add(0);
                m_GraphCnt.Add(0);
                m_GraphComplete.Add(false);
            }
            m_TImer.Start();
        }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            for (int i = 0; i < Pop_Size; i++)
            {
                Thread.Sleep((int)(Sleeper * 100));
                _parameters.ListOfPoints.Add(new ObservablePoint(trandom.NextDouble(F1LeftConstraint, F1RightConstraint),
                                                                 trandom.NextDouble(F2LeftConstraint, F2RightConstraint)
                                                                 ));
                DomainChart.EditBSeriesCollection(_parameters.ListOfPoints);
            }



            while (_parameters.IterationNumber < _parameters.IterationLimit && !_Stop)
            {
                // inicjalizacja tablic
                InitializePopulation(ref PopulationAfterSelection, Pop_Size / 2);
                InitializePopulation(ref PopulationAfterMutation, Pop_Size / 2);
                InitializePopulation(ref PopulationAfterCrossing, Pop_Size / 4);

                InitializePopulation(ref PopulationFunctionValue, Pop_Size);
                InitializePopulation(ref PopulationFunctionValueAfterSelection, Pop_Size / 2);
                InitializePopulation(ref PopulationFunctionValueAfterCrossing, Pop_Size / 4);

                // czas na obserwacje popsize'a i wykresu wartosci funkcji

                // wszystkie operacje wykonujemy na tablicy znajdujacej sie w Parameters   public double[][][] Population; // [2][popsize][popsize]

                FillRandomValues(ref Population);

                // operacja selekcji

                // 2 warianty i tutaj trzeba zrobic ze na zasadzie losowej jest wybierana metoda selekcji

                // selekcja turniejowa --> losujemy 2 punkty z populacji i wygrywa lepszy (o mniejszej wartosci),
                // dzielimy popsize na 2 rowne zbiory i jeden zbior jest porownywany wzgledem f1 a drugi wzgledem f2



                Selection(Population, ref PopulationAfterSelection);

                // parametr, aby w nastepnej iteracji uzupelnic brakujace osobniki w populacji
                refill = true;


                Function2ValueCountForAllPopulation(PopulationAfterSelection, ref PopulationFunctionValueAfterSelection);



                // selekcja ruletkowa --> obliczamy fitness, jaki to jest procent z calosci dla danego osobnika, obliczamy dystrybuante,
                // generujemy liczby losowe i szeregujemy okreslajac ktore elementy maja przetrwac

                // mozna tutaj juz wrzucic te osobniki na wykres dziedziny



                _parameters.RewriteThePoints(PopulationAfterSelection);

                DomainChart.EditASeriesCollection(_parameters.ListOfPoints);

                CheckDomain(ref PopulationOutsideTheDomain, PopulationAfterSelection);
                _parameters.RewriteThePoints(PopulationOutsideTheDomain);
                DomainChart.SetPointsOutsideTheDomain(_parameters.ListOfPoints);


                _parameters.RewriteThePoints(PopulationFunctionValueAfterSelection);
                ParetoChart.EditSeriesCollection(_parameters.ListOfPoints);

                ParetoChart.MakeParetoFunctions(FindMinAndMax(PopulationFunctionValueAfterSelection));

                CheckParetoDomain(ref PopulationOutsideTheDomain, PopulationFunctionValueAfterSelection);
                _parameters.RewriteThePoints(PopulationOutsideTheDomain);

                ParetoChart.SetPointsOutsideTheDomain(_parameters.ListOfPoints);



                MainChart.EditSeriesCollection(PopulationFunctionValueAfterSelection, _parameters.IterationNumber);

                // operacja
                Mutation(PopulationAfterSelection, ref PopulationAfterMutation);


                // losujemy ktore punkty zostana poddane mutacji (sprawdzamy wszystkie pod wzgledem prawdopodobienstwa) (prawdopodobienstwo mutacji dla kazdego osobnika)
                // jezeli wylosowano osobnika to losujemy kat oraz dlugosc wektora
                // sprawdzamy czy zmutowany osobnik znajduje sie w dziedzinie
                // jezeli nie wykorzystujemy funkcje kary aby zwiekszyc wartosc osobnika

                // mozna tutaj juz wrzucic te osobniki na wykres dziedziny


                // operacja krzyzowania
                // to jest chyba najtrudniejsza operacja, duzo pierdolenia z przeksztalceniami
                // ogolnie to staramy sie tak skrzyzowac aby np calkowicie odbic jeden punkt
                // do dyskusji jak to robimy

                Crossing(PopulationAfterMutation, ref PopulationAfterCrossing);

                // mozna tutaj juz wrzucic te osobniki na wykres dziedziny


                // obliczenie minimum
                SearchForMinValue(PopulationFunctionValueAfterSelection, ref MinF1, ref MinF2);

                _parameters.Minimum = $"{{{Math.Round(MinF1,2)};{Math.Round(MinF2,2)}}}";

                // przepisywanie tablicy PopulationAfterCrossing do Population

                Array.Clear(Population, 0, Population.Length);
                Array.Copy(PopulationAfterCrossing, Population, PopulationAfterCrossing.Length);

                // przepisywanie tablicy PopulationFunctionValueAfterCrossing do PopulationFunctionValue
                Array.Clear(PopulationFunctionValue, 0, PopulationFunctionValue.Length);
                Array.Copy(PopulationFunctionValueAfterCrossing, PopulationFunctionValue, PopulationFunctionValueAfterCrossing.Length);

                // czyszczenie tablic
                Array.Clear(PopulationAfterSelection, 0, PopulationAfterSelection.Length);
                Array.Clear(PopulationAfterMutation, 0, PopulationAfterMutation.Length);
                Array.Clear(PopulationAfterCrossing, 0, PopulationAfterCrossing.Length);

                Array.Clear(PopulationFunctionValueAfterSelection, 0, PopulationFunctionValueAfterSelection.Length);
                Array.Clear(PopulationFunctionValueAfterCrossing, 0, PopulationFunctionValueAfterCrossing.Length);

                // finalne utworzenie wykresu dziedziny oraz pareto frontu a takze wykresu wartosci poszczegolnych funkcji

                // jezeli przez 5 iteracji nie ma poprawy minimum zatrzymujemy algorytm

                // musimy obliczyc jeszcze to spierdolone odchylenie
                // suma po wszystkich punktach w populacji (od i do licznosci pareto frontu) |f(f1) - f2|

                _parameters.IterationNumber++;
                e.Cancel = true;
                Thread.Sleep(4000);
            }
        }
Exemplo n.º 25
0
 /// <summary>
 /// Zoom to Fit the chart when clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ZoomFitButton_Click(object sender, EventArgs e)
 {
     MainChart.AutozoomToData(true);
     MainChart.Focus();
 }
Exemplo n.º 26
0
 /// <summary>
 /// Zoom into the chart when clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ZoomInButton_Click(object sender, EventArgs e)
 {
     MainChart.ZoomIn();
     MainChart.Focus();
 }
Exemplo n.º 27
0
 public void EndUpdate()
 {
     MainChart.EndUpdate();
 }
Exemplo n.º 28
0
 /// <summary>
 /// Adds a chart data series to the chart, and refreshes display.
 /// </summary>
 /// <param name="DataSeries">Data series to be added.</param>
 public void ChartDataAdd(ChartDataSeries DataSeries)
 {
     m_MainData.Add(DataSeries);
     SetupPrimaryDataSeries();
     MainChart.Refresh();
 }
Exemplo n.º 29
0
 private void SeriesColorChangedEventCommandExecute(SeriesColorChangedEventArgs obj)
 {
     MainChart.SeriesColorChanged(obj.Series, obj.Color);
 }
Exemplo n.º 30
0
 public bool BeginUpdate()
 {
     return(MainChart.BeginUpdate());
 }