public virtual void FireFrameEvent(String eventName, object data)
        {
            FramedEventHandler handler = FramedEvents;

            if (handler != null)
            {
                handler(eventName, data);
            }
        }
 public HardwareContent(FrameForm form, List <Bundle> bundles) : base(form)
 {
     advancedMiningLabel = new Label()
     {
         Text      = "Advanced Mining",
         ForeColor = Color.FromArgb(255, 98, 112, 131),
         Font      = new Font("Arial", 12, FontStyle.Regular),
         Location  = new Point(leftMargin, topMargin),
         Size      = new Size(200, 23)
     };
     BundlesLoaded = (name, data) =>
     {
         if (name.Equals("BundlesLoaded"))
         {
             bundles = data as List <Bundle>;
             for (int i = 0; i < bundles.Count(); i++)
             {
                 this.RegisterChildContent(new AdvancedBundle(form, bundles[i], bundles, advancedBundlesTopMargin + i * advancedBundlesTopPadding + i * advancedBundleHeight, advancedBundleHeight));
             }
         }
         form.FramedEvents -= BundlesLoaded;
     };
     form.FramedEvents += BundlesLoaded;
 }
        public EstimatedDailyEarnings(FrameForm form) : base(form)
        {
            areaRectangle = new Rectangle(MainFrame.LeftPadding + leftMargin, topMargin + rectangleTopMargin, buttonWidth, buttonHeight);

            estimatedDailyEarningsLabel = new Label()
            {
                Text      = "ESTIMATED DAILY EARNINGS",
                ForeColor = MainFrame.TitleLabelColor,
                Font      = new Font("Arial", 8, FontStyle.Regular),
                Location  = new Point(MainFrame.LeftPadding + leftMargin, topMargin),
                Size      = new Size(200, 11)
            };
            ethBalance = new Label()
            {
                Text      = "0.02 ETH",
                ForeColor = Color.White,
                Font      = new Font("Arial", 11, FontStyle.Bold),
                Location  = new Point(MainFrame.LeftPadding + leftMargin + 20, topMargin + rectangleTopMargin + 17),
                Size      = new Size(150, 19),
                BackColor = areaBackgroundColor
            };
            usdBalance = new Label()
            {
                Text      = "USD 0.01",
                ForeColor = Color.White,
                Font      = new Font("Arial", 10, FontStyle.Regular),
                Location  = new Point(MainFrame.LeftPadding + leftMargin + 20, topMargin + rectangleTopMargin + 41),
                Size      = new Size(150, 19),
                BackColor = areaBackgroundColor
            };

            DailyEarningChanged = (name, data) =>
            {
                if (name.Equals("DailyETHEarningChanged"))
                {
                    String estimatedEthString;
                    String estimatedUsdString;

                    estimatedETH = Double.Parse(data.ToString());
                    Double usdEq = estimatedETH * MainFrame.ETHIndex;

                    if (estimatedETH.ToString().Contains(','))
                    {
                        int dotPos = estimatedETH.ToString().IndexOf(',');
                        estimatedEthString = estimatedETH.ToString().Replace(',', '.');
                        if (dotPos + 8 < estimatedETH.ToString().Length)
                        {
                            estimatedEthString = estimatedEthString.Substring(0, 8 + dotPos);
                        }
                    }
                    else
                    {
                        estimatedEthString = estimatedETH.ToString();
                    }


                    if (usdEq.ToString().Contains(','))
                    {
                        int usdDotPos = usdEq.ToString().IndexOf(',');
                        estimatedUsdString = usdEq.ToString().Replace(',', '.');
                        if (usdDotPos + 3 < usdEq.ToString().Length)
                        {
                            estimatedUsdString = estimatedUsdString.Substring(0, 3 + usdDotPos);
                        }
                    }
                    else
                    {
                        estimatedUsdString = usdEq.ToString();
                    }


                    ethBalance.Text = estimatedEthString + " ETH";
                    usdBalance.Text = "USD " + estimatedUsdString;
                }
            };

            form.FramedEvents += DailyEarningChanged;
        }
Exemplo n.º 4
0
        public StartMiningButton(FrameForm form, List <Bundle> bundles) : base(form)
        {
            StartMiningButton s = this;

            buttonBackground = Color.FromArgb(255, 39, 52, 62);
            statusLabel      = new Label()
            {
                Text      = "START",
                ForeColor = Color.White,
                Font      = new Font("Arial", 14, FontStyle.Bold),
                Location  = new Point(leftPadding + leftMargin + 86, topPadding + topMargin + 28),
                BackColor = buttonBackground
            };

            buttonRectangle          = new Rectangle(leftPadding + leftMargin, topPadding + topMargin, buttonWidth, buttonHeight);
            playPauseButtonRectangle = new Rectangle(buttonRectangle.X + 22, buttonRectangle.Y + 23, 27, 30);

            BundleStatusChangedHidden = (name, data) =>
            {
                if (name.Equals("BundleStatusChanged"))
                {
                    mining = IsMining(data as List <Bundle>);
                }
            };
            BundleStatusChanged = (name, data) =>
            {
                if (name.Equals("BundleStatusChanged"))
                {
                    bool newStatus = IsMining(data as List <Bundle>);
                    if (newStatus != mining)
                    {
                        mining = newStatus;
                        Graphics gfx = this.Form.CreateGraphics();
                        gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                        statusLabel.Text  = mining ? "STOP" : "START";

                        this.ClearPlayPause(gfx, playPauseButtonRectangle, buttonBackground);
                        if (mining)
                        {
                            this.DrawPause(gfx, playPauseButtonRectangle);
                        }
                        else
                        {
                            this.DrawPlay(gfx, playPauseButtonRectangle);
                        }
                        gfx.Dispose();
                    }
                }
            };
            statusLabel.Click += (o, i) =>
            {
                if (IsMining(bundles))
                {
                    foreach (Bundle bundle in bundles)
                    {
                        bundle.StopMining();
                    }
                }
                else
                {
                    foreach (Bundle bundle in bundles)
                    {
                        bundle.StartMining();
                    }
                }
                form.FireFrameEvent("BundleStatusChanged", bundles);
            };
            globalMouseClickEventHander = (o, i) =>
            {
                if (buttonRectangle.Contains(i.Location))
                {
                    if (IsMining(bundles))
                    {
                        foreach (Bundle bundle in bundles)
                        {
                            bundle.StopMining();
                        }
                    }
                    else
                    {
                        foreach (Bundle bundle in bundles)
                        {
                            bundle.StartMining();
                        }
                    }
                    form.FireFrameEvent("BundleStatusChanged", bundles);
                }
            };

            form.FramedEvents += BundleStatusChangedHidden;
        }
Exemplo n.º 5
0
        public Hardware(FrameForm form) : base(form)
        {
            leftAlgoMargin       = MainFrame.LeftPadding + 555;
            leftHashrateMargin   = leftAlgoMargin + 136;
            leftEstMargin        = leftHashrateMargin + 153;
            leftBundleNameMargin = leftPrefixMargin + 45;
            hardwareLabel        = new Label()
            {
                Text      = "Hardware",
                ForeColor = Color.FromArgb(255, 98, 112, 131),
                Font      = new Font("Arial", 12, FontStyle.Regular),
                Location  = new Point(leftMargin, topMargin),
                Size      = new Size(100, 23)
            };

            algorythmLabel = new Label()
            {
                Text      = "ALGORYTHM",
                ForeColor = MainFrame.TitleLabelColor,
                Font      = new Font("Arial", 8, FontStyle.Regular),
                Location  = new Point(leftAlgoMargin, topMargin + secondLabelLine),
                Size      = new Size(100, 15)
            };

            hashrateLabel = new Label()
            {
                Text      = "HASHRATE",
                ForeColor = MainFrame.TitleLabelColor,
                Font      = new Font("Arial", 8, FontStyle.Regular),
                Location  = new Point(leftHashrateMargin, topMargin + secondLabelLine),
                Size      = new Size(100, 15)
            };

            ethdayLabel = new Label()
            {
                Text      = "ETH/DAY",
                ForeColor = MainFrame.TitleLabelColor,
                Font      = new Font("Arial", 8, FontStyle.Regular),
                Location  = new Point(leftEstMargin, topMargin + secondLabelLine),
                Size      = new Size(100, 15)
            };

            BundlesLoaded = (name, data) =>
            {
                if (name.Equals("BundlesLoaded"))
                {
                    bundles            = data as List <Bundle>;
                    form.FramedEvents -= BundlesLoaded;
                    bundlesPrefixes    = new Label[bundles.Count];
                    bundlesNames       = new Label[bundles.Count];
                    bundlesAlgos       = new Label[bundles.Count];
                    bundlesHashrates   = new Label[bundles.Count];
                    bundlesEst         = new Label[bundles.Count];
                    for (int i = 0; i < bundles.Count(); i++)
                    {
                        String hashrate = bundles[i].GetHashrate().ToString();
                        if (hashrate.Contains(','))
                        {
                            int intsAfterDot = hashrate.Length - hashrate.IndexOf(',') - 1;
                            if (intsAfterDot > 3)
                            {
                                hashrate = hashrate.Substring(0, hashrate.IndexOf(',') + 3);
                            }
                            hashrate = hashrate.Replace(',', '.');
                        }
                        String estimates = bundles[i].Estimates.ToString();
                        if (estimates.Contains(','))
                        {
                            int intsAfterDot = estimates.Length - estimates.IndexOf(',') - 1;
                            if (intsAfterDot > 3)
                            {
                                estimates = estimates.Substring(0, estimates.IndexOf(',') + 3);
                            }
                            estimates = estimates.Replace(',', '.');
                        }
                        bundlesPrefixes[i] = new Label()
                        {
                            Text      = bundles[i].Type == 0 ? "CPU:" : "GPU:",
                            ForeColor = Color.White,
                            Font      = new Font("Arial", 11, FontStyle.Bold),
                            Location  = new Point(leftPrefixMargin, topMargin + secondLabelLine + hardwareFirstLineTopMargin + hardwareLineHeight * i + hardwareLabelTopMargin),
                            Size      = new Size(47, 20),
                            BackColor = hardwareBackgroundLine
                        };
                        bundlesNames[i] = new Label()
                        {
                            Text      = bundles[i].Name,
                            ForeColor = Color.White,
                            Font      = new Font("Arial", 11, FontStyle.Regular),
                            Location  = new Point(leftBundleNameMargin, topMargin + secondLabelLine + hardwareFirstLineTopMargin + hardwareLineHeight * i + hardwareLabelTopMargin),
                            Size      = new Size(400, 17),
                            BackColor = hardwareBackgroundLine
                        };
                        bundlesAlgos[i] = new Label()
                        {
                            Text      = bundles[i].Algo.Name,
                            ForeColor = Color.White,
                            Font      = new Font("Arial", 11, FontStyle.Regular),
                            Location  = new Point(leftAlgoMargin, topMargin + secondLabelLine + hardwareFirstLineTopMargin + hardwareLineHeight * i + hardwareLabelTopMargin),
                            Size      = new Size(120, 17)
                        };
                        bundlesHashrates[i] = new Label()
                        {
                            Text      = hashrate + " " + bundles[i].Algo.HashrateSizer,
                            ForeColor = Color.White,
                            Font      = new Font("Arial", 11, FontStyle.Regular),
                            Location  = new Point(leftHashrateMargin, topMargin + secondLabelLine + hardwareFirstLineTopMargin + hardwareLineHeight * i + hardwareLabelTopMargin),
                            Size      = new Size(120, 17)
                        };
                        bundlesEst[i] = new Label()
                        {
                            Text      = estimates,
                            ForeColor = Color.White,
                            Font      = new Font("Arial", 11, FontStyle.Regular),
                            Location  = new Point(leftEstMargin, topMargin + secondLabelLine + hardwareFirstLineTopMargin + hardwareLineHeight * i + hardwareLabelTopMargin),
                            Size      = new Size(120, 17)
                        };
                        int       top             = topMargin + secondLabelLine + hardwareFirstLineTopMargin + hardwareLineHeight * i + 4;
                        Rectangle activeRectangle = new Rectangle(MainFrame.LeftPadding + 19 + 23, top + 12, 16, 16);
                        Bundle    activeBundle    = bundles[i];
                        bundleStartPauseEvents.Add((o, i1) =>
                        {
                            if (activeRectangle.Contains(i1.Location))
                            {
                                if (activeBundle.IsMining())
                                {
                                    activeBundle.StopMining();
                                }
                                else
                                {
                                    activeBundle.StartMining();
                                }
                                form.FireFrameEvent("BundleStatusChanged", bundles);
                            }
                        });
                    }
                }
            };
            BundleStatusChanged = (name, data) =>
            {
                if (name.Equals("BundleStatusChanged"))
                {
                    Graphics gfx = form.CreateGraphics();
                    for (int i = 0; i < bundles.Count(); i++)
                    {
                        if (bundles[i].ToRedraw)
                        {
                            int top = topMargin + secondLabelLine + hardwareFirstLineTopMargin + hardwareLineHeight * i + 4;
                            this.DrawRoundedRectangle(gfx, new Rectangle(MainFrame.LeftPadding + 19, top, 510, 40), 20, new Pen(Color.FromArgb(255, 69, 79, 93), 1), Color.FromArgb(255, 46, 53, 62));
                            if (bundles[i].IsMining())
                            {
                                this.DrawPause(gfx, new Rectangle(MainFrame.LeftPadding + 19 + 23, top + 12, 16, 16));
                            }
                            else
                            {
                                this.DrawPlay(gfx, new Rectangle(MainFrame.LeftPadding + 19 + 23, top + 12, 16, 16));
                            }
                            bundles[i].Redrawed();
                        }
                    }
                    gfx.Dispose();
                }
            };

            BundleStatusChangedHidden = (name, data) =>
            {
                if (name.Equals("BundleStatusChanged"))
                {
                    for (int i = 0; i < bundles.Count(); i++)
                    {
                        if (bundles[i].IsMining())
                        {
                            String hashrate = bundles[i].GetHashrate().ToString();
                            if (hashrate.Contains(','))
                            {
                                int intsAfterDot = hashrate.Length - hashrate.IndexOf(',') - 1;
                                if (intsAfterDot > 3)
                                {
                                    hashrate = hashrate.Substring(0, hashrate.IndexOf(',') + 3);
                                }
                                hashrate = hashrate.Replace(',', '.');
                            }
                            String estimates = bundles[i].Estimates.ToString();
                            if (estimates.Contains(','))
                            {
                                int intsAfterDot = estimates.Length - estimates.IndexOf(',') - 1;
                                if (intsAfterDot > 6)
                                {
                                    estimates = estimates.Substring(0, estimates.IndexOf(',') + 6);
                                }
                                estimates = estimates.Replace(',', '.');
                            }
                            bundlesAlgos[i].Text     = bundles[i].Algo.Name;
                            bundlesHashrates[i].Text = hashrate + " " + bundles[i].Algo.HashrateSizer;
                            bundlesEst[i].Text       = estimates;
                        }
                    }
                }
            };

            form.FramedEvents += BundlesLoaded;
            form.FramedEvents += BundleStatusChangedHidden;
        }
Exemplo n.º 6
0
        public Balance(FrameForm form) : base(form)
        {
            areaRectangle = new Rectangle(MainFrame.LeftPadding + leftMargin, topMargin + rectangleTopMargin, buttonWidth, buttonHeight);

            yourBalance = new Label()
            {
                Text      = "YOUR BALANCE",
                ForeColor = MainFrame.TitleLabelColor,
                Font      = new Font("Arial", 8, FontStyle.Regular),
                Location  = new Point(MainFrame.LeftPadding + leftMargin, topMargin),
                Size      = new Size(200, 11)
            };
            ethBalance = new Label()
            {
                Text      = "0.02 ETH",
                ForeColor = Color.White,
                Font      = new Font("Arial", 11, FontStyle.Bold),
                Location  = new Point(MainFrame.LeftPadding + leftMargin + 20, topMargin + rectangleTopMargin + 17),
                Size      = new Size(150, 19),
                BackColor = areaBackgroundColor
            };
            usdBalance = new Label()
            {
                Text      = "USD 0.01",
                ForeColor = Color.White,
                Font      = new Font("Arial", 10, FontStyle.Regular),
                Location  = new Point(MainFrame.LeftPadding + leftMargin + 20, topMargin + rectangleTopMargin + 41),
                Size      = new Size(150, 19),
                BackColor = areaBackgroundColor
            };

            DailyEarningChanged = (name, data) =>
            {
                if (name.Equals("ETHBalanceChanged"))
                {
                    String ethStrBalance;
                    String usdStrBalance;

                    ETHBalance += Double.Parse(data.ToString());
                    if (ETHBalance.ToString().Contains(','))
                    {
                        int dotPos = ETHBalance.ToString().IndexOf(',');
                        ethStrBalance = ETHBalance.ToString().Replace(',', '.');
                        if (8 + dotPos < ETHBalance.ToString().Length)
                        {
                            ethBalance.Text = ethStrBalance.Substring(0, 8 + dotPos);
                        }
                    }
                    else
                    {
                        ethStrBalance = ethBalance.ToString();
                    }
                    Double usdEq = ETHBalance * MainFrame.ETHIndex;

                    if (usdEq.ToString().Contains(','))
                    {
                        int usdDotPos = usdEq.ToString().IndexOf(',');
                        usdStrBalance = usdEq.ToString().Replace(',', '.');
                        if (3 + usdDotPos < usdEq.ToString().Length)
                        {
                            usdStrBalance = usdStrBalance.Substring(0, 3 + usdDotPos);
                        }
                    }
                    else
                    {
                        usdStrBalance = usdEq.ToString();
                    }


                    ethBalance.Text = ethStrBalance + " ETH";
                    usdBalance.Text = "USD " + usdStrBalance;
                }
            };

            form.FramedEvents += DailyEarningChanged;
        }
Exemplo n.º 7
0
        public AdvancedBundle(FrameForm form, Bundle bundle, List <Bundle> bundles, int topMargin, int elementHeight) : base(form)
        {
            this.topMargin = topMargin;
            this.bundle    = bundle;


            bundleRectangle    = new Rectangle(MainFrame.LeftPadding + paddingLeft, topMargin, bundleWidth, elementHeight);
            playPauseRectangle = new Rectangle(MainFrame.LeftPadding + paddingLeft + playPauseLeftPadding, topMargin + playPauseTopPadding, 16, 16);

            bundlePrefix = new Label()
            {
                Text      = bundle.Type == 0 ? "CPU:" : "GPU:",
                ForeColor = Color.White,
                Font      = new Font("Arial", 11, FontStyle.Bold),
                Location  = new Point(leftPrefixMargin, topMargin + 13),
                Size      = new Size(47, 20),
                BackColor = hardwareBackgroundLine
            };
            bundleName = new Label()
            {
                Text      = bundle.Name,
                ForeColor = Color.White,
                Font      = new Font("Arial", 11, FontStyle.Regular),
                Location  = new Point(leftBundleNameMargin, topMargin + 13),
                Size      = new Size(400, 17),
                BackColor = hardwareBackgroundLine
            };
            globalMouseClickEventHander = (o, i1) =>
            {
                if (playPauseRectangle.Contains(i1.Location))
                {
                    if (bundle.IsMining())
                    {
                        bundle.StopMining();
                    }
                    else
                    {
                        bundle.StartMining();
                    }
                    form.FireFrameEvent("BundleStatusChanged", bundles);
                }
            };
            BundleStatusChanged = (name, data) =>
            {
                Graphics gfx = form.CreateGraphics();
                for (int i = 0; i < bundles.Count(); i++)
                {
                    if (bundles[i].Equals(bundle) && bundles[i].ToRedraw)
                    {
                        this.DrawRectangle(gfx, this.GetIncreasedRectangle(playPauseRectangle, 1), hardwareBackgroundLine);
                        if (bundles[i].IsMining())
                        {
                            this.DrawPause(gfx, playPauseRectangle);
                        }
                        else
                        {
                            this.DrawPlay(gfx, playPauseRectangle);
                        }
                        bundles[i].Redrawed();
                    }
                }
                gfx.Dispose();
            };
        }