private void SetupBindingCombos() { if (DeviceList.SelectedIndex > -1 && MapsView.SelectedIndices.Count > 0) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; TargetTypeCombo.Items.Clear(); TargetTypeCombo.Items.AddRange(UiTools.GetBindingTargetTypeList()); TargetTypeCombo.SelectedIndex = (int)binding.TargetType; BindTypeCombo.Items.Clear(); BindTypeCombo.Items.AddRange(Enum.GetNames(typeof(BindingType))); BindTypeCombo.SelectedIndex = (int)binding.BindingType; RepeatCheckbox.Checked = binding.Parent.AutoRepeat; UpdatePropertyCombo(); DeviceImage.Invalidate(); } else { TargetTypeCombo.Items.Clear(); BindTypeCombo.Items.Clear(); TargetPropertyCombo.ClearText(); } }
/// <summary> /// 获取目标设备的指定image路径 /// </summary> /// <param name="serial"></param> /// <param name="imageType"></param> /// <returns></returns> public static string PathOf(DeviceSerialNumber serial, DeviceImage imageType) { using (DeviceImageFinder _o = new DeviceImageFinder(serial)) { return(_o.PathOf(imageType)); } }
public async Task <IActionResult> Edit(int id, [Bind("ImageId,Image")] DeviceImage deviceImage) { if (id != deviceImage.ImageId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(deviceImage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeviceImageExists(deviceImage.ImageId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(deviceImage)); }
// Method to marshal from native to managed struct internal unsafe void __MarshalFrom(ref __Native @ref) { this.Size = @ref.Size; this.SizeImageInfo = @ref.SizeImageInfo; this.ViewCount = @ref.ViewCount; this.ButtonCount = @ref.ButtonCount; this.AxeCount = @ref.AxeCount; this.PovCount = @ref.PovCount; this.BufferSize = @ref.BufferSize; this.BufferUsed = @ref.BufferUsed; this.ImageInfoArrayPointer = @ref.ImageInfoArrayPointer; if (this.BufferSize > 0 && this.ImageInfoArrayPointer != IntPtr.Zero) { int nbImageInfoElements = BufferSize / sizeof(DeviceImage.__Native); Images = new DeviceImage[nbImageInfoElements]; var pImageInfo = (DeviceImage.__Native *) this.ImageInfoArrayPointer; for (int i = 0; i < Images.Length; i++) { var image = new DeviceImage(); image.__MarshalFrom(ref *pImageInfo); pImageInfo++; } } }
public void openDeviceImage(string filename) { //Construct new romimage DeviceImage newImage = new DeviceImage(filename); if (newImage.CalId == null) { Trace.TraceWarning(String.Format("Unable to identify rom at {0}", newImage.FilePath.ToString())); MessageBox.Show("Unable to idenfity rom at " + newImage.FilePath.ToString()); return; } foreach (DeviceImage image in SharpTuner.ImageList) { if (image.FilePath == filename) { Console.Write("Rom is already open!"); return; } } this.closeDeviceImageToolStripMenuItem.Enabled = true; obfuscateCALIDToolStripMenuItem.Enabled = true; SharpTuner.AddImage(newImage); this.openDeviceListBox.Items.Add(SharpTuner.ActiveImage.FileName); Trace.WriteLine("Successfully opened " + SharpTuner.ActiveImage.CalId + " filename: " + SharpTuner.ActiveImage.FileName); Refresh(); }
/// <summary> /// Thread que faz o processamento. /// </summary> private void WorkerThread(object sender, EventArgs e) { // atualiza os dados dos dispositivos try { context.WaitAnyUpdateAll(); } catch (Exception ex) { Console.WriteLine(ex.Message); } #region Drawing if (drawRGBImage) { rgbCamera.UpdateMetadata(); rgbImage.DrawFrame(rgbCamera, userManager); } else if (drawDepthImage) { depthSensor.UpdateMetadata(); depthSensor.UpdateHistogram(); depthImage.DrawFrame(depthSensor, userManager); } else { DeviceImage.DrawFrame(); } // desenha WindowManager.MainWindow.image.Source = DeviceImage.WriteableBitmap; #endregion // atualiza os usuários userManager.UpdateAllUsers(); mainUser = userManager.UpdateMainUser(); windowManager.MainWindow.usersLabel.Text = userManager.GetUsersLabel(); lock (this) { if (realtime) { recorder.Capture(mainUser, userManager.Skeleton); observer.Capture(mainUser); } } // calcula o fps do programa DateTime now = DateTime.Now; double timePassed = 0.0; timePassed += now.Millisecond + 1000 * (now.Second + 60 * (now.Minute + 60 * now.Hour)); timePassed -= time.Millisecond + 1000 * (time.Second + 60 * (time.Minute + 60 * time.Hour)); time = now; windowManager.MainWindow.fpsTextBlock.Text = (int)(1000 / timePassed) + " FPS"; }
private void MapsView_AfterLabelEdit(object sender, LabelEditEventArgs e) { ControlMap cm = ((ControlBinding)MapsView.SelectedItems[0].Tag).Parent; if (!string.IsNullOrEmpty(e.Label)) { cm.Name = e.Label; ((MidiMap)DeviceList.SelectedItem).Dirty = true; DeviceImage.Invalidate(); } else { e.CancelEdit = true; } }
private string Find1(DeviceImage image) { var exeResult = Device.Su($"find /dev/ -name {image.ToString().ToLower()}"); if (exeResult.Item2 == (int)LinuxReturnCode.KeyHasExpired) { return(null);//无法使用find命令,当场返回! } else { var result = from r in exeResult.Item1.LineAll where PathIsRight(r) select r; return(result.First()); } }
private string Find1(DeviceImage image) { var exeResult = ShellAsSu.SafetyInput($"find /dev/ -name {image.ToString().ToLower()}"); exeResult.PrintOnLog(this); if (exeResult.GetExitCode() == (int)LinuxReturnCode.KeyHasExpired) { return(null);//无法使用find命令,当场返回! } else { var result = from r in exeResult.LineAll where PathIsRight(r) select r; return(result.First()); } }
private string Find2(DeviceImage image) { string maybePath1 = $"/dev/block/platform/*/by-name/{image.ToString().ToLower()}"; string maybePath2 = $"/dev/block/platform/soc*/*/by-name/{image.ToString().ToLower()}"; var exeResult = Device.Su($"ls -l {maybePath1}"); if (exeResult.Item2 == (int)LinuxReturnCode.None) { return(maybePath1); } exeResult = Device.Su($"ls -l {maybePath2}"); if (exeResult.Item2 == (int)LinuxReturnCode.None) { return(maybePath2); } return(null); }
private string Find2(DeviceImage image) { string maybePath1 = $"/dev/block/platform/*/by-name/{image.ToString().ToLower()}"; string maybePath2 = $"/dev/block/platform/soc*/*/by-name/{image.ToString().ToLower()}"; var exeResult = ShellAsSu.SafetyInput($"ls -l {maybePath1}"); if (exeResult.IsSuccessful) { return(maybePath1); } exeResult = ShellAsSu.SafetyInput($"ls -l {maybePath2}"); if (exeResult.IsSuccessful) { return(maybePath2); } return(null); }
public static List <Mod> GetValidMods(this DeviceImage d) { List <Mod> tm = new List <Mod>(); foreach (Mod m in AvailableMods) { //TODO: When a mod is loaded, detect "FFFFFFF" CALID!!! if (m.InitialCalibrationId == d.CalId && m.TryCheckApplyMod(d.FilePath, d.FilePath + ".temp", true, false)) { tm.Add(m); Trace.WriteLine("Loaded Mod: " + m.FileName); } else if (m.ModIdent == d.CalId && m.TryCheckApplyMod(d.FilePath, d.FilePath + ".temp", false, false)) { tm.Add(m); Trace.WriteLine("Loaded Mod: " + m.FileName); } } return(tm); }
public async Task <IActionResult> Create([Bind("ImageId,Image")] DeviceImage deviceImage, IFormFile Image) { if (ModelState.IsValid) { if (Image?.Length > 0) { byte[] uploadedImage = null; using (var ms = new MemoryStream()) { Image.CopyTo(ms); uploadedImage = ms.ToArray(); } //deviceImage.Device.Images.Add(new DeviceImage() { Device = device, Image = uploadedImage }); _context.Add(deviceImage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View(deviceImage)); }
private void DeviceImage_DragDrop(object sender, DragEventArgs e) { string data = e.Data.GetData("Text").ToString(); if (data == MidiControlDataFormat && DragSource != null) { try { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; DragSource.Mapped = true; PointF pnt = ControlToImage(DeviceImage.PointToClient(new Point(e.X, e.Y))); DragSource.X = pnt.X; DragSource.Y = pnt.Y; DragSource.Width = .1f; DragSource.Height = .1f; DeviceImage.Invalidate(); midiMap.Dirty = true; } catch { } } }
/// <summary> /// 获取image的路径 /// </summary> /// <param name="imageType"></param> /// <returns></returns> public string PathOf(DeviceImage imageType) { return(Find1(imageType) ?? Find2(imageType)); }
/// <summary> /// 获取目标设备的指定image路径 /// </summary> /// <param name="device"></param> /// <param name="imageType"></param> /// <returns></returns> public static string PathOf(IDevice device, DeviceImage imageType) { return(new DeviceImageFinder(device).PathOf(imageType)); }
private List <DeviceImage> MakeImageList(List <IFormFile> files, Device device) { //Create the list var lst = new List <DeviceImage>(); //Loop through every image foreach (IFormFile file in files) { try { //The image object, just add images DeviceImage img = new DeviceImage() { Device = device, ContentType = file.ContentType, Description = file.FileName }; using (var ms = new MemoryStream()) { file.CopyTo(ms); //The normal image is easy, since we're keeping the original var image = Image.FromStream(ms); img.Image = ms.ToArray(); //Set the width and height for the thumbnails with the proper ratio var rect = new Rectangle(0, 0, 100, 100); if (image.Width > image.Height) { rect.Height = 100 * image.Height / image.Width; rect.Y = 50 - rect.Height / 2; } else { rect.Width = 100 * image.Width / image.Height; rect.X = 50 - rect.Width / 2; } var thumb = new Bitmap(100, 100); thumb.SetResolution(image.HorizontalResolution, image.VerticalResolution); using (var g = Graphics.FromImage(thumb)) { //These setting will help the image resize nicely g.CompositingMode = CompositingMode.SourceCopy; g.CompositingQuality = CompositingQuality.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.SmoothingMode = SmoothingMode.HighQuality; g.PixelOffsetMode = PixelOffsetMode.HighQuality; //Draw background, just a 100x100px square g.FillRectangle(Brushes.White, 0, 0, 100, 100); //Add the image itself, centered and resized using (var wrapMode = new ImageAttributes()) { wrapMode.SetWrapMode(WrapMode.TileFlipXY); g.DrawImage(image, rect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode); } } //Save the resulting thumbnail as a jpg using (var stream = new MemoryStream()) { thumb.Save(stream, ImageFormat.Jpeg); stream.Position = 0; img.Thumbnail = stream.ToArray(); } } lst.Add(img); } catch { //Whatever the issue was, just don't store the image } } return(lst); }
//public static void setSsmInterface(SsmInterface s) //{ // ssmInterface = s; //} public static void AddImage(DeviceImage d) { ImageList.Add(d); ActiveImage = d; }