当前位置:网站首页>C WinForm [get file path -- traverse folder pictures] - practical exercise 6
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
2022-07-05 07:55:00 【BoomBiuBiu】
1、 Drag to form pictureBox Control and Button Button , Change the corresponding Text And adjust the position
2、 Double click the main form to enter the form loader block
private void Form1_Load(object sender, EventArgs e)
{
// open windows , Set window size
HOperatorSet.SetWindowAttr("background_color", "black");
HOperatorSet.OpenWindow(0, 0, pictureBox1.Width, pictureBox1.Height, pictureBox1.Handle, "visible", "", out hv_WindowHandle);
HDevWindowStack.Push(hv_WindowHandle);
HDevWindowStack.SetActive(hv_WindowHandle);
}
Define handle :
HTuple hv_WindowHandle = new HTuple();
3、 Double click the get file path button
// Define some variables
string[] path;
int index = 0;
private void GetPath_btn_Click(object sender, EventArgs e)
{
// Define that the default path is empty
string defaultPath = "";
// Traverse the folder's pictures
FolderBrowserDialog dialog = new FolderBrowserDialog();
// Description on the open folder browse dialog
dialog.Description = " Please select the path of the picture file ";
// Whether to display the lower left corner of the dialog box New folder Button , The default is true
dialog.ShowNewFolderButton = false;
// Get the file under the file
// Press the OK selected button
if (dialog.ShowDialog() == DialogResult.OK)
{
// Get folder path
defaultPath = dialog.SelectedPath;
// Get all the files in the folder
path = Directory.GetFiles(defaultPath, "*.*");
// Read the picture
HOperatorSet.ReadImage(out ho_Image, path[index]);
}
// For the first time defaultPath It's empty , Press FolderBrowserDialog default setting ( Desktop ) choice
if (defaultPath != "")
{
// Set the default directory this time to the last selected directory
dialog.SelectedPath = defaultPath;
}
// Get the width and height of the image
// Get the size of the picture
HOperatorSet.GetImageSize(ho_Image, out hv_Width, out hv_Height);
// Adaptation window
if (HDevWindowStack.IsOpen())
{
HOperatorSet.SetPart(hv_WindowHandle, 0, 0, hv_Height, hv_Width);
}
// display picture
if (HDevWindowStack.IsOpen())
{
HOperatorSet.DispObj(ho_Image, hv_WindowHandle);
}
// The current status is displayed on the status bar
toolStripStatusLabel.Text = " Get file path succeeded ";
}
4、 Double click the get picture button
// Traverse images
private void Ergodic_btn_Click(object sender, EventArgs e)
{
// Read the picture
HOperatorSet.ReadImage(out ho_Image, path[index]);
// Get the size of the picture
HOperatorSet.GetImageSize(ho_Image, out hv_Width, out hv_Height);
// Adaptation window
if (HDevWindowStack.IsOpen())
{
HOperatorSet.SetPart(hv_WindowHandle, 0, 0, hv_Height, hv_Width);
}
// display picture
if (HDevWindowStack.IsOpen())
{
HOperatorSet.DispObj(ho_Image, hv_WindowHandle);
}
// Total number of pictures to be detected
toolStripStatusLabel2.Text = path.Length.ToString();
// Current number of pictures
toolStripStatusLabel4.Text = (index + 1).ToString();
this.index++;
// Determine whether the array index is exceeded
if (index > path.Length - 1)
{
index = 0;
}
toolStripStatusLabel.Text = " Traversal of pictures succeeded ";
}
5、 Run the program
边栏推荐
- Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
- solver. Learning notes of prototxt file parameters
- .NET服务治理之限流中间件-FireflySoft.RateLimit
- Global and Chinese market of urban rail connectors 2022-2028: Research Report on technology, participants, trends, market size and share
- Programming knowledge -- assembly knowledge
- TCP and UDP
- Altium designer 19.1.18 - change the transparency of copper laying
- How to define guid in AMI code
- Global and Chinese market for blood typing 2022-2028: Research Report on technology, participants, trends, market size and share
- Random function usage notes
猜你喜欢
Could NOT find XXX (missing: XXX_LIBRARY XXX_DIR)
Screen record of the opening ceremony of the Beijing winter olympics 2
Altium designer 19.1.18 - change the transparency of copper laying
From then on, I understand convolutional neural network (CNN)
研究發現,跨境電商客服系統都有這五點功能!
Practical application cases of digital Twins - fans
Ten thousand words detailed eight sorting must read (code + dynamic diagram demonstration)
Makefile application
Altium designer 19.1.18 - clear information generated by measuring distance
UEFI development learning 5 - simple use of protocol
随机推荐
Could NOT find XXX (missing: XXX_LIBRARY XXX_DIR)
Temperature sensor DS18B20 principle, with STM32 routine code
Win10 shortcut key
Consul installation
[popular science] some interesting things that I don't know whether they are useful or not
Record the torch encountered by win10 cuda. is_ False problem in available()
Markdown tips
Beijing Winter Olympics opening ceremony display equipment record 3
Global and Chinese market of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
[untitled] record the visual shock of the Winter Olympics and the introduction of the display screen
研究發現,跨境電商客服系統都有這五點功能!
Logistic regression: the most basic neural network
.NET服务治理之限流中间件-FireflySoft.RateLimit
Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share
Distinction between heap and stack
TCP and UDP
NSIS finds out whether the file exists and sets the installation path
Global and Chinese markets of large aperture scintillators 2022-2028: Research Report on technology, participants, trends, market size and share
. Net service governance flow limiting middleware -fireflysoft RateLimit
Global and Chinese markets for waste treatment air switches 2022-2028: Research Report on technology, participants, trends, market size and share