Ejemplo n.º 1
0
 private void TFEvoluirTicket_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode.Equals(Keys.F4))
     {
         afterGrava();
     }
     else if (e.Control && e.KeyCode.Equals(Keys.V))
     {
         if (Clipboard.ContainsImage())
         {
             using (TFAnexosHelpDesk fAnexo = new TFAnexosHelpDesk())
             {
                 fAnexo.st_print  = true;
                 fAnexo.Img_anexo = Clipboard.GetImage();
                 if (fAnexo.ShowDialog() == DialogResult.OK)
                 {
                     Anexo anexo = new Anexo();
                     anexo.Ds_anexo = fAnexo.pDs_anexo;
                     System.IO.MemoryStream ms = new System.IO.MemoryStream();
                     fAnexo.Img_anexo.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                     anexo.Imagem = ms.ToArray();
                     anexo.Tp_ext = string.Empty;
                     lAnexo.Add(anexo);
                     llkAnexo.Text = "Anexar Imagem (" + lAnexo.Count.ToString() + ")";
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        private void gAnexo_DoubleClick(object sender, EventArgs e)
        {
            if (bsAnexo.Current != null)
            {
                if (!string.IsNullOrEmpty((bsAnexo.Current as Anexo).Tp_ext))
                {
                    byte[] arquivoBuffer = (bsAnexo.Current as Anexo).Imagem;
                    string extensao      = (bsAnexo.Current as Anexo).Tp_ext; // retornar do banco tbm

                    string path = System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), extensao);

                    System.IO.File.WriteAllBytes(
                        path,
                        arquivoBuffer);

                    // para abrir o arquivo para o usuario
                    System.Diagnostics.Process.Start(path);
                }
                else
                {
                    using (TFAnexosHelpDesk fAnexo = new TFAnexosHelpDesk())
                    {
                        fAnexo.pDs_anexo = (bsAnexo.Current as Anexo).Ds_anexo;
                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
                        ms.Write((bsAnexo.Current as Anexo).Imagem, 0, (bsAnexo.Current as Anexo).Imagem.Length);
                        fAnexo.Img_anexo = Image.FromStream(ms);
                        fAnexo.ShowDialog();
                    }
                }
            }
        }