Пример #1
0
 /// <summary>
 /// Sets the window position of an application that is not already running (window dimensions are set when application is opened).
 /// </summary>
 /// <param name="process">The Process instance containing the assembly name.</param>
 /// <param name="position">The position instance to set the application's window to.</param>
 /// <exception cref="Exception"></exception>
 public static void SetWindowPosition(Process process, Position position)
 {
     if (process.StartInfo.FileName != "")
     {
         process.Start();
         Thread.Sleep(100);
         DLLInterops.MoveWindow(process.MainWindowHandle, position.X, position.Y, position.Width, position.Height, true);
     }
     else
     {
         throw new Exception("The specified process instance does not contain an assembly to start.");
     }
 }
Пример #2
0
        /// <summary>
        /// Displays an image in the console.
        /// </summary>
        /// <param name="imageLocation">The location of the image file.</param>
        /// <param name="imageSize">The image size to display.</param>
        /// <param name="consoleLocation">The point on the console buffer to display the image.</param>
        public static void DisplayImageInConsole(string imageLocation, Size imageSize, Point consoleLocation)
        {
            Image image = Image.FromFile(imageLocation);
            Form  form  = new Form();

            form.BackgroundImage       = image;
            form.BackgroundImageLayout = ImageLayout.Stretch;
            form.FormBorderStyle       = FormBorderStyle.None;
            var parent = Process.GetCurrentProcess().MainWindowHandle;
            var child  = form.Handle;

            DLLInterops.SetParent(child, parent);
            DLLInterops.MoveWindow(child, consoleLocation.X, consoleLocation.Y, imageSize.Width, imageSize.Height, true);
            Application.Run(form);
        }