我想透過Window Form app 去做個桌面程式。它能夠讀取圖片像C#內Resource讀取圖片那樣 以及能做到圖層堆疊像Photoshop。但是目前還無法實現外部讀取圖片功能如下圖所示我知道C#有OpenFileDialog class 可以達到做外部功能可是目前還需實現點選圖檔
將圖檔存進自行定義結構當中,然後能像c# resource直接將圖片叫出來用。C# 可以透過將PictureBox 堆疊在Panel 將Panel BackColor 設定為Transparent實現透明圖層概念但是我自己寫功能無法實現private void AddNewPhotoToolStripButton_Click(object sender, EventArgs e)
{
/*
var fileContent = string.Empty;
var filePath = string.Empty; using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.InitialDirectory = "c:\\";
openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
//Get the path of specified file
filePath = openFileDialog.FileName; //Read the contents of the file into a stream
var fileStream = openFileDialog.OpenFile(); using (StreamReader reader = new StreamReader(fileStream))
{
fileContent = reader.ReadToEnd();
}
}//end if
}
MessageBox.Show(fileContent, "File Content at path: " + filePath, MessageBoxButtons.OK);
*/
Panel backGround = new Panel();
backGround.Location = new System.Drawing.Point(67, 57);
backGround.Size = new System.Drawing.Size(800, 480);
backGround.BackgroundImage = Properties.Resources.fullground;
backGround.BackColor = Color.Transparent;
Controls.Add(backGround);
backGround.BringToFront();
} private void OvelayPhotolStripButton_Click(object sender, EventArgs e)
{
PictureBox a =new PictureBox();
a.Location = new System.Drawing.Point(200, 107);
a.Size = new System.Drawing.Size(200, 50);
a.BackgroundImage = Properties.Resources.needle;
a.BackColor = Color.Transparent;
Controls.Add(a);
a.BringToFront();
}
}目前結果如下圖請問該如何解決圖層透明堆疊問題圖片都是png檔
將圖檔存進自行定義結構當中,然後能像c# resource直接將圖片叫出來用。C# 可以透過將PictureBox 堆疊在Panel 將Panel BackColor 設定為Transparent實現透明圖層概念但是我自己寫功能無法實現private void AddNewPhotoToolStripButton_Click(object sender, EventArgs e)
{
/*
var fileContent = string.Empty;
var filePath = string.Empty; using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.InitialDirectory = "c:\\";
openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
//Get the path of specified file
filePath = openFileDialog.FileName; //Read the contents of the file into a stream
var fileStream = openFileDialog.OpenFile(); using (StreamReader reader = new StreamReader(fileStream))
{
fileContent = reader.ReadToEnd();
}
}//end if
}
MessageBox.Show(fileContent, "File Content at path: " + filePath, MessageBoxButtons.OK);
*/
Panel backGround = new Panel();
backGround.Location = new System.Drawing.Point(67, 57);
backGround.Size = new System.Drawing.Size(800, 480);
backGround.BackgroundImage = Properties.Resources.fullground;
backGround.BackColor = Color.Transparent;
Controls.Add(backGround);
backGround.BringToFront();
} private void OvelayPhotolStripButton_Click(object sender, EventArgs e)
{
PictureBox a =new PictureBox();
a.Location = new System.Drawing.Point(200, 107);
a.Size = new System.Drawing.Size(200, 50);
a.BackgroundImage = Properties.Resources.needle;
a.BackColor = Color.Transparent;
Controls.Add(a);
a.BringToFront();
}
}目前結果如下圖請問該如何解決圖層透明堆疊問題圖片都是png檔
提取码:bj1w里面“创建”。实现的是读取或拖拽图像到panel里面自动排列,并可以拖动图像位置并自动排列顺序,支持透明度,看能帮忙上不。
https://pan.baidu.com/s/1z3BI2ymhhZl7PBlbdghMJQ
提取码:kst1