private async void Button_Click(object sender, RoutedEventArgs e)
{
await Task.Run( () =>
{
for (int i = 0; i < 101; i++)
{
Dispatcher.Invoke((Action)(() =>
{
label1.Content = i.ToString();
}));
Thread.Sleep(1000);
}
});
}
let a = 10;
function func1(num){
return num-1;
}
a = func1(a);
console.log(a);
document.querySelectorAll(".some-class").forEach(cont=>{
cont.querySelector(".error-count").innerHTML = Array.from(cont.querySelectorAll(".delivery-table-item")).filter(e=>e.getAttribute("data-status")=="Ошибка").length;
});
$(".some-class").each((i,el)=>{
$(el).find(".error-count").html($(el).find(".delivery-table-item[data-status=Ошибка]").length);
})
Каждый слой (Layer) представляет из себя один canvas элемент на странице и может содержать в себе фигуры, группы фигур или группы групп.
rewriteLineText(3, @"D:\mytext.txt", "Новое значение");//№ линии, путь к файлу, значение
static void rewriteLineText(int rewriteLine,string path,string str){
FileStream fs = new FileStream(path, FileMode.Open);
var buff = new byte[1];
int byteStart = rewriteLine == 1 ? 0 : -1, byteEnd = -1;
for (int i = 0, line = 1; i < fs.Length; i++){
fs.Read(buff, 0, 1);
if (buff[0] == 10){//10 - перенос строки
if (line == rewriteLine)
{
byteEnd = i;
break;
}
line++;
if (line == rewriteLine)
byteStart = i + 1;
}
if (i == fs.Length - 1)
byteEnd = i;
}
if (byteStart == -1 || byteEnd == -1)
return;
var strByte = Encoding.UTF8.GetBytes(str);
fs.Position = byteEnd;
var tailBuff = new byte[fs.Length - byteEnd];
fs.Read(tailBuff, 0, (int)(fs.Length - byteEnd));
fs.Position = byteStart;
fs.Write(strByte, 0, strByte.Length);
fs.Write(tailBuff, 0, tailBuff.Length);
fs.SetLength(byteStart + strByte.Length + tailBuff.Length);
fs.Close();
}
string[] array = { "Иванов Иван Иванович", "Сидоров Сидор Сидорович", "Петров Петр Петрович" };
var find = "сид";
var finded = array.Where(v => v.Split(' ')[0].ToLower().Contains(find)).ToList();//[0] Сидоров Сидор Сидорович
SELECT COUNT(*) FROM `table` as t WHERE (SELECT SUM(size) FROM `table` WHERE `id` >= t.id ORDER BY id DESC) <= 1000000 ORDER BY id DESC
function getFiles($path,$lvl = 0){
$res = [];
$dir2 = scandir($path);
foreach($dir2 as $file2){
if (($file2!='.') && ($file2!='..')){
$fullpath = $path . DIRECTORY_SEPARATOR . $file2;
if(is_dir($fullpath)){
$res = array_merge($res,getFiles($fullpath,$lvl+1));
array_push($res,["path"=>$fullpath,"name"=>$file2,"type"=>"DIR","level"=>$lvl,"size"=>filesize($fullpath)]);
}else if(is_file($fullpath))
array_push($res,[ "path"=>$fullpath,"name"=>$file2,"type"=>"FILE","level"=>$lvl,"size"=>filesize($fullpath)]);
}
}
return $lvl == 0 ? array_reverse($res): $res;
}
function showFiles($arr){
foreach($arr as $v){
$margin = $v["level"] * 15;
if($v["type"] == "DIR")
echo "<span style='display:block;font-weight:bold;margin-left:{$margin}px;'>$v[name]</span>";
if($v["type"] == "FILE")
echo "<a style='margin-left:{$margin}px;display:block;' href='$v[path]'>$v[name] ($v[size] байт)</a>";
}
}
showFiles(getFiles('yourdir'));