Thursday, January 29, 2009

Repository Factory VS 2008

I tried to integrate the repository factory in VS 2008...But it takes 3 days...Finally i got the Guidance Package manager Toolkit and then opened the Repository Source in VS 2008 and modified the repoistory XML in the source to 9.0 and then i build and registered the component it comes in the menu and solution explorer....got the ideas from msdn ...

PdfSharp ASP.NET

PdfSharp tool is great to generate the PDF document from ASP.NET...I did some samples..this makes some tough job easier...Really great opensource to use,...

Paypal Pay Flow Recurring ASP.NET

I have done the paypal pay flow recurring service using the Payflow-dotnet dll..It is easy to create the payment...There is no need to navigate to the paypal..site...The purchases are made in our site..

Wednesday, January 21, 2009

Data Matrix 2D Bar Code C# ASP.NET Sample

I have created the Data matrix ASCII.Like below


This is sample and compared to the Standard this is same as in other site too.We can implement the Data Matrix in ASP.NET and Windows application.i have used the open source C# library from sourceforge ...but it supports rectangle and square automatically..I modified the source to generate the rectangle matrix

Tuesday, December 23, 2008

ASP.NET Design Patterns


Creational Patterns

Abstract Factory Creates an instance of several families of classes
Builder Separates object construction from its representation
Factory Method Creates an instance of several derived classes
Prototype A fully initialized instance to be copied or cloned
Singleton A class of which only a single instance can exist

Structural Patterns

Adapter Match interfaces of different classes
Bridge Separates an object’s interface from its implementation
Composite A tree structure of simple and composite objects
Decorator Add responsibilities to objects dynamically
Facade A single class that represents an entire subsystem
Flyweight A fine-grained instance used for efficient sharing
Proxy An object representing another object

Behavioral Patterns

Chain of Resp A way of passing a request between a chain of objects
Command Encapsulate a command request as an object
Interpreter A way to include language elements in a program
Iterator Sequentially access the elements of a collection
Mediator Defines simplified communication between classes
Memento Capture and restore an object's internal state
Observer A way of notifying change to a number of classes
State Alter an object's behavior when its state changes
Strategy Encapsulates an algorithm inside a class
Template Method Defer the exact steps of an algorithm to a subclass
Visitor Defines a new operation to a class without change

Reference:

http://www.dofactory.com/Patterns/Patterns.aspx





Create Dynamic ASP.NET Website in 30 minutes

ASP.NET Patterns & Practices

Create Data Access Layer Using Data Access Guidance Package

Data Access Guidance Package in the Web Service Software Factory to generate a data access layer for a Web Client Software Factory application

The factory pattern is easy to implement,it has the code generation capabilities........

Download and install

1.GuidanceAutomationExtensions.msi
2.DataAccessGuidancePackageSetup.msi



Resources:

http://www.codeplex.com/RepositoryFactory

http://www.pnpguidance.net/Category/RepositoryFactory.aspx





Friday, January 25, 2008

Convolution C#.NET

Convolution matrix

public static bool Conv3x3(Bitmap b, ConvMatrix m)
{
// Avoid divide by zero errors
if (0 == m.Factor) return false;

Bitmap bSrc = (Bitmap)b.Clone();

// GDI+ still lies to us - the return format is BGR, NOT RGB.
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
BitmapData bmSrc = bSrc.LockBits(new Rectangle(0, 0, bSrc.Width, bSrc.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

int stride = bmData.Stride;
int stride2 = stride * 2;
System.IntPtr Scan0 = bmData.Scan0;
System.IntPtr SrcScan0 = bmSrc.Scan0;

unsafe
{
byte* p = (byte*)(void*)Scan0;
byte* pSrc = (byte*)(void*)SrcScan0;

int nOffset = stride - b.Width * 3;
int nWidth = b.Width - 2;
int nHeight = b.Height - 2;

int nPixel;

for (int y = 0; y < nHeight; ++y)
{
for (int x = 0; x < nWidth; ++x)
{
nPixel = ((((pSrc[2] * m.TopLeft) + (pSrc[5] * m.TopMid) + (pSrc[8] * m.TopRight) +
(pSrc[2 + stride] * m.MidLeft) + (pSrc[5 + stride] * m.Pixel) + (pSrc[8 + stride] * m.MidRight) +
(pSrc[2 + stride2] * m.BottomLeft) + (pSrc[5 + stride2] * m.BottomMid) + (pSrc[8 + stride2] * m.BottomRight)) / m.Factor) + m.Offset);

if (nPixel < 0) nPixel = 0;
if (nPixel > 255) nPixel = 255;

p[5 + stride] = (byte)nPixel;

nPixel = ((((pSrc[1] * m.TopLeft) + (pSrc[4] * m.TopMid) + (pSrc[7] * m.TopRight) +
(pSrc[1 + stride] * m.MidLeft) + (pSrc[4 + stride] * m.Pixel) + (pSrc[7 + stride] * m.MidRight) +
(pSrc[1 + stride2] * m.BottomLeft) + (pSrc[4 + stride2] * m.BottomMid) + (pSrc[7 + stride2] * m.BottomRight)) / m.Factor) + m.Offset);

if (nPixel < 0) nPixel = 0;
if (nPixel > 255) nPixel = 255;

p[4 + stride] = (byte)nPixel;

nPixel = ((((pSrc[0] * m.TopLeft) + (pSrc[3] * m.TopMid) + (pSrc[6] * m.TopRight) +
(pSrc[0 + stride] * m.MidLeft) + (pSrc[3 + stride] * m.Pixel) + (pSrc[6 + stride] * m.MidRight) +
(pSrc[0 + stride2] * m.BottomLeft) + (pSrc[3 + stride2] * m.BottomMid) + (pSrc[6 + stride2] * m.BottomRight)) / m.Factor) + m.Offset);

if (nPixel < 0) nPixel = 0;
if (nPixel > 255) nPixel = 255;

p[3 + stride] = (byte)nPixel;

p += 3;
pSrc += 3;
}
p += nOffset;
pSrc += nOffset;
}
}

b.UnlockBits(bmData);
bSrc.UnlockBits(bmSrc);

return true;
}

Ruler in C#.NET

Here i have posted Ruler user control

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

namespace RulerTest
{
public partial class Ruler : UserControl
{
private int _width;
private int _height;

public int RulerWidth
{
get { return _width; }
set { _width = value; }
}
public int RulerHeight
{
get { return _height; }
set { _height = value; }
}

public Ruler()
{
InitializeComponent();
}


private void DrawRuler(Graphics g, int formWidth, int formHeight)
{
// Border
//g.DrawRectangle(Pens.Black, 0, 0, formWidth - 1, formHeight - 1);


// Width
//g.DrawString(formWidth + " pixels", Font, Brushes.Black, 10, (formHeight / 2) - (Font.Height / 2));

// Ticks
for (int i = 0; i < formWidth; i++)
{
if (i % 2 == 0)
{
int tickHeight;
if (i % 100 == 0)
{
tickHeight = 15;
DrawTickLabel(g, i.ToString(), i, formHeight, tickHeight);
DrawTick(g, i, formHeight, tickHeight);
}
else if (i % 10 == 0)
{
tickHeight = 10;
DrawTick(g, i, formHeight, tickHeight);
}
else
{
tickHeight = 5;
}


}
}
}

private static void DrawTick(Graphics g, int xPos, int formHeight, int tickHeight)
{

// Top
g.DrawLine(Pens.White, xPos + 50, 40, xPos + 50, -tickHeight + 40);

// Left
g.DrawLine(Pens.White, 40, xPos + 50, -tickHeight + 40, xPos + 50);

}


private void DrawTickLabel(Graphics g, string text, int xPos, int formHeight, int height)
{
// Top
g.DrawString(text, Font, Brushes.White, xPos + 45, -height + 20);

// Left
g.DrawString(text, Font, Brushes.White, -height+20, xPos+45);
}

private void Ruler_Paint(object sender, PaintEventArgs e)
{
Graphics graphics = e.Graphics;
int height = Width;
int width = Height;

DrawRuler(graphics, width, height);



}


}
}