Click here to Skip to main content
15,885,365 members
Articles / Desktop Programming / WPF

Saving-Rebuilding InkCanvas Strokes

Rate me:
Please Sign up or sign in to vote.
3.85/5 (7 votes)
29 Nov 2006CPOL2 min read 93.5K   2K   22  
An article on the InkCanvas and InkPresenter WPF controls.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OracleClient;

namespace WindowsApplication2
{
    class Signature
    {

        /// <summary>
        /// Inserts a BLOB into an Oracle DataBase
        /// </summary>
        /// <param name="connectionString">The ConnectionString to the database</param>
        /// <param name="signatureBytes">Signature bytes to be saved</param>
        public static void UploadImage(string connectionString, byte[] signatureBytes)
		{
            try
            {
                OracleConnection conn = new OracleConnection(connectionString);
			    conn.Open() ; 

			    OracleCommand cmd = new OracleCommand("insert into tabel(Signature) values(:Signature)", conn); 
                //OracleCommand cmd = new OracleCommand("update courrierlog set Signature=:Signature where id = 312", conn); 
			    cmd.Parameters.Add("Signature", OracleType.Blob) ;
			    cmd.Parameters["Signature"].Value = signatureBytes;
    			
			    cmd.ExecuteNonQuery();
    			
			    conn.Close(); 
            }
            catch(Exception ex)
            {
                throw ex;
            }
		}

		
		/// <summary>
		/// Downloads a byte[] from a BLOB
		/// </summary>
		/// <param name="connectionString"></param>
		/// <returns></returns>		
		public static byte[] DownloadImage(string connectionString)
		{
            try
            {
			    OracleConnection conn = new OracleConnection(connectionString);
			    conn.Open();			

			    OracleCommand cmd = new OracleCommand("select signature from tabel order by id desc", conn); 
                //OracleCommand cmd = new OracleCommand("select signature from courrierlog where id = 312", conn); 
			    byte[] barrImg = cmd.ExecuteScalar() as byte [];

			    conn.Close();

			    return barrImg;
            }
            catch(Exception ex)
            {
                throw ex;
            }
		}
    }

    
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Romania Romania
is a developer at LetsVR.ro.

Comments and Discussions