khorsandreza
دوشنبه 22 بهمن 1397, 21:21 عصر
سلام وقت دوستان بخیر من یک User Control درست کردم (تصویر را ببینید) در فرم دو کلید اضافه شده حال می خواهم در بعضی فرم ها که درگ می کنم Visble بودن این کلیدها دسترسی داشته باشم
149781
این هم سورس
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using WMPLib;
namespace xVideo
{
public partial class VideoControl : UserControl
{
public VideoControl()
{
InitializeComponent();
SnapShot.Parent = WMP;
}
private Bitmap TakeImage(int X, int Y, int Width, int Height)
{
Bitmap Img = new Bitmap(Width, Height);
Graphics g = Graphics.FromImage(Img);
g.CopyFromScreen(X, Y, 0, 0, Img.Size);
g.Dispose();
return Img;
}
public Bitmap ResizeBitmap(Bitmap bmp, int width, int height)
{
Bitmap result = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(result))
{
g.DrawImage(bmp, 0, 0, width, height);
}
return result;
}
private void SnapShot_Click(object sender, EventArgs e)
{
try
{
Bitmap bmp = TakeImage(this.ParentForm.Location.X + 28, this.ParentForm.Location.Y + 40, WMP.Width - 40, WMP.Height - 80);
Bitmap newbmp = ResizeBitmap(bmp, 140, 96);
pictureBox1.Image = bmp;
string _filepath = Path.GetTempPath() + "snapshot.jpg";
newbmp.Save(_filepath, System.Drawing.Imaging.ImageFormat.Jpeg);
SnapShotTimer.Enabled = true;
pictureBox1.Visible = true;
}
catch
{
MessageBox.Show("خطا در ایجاد اسکرین شات");
}
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog OpenFile = new OpenFileDialog();
if (OpenFile.ShowDialog() == DialogResult.OK)
{
WMP.Ctlcontrols.stop();
string adre;
adre = OpenFile.FileName;
WMP.currentPlaylist.appendItem(WMP.newMedia(adre)) ;
WMP.Ctlcontrols.play();
}
}
private void SnapShotTimer_Tick(object sender, EventArgs e)
{
SnapShotTimer.Enabled = false;
pictureBox1.Visible = false;
}
}
}
149781
این هم سورس
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using WMPLib;
namespace xVideo
{
public partial class VideoControl : UserControl
{
public VideoControl()
{
InitializeComponent();
SnapShot.Parent = WMP;
}
private Bitmap TakeImage(int X, int Y, int Width, int Height)
{
Bitmap Img = new Bitmap(Width, Height);
Graphics g = Graphics.FromImage(Img);
g.CopyFromScreen(X, Y, 0, 0, Img.Size);
g.Dispose();
return Img;
}
public Bitmap ResizeBitmap(Bitmap bmp, int width, int height)
{
Bitmap result = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(result))
{
g.DrawImage(bmp, 0, 0, width, height);
}
return result;
}
private void SnapShot_Click(object sender, EventArgs e)
{
try
{
Bitmap bmp = TakeImage(this.ParentForm.Location.X + 28, this.ParentForm.Location.Y + 40, WMP.Width - 40, WMP.Height - 80);
Bitmap newbmp = ResizeBitmap(bmp, 140, 96);
pictureBox1.Image = bmp;
string _filepath = Path.GetTempPath() + "snapshot.jpg";
newbmp.Save(_filepath, System.Drawing.Imaging.ImageFormat.Jpeg);
SnapShotTimer.Enabled = true;
pictureBox1.Visible = true;
}
catch
{
MessageBox.Show("خطا در ایجاد اسکرین شات");
}
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog OpenFile = new OpenFileDialog();
if (OpenFile.ShowDialog() == DialogResult.OK)
{
WMP.Ctlcontrols.stop();
string adre;
adre = OpenFile.FileName;
WMP.currentPlaylist.appendItem(WMP.newMedia(adre)) ;
WMP.Ctlcontrols.play();
}
}
private void SnapShotTimer_Tick(object sender, EventArgs e)
{
SnapShotTimer.Enabled = false;
pictureBox1.Visible = false;
}
}
}