Locations of visitors to this page


Onteora Software - General

Onteora Software

Ken Tucker's Blog

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Welcome to BlogEngine.NET 1.3

If you see this post it means that BlogEngine.NET 1.3 is running and the hard part of creating your own blog is done. There is only one thing you need to do from this point on to take full advantage of the blog and that is to set up the first author profile.

Write Permissions

To be able to log in to the blog and writing posts, you need to enable write permissions on the App_Data folder. If you’re blog is hosted at a hosting provider, you can either log into your account’s admin page or call the support. You need write permissions on the App_Data folder because all posts and comments are saved as XML files and placed in the App_Data folder.

Username and password

When you've got write permissions to the App_Data folder, you need to change the username and password. Find the sign-in link located either at the bottom or top of the page depending on your current theme and click it. Now enter "admin" in both the username and password fields and click the button. You will now see an admin menu appear. It has a link to the "Users" admin page. From there you can change the username and password.

On the web

You can find BlogEngine.NET on the official website. Here you'll find tutorials, documentation, tips and tricks and much more. The ongoing development of BlogEngine.NET can be followed at CodePlex where the daily builds will be published for anyone to download.

Good luck and happy writing.

The BlogEngine.NET team

Currently rated 4.4 by 3 people

  • Currently 4.4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,
Categories: General
Posted by Admin on Friday, December 21, 2007 7:00 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Dry Dock

The past few weeks the ship I work on has been in dry dock.  I hope to be home in about a week and start adding some new blog entries soon.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General
Posted by Ken Tucker on Saturday, October 06, 2007 4:14 PM
Permalink | Comments (0) | Post RSSRSS comment feed

GotDotNet Phase out

GotDotNet Phase out


Since the GotDotNet website is being phased out I am placing my user samples here .

Video Capture Box

A inherted picturebox control which allows you to capture an image from a webcam. Also adds a ByteImage Property to make it easier to bind to an image from a database.


Enum Windows

A module you can add to your projects which contains an enum with all the WM_ messages. Good to use when overriding wndproc.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General
Posted by Ken Tucker on Tuesday, July 03, 2007 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Printer Compatibility Library 1.0

Printer Compatibility Library 1.0



Visual Basic 6.0 and earlier had a printer object which made it simple to print. The Printer Compatibility Library 1.0 makes it possible to use the same object with VB or C# 2005. After installing the Power Pack just add a reference to Microsoft.VisualBasic.PowerPacks.Printing.Printer

 

VB Sample

Imports Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim p As New Printer
        p.Print("Page 1")
        p.NewPage()
        p.Print("Page 2")
        p.EndDoc()
    End Sub
End Class

 

C# Sample

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6;

namespace PrinterCS
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Printer p = new Printer();
            p.Print("Page 1");
            p.NewPage();
            p.Print("Page 2");
            p.EndDoc();
        }
    }
}
 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General | VB | C#
Posted by Ken Tucker on Friday, December 22, 2006 11:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

.Net Framework 3.0 Text to Speech

.Net Framework 3.0 Text to Speech



The dot net framework 3.0 now has a managed provider for text to speech. I tested this app on a machine with windows xp service pack 2 and the Dot Net FrameWork 3.0 RC1. The link is to set up instructions for the .net framework 3.0

 

For this sample add a reference to system.speech, place a textbox named txtSay, a button named btnSay, and listbox named lstVoice. The application fills a list box with the installed voices on the system at startup. When you click on the button it says the text in the textbox with the selected voice.




VB Sample

Imports System.Speech.Synthesis

Public Class Form1

    Private Sub btnSay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSay.Click
        Dim spk As New SpeechSynthesizer
        spk.SelectVoice(lstVoice.SelectedItem.ToString)
        spk.Speak(txtSay.Text)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim spk As New SpeechSynthesizer
        For Each voice As InstalledVoice In spk.GetInstalledVoices
            lstVoice.Items.Add(voice.VoiceInfo.Name)
        Next
        lstVoice.SelectedIndex = 0
        txtSay.Text = "Hello World!"
    End Sub
End Class

 

C# Sample

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Speech.Synthesis;

namespace CS3._Speech
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            SpeechSynthesizer spk = new SpeechSynthesizer();
            foreach(InstalledVoice voice in spk.GetInstalledVoices())
            {
                lstVoice.Items.Add(voice.VoiceInfo.Name);
            }
            lstVoice.SelectedIndex = 0;
            txtSay.Text = "Hello World";
        }

        private void btnSay_Click(object sender, EventArgs e)
        {
            SpeechSynthesizer spk = new SpeechSynthesizer();

            spk.SelectVoice(lstVoice.SelectedItem.ToString());
            spk.Speak(txtSay.Text);
        }
    }
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General | VB | C#
Posted by Ken Tucker on Thursday, September 21, 2006 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Beta Certification Exam

Beta Certification Exam



I took the beta exam for Microsoft Windows Mobile 5.0 - Application Development (exam number 70-540) with the visual basic option. The exam had 81 questions with a 4 hour time limit. There was one c# question slipped in there.



There were questions on the creating menus, smart phone connection status to the network, interacting with contact list, listing items in the task list, serial port, xml, and httpwebrequests.


SQL Everywhere (formerly SQL Mobile) was a topic which had a few questions. You will need to know how to repair a database, and sync with a sql 2005 database.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General | Archive
Posted by Ken Tucker on Wednesday, September 06, 2006 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Secure Strings

Secure Strings



The SecureString is a new class that was added in the .Net framework 2.0 which allows you to store info in memory securely. The SecureString could be used to safely secure a password or credit number. The example shows how to add info to the string, prevent changes from being make to the data, and finally how to get the info back. I included c# and VB samples.





C# sample

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Security;
using System.Runtime.InteropServices;

namespace SecureStringCS
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //
            // How to add to a secure string
            //
            SecureString ss = new SecureString();
            foreach (Char c in "This is some info I need to keep secure".ToCharArray())
            {
                ss.AppendChar(c);
            }
            //
            // Prevent changes
            //
            ss.MakeReadOnly();

            //
            // How to get the info back
            //

            IntPtr ptr;
            ptr=Marshal.SecureStringToBSTR(ss);

            String s;
            s = Marshal.PtrToStringAuto(ptr);
            Marshal.ZeroFreeBSTR(ptr);

        }
    }
}

VB sample

Imports System.Security
Imports System.Runtime.InteropServices

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        '
        ' how to add to a secure string
        '
        Dim ss As New SecureString
        For Each c As Char In "This is some info I need to keep secure".ToCharArray
            ss.AppendChar(c)
        Next

        ' prevent changes

        ss.MakeReadOnly()

        '
        ' how to get the info back
        '
        Dim ptr As IntPtr
        ptr = Marshal.SecureStringToBSTR(ss)
        Dim s As String

        s = Marshal.PtrToStringAuto(ptr)
        Marshal.ZeroFreeBSTR(ptr)

    End Sub
End Class

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General | VB | C#
Posted by Ken Tucker on Tuesday, August 29, 2006 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Encrypting Data

Encrypting Data



Here is a vb2005 example on how to encrypt and decrypt data. I am storing the encryption key as a base64 string in the programs settings. The settings name is Key and its starting string value was Unknown. In a production application I would store it in a more secure location.





Imports System.Security.Cryptography
Imports System.IO
Imports System.Text

Public Class Form1
    Public Key() As Byte
    Public IV() As Byte

    Public Function Encrypt(ByVal strData As String) As Byte()
        Dim data() As Byte = ASCIIEncoding.ASCII.GetBytes(strData)
        Dim tdes As TripleDESCryptoServiceProvider = _
                New TripleDESCryptoServiceProvider
        If Key Is Nothing Then
            tdes.GenerateKey()
            tdes.GenerateIV()
            Key = tdes.Key
            IV = tdes.IV
        Else
            tdes.Key = Key
            tdes.IV = IV
        End If
        Dim encryptor As ICryptoTransform = tdes.CreateEncryptor()
        Dim ms As New MemoryStream
        Dim cs As CryptoStream = _
                New CryptoStream(ms, encryptor, CryptoStreamMode.Write)
        cs.Write(data, 0, data.Length)
        cs.FlushFinalBlock()
        ms.Position = 0
        Dim result(Convert.ToInt32(ms.Length - 1)) As Byte
        ms.Read(result, 0, Convert.ToInt32(ms.Length))
        cs.Close()
        Return result
    End Function

    Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click
        Dim data() As Byte
        data = System.Text.Encoding.Default.GetBytes(TextBox1.Text)
        Dim result() As Byte

        Dim sha As New SHA1Managed
        ' This is one implementation of the abstract class SHA1.
        result = sha.ComputeHash(data)
        lblEncrypted.Text = Convert.ToBase64String(Encrypt(TextBox1.Text))
        lblDecrypted.Text = Decrypt(Convert.FromBase64String(lblEncrypted.Text))
    End Sub

    Public Function GetEncryptedData(ByVal Data As String) As String
        Dim shaM As New SHA1Managed
        Convert.ToBase64String(shaM.ComputeHash(System.Text.Encoding.ASCII.GetBytes(Data)))
        Dim eNC_data() As Byte = System.Text.ASCIIEncoding.ASCII.GetBytes(Data)
        Dim eNC_str As String = Convert.ToBase64String(eNC_data)
        GetEncryptedData = eNC_str
    End Function

    Public Function GetDecryptedData(ByVal Data As String) As String
        Dim dEC_data() As Byte = Convert.FromBase64String(Data)
        Dim dEC_Str As String = System.Text.ASCIIEncoding.ASCII.GetString(dEC_data)
        GetDecryptedData = dEC_Str
    End Function
    Public Function Decrypt(ByVal data() As Byte) As String
        Dim tdes As TripleDESCryptoServiceProvider = _
                New TripleDESCryptoServiceProvider
        tdes.Key = Key
        tdes.IV = IV
        Dim decryptor As ICryptoTransform = tdes.CreateDecryptor()
        Dim ms As New MemoryStream
        Dim cs As CryptoStream = New CryptoStream(ms, decryptor, CryptoStreamMode.Write)
        cs.Write(data, 0, data.Length)
        cs.FlushFinalBlock()
        ms.Position = 0
        Dim result(Convert.ToInt32(ms.Length - 1)) As Byte
        ms.Read(result, 0, Convert.ToInt32(ms.Length))
        cs.Close()
        Return ASCIIEncoding.ASCII.GetString(result)
    End Function

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try
            My.Settings.Key = Convert.ToBase64String(Key)
            My.Settings.IV = Convert.ToBase64String(IV)
        Catch
        End Try
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Settings.Key <> "Unknown" Then
            Key = Convert.FromBase64String(My.Settings.Key)
            IV = Convert.FromBase64String(My.Settings.IV)
        End If

    End Sub
End Class

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General | VB
Posted by Ken Tucker on Saturday, July 01, 2006 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

DXCore

DXCore



Developers express has a free product DX Core. It is a framework to develop add ins for visual studio. With it you can paint on the ide, work with the text, etc.


I answer alot of questions in the newsgroups and forums. From time to time I copy code from the ide and when it pasted it looses the format. To overcome this limitation I usually paste the text in notepad. I then recopy the text and paste it in the question I am answering to preseve the format.


Today I used the dxcore to add the copy as text to context menu when you right click on selected code. Step one download and install the DXCore. Note the dx core does not work with the express editions of visual studio.


Step 2 from the DevExpress menu added to visual studio select New Plug in. This will create a project for the addin.


Step 3 Drag a Action on to the designer from the toolbox. Set it action name, button text, and desciption to Copy as Text. Set the CommonMenu to EditorContext. Double Click on the action and add this code to the Action_Execute Event.

    Private Sub Action1_Execute(ByVal ea As DevExpress.CodeRush.Core.ExecuteEventArgs) Handles Action1.Execute
        Dim template As String = CodeRush.Selection.Text

        Clipboard.SetDataObject(template)

    End Sub

Run this from the ide. It will open up another instance of the ide. Open a project and select some code and right click on it. You will see the copy as text in the menu, Boy does dev express make it easy.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General | DXCore
Posted by Ken Tucker on Monday, May 15, 2006 10:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

SQL Everywhere

SQL Everywhere



Microsoft will be removing the restrictions on sql sever 2005 mobile edition so it works in a desktop environment. Check out the SQL everywhere FAQ on Steve Lasker's blog


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General | Sql
Posted by Ken Tucker on Monday, April 10, 2006 11:42 AM
Permalink | Comments (0) | Post RSSRSS comment feed