public void FillDataGrid(object sender, SocketEventArgs e) { DataTable dataTable = CreateDataTable(e.Command.ColumnsList, e.Command.TypesList, e.Command.ValuesList); mainWindow.MainDataGrid.Dispatcher.Invoke(new Action( delegate() { mainWindow.MainDataGrid.ItemsSource = dataTable.DefaultView; })); }
public void SetImage(object sender, SocketEventArgs e) { BinaryImageConverter converter = new BinaryImageConverter(); mainWindow.MainDataGrid.Dispatcher.Invoke(new Action( delegate() { mainWindow.MainImage.Source = converter.Convert(e.Command.File, typeof(byte[]), null, null) as BitmapImage; })); }
public void SaveFile(object sender, SocketEventArgs e) { using (FileStream fs = new FileStream(e.Command.FilePath, FileMode.Create)) { int bufferSize = int.Parse(Resources.Buffer); int position = 0; while (position < e.Command.File.Length) { fs.Write(e.Command.File, position, bufferSize); position += bufferSize; } fs.Write(e.Command.File, position - bufferSize, e.Command.File.Length - position); } }