My online notes – Section 0003

Note 1: Check if current user is administrator

WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
Console.WriteLine("Programm wird unter dem Usercontext ausgeführt: {0}", principal.Identity.Name);
Console.WriteLine("Adminrechte vorhanden: {0}", principal.IsInRole(WindowsBuiltInRole.Administrator) ? "Ja" : "Nein");

Note 2: ContextMenuStrip at selected row open and Index in DataTable localize.

private void dgv_MouseUp(object sender, MouseEventArgs e)
{
  DataGridView.HitTestInfo hitTest = ((DataGridView)sender).HitTest(e.X, e.Y);

  if (hitTest .Type == DataGridViewHitTestType.Cell)
  {
     dgv.CurrentCell = dgv.Rows[hTest.RowIndex].Cells[hTest.ColumnIndex];
  }
}

Continue reading My online notes – Section 0003

My online notes – Section 0001

Note 1:

MongoDB Applied Design Patterns
https://www.dropbox.com/s/5nksr6e8z09mu83/Oreilly.MongoDB.Applied.Design.Patterns.Mar.2013.epub?dl=0

Peopleware
https://www.dropbox.com/s/4v3j51mkt13yusc/Peopleware.epub?dl=0

Note 2:

1. List all properties and their values

static void Main(string[] args)
{
	string fileName = Path.Combine(Directory.GetCurrentDirectory(), "All Polished.mp4");
	ShellObject shellObject= ShellObject.FromParsingName(fileName);
	PropertyInfo[] propertyInfos = shellObject.Properties.System.GetType().GetProperties();
	foreach (var propertyInfo in propertyInfos)
	{
		object value = propertyInfo.GetValue(shellObject.Properties.System, null);

		if (value is ShellProperty<int?>)
		{
			var nullableIntValue = (value as ShellProperty<int?>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {nullableIntValue}");
		}
		else if (value is ShellProperty<ulong?>)
		{
			var nullableLongValue =
				(value as ShellProperty<ulong?>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {nullableLongValue}");
		}
		else if (value is ShellProperty<string>)
		{
			var stringValue =
				(value as ShellProperty<string>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {stringValue}");
		}
		else if (value is ShellProperty<object>)
		{
			var objectValue =
				(value as ShellProperty<object>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {objectValue}");
		}
		else
		{
			Console.WriteLine($"{propertyInfo.Name} - Dummy value");
		}
	}
	Console.ReadLine();
}

FluentValidation

https://github.com/JeremySkinner/FluentValidation

NodaTime

http://nodatime.org/

Quartz.net

http://www.quartz-scheduler.net/

Continue reading My online notes – Section 0001