Esempio n. 1
0
        private void tmrTimeUpdate_Tick(object sender, EventArgs e)
        {
            if (_engine.ExitTime.HasValue && DateTime.Now >= _engine.ExitTime)
            {
                Application.Exit();
            }

            UpdateTimes();

            if (_engine.PricesUpdated)
            {
                UpdateGrid();

                HistoryChart historyChart = tabHistory.Controls["historyChart"] as HistoryChart;
                if (historyChart != null)
                {
                    historyChart.UpdateChart(TimeSpan.FromMinutes(20), 3);
                }
                if (_totalHistoryForm != null)
                {
                    _totalHistoryForm.UpdateChart();
                }

                _engine.PricesUpdated = false;
            }

            MiningModeEnum[] autoModes = { MiningModeEnum.Automatic, MiningModeEnum.Donation };
            if (!autoModes.Contains(_engine.MiningMode))
            {
                return;
            }

            RunBestAlgo();
        }
Esempio n. 2
0
        private void tmrTimeUpdate_Tick(object sender, EventArgs e)
        {
            if (_engine.ExitTime.HasValue && DateTime.Now >= _engine.ExitTime)
            {
                Application.Exit();
            }

            UpdateTimes();

            if (_engine.PricesUpdated)
            {
                UpdateGrid();

                if (_engine.ShowHistory)
                {
                    HistoryChart historyChart = tabHistory.Controls["historyChart"] as HistoryChart;
                    historyChart?.UpdateChart(_engine.StatWindow, 3);
                    _totalHistoryForm?.UpdateChart();
                }

                _engine.PricesUpdated = false;
            }

            MiningModeEnum[] autoModes = { MiningModeEnum.Automatic, MiningModeEnum.Donation };
            if (!autoModes.Contains(_engine.MiningMode))
            {
                return;
            }

            RunBestAlgo();
        }
Esempio n. 3
0
        private void MainWindow_Shown(object sender, EventArgs e)
        {
            // speeds up data grid view performance.
            typeof(DataGridView).InvokeMember("DoubleBuffered",
                                              BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty, null, dgPrices,
                                              new object[] { true });
            typeof(DataGridView).InvokeMember("DoubleBuffered",
                                              BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty, null, dgServices,
                                              new object[] { true });

            dgServices.AutoGenerateColumns = false;
            dgServices.DataSource          = new SortableBindingList <IService>(_engine.Services);

            dgPrices.AutoGenerateColumns = false;
            dgPrices.DataSource          = new SortableBindingList <PriceEntryBase>(_engine.PriceEntries);

            if (!_engine.DoDonationMinging)
            {
                textDonationStart.Enabled = false;
                textDonationEnd.Enabled   = false;
            }

            lblCurrencySymbol.Text = string.Empty; // Avoid flashing template value when starting

            if (!_engine.RemoteReceive)
            {
                tabPage.TabPages.Remove(tabRemote);
            }

            UpdateButtons();
            RunCycle();
            UpdateGrid(true);

            if (Program.MinimizeOnStart)
            {
                MinimizeWindow();
            }

            tmrPriceCheck.Enabled = true;
            if (!string.IsNullOrWhiteSpace(_engine.CurrencyCode))
            {
                tmrExchangeUpdate.Enabled = true;
            }
            if (Program.HasAutoStart)
            {
                _engine.MiningMode = MiningModeEnum.Automatic;
                UpdateButtons();
                RunBestAlgo();
            }

            HistoryChart historyChart = tabHistory.Controls["historyChart"] as HistoryChart;

            if (historyChart != null)
            {
                historyChart.History = _engine.PriceHistories;
                historyChart.FlipLegend();
                historyChart.UpdateChart(_engine.StatWindow);
                historyChart.Chart.DoubleClick += ChartOnDoubleClick;
            }
        }
Esempio n. 4
0
        static void Main()
        {
            Weights = Enumerable.Range(0, Count).Select(z => rnd.Next(MaxWeight)).ToArray();
            if (Weights.Sum() % 2 != 0)
            {
                Weights[0]++;
            }

            form = new Form();
            var table = new TableLayoutPanel()
            {
                Dock = DockStyle.Fill, RowCount = 2, ColumnCount = 1
            };



            valuationsChart = new HistoryChart
            {
                Lines =
                {
                    new HistoryChartValueLine {
                        DataFunction =        { Color = Color.Green,  BorderWidth = 2 }
                    },
                    new HistoryChartValueLine {
                        DataFunction =        { Color = Color.Orange, BorderWidth = 2 }
                    },
                },
                Max  = 1,
                Dock = DockStyle.Fill
            };
            agesChart = new HistoryChart
            {
                Lines = { new HistoryChartValueLine {
                              DataFunction =        { Color= Color.Blue, BorderWidth = 2 }
                          } },
                Dock = DockStyle.Fill,
                Max  = 100
            };

            table.Controls.Add(valuationsChart, 0, 0);
            table.Controls.Add(agesChart, 0, 1);

            for (int i = 0; i < 2; i++)
            {
                table.RowStyles.Add(new RowStyle {
                    SizeType = SizeType.Percent, Height = 50
                });
            }

            form.Controls.Add(table);
            form.WindowState = FormWindowState.Maximized;

            new Thread(Algorithm)
            {
                IsBackground = true
            }.Start();
            Application.Run(form);
        }
Esempio n. 5
0
        protected override void UpdateCharts()
        {
            computedFunction.Points.Clear();
            for (int i = 0; i < FunctionInputs.Length; i++)
            {
                computedFunction.Points.Add(new DataPoint(FunctionInputs[i][0], FunctionOutput[i]));
            }

            HistoryChart.AddRange(LearningErrors);
            double error;

            while (LearningErrors.TryDequeue(out error))
            {
                ;
            }
        }
Esempio n. 6
0
        private void btnReloadConfig_Click(object sender, EventArgs e)
        {
            MiningModeEnum originalMode = _engine.MiningMode;
            ServiceEnum    service      = ServiceEnum.Manual;
            string         algo         = string.Empty;

            if (_engine.CurrentPriceEntry != null)
            {
                service = _engine.CurrentPriceEntry.ServiceEntry.ServiceEnum;
                algo    = _engine.CurrentPriceEntry.AlgoName;
            }

            _engine.Cleanup();
            _engine = new MiningEngine
            {
                WriteConsoleAction = WriteConsole,
                WriteRemoteAction  = WriteRemote
            };

            if (!_engine.LoadConfig())
            {
                MessageBox.Show("Something went wrong with reloading your configuration file. Check for errors.",
                                "Error loading conf", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            dgServices.DataSource = new SortableBindingList <IService>(_engine.Services);
            dgPrices.DataSource   = new SortableBindingList <PriceEntryBase>(_engine.PriceEntries);

            _engine.MiningMode = originalMode;

            _engine.LoadExchangeRates();
            RunCycle();
            UpdateButtons();
            UpdateGrid();

            HistoryChart historyChart = tabHistory.Controls["historyChart"] as HistoryChart;

            if (historyChart != null)
            {
                historyChart.UpdateChart();
            }

            if (originalMode == MiningModeEnum.Manual)
            {
                _engine.RequestStart(service, algo, IsMinimizedToTray);
            }
        }
        private void OpenFile_Click(object sender, EventArgs e)
        {
            int          size   = -1;
            var          FD     = new System.Windows.Forms.OpenFileDialog();
            DialogResult result = FD.ShowDialog(); // Show the dialog.

            if (result == DialogResult.OK)         // Test result.
            {
                string file = FD.FileName;
                try
                {
                    using (Stream stream = File.Open(file, FileMode.Open))
                    {
                        var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

                        dataList = (List <Data>)bformatter.Deserialize(stream);
                    }
                    PulseLB.Text          = dataList[0].pulse;
                    RPMLB.Text            = dataList[0].rpm;
                    SpeedLB.Text          = dataList[0].speed;
                    DistanceLB.Text       = dataList[0].distance;
                    RequestedPowerLB.Text = dataList[0].requestedPower;
                    EnergyLB.Text         = dataList[0].energy;
                    ElepsedTimeLB.Text    = dataList[0].elapsedTime;
                    ActualPowerLB.Text    = dataList[0].actualpower;

                    HistoryChart.Series.Add("speed");
                    HistoryChart.Series["speed"].ChartType           = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                    HistoryChart.ChartAreas[0].AxisX.IsMarginVisible = false;
                    HistoryChart.Invoke(new Action(() =>
                    {
                        foreach (Data data in dataList)
                        {
                            HistoryChart.Series["speed"].Points.AddY(data.speed);
                        }
                    }));
                }
                catch (IOException)
                {
                }
            }
            Console.WriteLine(size);   // <-- Shows file size in debugging mode.
            Console.WriteLine(result); // <-- For debugging use.
        }
Esempio n. 8
0
        private void InitHistoryChart()
        {
            HistoryChart preChart = tabHistory.Controls["historyChart"] as HistoryChart;

            if (preChart != null)
            {
                HistoryChart historyChart = new HistoryChart
                {
                    Dock    = DockStyle.Fill,
                    History = _engine.PriceHistories
                };

                historyChart.FlipLegend();
                historyChart.UpdateChart(_engine.StatWindow, 3);
                historyChart.Chart.DoubleClick += ChartOnDoubleClick;
                tabHistory.Controls.Remove(preChart);
                tabHistory.Controls.Add(historyChart);
            }
        }
Esempio n. 9
0
        public History()
        {
            InitializeComponent();

            HistoryChart = new HistoryChart
            {
                Left     = 1,
                Top      = 1,
                Width    = Width - 2,
                Height   = Height - 2,
                BarWidth = Constants.BarWidth,
                BarSpace = Constants.BarSpace,
                FontName = "Lucida Console",
                FontSize = 8
            };

            Controls.Add(HistoryChart);

            Closing += OnClosingInternal;
        }
Esempio n. 10
0
        protected virtual void PrepareCharts()
        {
            var learningPoints = new Series()
            {
                ChartType  = SeriesChartType.Point,
                Color      = Color.Red,
                MarkerSize = 10
            };

            for (int i = 0; i < LearningInputs.Length; i++)
            {
                learningPoints.Points.Add(new DataPoint(LearningInputs[i][0], LearningAnswers[i][0]));
            }

            computedFunction = new Series()
            {
                MarkerSize = 10, Color = Color.Green, ChartType = SeriesChartType.Point
            };

            AreaChart = new Chart
            {
                ChartAreas = { new ChartArea()
                               {
                                   AxisY ={ Maximum             = 1, Minimum = -1 }
                               } },
                Series = { learningPoints, computedFunction },
                Dock   = DockStyle.Top
            };

            HistoryChart = new HistoryChart
            {
                Lines =
                {
                    new HistoryChartValueLine {
                        DataFunction =        { Color= Color.Blue }
                    },
                },
                Dock = DockStyle.Bottom,
                Max  = MaxError
            };
        }
Esempio n. 11
0
        public static void Run(LearningArguments _arguments)
        {
            arguments = _arguments;
            baseMaker = _arguments.BaseMaker;
            baseMaker.Generate();

            table = new UserControl
            {
                Dock = DockStyle.Left,
                Size = new Size(400, 400)
            };

            success = new HistoryChart
            {
                Lines =
                {
                    new HistoryChartValueLine
                    {
                        DataFunction ={ Color                    = Color.Blue },
                    }
                },
                Dock = DockStyle.Right,
                Size = new Size(400, 400)
            };

            form = new Form()
            {
                Text       = "Symbols recognition",
                ClientSize = new Size(800, 400),
                Controls   =
                {
                    table,
                    success
                }
            };
            new Action(Learn).BeginInvoke(null, null);
            Application.Run(form);
        }
Esempio n. 12
0
        public void initControls()
        {
            /*load overall info control*/
            int[] todayData = { 0, 0, 0 }, sumData = { 0, 0, 0 };
            /*get data from DB*/
            IProvinceSumDataBLL    psdb = new ProvinceSumDataBLL();
            List <ProvinceSumData> psd  = psdb.selectALL();

            foreach (var data in psd)
            {
                sumData[0] += data.confirmed;
                sumData[1] += data.suspect;
                sumData[2] += data.death;
            }
            this.overallInfo = new Overallinfo(new Label[] { (Label)Controls.Find("LabelSumConfirmed", true)[0],
                                                             (Label)Controls.Find("LabelSumSuspect", true)[0],
                                                             (Label)Controls.Find("LabelSumDeath", true)[0], },
                                               todayData,
                                               sumData);
            /*load province rank control*/
            String[] proName = { };
            int[][]  datas   = { };
            /*get data from DB*/
            Dictionary <String, int[]> proData = new Dictionary <string, int[]>();

            foreach (var data in psd)
            {
                proData[data.province] = new int[] { data.confirmed, data.suspect, data.death }
            }
            ;
            this.provinceRank = new ProvinceRank(proData, (DataGridView)Controls.Find("DataGridView", true)[0]);
            /*load history chart control*/
            IProvinceDailyDataBLL      pddb       = new ProvinceDailyDataBLL();
            List <ProvinceDailyData>   pdd        = pddb.selectALL();
            Dictionary <String, int[]> sdd        = new Dictionary <string, int[]>();
            List <DailyData>           dailydatas = new List <DailyData>();

            for (int i = 0; i < pdd.Count; i++)
            {
                sdd[pdd[i].date] = new int[] { 0, 0, 0 };
            }
            foreach (var pair in sdd)
            {
                List <ProvinceDailyData> dd = pddb.selectByDate(pair.Key);
                foreach (var day in dd)
                {
                    sdd[pair.Key][0] += day.confirmed;
                    sdd[pair.Key][1] += day.suspect;
                    sdd[pair.Key][2] += day.death;
                }
            }

            int yesterdayCon = 0;

            foreach (var pair in sdd)
            {
                dailydatas.Add(new DailyData(pair.Key, pair.Value[0] - yesterdayCon, pair.Value[1], pair.Value[2]));
                yesterdayCon = pair.Value[0];
            }
            this.historyChart = new HistoryChart(dailydatas, (Chart)Controls.Find("Chart1", true)[0]);
            /*load news*/
            INewsDataBLL    ndb      = new NewsDataBLL();
            List <NewsData> nd       = ndb.selectALL();
            List <String[]> newsList = new List <string[]>();

            foreach (var news in nd)
            {
                newsList.Add(new String[] { news.title, news.url });
            }

            this.plagueNews = new PlagueNews(newsList, (ListBox)Controls.Find("listbox1", true)[0]);
            /*load knowledges*/
            IKnowledgeDataBLL    kdb      = new KnowledgeDataBLL();
            List <KnowledgeData> kd       = kdb.selectALL();
            List <string[]>      knowList = new List <string[]>();

            foreach (var strArr in kd)
            {
                knowList.Add(new string[] { strArr.title, strArr.type, strArr.content });
            }
            this.plagueKnowledge = new PlagueKnowledge(knowList, (RichTextBox)Controls.Find("richTextBox1", true)[0],
                                                       (Label)Controls.Find("label13", true)[0], (Label)Controls.Find("label14", true)[0],
                                                       (Button)Controls.Find("button1", true)[0], (Button)Controls.Find("button2", true)[0]);
            /*load plauge map*/
            IProvinceDefaultColorBLL    pdcb      = new ProvinceDefaultColorBLL();
            List <ProvinceDefaultColor> pdc       = pdcb.selectALL();
            Dictionary <String, Color>  befColor  = new Dictionary <string, Color>(),
                                        colOffset = new Dictionary <string, Color>();

            foreach (var prov in pdc)
            {
                befColor[prov.province]  = Color.FromArgb(255, prov.r, prov.g, prov.b);
                colOffset[prov.province] = Color.FromArgb(prov.rOffset, prov.gOffset, prov.bOffset);
            }

            IPlagueColorBLL         pcb      = new PlagueColorBLL();
            List <PlagueColor>      pc       = pcb.selectALL();
            Dictionary <int, Color> plgColor = new Dictionary <int, Color>();

            foreach (var p in pc)
            {
                plgColor[p.floor] = Color.FromArgb(255, p.r, p.g, p.b);
            }

            this.plagueMap = new PlagueMap(this.toolTip1, befColor, colOffset, proData, plgColor, this);
        }
Esempio n. 13
0
        static void Main()
        {
            task.Prepare();

            var targetFunction = new Series()
            {
                ChartType   = SeriesChartType.Line,
                Color       = Color.Red,
                BorderWidth = 2
            };

            for (int i = 0; i < task.Inputs.Length; i++)
            {
                targetFunction.Points.Add(new DataPoint(task.Inputs[i][0], task.Answers[i][0]));
            }

            computedFunction = new Series()
            {
                ChartType   = SeriesChartType.Line,
                Color       = Color.Green,
                BorderWidth = 2
            };

            history = new HistoryChart
            {
                Max       = task.MaxError,
                DotsCount = 200,
                Lines     =
                {
                    new HistoryChartValueLine
                    {
                        DataFunction ={ Color                    = Color.Blue }
                    }
                },
                Dock = DockStyle.Bottom
            };

            form = new Form()
            {
                Text            = task.GetType().Name,
                Size            = new Size(800, 600),
                FormBorderStyle = FormBorderStyle.FixedDialog,
                Controls        =
                {
                    new Chart
                    {
                        ChartAreas =
                        {
                            new ChartArea
                            {
                                AxisX =
                                {
                                    Minimum = task.Inputs.Min(z => z[0]),
                                    Maximum = task.Inputs.Max(z => z[0])
                                },
                                AxisY =
                                {
                                    Minimum = Math.Min(-1.5, task.Answers.Min(z => z[0])),
                                    Maximum = Math.Max(1.5,  task.Answers.Max(z => z[0]))
                                }
                            }
                        },
                        Series ={ targetFunction,  computedFunction },
                        Dock   = DockStyle.Top
                    },
                    history
                }
            };

            task.UpdateCharts += (s, a) => form.BeginInvoke(new Action(UpdateCharts));
            new Action(task.Learn).BeginInvoke(null, null);
            Application.Run(form);
        }