Create a desktop video recorder in C#

We have to record our desktop activity for make various reason, like make a demo for an application, or making video tutorial for an application etc.

the prototype application is like

This project can be done in 3 steps

  • taking screenshot of ur desktop continously
  • Make an video file using the images

So first step taking screenshot of ur desktop continously

so first we have to take the screen shot of the desktop, for that we have to write the code
int ScreenWidth = Screen.PrimaryScreen.Bounds.Width;
int ScreenHeight = Screen.PrimaryScreen.Bounds.Height;
Graphics g;
Bitmap b = new Bitmap(ScreenWidth, ScreenHeight);
g = Graphics.FromImage(b);
g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);

Now we have to make avi file from these images, for that we aviwrapper u can download it from here.

now about making avi file from these images , the code i used is like
AviManager aviManager = new AviManager(@"..\..\Output\output.avi", false);
VideoStream aviStream = null;
aviStream = aviManager.AddVideoStream(true,4, bi);
aviStream.AddFrame(b);

the link for full source code is here

Advertisements
Posted in C#, Winform app | Tagged , , , , | 31 Comments

C# tricks: How to remove loader lock error in visual studio debugging

Some time we get a very unexpected error Loader lock error from debuggers managed debugging assistants,  normally directx depended program’s fall in this type of debugging problem, its just an exception, to free ur program from this exception follow below

first press ctrl +D or go to debug-exception u will get below image

Click the + sign beside Manage debugging assistants

now uncheck the loader lock and click ok, problrm solve.

 

Posted in C#, CPP, F SHARP | Tagged , , , , , , | Leave a comment

Make a database management system for survey (part-3)

it is the continuation of a previous post.

here i will show how the various types of search show in c# for oracle

To show all table n a gridview, we have to write below code  .

string selected = "select * from " + tableName;
DataSet dataSet = new DataSet();
OracleDataAdapter dataAdapt = new OracleDataAdapter(selected, oracleConect);
dataAdapt.Fill(dataSet, tableName);
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = dataSet;
dataGridView1.DataMember = tableName;

Show data depend on user modification u can use code like
tableName = "ALLC";
string MI = numericUpDown3.Value.ToString();
string MA = numericUpDown4.Value.ToString();
string selected = "select * from " + tableName + " WHERE SALARY >= " + MI + " AND SALARY <= " + MA;
DataSet dataSet = new DataSet();
OracleDataAdapter dataAdapt = new OracleDataAdapter(selected, oracleConect);
dataAdapt.Fill(dataSet, tableName);
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = dataSet;
dataGridView1.DataMember = tableName;

Posted in C#, DATABASE, Winform app | Tagged , , , , , , , , , , , , , , | Leave a comment

C#: basic calculator developing in winform part 1-(design phase)

for starting c# win form it is best to start with a common easy desktop application.
here Rakibe kuet eee 06 design a calculator for starting win form application.

the design source code is

namespace Calculator
{
    partial class Form1
    {
        /// 
        /// Required designer variable.
        /// 
        private System.ComponentModel.IContainer components = null;

        /// 
        /// Clean up any resources being used.
        /// 
        /// true if managed resources should be disposed; otherwise, false.
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// 
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// 
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.button9 = new System.Windows.Forms.Button();
            this.button30 = new System.Windows.Forms.Button();
            this.button29 = new System.Windows.Forms.Button();
            this.button28 = new System.Windows.Forms.Button();
            this.button27 = new System.Windows.Forms.Button();
            this.button26 = new System.Windows.Forms.Button();
            this.button25 = new System.Windows.Forms.Button();
            this.button24 = new System.Windows.Forms.Button();
            this.button23 = new System.Windows.Forms.Button();
            this.button22 = new System.Windows.Forms.Button();
            this.button21 = new System.Windows.Forms.Button();
            this.button20 = new System.Windows.Forms.Button();
            this.button19 = new System.Windows.Forms.Button();
            this.button18 = new System.Windows.Forms.Button();
            this.button17 = new System.Windows.Forms.Button();
            this.button16 = new System.Windows.Forms.Button();
            this.button15 = new System.Windows.Forms.Button();
            this.button14 = new System.Windows.Forms.Button();
            this.button13 = new System.Windows.Forms.Button();
            this.button12 = new System.Windows.Forms.Button();
            this.button11 = new System.Windows.Forms.Button();
            this.button10 = new System.Windows.Forms.Button();
            this.button8 = new System.Windows.Forms.Button();
            this.button7 = new System.Windows.Forms.Button();
            this.button6 = new System.Windows.Forms.Button();
            this.button5 = new System.Windows.Forms.Button();
            this.button4 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.button1 = new System.Windows.Forms.Button();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.display = new System.Windows.Forms.TextBox();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.SuspendLayout();
            // 
            // groupBox1
            // 
            this.groupBox1.AutoSize = true;
            this.groupBox1.BackColor = System.Drawing.SystemColors.ButtonFace;
            this.groupBox1.Controls.Add(this.button9);
            this.groupBox1.Controls.Add(this.button30);
            this.groupBox1.Controls.Add(this.button29);
            this.groupBox1.Controls.Add(this.button28);
            this.groupBox1.Controls.Add(this.button27);
            this.groupBox1.Controls.Add(this.button26);
            this.groupBox1.Controls.Add(this.button25);
            this.groupBox1.Controls.Add(this.button24);
            this.groupBox1.Controls.Add(this.button23);
            this.groupBox1.Controls.Add(this.button22);
            this.groupBox1.Controls.Add(this.button21);
            this.groupBox1.Controls.Add(this.button20);
            this.groupBox1.Controls.Add(this.button19);
            this.groupBox1.Controls.Add(this.button18);
            this.groupBox1.Controls.Add(this.button17);
            this.groupBox1.Controls.Add(this.button16);
            this.groupBox1.Controls.Add(this.button15);
            this.groupBox1.Controls.Add(this.button14);
            this.groupBox1.Controls.Add(this.button13);
            this.groupBox1.Controls.Add(this.button12);
            this.groupBox1.Controls.Add(this.button11);
            this.groupBox1.Controls.Add(this.button10);
            this.groupBox1.Controls.Add(this.button8);
            this.groupBox1.Controls.Add(this.button7);
            this.groupBox1.Controls.Add(this.button6);
            this.groupBox1.Controls.Add(this.button5);
            this.groupBox1.Controls.Add(this.button4);
            this.groupBox1.Controls.Add(this.button3);
            this.groupBox1.Controls.Add(this.button2);
            this.groupBox1.Controls.Add(this.button1);
            this.groupBox1.Cursor = System.Windows.Forms.Cursors.PanNW;
            this.groupBox1.Location = new System.Drawing.Point(24, 118);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(369, 379);
            this.groupBox1.TabIndex = 31;
            this.groupBox1.TabStop = false;
            // 
            // button9
            // 
            this.button9.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button9.Location = new System.Drawing.Point(218, 82);
            this.button9.Name = "button9";
            this.button9.Size = new System.Drawing.Size(54, 51);
            this.button9.TabIndex = 60;
            this.button9.Text = "x^y";
            this.button9.UseVisualStyleBackColor = true;
            // 
            // button30
            // 
            this.button30.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button30.Location = new System.Drawing.Point(278, 306);
            this.button30.Name = "button30";
            this.button30.Size = new System.Drawing.Size(54, 51);
            this.button30.TabIndex = 59;
            this.button30.Text = "×10^x";
            this.button30.UseVisualStyleBackColor = true;
            // 
            // button29
            // 
            this.button29.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button29.Location = new System.Drawing.Point(217, 306);
            this.button29.Name = "button29";
            this.button29.Size = new System.Drawing.Size(54, 51);
            this.button29.TabIndex = 58;
            this.button29.Text = "+";
            this.button29.UseVisualStyleBackColor = true;
            this.button29.Click += new System.EventHandler(this.button29_Click);
            // 
            // button28
            // 
            this.button28.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button28.Location = new System.Drawing.Point(277, 136);
            this.button28.Name = "button28";
            this.button28.Size = new System.Drawing.Size(54, 51);
            this.button28.TabIndex = 57;
            this.button28.Text = "Cos θ";
            this.button28.UseVisualStyleBackColor = true;
            // 
            // button27
            // 
            this.button27.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button27.Location = new System.Drawing.Point(37, 193);
            this.button27.Name = "button27";
            this.button27.Size = new System.Drawing.Size(54, 51);
            this.button27.TabIndex = 56;
            this.button27.Text = "4";
            this.button27.UseVisualStyleBackColor = true;
            // 
            // button26
            // 
            this.button26.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button26.Location = new System.Drawing.Point(97, 193);
            this.button26.Name = "button26";
            this.button26.Size = new System.Drawing.Size(54, 51);
            this.button26.TabIndex = 55;
            this.button26.Text = "5";
            this.button26.UseVisualStyleBackColor = true;
            this.button26.Click += new System.EventHandler(this.button26_Click);
            // 
            // button25
            // 
            this.button25.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button25.Location = new System.Drawing.Point(37, 252);
            this.button25.Name = "button25";
            this.button25.Size = new System.Drawing.Size(54, 51);
            this.button25.TabIndex = 54;
            this.button25.Text = "1";
            this.button25.UseVisualStyleBackColor = true;
            // 
            // button24
            // 
            this.button24.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button24.Location = new System.Drawing.Point(97, 252);
            this.button24.Name = "button24";
            this.button24.Size = new System.Drawing.Size(54, 51);
            this.button24.TabIndex = 53;
            this.button24.Text = "2";
            this.button24.UseVisualStyleBackColor = true;
            // 
            // button23
            // 
            this.button23.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button23.Location = new System.Drawing.Point(277, 193);
            this.button23.Name = "button23";
            this.button23.Size = new System.Drawing.Size(54, 51);
            this.button23.TabIndex = 52;
            this.button23.Text = "Log";
            this.button23.UseVisualStyleBackColor = true;
            // 
            // button22
            // 
            this.button22.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button22.Location = new System.Drawing.Point(157, 252);
            this.button22.Name = "button22";
            this.button22.Size = new System.Drawing.Size(54, 51);
            this.button22.TabIndex = 51;
            this.button22.Text = "3";
            this.button22.UseVisualStyleBackColor = true;
            // 
            // button21
            // 
            this.button21.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button21.Location = new System.Drawing.Point(218, 252);
            this.button21.Name = "button21";
            this.button21.Size = new System.Drawing.Size(54, 51);
            this.button21.TabIndex = 50;
            this.button21.Text = "-";
            this.button21.UseVisualStyleBackColor = true;
            // 
            // button20
            // 
            this.button20.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button20.Location = new System.Drawing.Point(277, 252);
            this.button20.Name = "button20";
            this.button20.Size = new System.Drawing.Size(54, 51);
            this.button20.TabIndex = 49;
            this.button20.Text = "ln";
            this.button20.UseVisualStyleBackColor = true;
            // 
            // button19
            // 
            this.button19.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button19.Location = new System.Drawing.Point(37, 306);
            this.button19.Name = "button19";
            this.button19.Size = new System.Drawing.Size(54, 51);
            this.button19.TabIndex = 48;
            this.button19.Text = ".";
            this.button19.UseVisualStyleBackColor = true;
            // 
            // button18
            // 
            this.button18.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button18.Location = new System.Drawing.Point(97, 306);
            this.button18.Name = "button18";
            this.button18.Size = new System.Drawing.Size(54, 51);
            this.button18.TabIndex = 47;
            this.button18.Text = "0";
            this.button18.UseVisualStyleBackColor = true;
            // 
            // button17
            // 
            this.button17.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button17.Location = new System.Drawing.Point(157, 306);
            this.button17.Name = "button17";
            this.button17.Size = new System.Drawing.Size(54, 51);
            this.button17.TabIndex = 46;
            this.button17.Text = "=";
            this.button17.UseVisualStyleBackColor = true;
            this.button17.Click += new System.EventHandler(this.button17_Click);
            // 
            // button16
            // 
            this.button16.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button16.Location = new System.Drawing.Point(217, 193);
            this.button16.Name = "button16";
            this.button16.Size = new System.Drawing.Size(54, 51);
            this.button16.TabIndex = 45;
            this.button16.Text = "×";
            this.button16.UseVisualStyleBackColor = true;
            // 
            // button15
            // 
            this.button15.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button15.Location = new System.Drawing.Point(158, 193);
            this.button15.Name = "button15";
            this.button15.Size = new System.Drawing.Size(54, 51);
            this.button15.TabIndex = 44;
            this.button15.Text = "6";
            this.button15.UseVisualStyleBackColor = true;
            // 
            // button14
            // 
            this.button14.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button14.Location = new System.Drawing.Point(218, 136);
            this.button14.Name = "button14";
            this.button14.Size = new System.Drawing.Size(54, 51);
            this.button14.TabIndex = 43;
            this.button14.Text = "÷";
            this.button14.UseVisualStyleBackColor = true;
            // 
            // button13
            // 
            this.button13.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button13.Location = new System.Drawing.Point(157, 136);
            this.button13.Name = "button13";
            this.button13.Size = new System.Drawing.Size(54, 51);
            this.button13.TabIndex = 42;
            this.button13.Text = "9";
            this.button13.UseVisualStyleBackColor = true;
            // 
            // button12
            // 
            this.button12.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button12.Location = new System.Drawing.Point(97, 136);
            this.button12.Name = "button12";
            this.button12.Size = new System.Drawing.Size(54, 51);
            this.button12.TabIndex = 41;
            this.button12.Text = "8";
            this.button12.UseVisualStyleBackColor = true;
            this.button12.Click += new System.EventHandler(this.button12_Click);
            // 
            // button11
            // 
            this.button11.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button11.Location = new System.Drawing.Point(37, 136);
            this.button11.Name = "button11";
            this.button11.Size = new System.Drawing.Size(54, 51);
            this.button11.TabIndex = 40;
            this.button11.Text = "7";
            this.button11.UseVisualStyleBackColor = true;
            // 
            // button10
            // 
            this.button10.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button10.Location = new System.Drawing.Point(278, 81);
            this.button10.Name = "button10";
            this.button10.Size = new System.Drawing.Size(54, 51);
            this.button10.TabIndex = 39;
            this.button10.Text = "Sinθ";
            this.button10.UseVisualStyleBackColor = true;
            // 
            // button8
            // 
            this.button8.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button8.Location = new System.Drawing.Point(157, 82);
            this.button8.Name = "button8";
            this.button8.Size = new System.Drawing.Size(54, 51);
            this.button8.TabIndex = 38;
            this.button8.Text = "y√x";
            this.button8.UseVisualStyleBackColor = true;
            // 
            // button7
            // 
            this.button7.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button7.Location = new System.Drawing.Point(97, 82);
            this.button7.Name = "button7";
            this.button7.Size = new System.Drawing.Size(54, 51);
            this.button7.TabIndex = 37;
            this.button7.Text = "√x";
            this.button7.UseVisualStyleBackColor = true;
            // 
            // button6
            // 
            this.button6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button6.Location = new System.Drawing.Point(37, 82);
            this.button6.Name = "button6";
            this.button6.Size = new System.Drawing.Size(54, 51);
            this.button6.TabIndex = 36;
            this.button6.Text = "Conv.";
            this.button6.UseVisualStyleBackColor = true;
            this.button6.Click += new System.EventHandler(this.button6_Click);
            // 
            // button5
            // 
            this.button5.BackColor = System.Drawing.Color.Red;
            this.button5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
            this.button5.FlatAppearance.BorderColor = System.Drawing.Color.Red;
            this.button5.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Red;
            this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button5.ForeColor = System.Drawing.Color.White;
            this.button5.Location = new System.Drawing.Point(278, 25);
            this.button5.Name = "button5";
            this.button5.Size = new System.Drawing.Size(54, 51);
            this.button5.TabIndex = 35;
            this.button5.Text = "AC";
            this.button5.UseVisualStyleBackColor = true;
            this.button5.Click += new System.EventHandler(this.button5_Click);
            this.button5.Enter += new System.EventHandler(this.button5_Enter);
            this.button5.Leave += new System.EventHandler(this.button5_Enter);
            this.button5.MouseClick += new System.Windows.Forms.MouseEventHandler(this.button5_MouseClick);
            this.button5.MouseCaptureChanged += new System.EventHandler(this.button5_MouseEnter);
            this.button5.MouseEnter += new System.EventHandler(this.button5_MouseEnter);
            this.button5.MouseLeave += new System.EventHandler(this.button5_MouseEnter);
            this.button5.MouseHover += new System.EventHandler(this.button5_MouseEnter);
            this.button5.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.button5_PreviewKeyDown);
            this.button5.Validated += new System.EventHandler(this.button5_Enter);
            // 
            // button4
            // 
            this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button4.Location = new System.Drawing.Point(217, 25);
            this.button4.Name = "button4";
            this.button4.Size = new System.Drawing.Size(54, 51);
            this.button4.TabIndex = 34;
            this.button4.Text = "Clear";
            this.button4.UseVisualStyleBackColor = true;
            // 
            // button3
            // 
            this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button3.Location = new System.Drawing.Point(158, 25);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(54, 51);
            this.button3.TabIndex = 33;
            this.button3.Text = "M+";
            this.button3.UseVisualStyleBackColor = true;
            // 
            // button2
            // 
            this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button2.Location = new System.Drawing.Point(97, 25);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(54, 51);
            this.button2.TabIndex = 32;
            this.button2.Text = "Shift";
            this.button2.UseVisualStyleBackColor = true;
            // 
            // button1
            // 
            this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.button1.Location = new System.Drawing.Point(37, 25);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(54, 51);
            this.button1.TabIndex = 31;
            this.button1.Text = "Const.";
            this.button1.UseVisualStyleBackColor = true;
            // 
            // groupBox2
            // 
            this.groupBox2.BackColor = System.Drawing.SystemColors.ButtonFace;
            this.groupBox2.Controls.Add(this.display);
            this.groupBox2.Location = new System.Drawing.Point(24, 12);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(369, 100);
            this.groupBox2.TabIndex = 32;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Display";
            // 
            // display
            // 
            this.display.Font = new System.Drawing.Font("Microsoft Sans Serif", 28F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.display.Location = new System.Drawing.Point(15, 19);
            this.display.Multiline = true;
            this.display.Name = "display";
            this.display.Size = new System.Drawing.Size(339, 59);
            this.display.TabIndex = 1;
            this.display.Text = "0";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(419, 508);
            this.Controls.Add(this.groupBox2);
            this.Controls.Add(this.groupBox1);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.KeyPreview = true;
            this.Name = "Form1";
            this.Text = "Rakeeb\'s Calculator";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
            this.groupBox1.ResumeLayout(false);
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.Button button30;
        private System.Windows.Forms.Button button29;
        private System.Windows.Forms.Button button28;
        private System.Windows.Forms.Button button27;
        private System.Windows.Forms.Button button26;
        private System.Windows.Forms.Button button25;
        private System.Windows.Forms.Button button24;
        private System.Windows.Forms.Button button23;
        private System.Windows.Forms.Button button22;
        private System.Windows.Forms.Button button21;
        private System.Windows.Forms.Button button20;
        private System.Windows.Forms.Button button19;
        private System.Windows.Forms.Button button18;
        private System.Windows.Forms.Button button17;
        private System.Windows.Forms.Button button16;
        private System.Windows.Forms.Button button15;
        private System.Windows.Forms.Button button14;
        private System.Windows.Forms.Button button13;
        private System.Windows.Forms.Button button12;
        private System.Windows.Forms.Button button11;
        private System.Windows.Forms.Button button10;
        private System.Windows.Forms.Button button8;
        private System.Windows.Forms.Button button7;
        private System.Windows.Forms.Button button6;
        private System.Windows.Forms.Button button5;
        private System.Windows.Forms.Button button4;
        private System.Windows.Forms.Button button3;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.TextBox display;
        private System.Windows.Forms.Button button9;
        private System.Windows.Forms.ToolTip toolTip1;

    }
}

the full sourcecode is here. its is just design

Posted in C#, Winform app | Tagged , , , , | 1 Comment

extract all marked rectangle from hand print image c#

few days ago i have to make an application where a template image with some marked rectangle will be given using that template i have to extract same positions rectangle from other input  images. in c# i make that application using aforge color filtering and blob extraction.

purpose was required data gather from hand print , the print size will be always same so extracted places would be same, so this application was needed.

full code for that application is here

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AForge.Imaging;
using AForge.Imaging.Filters;
using AForge;
using System.Drawing;
using System.Drawing.Imaging;

namespace createdtemplateforhand
{
    public partial class Form1 : Form
    {
        ColorFiltering filter = new ColorFiltering();
        GrayscaleBT709 grayscaleFilter = new GrayscaleBT709();
        BlobCounter blobCounter = new BlobCounter();
        public Form1()
        {
            InitializeComponent();
            filter.Red = new IntRange(160, 255);
            filter.Green = new IntRange(0, 100);
            filter.Blue = new IntRange(0, 100);
        }
        Rectangle[] rects = null;
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog o = new OpenFileDialog();
            if (DialogResult.OK == o.ShowDialog())
                pictureBox1.ImageLocation = o.FileName;
            Bitmap objectsImage = null;
            Bitmap image = new Bitmap(o.FileName);
            objectsImage = filter.Apply(image);
            BitmapData objectsData = objectsImage.LockBits(new Rectangle(0, 0, image.Width, image.Height),
                ImageLockMode.ReadOnly, image.PixelFormat);

            // grayscaling
            UnmanagedImage grayImage = grayscaleFilter.Apply(new UnmanagedImage(objectsData));

            // unlock image
            objectsImage.UnlockBits(objectsData);

            // locate blobs 
            blobCounter.ProcessImage(grayImage);
            rects = blobCounter.GetObjectRectangles();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog o = new OpenFileDialog();
            if (DialogResult.OK == o.ShowDialog())
          pictureBox2.ImageLocation = o.FileName;
            Bitmap image = new Bitmap(o.FileName);
            int i = 0;
                     foreach (Rectangle r in rects)
            {               
                Bitmap bmp = new Bitmap(r.Width, r.Height);
                Graphics g = Graphics.FromImage(bmp);
               g.DrawImage(image, 0, 0, r, GraphicsUnit.Pixel);
                bmp.Save(i+".jpeg");
                 i++;
            }
        }
       
    }
}

here the input template was given and i getting rectangle data.
first taking the template data

now input the images

now see the extracted images

for the csharp file download here

Posted in C#, Image Processing, Winform app | Tagged , , , | 2 Comments

Make a database management system for survey (part-2)

it is the continuation of a previous post

I use oracle connection. in c# for oracle connection  i have to use one dll name  using System.Data.OracleClient; and connection code is

public static bool setConnection(string userId, string pass, string hostStr)
{
try
{
string connectStr = "Data Source=" + hostStr + ";Persist Security Info=True;User ID=" + userId + ";Password=" + pass + ";Unicode=True";
oracleConect = new OracleConnection(connectStr);
oracleConect.Open();
oraCommand = oracleConect.CreateCommand();
return true;
}
catch (OracleException oraxpr1)
{
return false;
}
Console.WriteLine("Connected...");
}

for inserting data i have to write code like

 string connectStr = "Data Source=" + "xe" + ";Persist Security Info=True;User ID=" + "userid" + ";Password=" + "pass" + ";Unicode=True";
            oracleConect = new OracleConnection(connectStr);
            oracleConect.Open();
            oraCommand = oracleConect.CreateCommand();
oraCommand.CommandText= "insert into  question values(" + "qe.nextval" + ",'" + richTextBox1.Text.ToString() + "')";
                    oraCommand.ExecuteNonQuery();
                    oraCommand.CommandText = "commit";
                    oraCommand.ExecuteNonQuery();

Foe searching data i have to write code like

          oracleConect = new OracleConnection(connectStr);
            oracleConect.Open();
            oraCommand = oracleConect.CreateCommand();
            InitializeComponent();
            oraCommand.CommandText = "select * from question ";
               OracleDataReader reader = oraCommand.ExecuteReader();
           while (reader.Read())
            {
                string retId = reader["descrip"].ToString();
                listBox1.Items.Add(retId);
            }

for delete i have to write code

oraCommand.CommandText = "delete from answer where ansid ='"+ans"'";
oraCommand.ExecuteNonQuery();
oraCommand.CommandText = "commit";
oraCommand.ExecuteNonQuery();

in next blog i will show how different type of search worked in c# oracle

Posted in C#, DATABASE, Winform app | Tagged , , , , , , , , , , , , , , , | 1 Comment

Bluetooth device Connection in c# winform application without any dll for windows 7

For establish connection with another device in bluetooth we need to add that device in our OS .To do that in programmatically we have to write below code.

the code for add device is simple


void adddevice()
        {
            try
            {  //add device n os
Process p=Process.Start("E:\\Windows\\System32\\DevicePairingWizard.exe");//here write ur own windows drive
               while (true)
                {
                    if (p.HasExited) //determine if process end
                       break;
                }
                //generate busy com ort list

                List tList = new List();
               listBox1.Items.Clear();
             foreach (string s in SerialPort.GetPortNames())
                {
                 tList.Add(s);
                }
                tList.Sort();
          listBox1.Items.Add("NO PORT");
          listBox1.Items.AddRange(tList.ToArray());
         listBox1.SelectedIndex = 0;
 richTextBox1.Text = richTextBox1.Text + Environment.NewLine + "COMPORT GENERATED";
            }
         catch (Exception ee)
     {             if(DialogResult.Retry== MessageBox.Show("CANT FIND UR ADDED DEVICE..", "Problem occured", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error))
                adddevice();
            }
        }

Now for remove u can run just another process
Process p = Process.Start("E:\\Windows\\System32\\control.exe ");

before connection u have to select ur required port, only user can know which port are using the device. u have to select that port from here.

for connection there are simple code like

    bool connectbluetooth()
        {
            try
            {
                if (listBox1.SelectedIndex != 0)
                {
                    scom = listBox1.SelectedItem.ToString();
                    port = new SerialPort(scom, 9600, Parity.None, 8, StopBits.One);
                     port.Open();
  richTextBox1.Text = richTextBox1.Text + Environment.NewLine + "CONNECTION OPEN SUCCESSFUL"; ;
                    return true;
                }
                else
                    MessageBox.Show("Please select com port","Missing port",MessageBoxButtons.OK,MessageBoxIcon.Information);
                return false;
            }
            catch (Exception a)
            {
                if (DialogResult.Retry == MessageBox.Show(a.Message, "problem occured", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning))
                    connectbluetooth();
                else
                return false;
                return false;
            }
          }

now for sending data there are very simple function like i used here

 bool send(string text) {
           try
           {
        port.WriteTimeout = 10000;//define how much time wait for send data
                port.Write(text);
     return true;
            }
            catch(Exception a)
            {
                if (DialogResult.Retry == MessageBox.Show(a.Message, "Problem occured", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning))
                    send(text);
                else
                    return false;
                return false;
            }
        }

the receiver will get this data in his hyper terminal. next i will show how to send files and also receive.
full sourcecode can download from here

 
and to see the hardware part bluetooth modulation check here
 

Posted in C#, Winform app | Tagged , , , , , , , , | 37 Comments