Thursday, 18 August 2011

where to register notes to be appeared in intellisent (intelligent)

before the class, add your notes as this:

///
/// This function will create an image with from the given filename
///

public class MyFile
{
... the rest of code

Visual Studio shortcut keys

You are familiar with many of Visual Studio's shortcut keys, but not all of them. Here is a handy reference that can make your .NET lifestyle easier and a lot more productive. The 'must-know' shortcut keys are highlighted.


General

Shortcut Description
Ctrl-X or
Shift-Delete
Cuts the currently selected item to the clipboard
Ctrl-C or
Ctrl-Insert
Copies the currently selected item to the clipboard
Ctrl-V or
Shift-Insert
Pastes the item in the clipboard at the cursor
Ctrl-Z or
Alt-Backspace
Undo previous editing action
Ctrl-Y or
Ctrl-Shift-Z
Redo the previous undo action
Ctrl-Shift-V or
Ctrl-Shift-Insert
Pastes an item from the clipboard ring tab of the Toolbox at the cursor in the file and automatically selects the pasted item. Cycle through the items on the clipboard by pressing the shortcut keys repeatedly
Esc Closes a menu or dialog, cancels an operation in progress, or places focus in the current document window
Ctrl-S Saves the selected files in the current project (usually the file that is being edited)
Ctrl-Shift-S Saves all documents and projects
Ctrl-P Displays the Print dialog
F7 Switches from the design view to the code view in the editor
Shift-F7 Switches from the code view to the design view in the editor
F8 Moves the cursor to the next item, for example in the TaskList window or Find Results window
Shift-F8 Moves the cursor to the previous item, for example in the TaskList window or Find Results window
Shift-F12 Finds a reference to the selected item or the item under the cursor
Ctrl-Shift-G Opens the file whose name is under the cursor or is currently selected
Ctrl-/ Switches focus to the Find/Command box on the Standard toolbar
Ctrl-Shift-F12 Moves to the next task in the TaskList window
Ctrl-Shift-8 Moves backward in the browse history. Available in the object browser or Class View window
Alt-Left Arrow Go back in the web browser history
Alt-Right Arrow Go forward in the web browser history

Tuesday, 28 June 2011

Design time error: In this mode, command line arguments will not be passed


problem

c# idiot fucken error!!! (microsoft SUCKS)
---------------------------
The current project settings specify that the project will be debugged with specific security permissions.  In this mode, command line arguments will not be passed to the executable.
Do you want to continue debugging anyway?
[Yes]   [No]  
---------------------------
difficulty level

3/10 :|
compatibility

vs2008 .net 2.5
solution

- open the properties of the application
- go to at security tab
- click "Enable ClickOnce security settings"
- select "This is a partial trust" (at the end you may turn it back)
- Under all these, there is a button "Advanced" where it is not displayed sometimes if your monitor has lo resolution, scroll down to see it, press it and there you may find the settings if you with to use this "permission set" on debug execution. If you selected to use this settings you cannot use the specified command line arguments at "debug" tab of the parameters (one more reason why Microsoft sucks). Your application will use the command line arguments finally in "release" version. Who fucks Microsoft anyway, add some code to feed your application with the command line argument from inside your code. This is not so professional but with Microsoft we can't be professionals anyway!
- SAVE the parameters window and then ReBuild!

Runtime error Request for the permission of type 'System.Security.Permissions.FileIOPermission

problem

c# security fucken error!!! (microsoft SUCKS)
---------------------------
Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
difficulty level

3/10 :|
compatibility

vs2008 .net 2.5
solution

- be sure that the file you are trying to open it from you code, is in the same directory or somewhere where is valid to reach- open the properties of the application
- go to at security tab
- click "Enable ClickOnce security settings"
- select "This is a partial trust"
- Zone your application: (custom)
- Select above all the secutiry settings required from the environment where the application will run (consider about this!). You must include FileIOPermission if your application open files. Do not include regardless permissions because in case where the end user hasn't them (i.e. guest user) your application will not run.
- Under all these, there is a button "Advanced" where it is not displayed sometimes if your monitor has lo resolution, scroll down to see it, press it and there you may find the settings if you with to use this "permission set" on debug execution. If you selected to use this settings you cannot use the specified arguments at "debug" tab of the parameters (one more reason why Microsoft sucks). Your application will use the command line arguments finally in "release" version.
- SAVE the parameters window and then ReBuild!
- open the file c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config ; this key and update accordingly: <trust level="Full" originUrl=""/>

Printing the Form (Visual C#)

This example demonstrates printing a copy of the current form.
You may also use the PrintDocument component instead of PrintForm component with the same way.

This technique captures the gdi handler of the form and pastes it as image to the printer (as bitmap). It is not so good idea because the image has no good quality! If you plan to print photos and other material that requests high quality forget this technique and start to play drawing in the printer's canvas (i will show you in another post it is very easy).

Lest CODE!

[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern long BitBlt (IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
private Bitmap memoryImage;
private void CaptureScreen()
{

Thursday, 23 June 2011

how to handle files, directories and drives

problem

c# - how to handle files, directories and drives --- Working with the File Type --- in practice! >>guide<<
difficulty level

3/10 :|
compatibility

flex 4.0
solution

Method Meaning in Life
ReadAllBytes() Opens the specified file, returns the binary data as an array of bytes, and then closes the file
ReadAllLines() Opens a specified file, returns the character data as an array of strings, and then closes the file
ReadAllText() Opens a specified file, returns the character data as a System.String, and then closes the file
WriteAllBytes() Opens the specified file, writes out the byte array, and then closes the file
WriteAllLines() Opens a specified file, writes out an array of strings, and then closes the file
WriteAllText() Opens a specified file, writes the character data, and then closes the file
Using these new methods of the File type, you are able to read and write batches of data in just a few lines of code. Even better, each of these new members automatically closes down the underlying file handle. For example, the following console program (named SimpleFileIO) will persist the string data into a new file on the C drive (and read it into memory) with minimal fuss:

using System;
using System.IO;   // important!
class Program
{
  static void Main(string[] args)
  {
    Console.WriteLine("***** Simple IO with the File Type *****\n");
    string[] myTasks = {
    "Fix bathroom sink", "Call Dave",
    "Call Mom and Dad", "Play Xbox 360"};
    // Write out all data to file on C drive.
    File.WriteAllLines(@"C:\tasks.txt", myTasks);
    // Read it all back and print out.
    foreach (string task in File.ReadAllLines(@"C:\tasks.txt"))
      Console.WriteLine("TODO: {0}", task);
    Console.ReadLine();
  }
}

how to pass command line arguments in the main form of an application

1. open the "program.cs" file form solution explorer of vs

2. in the follow code... add the red marked text
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormMain(args));  //Your Form might not named FormMain
        }

3.  Open your Main Form -> right click -> view code, to see the actual code

4. Modify the follow code, add again the red marked text
        public FormMain(string[] args)           //Your Form might not named FormMain

At this point in the FormMain contructor the args string array contains the command line arguments.
How to add arguments now in VS?

5. From solution explorer of vs -> double click the "properties" node -> click on "debug" tab -> type your arguments in "command line arguments" box