изображение по умолчанию
Добавьте на форму элемент управления PictureBox. Раскройте бермудский треугольник. Нажмите на Choose Image.

В диалоговом окне нажмите на кнопку Import.

Выберите изображение.

Нажмите OK.

Результат работы программы.

изображение выбирает пользователь
Form1.cs
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
_0053 {
-
public
partial
class
Form1 : Form {
-
public
Form1() {
-
InitializeComponent();
-
}
-
private
void
button1_Click(
object
sender, EventArgs e) {
-
openFileDialog1.Filter =
"Images (*.jpg; *.jpeg; *.gif; *.bmp; *.ico; *.png) | *.jpg; *.jpeg; *.gif; *.bmp; *.ico; *.png"
;
-
if
(openFileDialog1.ShowDialog() == DialogResult.OK) {
-
Bitmap myImage =
new
Bitmap(openFileDialog1.FileName);
-
//если размер изображения больше PictureBox,отображаем изображение в режиме Zoom
-
if
(myImage.Size.Height > pictureBox1.Size.Height & myImage.Size.Width > pictureBox1.Size.Width) {
-
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
-
pictureBox1.Image = (Image)myImage;
-
}
-
//если размер изображения меньше или равен PictureBox,отображаем изображение в режиме CenterImage
-
else
{
-
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
-
//обязательно привести к типу Image
-
pictureBox1.Image = (Image)myImage;
-
}
-
}
-
}
-
}
}
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
_0053 {
-
public
partial
class
Form1 : Form {
-
public
Form1() {
-
InitializeComponent();
-
}
-
private
void
button1_Click(
object
sender, EventArgs e) {
-
openFileDialog1.Filter =
"Images (*.jpg; *.jpeg; *.gif; *.bmp; *.ico; *.png) | *.jpg; *.jpeg; *.gif; *.bmp; *.ico; *.png"
;
-
if
(openFileDialog1.ShowDialog() == DialogResult.OK) {
-
Bitmap myImage =
new
Bitmap(openFileDialog1.FileName);
-
//если размер изображения больше PictureBox,отображаем изображение в режиме Zoom
-
if
(myImage.Size.Height > pictureBox1.Size.Height & myImage.Size.Width > pictureBox1.Size.Width) {
-
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
-
pictureBox1.Image = (Image)myImage;
-
}
-
//если размер изображения меньше или равен PictureBox,отображаем изображение в режиме CenterImage
-
else
{
-
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
-
//обязательно привести к типу Image
-
pictureBox1.Image = (Image)myImage;
-
}
-
}
-
}
-
}
}

слайдер
Form1.cs
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
_0054 {
-
public
partial
class
Form1 : Form {
-
//количество файлов
-
int
amount = 8;
-
//массив путей файлов
-
string
[] arra;
-
//индекс массива
-
int
index = 0;
-
//метод заполняет массив
-
void
CreateArray() {
-
//имя файла
-
int
name = 1;
-
arra =
new
string
[amount];
-
for
(
int
i=0; i<arra.Length; i++) {
-
arra[i] =
@"img/"
+ name++ +
".jpg"
;
-
}
-
}
-
public
Form1() {
-
InitializeComponent();
-
}
-
//кнопка Start
-
private
void
button1Start_Click(
object
sender, EventArgs e) {
-
timer1.Start();
-
}
-
//кнопка Stop
-
private
void
button2Stop_Click(
object
sender, EventArgs e) {
-
timer1.Stop();
-
}
-
//таймер
-
private
void
timer1_Tick(
object
sender, EventArgs e) {
-
CreateArray();
-
if
(index >= arra.Length) {
-
index = 0;
-
}
-
Bitmap myImage =
new
Bitmap(arra[index++]);
-
label1.Text = index.ToString();
-
pictureBox1.Image = (Image)myImage;
-
}
-
}
}
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
_0054 {
-
public
partial
class
Form1 : Form {
-
//количество файлов
-
int
amount = 8;
-
//массив путей файлов
-
string
[] arra;
-
//индекс массива
-
int
index = 0;
-
//метод заполняет массив
-
void
CreateArray() {
-
//имя файла
-
int
name = 1;
-
arra =
new
string
[amount];
-
for
(
int
i=0; i<arra.Length; i++) {
-
arra[i] =
@"img/"
+ name++ +
".jpg"
;
-
}
-
}
-
public
Form1() {
-
InitializeComponent();
-
}
-
//кнопка Start
-
private
void
button1Start_Click(
object
sender, EventArgs e) {
-
timer1.Start();
-
}
-
//кнопка Stop
-
private
void
button2Stop_Click(
object
sender, EventArgs e) {
-
timer1.Stop();
-
}
-
//таймер
-
private
void
timer1_Tick(
object
sender, EventArgs e) {
-
CreateArray();
-
if
(index >= arra.Length) {
-
index = 0;
-
}
-
Bitmap myImage =
new
Bitmap(arra[index++]);
-
label1.Text = index.ToString();
-
pictureBox1.Image = (Image)myImage;
-
}
-
}
}
