private static void handle_SendScreen(GetScreen command) { Bitmap desktop = CaptureScreen.CaptureDesktop2(); if (desktop == null) { Console.WriteLine("null image"); } MyCodec.Code(desktop, command.quality); send_byte(resTObyte(new SendScreen(MyCodec.Blocks, MyCodec.BlocksData))); desktop.Dispose(); System.GC.Collect(); }
void PickUpAndShowit() { print("사진 불러오기"); string pathToFile = GetScreen.GetLastScreenshotPath(); if (pathToFile == null) { return; } Texture2D texture = GetScreenshotImage(pathToFile); Sprite sp = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); pickUpImage.enabled = true; pickUpImage.GetComponent <Image>().sprite = sp; }
/// <summary> /// Runs the screen driver. /// </summary> public void Run() { try { Interpreter = new Interpreter(); // Check for missing files before running string[] missingFiles = CheckForMissingFiles(); if (missingFiles.Length > 0) { Log.LogMissingFiles(missingFiles); MissingFilesMenu.MissingFiles = missingFiles; CurrentScreen = MissingFilesMenu; } else { CurrentScreen = MainMenu; } LastScreen = CurrentScreen; // Run the screen driver loop do { MenuAction nextAction = CurrentScreen.Publish(this); GetScreen nextScreen = nextAction?.Invoke(this); if (nextScreen != CurrentScreen) { LastScreen = CurrentScreen; CurrentScreen = nextScreen; } } while (CurrentScreen != null); } catch (Exception ex) { Log.LogException(ex); // Oh no! Tell the user what went wrong so it can be reported! ExceptionMenu.Exception = ex; ExceptionMenu.Publish(this); } }
/// <summary> /// Checks all classes for any missing required runtime files. /// </summary> /// <returns></returns> private string[] CheckForMissingFiles() { // Use a hashset to avoid duplicate file names. HashSet <string> files = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); // Enumerate over all screen properties foreach (PropertyInfo prop in this.GetType().GetProperties()) { if (typeof(GetScreen).IsAssignableFrom(prop.PropertyType)) { // Check if this property has a setter, skip non-constant properties if (prop.GetSetMethod(true) == null) { GetScreen screen = (GetScreen)prop.GetValue(this); foreach (string file in screen.GetMissingFiles()) { files.Add(file); } } } } return(files.ToArray()); }
void Awake() { _instance = this; }