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; }
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(); }; }