Hi all,
Today we will see how to customize your form shape according to your needs.
get bored looking at your rectangular shaped form.....
Following are simple steps to do this.
Step 1: Create a Windows Form Application
Step 2: Select Form1, In Properties change FormBorderStyle property to None.
Step 3: Set the image to BackgroundImage property of Form1. (This image will be the shape of your form)
Step 4: Set form Width and height equal to background image width and height.
Step 5: Set Transperencykey to Magenta color.
Step 6: Run and see your form.....
Be happy...... Make every one happy..............
Mahesh Bagul
Monday, December 27, 2010
ClickOnce Deployment
ClickOnce deployment enables you to publish Windows-based applications to a Web server or network file share for simplified installation.
Visual Studio provides full support for publishing and updating applications deployed with ClickOnce technology.
ClickOnce deployment is available for projects created with Visual Basic and Visual C#, but not for Visual C++.
Please refer MSDN for more details about ClickOnce deployment
http://msdn.microsoft.com/en-us/library/t71a733d(VS.90).aspx
Following are the steps for ClickOnce deployment:
Step 1: Create a Windows Form Application. Give name as RubberBandRectangle.
Step 2: Right click on the RubberBandRectangle project from the solution explorer and select Properties from the context menu.
Step 3: Select Publish tab.
Specify Publishing folder location. In My case I have given "F:\RubberBand Publish\" path. (This folder path must be shared)
Enter Installation Folder URL:
//MAHESHB/RubberBand%20Publish/ (In my case)
Step 4: Click on Update and turn on Update feature by checking "The Application should check for updates"
Step 5: After you done with it Click on Publish Now button.
That's it... You have done it.
Keep smiling....
Mahesh Bagul
Visual Studio provides full support for publishing and updating applications deployed with ClickOnce technology.
ClickOnce deployment is available for projects created with Visual Basic and Visual C#, but not for Visual C++.
Please refer MSDN for more details about ClickOnce deployment
http://msdn.microsoft.com/en-us/library/t71a733d(VS.90).aspx
Following are the steps for ClickOnce deployment:
Step 1: Create a Windows Form Application. Give name as RubberBandRectangle.
Step 2: Right click on the RubberBandRectangle project from the solution explorer and select Properties from the context menu.
Step 3: Select Publish tab.
Specify Publishing folder location. In My case I have given "F:\RubberBand Publish\" path. (This folder path must be shared)
Enter Installation Folder URL:
//MAHESHB/RubberBand%20Publish/ (In my case)
Step 4: Click on Update and turn on Update feature by checking "The Application should check for updates"
That's it... You have done it.
Keep smiling....
Mahesh Bagul
Thursday, December 16, 2010
Draw Rubber Band like Explorer using C# .NET
Hi Friends,
Today we will see how to draw a rubber band rectangle like Explorer does. in C#. You can easily do the same in VB.NET also.
It was a tough task assigned by my project manager. But I have achieved it.
Steps:
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace RubberBandRectangle
{
///
/// Class to simulate Rubber Band rectangle
///
///Mahesh Bagul
public partial class frmMain : Form
{
#region Declaration
private Point MouseDownPosition { get; set; }
private Point CurrentMousePos { get; set; }
Color selectionColor;
Brush selectionBrush;
Color frameColor;
Pen framePen;
#endregion
#region Constructor
public frmMain()
{
InitializeComponent();
this.MouseDownPosition = Point.Empty;
DoubleBuffered = true;
this.BackColor = Color.White;
this.selectionColor = Color.FromArgb(200, 0xE8, 0xED, 0xF5);
this.selectionBrush = new SolidBrush(selectionColor);
this.frameColor = Color.FromArgb(0x33, 0x5E, 0xA8);
this.framePen = new Pen(frameColor);
}
#endregion
#region FormEvents
///
/// MouseMove event
///
///
///Mahesh Bagul
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Button == MouseButtons.Left && MouseDownPosition != Point.Empty)
Invalidate();
}
///
/// OnPaint Event
///
///
///Mahesh Bagul
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
if (MouseDownPosition != Point.Empty)
{
CurrentMousePos = this.PointToClient(MousePosition);
Rectangle selectedRect = new Rectangle(
Math.Min(MouseDownPosition.X, CurrentMousePos.X),
Math.Min(MouseDownPosition.Y, CurrentMousePos.Y),
Math.Abs(CurrentMousePos.X - MouseDownPosition.X),
Math.Abs(CurrentMousePos.Y - MouseDownPosition.Y));
e.Graphics.FillRectangle(selectionBrush, selectedRect);
e.Graphics.DrawRectangle(framePen, selectedRect);
}
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Invalidate();
}
///
/// OnMouseDown Event
///
///
///Mahesh Bagul
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (e.Button == MouseButtons.Left)
MouseDownPosition = e.Location;
}
///
/// OnMouseUp Event
///
///
///Mahesh Bagul
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
MouseDownPosition = Point.Empty;
Invalidate();
}
#endregion
#region Functions
#endregion
}
}
Compile and Run..... fill beauty of .NET.
Keep Smiling.
Mahesh Bagul
Today we will see how to draw a rubber band rectangle like Explorer does. in C#. You can easily do the same in VB.NET also.
It was a tough task assigned by my project manager. But I have achieved it.
Steps:
- Create a Windows Form application named as RubberBandRectangle.
- Give Form name as frmMain
- Paste the following code in your frmMain.cs file
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace RubberBandRectangle
{
///
/// Class to simulate Rubber Band rectangle
///
///
public partial class frmMain : Form
{
#region Declaration
private Point MouseDownPosition { get; set; }
private Point CurrentMousePos { get; set; }
Color selectionColor;
Brush selectionBrush;
Color frameColor;
Pen framePen;
#endregion
#region Constructor
public frmMain()
{
InitializeComponent();
this.MouseDownPosition = Point.Empty;
DoubleBuffered = true;
this.BackColor = Color.White;
this.selectionColor = Color.FromArgb(200, 0xE8, 0xED, 0xF5);
this.selectionBrush = new SolidBrush(selectionColor);
this.frameColor = Color.FromArgb(0x33, 0x5E, 0xA8);
this.framePen = new Pen(frameColor);
}
#endregion
#region FormEvents
///
/// MouseMove event
///
///
///
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Button == MouseButtons.Left && MouseDownPosition != Point.Empty)
Invalidate();
}
///
/// OnPaint Event
///
///
///
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
if (MouseDownPosition != Point.Empty)
{
CurrentMousePos = this.PointToClient(MousePosition);
Rectangle selectedRect = new Rectangle(
Math.Min(MouseDownPosition.X, CurrentMousePos.X),
Math.Min(MouseDownPosition.Y, CurrentMousePos.Y),
Math.Abs(CurrentMousePos.X - MouseDownPosition.X),
Math.Abs(CurrentMousePos.Y - MouseDownPosition.Y));
e.Graphics.FillRectangle(selectionBrush, selectedRect);
e.Graphics.DrawRectangle(framePen, selectedRect);
}
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Invalidate();
}
///
/// OnMouseDown Event
///
///
///
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (e.Button == MouseButtons.Left)
MouseDownPosition = e.Location;
}
///
/// OnMouseUp Event
///
///
///
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
MouseDownPosition = Point.Empty;
Invalidate();
}
#endregion
#region Functions
#endregion
}
}
Compile and Run..... fill beauty of .NET.
Keep Smiling.
Mahesh Bagul
Friday, December 3, 2010
Windows 7 - Enable/Turn on Remote Desktop
Remote Desktop is disabled by default in Windows 7 and also in Vista.
Simple steps to turn on Remote Desktop:
Right-click Computer and select Properties
click the Remote Settings link on the left hand side:
Check Allow Remote Assistance connections to this computerSelect Allow connections from computers running any version of Remote Desktop(less secure) radio button
It's done....
Keep smiling...
Mahesh Bagul
Simple steps to turn on Remote Desktop:
Right-click Computer and select Properties
click the Remote Settings link on the left hand side:
Check Allow Remote Assistance connections to this computerSelect Allow connections from computers running any version of Remote Desktop(less secure) radio button
It's done....
Keep smiling...
Mahesh Bagul
Windows 7 - Enable Telnet feature
By default Telnet is disabled in Windows 7 for security reason.
Following are simple steps to enable Telnet.
Start
Control Panel
Programs And Features
Turn Windows features on or off
Check Telnet Client
Hit OK
After that you can start Telnet via Command Prompt.
...........
Keep enjoying
Mahesh Bagul.
Thursday, December 2, 2010
Get Assembly attributes using C# .NET
Hi,
Extracting attributes of an assembly is very easy using .NET.
Following program will show this.
private void RetrieveAssemblyInfo()
{
Assembly asm = Assembly.GetExecutingAssembly ();
if ( asm == null )
return;
object[] asmAttributes = asm.GetCustomAttributes(false );
if ( asmAttributes.Length == 0 )
return;
foreach ( Attribute attribute in asmAttributes )
{
if ( attribute.GetType () == typeof ( AssemblyTitleAttribute ) )
{
tbxAssemblyTitle.Text = ( ( AssemblyTitleAttribute ) attribute ).Title;
}
else if ( attribute.GetType () == typeof ( AssemblyCompanyAttribute ) )
{
tbxCompanyName.Text = ( ( AssemblyCompanyAttribute ) attribute ).Company;
}
else if ( attribute.GetType () == typeof ( AssemblyCopyrightAttribute ) )
{
tbxCopyrights.Text = ( ( AssemblyCopyrightAttribute ) attribute ).Copyright;
}
else if ( attribute.GetType () == typeof ( AssemblyFileVersionAttribute ) )
{
tbxVersion.Text = ( ( AssemblyFileVersionAttribute ) attribute ).Version;
}
}
}
private void button1_Click( object sender, EventArgs e )
{
RetrieveAssemblyInfo ();
}
Extracting attributes of an assembly is very easy using .NET.
Following program will show this.
private void RetrieveAssemblyInfo()
{
Assembly asm = Assembly.GetExecutingAssembly ();
if ( asm == null )
return;
object[] asmAttributes = asm.GetCustomAttributes(false );
if ( asmAttributes.Length == 0 )
return;
foreach ( Attribute attribute in asmAttributes )
{
if ( attribute.GetType () == typeof ( AssemblyTitleAttribute ) )
{
tbxAssemblyTitle.Text = ( ( AssemblyTitleAttribute ) attribute ).Title;
}
else if ( attribute.GetType () == typeof ( AssemblyCompanyAttribute ) )
{
tbxCompanyName.Text = ( ( AssemblyCompanyAttribute ) attribute ).Company;
}
else if ( attribute.GetType () == typeof ( AssemblyCopyrightAttribute ) )
{
tbxCopyrights.Text = ( ( AssemblyCopyrightAttribute ) attribute ).Copyright;
}
else if ( attribute.GetType () == typeof ( AssemblyFileVersionAttribute ) )
{
tbxVersion.Text = ( ( AssemblyFileVersionAttribute ) attribute ).Version;
}
}
}
private void button1_Click( object sender, EventArgs e )
{
RetrieveAssemblyInfo ();
}
Subscribe to:
Posts (Atom)