//Обрабатываем нажатие клавиши
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!keyToTag.ContainsKey(e.KeyChar)) return;
string file = listPicture.Dequeue();
string targetDirectoryPath = Path.Combine(TargetPath, keyToTag[e.KeyChar]);
if (!Directory.Exists(targetDirectoryPath)) Directory.CreateDirectory(targetDirectoryPath);
string targetPath = Path.Combine(TargetPath, keyToTag[e.KeyChar], Path.GetFileName(file));
File.Copy(file, targetPath, true);
if (listPicture.Count == 0)
{
MessageBox.Show("Image run out");
Application.Exit();
}
else
{
pictureBox1.Image = Image.FromFile(listPicture.Peek());
}
}
//Задаём параметры
Queue<string> listPicture = new Queue<string>();
string SourcePath = @".\SourceImage";
string TargetPath = @".\TargetImage";
//Задаем соответствие "горячих клавиш" тэгу
Dictionary<char, string> keyToTag = new Dictionary<char, string>
{
{ 'a', "Tag1" }, { 's', "Tag2" }, { 'd', "Tag3" }, { 'f', "Tag4" }
};
public Form1()
{
InitializeComponent();
//Читаем список файлов из папки
foreach(var file in Directory.EnumerateFiles(SourcePath))
{
listPicture.Enqueue(file);
}
// Показываем первую картинку
pictureBox1.Image = Image.FromFile(listPicture.Peek());
}
private TreeNode SearchNode(string SearchText, TreeNode StartNode)
{
TreeNode node = null;
while (StartNode != null)
{
if (StartNode.Text.ToLower().Contains(SearchText.ToLower()))
{
node = StartNode;
break;
};
if (StartNode.Nodes.Count != 0)
{
node = SearchNode(SearchText, StartNode.Nodes[0]);
if (node != null)
{
break;
};
};
StartNode = StartNode.NextNode;
};
return node;
}
.OfType<JObject>()
, на то как сделано на скриншоте - .OfType<JContainer>()
.XDocument xdoc = XDocument.Load("test.xml");
xdoc.Descendants("gruppa").Where(x => (string)x.Value == "5-А").Remove();
xdoc.Save("test.xml");
XDocument xdoc = XDocument.Load("test.xml");
var query = xdoc.Descendants("gruppa").ToList();
foreach (var x in query)
{
if (x.Value == "5-А") x.Remove();
}
xdoc.Save("test.xml");
if (form2.ShowDialog() == DialogResult.OK
&& form3.ShowDialog() == DialogResult.OK)
{
timer1.Enabled = true;
}
private static DateTime GetNISTTime2()
{
using (var tcp = new TcpClient("time.nist.gov", 13))
using (var reader = new StreamReader(tcp.GetStream()))
{
var timeStr = reader.ReadToEnd();
var dt = DateTime.ParseExact("20" + timeStr.Substring(7, 17), "yyyy-MM-dd HH:mm:ss", null);
return dt.ToLocalTime();
}
}