public FmDUIScaleableControlDemo() { InitializeComponent(); DUIThreadSafeBitmapBrush backMeshBrush = new DUIThreadSafeBitmapBrush(new Size(20, 20), (g, s) => { using (DUISolidBrush brushMeshDark = new DUISolidBrush(Color.FromArgb(29, 29, 29))) using (DUISolidBrush brushMeshLight = new DUISolidBrush(Color.FromArgb(159, 159, 159))) { g.FillRectangle(brushMeshDark, new Rectangle(0, 0, 10, 10)); g.FillRectangle(brushMeshDark, new Rectangle(10, 10, 10, 10)); g.FillRectangle(brushMeshLight, new Rectangle(10, 0, 10, 10)); g.FillRectangle(brushMeshLight, new Rectangle(0, 10, 10, 10)); } }); DUIImage dUIImage = DUIImage.FromFile(@"Resources\1.jpg"); DUIScaleableControl dUIScaleableControl = new DUIScaleableControl() { Dock = DockStyle.Fill }; dUIScaleableControl.Paint += (s, e) => { backMeshBrush.Draw(e.Graphics, dUIScaleableControl.ScaleableBounds); e.Graphics.DrawImage(dUIImage, 0, 0); }; this.duiNativeControl1.DUIControls.Add(dUIScaleableControl); }
private void btnAddImage_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = false; ofd.Title = "选择图片哦"; if (ofd.ShowDialog() == DialogResult.OK) { this.duiNativeControl1.DUIControls.Add(new DUIEditableControlWithCenter(dUIEditableCenterControl) { X = random.Next(0, this.ClientSize.Width - 100), Y = random.Next(0, this.ClientSize.Height - 100), Width = 100, Height = 100, CanRotate = true, CanSkew = true, CenterX = 35, CenterY = 35, IsCenterFollow = true, BorderWidth = 15, BackgroundImage = DUIImage.FromFile(ofd.FileName) }); } }
public FmDUIEditableControlDemo() { InitializeComponent(); DUIEditableControlWithCenter dUIEditableControl1 = new DUIEditableControlWithCenter(dUIEditableCenterControl) { X = random.Next(0, this.ClientSize.Width - 100), Y = random.Next(0, this.ClientSize.Height - 100), Width = 100, Height = 100, CanRotate = true, CanSkew = true, CenterX = 35, CenterY = 35, IsCenterFollow = true, BorderWidth = 15, BackgroundImage = DUIImage.FromFile(@"Resources\1.jpg") }; DUIEditableControlWithCenter dUIEditableControl2 = new DUIEditableControlWithCenter(dUIEditableCenterControl) { X = random.Next(0, this.ClientSize.Width - 100), Y = random.Next(0, this.ClientSize.Height - 100), Width = 100, Height = 100, CanRotate = true, CanSkew = true, CenterX = 35, CenterY = 35, IsCenterFollow = true, BorderWidth = 15, BackgroundImage = DUIImage.FromFile(@"Resources\2.jpg") }; this.duiNativeControl1.DUIControls.Add(dUIEditableCenterControl); this.duiNativeControl1.DUIControls.Add(dUIEditableControl1); this.duiNativeControl1.DUIControls.Add(dUIEditableControl2); }