public async Task LoadMostDownloaded() { panel1.Controls.Clear(); panel1.Controls.Add(new MaterialLabel() { Text = "Loading ..." }); var x = await CratesIO.Summery(); int offset = 0; panel1.Controls.Clear(); foreach (var i in x.most_downloaded) { Panel p = new Panel(); p.Controls.Add(new MaterialLabel() { Text = "Name: " + i.name, AutoSize = true }); p.Controls.Add(new MaterialLabel() { Text = "Version: " + i.max_version, Location = new Point(0, 20), AutoSize = true }); var btn = new MaterialRaisedButton() { Text = "Install", Location = new Point(2, 40), Enabled = InstalledPackages.ContainsKey(i.name) == false }; btn.Click += (ssender, ee) => { }; p.Controls.Add(btn); p.Controls.Add(new MaterialLabel() { Text = "Description: \n" + i.description, Location = new Point(150, 0), AutoSize = true }); p.BorderStyle = BorderStyle.FixedSingle; p.Location = new Point(0, offset); p.Size = new Size(panel1.Size.Width - 20, p.Size.Height); offset += p.Height + 5; panel1.Controls.Add(p); } }
private void InitializeComponent() { // Auto generated by the designer notNowButton = new MaterialRaisedButton(); this.updateButton = new MaterialRaisedButton(); this.changeLogText = new MaterialLabel(); this.SuspendLayout(); // // notNowButton // this.notNowButton.Depth = 0; this.notNowButton.Location = new Point(12, 257); this.notNowButton.MouseState = MouseState.HOVER; this.notNowButton.Name = "notNowButton"; this.notNowButton.Primary = true; this.notNowButton.Size = new Size(120, 31); this.notNowButton.TabIndex = 0; this.notNowButton.Text = "Not Now"; this.notNowButton.UseVisualStyleBackColor = true; // // updateButton // this.updateButton.Depth = 0; this.updateButton.Location = new Point(368, 257); this.updateButton.MouseState = MouseState.HOVER; this.updateButton.Name = "updateButton"; this.updateButton.Primary = true; this.updateButton.Size = new Size(120, 31); this.updateButton.TabIndex = 1; this.updateButton.Text = "Update"; this.updateButton.UseVisualStyleBackColor = true; // // changeLogText // this.changeLogText.Depth = 0; this.changeLogText.Font = new Font("Roboto", 11F); this.changeLogText.ForeColor = Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.changeLogText.Location = new Point(12, 75); this.changeLogText.MouseState = MouseState.HOVER; this.changeLogText.Name = "changeLogText"; this.changeLogText.Size = new Size(476, 160); this.changeLogText.TabIndex = 2; this.changeLogText.Text = "changeLogText"; // // UpdateDialog // // Default ClientSize this.ClientSize = new Size(500, 300); this.Controls.Add(this.changeLogText); this.Controls.Add(this.updateButton); this.Controls.Add(this.notNowButton); this.Name = "UpdateDialog"; this.Text = "An Update is Available"; this.Icon = Properties.Resources.MainIcon; this.ResumeLayout(false); }
protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; g.TextRenderingHint = TextRenderingHint.AntiAlias; g.Clear(Parent.BackColor); //Hover Color c = Shade != Shades.None ? MaterialSkinManager.GetMaterialColor(Shade) : SkinManager.GetFlatButtonHoverBackgroundColor(); using (Brush b = Shade != Shades.None ? new SolidBrush(c) : new SolidBrush(Color.FromArgb((int)(_hoverAnimationManager.GetProgress() * c.A), c.RemoveAlpha()))) // g.FillRectangle(b, ClientRectangle); //Ripple if (_animationManager.IsAnimating()) { g.SmoothingMode = SmoothingMode.AntiAlias; for (var i = 0; i < _animationManager.GetAnimationCount(); i++) { var animationValue = _animationManager.GetProgress(i); var animationSource = _animationManager.GetSource(i); using (Brush rippleBrush = new SolidBrush(Color.FromArgb((int)(101 - (animationValue * 100)), Color.Black))) { var rippleSize = (int)(animationValue * Width * 2); g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); } } g.SmoothingMode = SmoothingMode.None; } //Icon if (Icon != null) { var iconRect = new Rectangle(8, (Height / 2) - Icon.Height / 2, Icon.Width, Icon.Height); //create a color matrix object & set the opacity var matrix = new ColorMatrix { Matrix33 = Enabled ? (float)0.75 : (float)0.30 }; //set the color(opacity) of the image var attributes = new ImageAttributes(); attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); // Draw the image g.DrawImage(Icon, iconRect, 0, 0, Icon.Width, Icon.Height, GraphicsUnit.Pixel, attributes); } //Text var textRect = ClientRectangle; if (Icon != null) { // // Resize and move Text container // // First 8: left padding // 24: icon width // Second 4: space between Icon and Text // Third 8: right padding textRect.Width -= 8 + 24 + 4 + 8; // First 8: left padding // 24: icon width // Second 4: space between Icon and Text textRect.X += 8 + 24 + 4; } var fontColor = Enabled ? (Primary ? SkinManager.ColorScheme.PrimaryBrush : SkinManager.GetPrimaryTextBrush()) : SkinManager.GetFlatButtonDisabledTextBrush(); if (Shade != Shades.None) { fontColor = MaterialSkinManager.GetMaterialBrush(Shade); } g.DrawString( Text.ToUpper(), SkinManager.ROBOTO_MEDIUM_10, fontColor, textRect, new StringFormat { Alignment = MaterialRaisedButton.ContentToTextHAlignment(TextAlign), LineAlignment = MaterialRaisedButton.ContentToTextVAlignment(TextAlign) }); }
public async Task Search(string term) { panel1.Controls.Clear(); panel1.Controls.Add(new MaterialLabel() { Text = "Loading ..." }); var x = await CratesIO.Search(term); int offset = 0; panel1.Controls.Clear(); foreach (var i in x.crates) { Panel p = new Panel(); p.Controls.Add(new MaterialLabel() { Text = "Name: " + i.name, AutoSize = true }); p.Controls.Add(new MaterialLabel() { Text = "Version: " + i.max_version, Location = new Point(0, 20), AutoSize = true }); var btn = new MaterialRaisedButton() { Name = i.name + "~" + i.max_version, AutoSize = true ,Text = InstalledPackages.ContainsKey(i.name) == false? "Install" : "Uninstall", Location = new Point(2, 40)}; btn.Click += (ssender, ee) => { var b = ssender as MaterialRaisedButton; if (b.Text == "Install") { var toml = File.ReadAllText(Path.Combine(Globals.CurrentProject, "Cargo.toml")); string rep = ""; foreach (var xx in toml.Replace("\r\n", "\n").Split('\n')) { if (xx.Trim() == "[dependencies]") { rep += xx + "\r\n" + b.Name.Split('~')[0] + " = " + b.Name.Split('~')[1] + "\r\n"; } else { rep += xx + "\r\n"; } } File.WriteAllText(Path.Combine(Globals.CurrentProject, "Cargo.toml"), rep); MessageBox.Show("Installed package " + b.Name.Split('~')[0]); this.Close(); } else { var toml = File.ReadAllText(Path.Combine(Globals.CurrentProject, "Cargo.toml")); string rep = ""; bool founddep = false; foreach (var xx in toml.Replace("\r\n", "\n").Split('\n')) { if (founddep) { if (xx.Split('=')[0].Trim() == b.Name.Split('~')[0]) { rep = xx; break; } } if (xx.Trim() == "[dependencies]") { founddep = true; } } File.WriteAllText(Path.Combine(Globals.CurrentProject, "Cargo.toml"), toml.Replace(rep, "")); MessageBox.Show("Uninstalled package " + b.Name.Split('~')[0]); this.Close(); } }; p.Controls.Add(btn); p.Controls.Add(new MaterialLabel() { Text = "Description: \n" + i.description, Location = new Point(150, 0), AutoSize = true }); p.BorderStyle = BorderStyle.FixedSingle; p.Location = new Point(0, offset); p.Size = new Size(panel1.Size.Width - 20, p.Size.Height); offset += p.Height + 5; panel1.Controls.Add(p); } }