Files
AntdUI/example/Demo/Controls/Preview.cs
2025-07-17 16:23:45 +08:00

150 lines
6.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// COPYRIGHT (C) Tom. ALL RIGHTS RESERVED.
// THE AntdUI PROJECT IS AN WINFORM LIBRARY LICENSED UNDER THE Apache-2.0 License.
// LICENSED UNDER THE Apache License, VERSION 2.0 (THE "License")
// YOU MAY NOT USE THIS FILE EXCEPT IN COMPLIANCE WITH THE License.
// YOU MAY OBTAIN A COPY OF THE LICENSE AT
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE
// DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND
// LIMITATIONS UNDER THE License.
// GITCODE: https://gitcode.com/AntdUI/AntdUI
// GITEE: https://gitee.com/AntdUI/AntdUI
// GITHUB: https://github.com/AntdUI/AntdUI
// CSDN: https://blog.csdn.net/v_132
// QQ: 17379620
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Demo.Controls
{
public partial class Preview : UserControl
{
Form form;
public Preview(Form _form)
{
form = _form;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
AntdUI.Preview.open(new AntdUI.Preview.Config(form, Properties.Resources.img1));
}
private void button2_Click(object sender, EventArgs e)
{
AntdUI.Preview.open(new AntdUI.Preview.Config(form, new Image[] { Properties.Resources.bg1, Properties.Resources.bg7, Properties.Resources.bg2, Properties.Resources.bg3 })
{
Btns = new AntdUI.Preview.Btn[] {
new AntdUI.Preview.Btn("download","<svg viewBox=\"64 64 896 896\"><path d=\"M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z\"></path></svg>")
},
OnBtns = (id, data) =>
{
switch (id)
{
case "download":
//<2F>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ذ<EFBFBD>ť
break;
}
}
});
}
private void button3_Click(object sender, EventArgs e)
{
AntdUI.Preview.open(new AntdUI.Preview.Config(form, new object[] { 1, 2, 3, 7 }, (i, tag, call) =>
{
if (i == 0) return Properties.Resources.bg1;
else if (i == 2) return Properties.Resources.bg3;
else if (i == 3)
{
for (int prog = 0; prog <= 100; prog++)
{
System.Threading.Thread.Sleep(10);
call(prog / 100F, prog + "%");
}
System.Threading.Thread.Sleep(500);
return Properties.Resources.bg7;
}
for (int prog = 0; prog <= 20; prog++)
{
System.Threading.Thread.Sleep(50);
call(prog / 100F, prog + "%");
}
System.Threading.Thread.Sleep(500);
call(0.2F, "<22><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
return null;
})
{
Btns = new AntdUI.Preview.Btn[] {
new AntdUI.Preview.Btn("download","<svg viewBox=\"64 64 896 896\"><path d=\"M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z\"></path></svg>")
},
OnBtns = (id, data) =>
{
switch (id)
{
case "download":
//<2F>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ذ<EFBFBD>ť
break;
}
}
});
}
private void button4_Click(object sender, EventArgs e)
{
var imgTextList = new List<AntdUI.Preview.ImageTextContent>()
{
new AntdUI.Preview.ImageTextContent(Properties.Resources.bg1, "<22><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>Ҷ(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)", Color.Green)
{
TextAlign = ContentAlignment.TopCenter
},
new AntdUI.Preview.ImageTextContent(Properties.Resources.bg7, "Τһ<CEA4><D2BB>,<2C><>ʢ<EFBFBD><CAA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ը(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)", Color.Red)
{
TextAlign = ContentAlignment.TopLeft
},
new AntdUI.Preview.ImageTextContent(Properties.Resources.bg2, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)")
{
TextAlign = ContentAlignment.TopRight
},
new AntdUI.Preview.ImageTextContent(Properties.Resources.bg1, "<22><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>Ҷ(<28>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>)", Color.Green)
{
TextAlign = ContentAlignment.MiddleCenter
},
new AntdUI.Preview.ImageTextContent(Properties.Resources.bg7, "Τһ<CEA4><D2BB>,<2C><>ʢ<EFBFBD><CAA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ը(<28>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>)", Color.Red)
{
TextAlign = ContentAlignment.MiddleLeft
},
new AntdUI.Preview.ImageTextContent(Properties.Resources.bg2, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>)")
{
TextAlign = ContentAlignment.MiddleRight
},
new AntdUI.Preview.ImageTextContent(Properties.Resources.bg1, "<22><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>Ҷ(<28>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD>)", Color.Green)
{
TextAlign = ContentAlignment.BottomCenter
},
new AntdUI.Preview.ImageTextContent(Properties.Resources.bg7, "Τһ<CEA4><D2BB>,<2C><>ʢ<EFBFBD><CAA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ը(<28>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD>)",Color.Red)
{
TextAlign = ContentAlignment.BottomLeft
},
new AntdUI.Preview.ImageTextContent(Properties.Resources.bg2, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD><EFBFBD>)")
{
TextAlign = ContentAlignment.BottomRight
},
new AntdUI.Preview.ImageTextContent(Properties.Resources.bg7)
{
Text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>",
TextAlign = ContentAlignment.BottomLeft
}
};
AntdUI.Preview.open(new AntdUI.Preview.Config(form, imgTextList));
}
}
}