Ejemplo n.º 1
0
        public override bool ShowModalX(ICommonDialog form, bool keepModeless = false)
        {
            IntPtr mainHandle = GetTopWindowHandle();

            if (keepModeless)
            {
                #if !__MonoCS__
                //NativeMethods.PostMessage(mainHandle, NativeMethods.WM_KEEPMODELESS, IntPtr.Zero, IntPtr.Zero);
                #endif
            }

            //UIHelper.CenterFormByParent((Form)form, mainHandle);

            return(base.ShowModalX(form, keepModeless));
        }
Ejemplo n.º 2
0
        public Image ScanImage(ImageFormat outputFormat, string fileName)
        {
            if (outputFormat == null)
            {
                throw new ArgumentNullException("outputFormat");
            }

            FileIOPermission filePerm = new FileIOPermission(FileIOPermissionAccess.AllAccess, fileName);

            filePerm.Demand();

            ImageFile imageObject = null;

            try
            {
                if (WiaManager == null)
                {
                    WiaManager = new CommonDialog();
                }

                imageObject =
                    WiaManager.ShowAcquireImage(WiaDeviceType.ScannerDeviceType,
                                                WiaImageIntent.GrayscaleIntent, WiaImageBias.MaximizeQuality,
                                                outputFormat.Guid.ToString("B"), false, true, true);

                imageObject.SaveFile(fileName);
                return(Image.FromFile(fileName));
            }
            catch (COMException ex)
            {
                string message = "Error scanning image";
                throw new WiaOperationException(message, ex);
            }
            finally
            {
                if (imageObject != null)
                {
                    Marshal.ReleaseComObject(imageObject);
                }
            }
        }
Ejemplo n.º 3
0
        public override bool ShowModalX(ICommonDialog form, bool keepModeless = false)
        {
            IntPtr mainHandle = GetTopWindowHandle();

            if (keepModeless)
            {
                foreach (IWindow win in fRunningForms)
                {
                    if (win is IBaseWindow)
                    {
                        IntPtr handle = ((Form)win).Handle;

                        #if !__MonoCS__
                        NativeMethods.PostMessage(handle, NativeMethods.WM_KEEPMODELESS, IntPtr.Zero, IntPtr.Zero);
                        #endif
                    }
                }
            }

            UIHelper.CenterFormByParent((Form)form, mainHandle);

            return(base.ShowModalX(form, keepModeless));
        }
Ejemplo n.º 4
0
 public bool ShowModalX(ICommonDialog form, bool keepModeless = false)
 {
     return(false);
 }
Ejemplo n.º 5
0
        private static void OnAccept(IAsyncResult result)
        {
            byte[] buffer = new byte[1024];
            try
            {
                Socket client         = null;
                string headerResponse = "";
                if (serverSocket != null && serverSocket.IsBound)
                {
                    client = serverSocket.EndAccept(result);
                    var i = client.Receive(buffer);
                    headerResponse = (System.Text.Encoding.UTF8.GetString(buffer)).Substring(0, i);
                    Console.WriteLine(headerResponse);
                }
                if (client != null)
                {
                    var key = headerResponse.Replace("ey:", "`")
                              .Split('`')[1]
                              .Replace("\r", "").Split('\n')[0]
                              .Trim();

                    var test1 = AcceptKey(ref key);

                    var newLine = "\r\n";

                    var response = "HTTP/1.1 101 Switching Protocols" + newLine
                                   + "Upgrade: websocket" + newLine
                                   + "Connection: Upgrade" + newLine
                                   + "Sec-WebSocket-Accept: " + test1 + newLine + newLine;
                    client.Send(System.Text.Encoding.UTF8.GetBytes(response));

                    var i = client.Receive(buffer);
                    //Console.WriteLine("Iniciando escanneo");
                    string msasd = "";
                    try
                    {
                        List <string> devices  = WIAScanner.GetDevices();
                        ICommonDialog instance = (ICommonDialog)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("850D1D11-70F3-4BE5-9A11-77AA6B2BB201")));

                        Device device = instance.ShowSelectDevice(WiaDeviceType.UnspecifiedDeviceType, true, false);
                        if (device != null)
                        {
                            List <Image> images = WIAScanner.Scan(device.DeviceID);
                            foreach (Image image in images)
                            {
                                Bitmap       objBitmap = new Bitmap(image, new Size(1250, 1550));
                                MemoryStream ms        = new MemoryStream();
                                objBitmap.Save(ms, ImageFormat.Jpeg);
                                msasd = Convert.ToBase64String(ms.ToArray());
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        //
                    }
                    //Console.WriteLine("Escaneo Terminado...");
                    //Console.WriteLine("Escaneo Terminado...");
                    //Console.WriteLine("Iniciando Envio de paquete");
                    int particion = msasd.Length / 100;
                    int mod       = msasd.Length % 100;
                    for (int l = 0; l < 100; l++)
                    {
                        byte[] Bytes = CodificarMensajeParaEnviar(msasd.Substring(particion * l, particion));
                        int    k     = client.Send(Bytes, Bytes.Length, SocketFlags.None);
                    }
                    if (mod != 0)
                    {
                        byte[] Bytes2 = CodificarMensajeParaEnviar(msasd.Substring(particion * 100));
                        int    k2     = client.Send(Bytes2, Bytes2.Length, SocketFlags.None);
                    }
                    else
                    {
                        byte[] Bytes2 = CodificarMensajeParaEnviar("");
                        int    k2     = client.Send(Bytes2, Bytes2.Length, SocketFlags.None);
                    }
                    //Console.WriteLine("Envio Terminado");
                    //Console.WriteLine("Se enviaron {0} bytes de informacion", msasd.Length);
                }
            }
            catch (SocketException exception)
            {
                throw exception;
            }
            finally
            {
                if (serverSocket != null && serverSocket.IsBound)
                {
                    serverSocket.BeginAccept(null, 0, OnAccept, null);
                }
            }
        }
Ejemplo n.º 6
0
 public CommonDialog(Generator g, Type type, bool initialize = true)
     : base(g, type, initialize)
 {
     inner = (ICommonDialog)Handler;
 }
Ejemplo n.º 7
0
		protected CommonDialog (Generator g, Type type, bool initialize = true)
			: base (g, type, initialize)
		{
			handler = (ICommonDialog)Handler;
		}
Ejemplo n.º 8
0
        public virtual bool ShowModalX(ICommonDialog form, bool keepModeless = false)
        {
            var owner = GetActiveWindow();

            return((form == null) ? false : form.ShowModalX(owner));
        }
Ejemplo n.º 9
0
 protected CommonDialog(Generator g, Type type, bool initialize = true)
     : base(g, type, initialize)
 {
     handler = (ICommonDialog)Handler;
 }
Ejemplo n.º 10
0
        public Image ScanImage(ImageFormat outputFormat, string fileName)
        {
            if (outputFormat == null)
                throw new ArgumentNullException("outputFormat");

            var filePerm =
                 new FileIOPermission(FileIOPermissionAccess.AllAccess, fileName);
            filePerm.Demand();

            ImageFile imageObject = null;

            try
            {
                if (WiaManager == null)
                    WiaManager = new CommonDialogClass();
                imageObject =
                     WiaManager.ShowAcquireImage(WiaDeviceType.ScannerDeviceType,
                          WiaImageIntent.ColorIntent, WiaImageBias.MinimizeSize,
                          outputFormat.Guid.ToString("B"), false, true, true);

                imageObject.SaveFile(fileName);
                return Image.FromFile(fileName);
            }
            catch (COMException ex)
            {
                const string message = "Error scanning image";
                throw new WiaOperationException(message, ex);
            }
            finally
            {
                if (imageObject != null)
                    Marshal.ReleaseComObject(imageObject);
            }
        }