namespace iconGen
{
public partial class Form1 : Form
{
public Form1(){
InitializeComponent();
var exts = new List<string>(){
".jpg",".png",".gif",".jpeg",".bmp"
};
foreach (var ext in exts)
{
cbl_exts.Items.Add(ext);
cbl_exts.SetItemChecked(cbl_exts.Items.Count-1,true);
}
tb_savepath.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
}
public Dictionary<String, Bitmap> scanDir(string path, List<String> extsVal)
{
Dictionary<String, Bitmap> result = new Dictionary<string, Bitmap>();
var dirs = Directory.GetDirectories(path);
foreach (var dir in dirs){
if (Directory.GetFiles(dir).Where(s => extsVal.Contains(new FileInfo(s).Extension)).Count() > 0)
{
string name = new FileInfo(dir).Name;
string newname = name;
for (var i = 1; result.ContainsKey(newname); i++)
newname = name + "_" + i;
result.Add(newname, createImg(dir, Int32.Parse(tb_width.Text), Int32.Parse(tb_height.Text), Int32.Parse(tb_wh.Text),
cb_auto.Checked, Int32.Parse(tb_padding.Text), extsVal));
}
var res = scanDir(dir, extsVal);
foreach (var key in res.Keys){
string newname = key;
for (var i = 1; result.ContainsKey(newname); i++)
newname = key+ "_" + i;
Bitmap bm;
res.TryGetValue(key, out bm);
result.Add(newname, bm);
bm.Dispose();
}
}
return result;
}
public Bitmap createImg(string path,int imgWidth,int imgHeight,int iconWH,bool isAutoWH,int padding,List<string> exts){
var files = Directory.GetFiles(path).Where(s => exts.Contains(new FileInfo(s).Extension)).ToArray();
var count = files.Length;
if (isAutoWH)
{
for (int i = Math.Min(imgWidth, imgHeight); i > 0; i--)
{
var maxCount = Math.Floor((double)imgWidth / i) * Math.Floor((double)imgHeight / i);
if (maxCount >= count)
{
iconWH = i - padding <= 0 ? i : i - padding;
break;
}
}
}
Bitmap bm = new Bitmap(imgWidth, imgHeight);
using (Graphics g = Graphics.FromImage(bm))
{
for (int i = 0; i < count; i++)
{
var img = Image.FromFile(files[i]);
int x = i % (imgWidth / (iconWH + padding)) * (iconWH + padding);
int y = (int)(Math.Floor((double)(i / (imgWidth / (iconWH + padding)))) * (iconWH + padding));
g.DrawImage(img, x, y, iconWH, iconWH);
img.Dispose();
}
}
return bm;
}
private void btn_scandir_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
tb_scandir.Text = fbd.SelectedPath;
}
private void btn_savepath_Click(object sender, EventArgs e){
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
tb_savepath.Text = fbd.SelectedPath;
}
private void button1_Click(object sender, EventArgs e){
try
{
List<string> extsVal = new List<string>();
foreach (var checkedItem in cbl_exts.CheckedItems)
extsVal.Add(checkedItem as string);
var t = scanDir(tb_scandir.Text, extsVal);
var p = new DirectoryInfo(tb_savepath.Text);
foreach (var key in t.Keys){
Bitmap bm;
t.TryGetValue(key, out bm);
bm.Save(p.FullName + @"\" + key + ".png", ImageFormat.Png);
bm.Dispose();
}
Process.Start("explorer.exe", p.FullName);
}
catch (Exception ee)
{
MessageBox.Show(ee.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void cb_auto_CheckedChanged(object sender, EventArgs e)
{
tb_wh.ReadOnly = cb_auto.Checked;
}
}
}
int num = 0;
Console.Write("Введите целое число -> ");
int num;
try
{
num = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Ваше число в квадрате -> " + Math.Pow(Convert.ToDouble(num), 2.0));
}
catch (FormatException)
{
Console.WriteLine("Несоответствие типа.");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
var mouseX = 0,mouseY = 0;
//Вешаем обработчки на движение мыши
canvas.addEventListener("mousemove", function(e) {
mouseX = e.offsetX;
mouseY = e.offsetY;
});
//... function draw
player.angle = getAngle(player.x,player.y,mouseX,mouseY);//в радианах
//...
var angleStep = (1).toRadian();//Шаг угла между лучами
var angleRayStart = player.angle - angleStep * rays.length/2;//Угол первого луча, далее угол увеличивается на angleStep, таким образом средний луч будет где-то как раз куда смотрит игрок
//...
//Получить угол между двумя точками
function getAngle(dx, dy, dx1, dy1) {
return Math.atan2(dy - dy1, dx - dx1) + Math.PI;
}
const interval = 1000; // миллисекунды
const min = 1;
const max = 7;
let number = 12027;
setInterval(() =>{
number += min + ~~(Math.random()*(max - min));
output2.innerHTML = "";
number.toString().split("").forEach(s=>output2.innerHTML += "<span>"+s+"</span>");
}
, interval);
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
dataGridView1.CellEndEdit += dataGridView1_CellEndEdit;
}
public void recalculateRow(int rowInx){
var zak = dataGridView1.Rows[rowInx].Cells[0].Value;
var perc = dataGridView1.Rows[rowInx].Cells[1].Value;
dataGridView1.Rows[rowInx].Cells[2].Value = "";
if (zak == null || perc == null)
return;
try{
dataGridView1.Rows[rowInx].Cells[2].Value = float.Parse(zak.ToString()) + float.Parse(zak.ToString()) * (float.Parse(perc.ToString())/100);
}catch(FormatException e){
}
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) {
recalculateRow(e.RowIndex);
}
}
sql = @"UPDATE `accounts` SET `password_key`= ?key, `password_salt`= ?salt WHERE `username` = '{userName}'";
var force = 5;
obj.velocity.x += collision.contacts[0].normal.x * force;
obj.velocity.y += collision.contacts[0].normal.y * force;
obj.velocity.z += collision.contacts[0].normal.z * force;