S
H
A
R
E

Monday, May 16, 2011

All-In-One Code Framework Sample Browser



Have you ever heard about All-In-One Code Framework, a centralized code sample library from Microsoft?  Have you ever tried its cool Sample Browser application that makes the sample search and download easy and hassle free?


This extension of Visual Studio integrates the Sample Browser of All-In-One Code Framework, which helps search for code samples whenever you are coding with VS2010. Along with the powerful filter, you can find and download the most proper & useful sample in a few seconds, right from within Visual Studio!
Configuration:
The first time you launch the search tool, a configuration dialog box pops up. You will be asked to specify a directory for downloaded samples,  and the connection settings determines proxy using, if no samples shows up after searching, you can try to change the connection setting to IE proxy setting.
Also, you can call this configuration box out by click the hyperlink “Configurations” on the left bottom.
How to use:
  • Menu command, Tools->Search Code Sample:
It launches the sample browser extension and display history tabs when last time the extension closed, if no history tabs, it searches for condition (Key word: Empty, all language, all technology) by default.
  • Code editor context menu command, Search Code Sample:
It launches the sample browser extension and searches for conditions based on the selection string in current active code file and its file extensions.
For instance, in the picture above, the search condition is (Key word: Form1, C# language, all technology)
  • Shortcut Key, Alt+F1:
Same as the context menu command, if no code editor is opened, it searches for condition (Key word: Empty, all language, all technology) by default.
  • You can download the sample by click the Hyperlink “Download” or open its description page by double click on the sample name.
  • If you cannot find a proper sample via this tool, you can also request for this sample by click on the hyper link “Request a code sample”.
BY: Ziwei_Vic

Download Here or Here

Read More!

VBnet Tool: Remove Unused References

Got too many unused project references in your face? Clean them up with the aptly named 'Remove Unused References' extension!
Just right-click on a project (or solution) and choose 'Remove Unused References' from the menu and this extension will go to work while you wait (*). After it's done you can almost smell that lemon scent.
BY : spongman (Code Without Borders)
Download Here or Here

Read More!

VBnet Get Process List


'This A ConsoleApplication
Imports System.Diagnostics
Module Module1
    Sub Main()
        Dim proc() As Process = Process.GetProcesses()
        For Each p As Process In proc
            Try
                Console.Write(p.MainModule.FileName)
                If p.MainWindowTitle.Length > 0 Then
                    Console.WriteLine(" - " & p.MainWindowTitle)
                End If
            Catch ex As Exception
            End Try
        Next p
        Console.ReadKey()
    End Sub
End Module



Read More!

CSharp Get Process List

//This A ConsoleApplication
using System;
using System.Diagnostics; //manual using

class Program
{
    static void Main()
    {
        // Get List Of Running process
        Process [] proc = Process.GetProcesses();
        // Get one-by-one of process lists.
        foreach (Process p in proc)
        {
            try
            {
                Console.Write(p.MainModule.FileName.ToString());
                if (p.MainWindowTitle.Length > 0)
                Console.WriteLine(" - " + p.MainWindowTitle.ToString());
                else Console.WriteLine();
            }
            catch (Exception e){}
       }
        Console.ReadKey();
    }

Read More!

Sunday, May 15, 2011

VB.net - Get the name of enumerate color names



Module Module1
    'This example to calling back the name of declared enum
    ' Get the name of enumerate color names
    'sample by: Klampok_Child
    Sub Main()
        For Each color In [Enum].GetNames(GetType(ConsoleColor))
            Console.WriteLine(color)
            System.Threading.Thread.Sleep(200)
        Next
    End Sub
End Module

Read More!

CSharp Array Of Textbox


private void Form1_Load(object sender, EventArgs e)
        {
            TextBox[] tx;
            int count = 7;

            //Create text box
            tx = new TextBox[count];
            for (int i = 0; i < count; i++)
            {
                tx[i] = new TextBox();
                tx[i].Parent = this;
                // space 5px of each texbox
                tx[i].Top = i * (tx[i].Height+5);
            }

        }

Read More!

Saturday, May 07, 2011

VB.net Capture Color at Screen where Cursor Clicked

Make a form apllication with your Visual studio editor,choose VB Language, and then insert 1 button and 1 timer.

OnForm load, insert this code:
Private Sub Form1_Load() Handles MyBase.Load
        Me.Size = New Size(200, 100)
        Button1.Dock = DockStyle.Fill
        Timer1.Interval = 50
        Me.TopMost = True
        MsgBox("Press Start Capture to Start." & _
        "and then clik on your screen") 
End Sub

On Button Click:

Private Sub Button1_Click() Handles Button1.Click
        Timer1.Start()
        Me.WindowState = FormWindowState.Minimized
End Sub

when button pressed, program will start to waiting with timer when mouse clicked.

and this the code for timer tick event:
Private Sub Timer1_Tick() Handles Timer1.Tick
        If Control.MouseButtons = Windows.Forms.MouseButtons.Left Then
            Timer1.Stop()
            Dim c As Color
            Dim bmp As New Bitmap(1, 1)
            Dim g As Graphics = Graphics.FromImage(bmp)
            g.CopyFromScreen(Control.MousePosition, New Point(0, 0), New Size(1, 1))
            c = bmp.GetPixel(0, 0)
            g.Dispose()
            bmp.Dispose()
            Me.WindowState = FormWindowState.Normal
            Me.TopMost = True
            Clipboard.SetText(ColorTranslator.ToHtml(c))
            MsgBox("Color captured to clipboard." & vbNewLine & "Just paste it.")
        End If
    End Sub

when timer found condition where mouse state is clicked, then timer will stop and get the color at mouse clicked, the result is saving in the clipboard, you just paste it. this I make because i need to capture my blog color and then applying color to my new widget. :-)
Read More!

Thursday, May 05, 2011

PHP, Reserved Variables Server

Use Like This $_SERVER[var_name], this list of var_name and the call back result:


'PHP_SELF'
The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The file constant contains the full path and filename of the current (i.e. included) file. If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.
'argv'
Array of arguments passed to the script. When the script is run on the command line, this gives C-style access to the command line parameters. When called via the GET method, this will contain the query string.
'argc'
Contains the number of command line parameters passed to the script (if run on the command line).
'GATEWAY_INTERFACE'
What revision of the CGI specification the server is using; i.e. 'CGI/1.1'.



'SERVER_ADDR'
The IP address of the server under which the current script is executing.
'SERVER_NAME'
The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.
'SERVER_SOFTWARE'
Server identification string, given in the headers when responding to requests.
'SERVER_PROTOCOL'
Name and revision of the information protocol via which the page was requested; i.e. 'HTTP/1.0';
'REQUEST_METHOD'
Which request method was used to access the page; i.e. 'GET', 'HEAD', 'POST', 'PUT'.
Note:
PHP script is terminated after sending headers (it means after producing any output without output buffering) if the request method was HEAD.
'REQUEST_TIME'
The timestamp of the start of the request. Available since PHP 5.1.0.
'QUERY_STRING'
The query string, if any, via which the page was accessed.
'DOCUMENT_ROOT'
The document root directory under which the current script is executing, as defined in the server's configuration file.
'HTTP_ACCEPT'
Contents of the Accept: header from the current request, if there is one.
'HTTP_ACCEPT_CHARSET'
Contents of the Accept-Charset: header from the current request, if there is one. Example: 'iso-8859-1,*,utf-8'.
'HTTP_ACCEPT_ENCODING'
Contents of the Accept-Encoding: header from the current request, if there is one. Example: 'gzip'.
'HTTP_ACCEPT_LANGUAGE'
Contents of the Accept-Language: header from the current request, if there is one. Example: 'en'.
'HTTP_CONNECTION'
Contents of the Connection: header from the current request, if there is one. Example: 'Keep-Alive'.
'HTTP_HOST'
Contents of the Host: header from the current request, if there is one.
'HTTP_REFERER'
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
'HTTP_USER_AGENT'
Contents of the User-Agent: header from the current request, if there is one. This is a string denoting the user agent being which is accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586). Among other things, you can use this value with get_browser() to tailor your page's output to the capabilities of the user agent.
'HTTPS'
Set to a non-empty value if the script was queried through the HTTPS protocol.
Note: Note that when using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol.
'REMOTE_ADDR'
The IP address from which the user is viewing the current page.
'REMOTE_HOST'
The Host name from which the user is viewing the current page. The reverse dns lookup is based off the REMOTE_ADDR of the user.
Note: Your web server must be configured to create this variable. For example in Apache you'll need HostnameLookups On inside httpd.conf for it to exist. See also gethostbyaddr().
'REMOTE_PORT'
The port being used on the user's machine to communicate with the web server.
'SCRIPT_FILENAME'
The absolute pathname of the currently executing script.
Note:
If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.
'SERVER_ADMIN'
The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host.
'SERVER_PORT'
The port on the server machine being used by the web server for communication. For default setups, this will be '80'; using SSL, for instance, will change this to whatever your defined secure HTTP port is.
'SERVER_SIGNATURE'
String containing the server version and virtual host name which are added to server-generated pages, if enabled.
'PATH_TRANSLATED'
Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.
Note: As of PHP 4.3.2, PATH_TRANSLATED is no longer set implicitly under the Apache 2 SAPI in contrast to the situation in Apache 1, where it's set to the same value as the SCRIPT_FILENAME server variable when it's not populated by Apache. This change was made to comply with the CGI specification that PATH_TRANSLATED should only exist if PATH_INFO is defined. Apache 2 users may use AcceptPathInfo = On inside httpd.conf to define PATH_INFO.
'SCRIPT_NAME'
Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.
'REQUEST_URI'
The URI which was given in order to access this page; for instance, '/index.html'.
'PHP_AUTH_DIGEST'
When running under Apache as module doing Digest HTTP authentication this variable is set to the 'Authorization' header sent by the client (which you should then use to make the appropriate validation).
'PHP_AUTH_USER'
When running under Apache or IIS (ISAPI on PHP 5) as module doing HTTP authentication this variable is set to the username provided by the user.
'PHP_AUTH_PW'
When running under Apache or IIS (ISAPI on PHP 5) as module doing HTTP authentication this variable is set to the password provided by the user.
'AUTH_TYPE'
When running under Apache as module doing HTTP authenticated this variable is set to the authentication type.
'PATH_INFO'
Contains any client-provided pathname information trailing the actual script filename but preceding the query string, if available. For instance, if the current script was accessed via the URL http://www.example.com/php/path_info.php/some/stuff?foo=bar, then $_SERVER['PATH_INFO'] would contain /some/stuff.
'ORIG_PATH_INFO'
Original version of 'PATH_INFO' before processed by PHP. 
For More: visit php.net


Read More!

Monday, May 02, 2011

VB.net Console with Form and Muti-threading


I using VS 2010, lets try it, Make your project with VB language, choose Console Application.
In Console Apllication, you can’t import the windows class (Imports System.Windows.Forms). Because, the references it not included automatically in Console Apllication project, but, it can be set, use this way:

·         On Solution Explorer, klik ‘My Project’ (Project properties and configurations):



·         Choose ‘Refferences’:

·         Click Add:

·         Select “System.Windows.Forms”:

“Click OK”, now you can create form in your console application :-), now you can use this import: Imports System.Windows.Forms.

NEXT: THE CODING

Import System.Windows.Forms in your project, and declaring this

    Dim T1 As New Threading.Thread(AddressOf Thread_one)
    Dim i As Integer = 0

Var I is use for counter, T1 is the thread class object, and Thread_One is the sub program that will run as thread T1.

Create the Main Sub:

    Sub Main()
        Console.WriteLine("Press enter and then the second thread will be run..")
        Console.ReadKey()
        T1.Start()
        Console.Write("Input User: ")
        Console.ReadLine()
        T1.Abort()
    End Sub

And this is the handler of Second Thread:

    Private Sub Thread_one()
        Dim Thread_one_form As New Form
        Dim Thread_one_label As New Label
        Dim i As Integer = 0
        Thread_one_form.Show()
        Thread_one_form.Top = 0
        Thread_one_form.Width = 200
        Thread_one_form.Height = 100
        Thread_one_label.Parent = Thread_one_form
        Thread_one_label.Dock = DockStyle.Top
        Thread_one_form.Text = "Waiting User Input"
        While True
            Thread_one_label.Text = i & " seconds."
            i += 1
            Threading.Thread.Sleep(1000)
            Thread_one_form.Left = (i + 1) * 10
            Thread_one_form.Update()
        End While
    End Sub

This subwill showing the form and wating for user input. U can edit this code for make your application run more better and escape from Not responding form process.

Download Tutorial (docx) and Project (VB2010)

Read More!

Thursday, April 28, 2011

CSharp Rounded Blinking Box in Console


Using VS2008 and written with CSharp Language, The rounded box will be blinking, use a simple timer handler you can try It, and this is the code:
using System;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Kotak_Dekorasi k = new Kotak_Dekorasi();
            k.New(1, 1, 78, 5, 200);
           
        re:
           // j.Jalan();
            k.Jalan();
            Console.ReadKey();
            k.Berhenti();
            //j.Berhenti();
            Console.ReadKey();
            goto re;
        }
    }
    class Kotak_Dekorasi
    {
        TimerCallback TmH;
        public Timer tm;
        static char c1 = '*', c2 = ' ';
        static int x1, y1, x2, y2, d;
          public void New(int xx1, int yy1, int xx2, int yy2, int delay)
        {
            x1 = xx1; x2 = xx2; y1 = yy1; y2 = yy2; d = delay;
        }
          public void Jalan()
          {
              TmH = new TimerCallback(kedip);
              tm = new Timer(TmH, 0, 0, 300);

          }
          public void Berhenti()
          {
              tm.Dispose();
          }
        static void kedip(object kondisi) //TImer Handler bro..,
        {
            int i,j;
             Console.ForegroundColor = ConsoleColor.Green;
            //Atas-Bawah
           for (i = x1; i <= x2; i++)
            {
                Console.SetCursorPosition(i, y1);
                lip(i);
                Console.SetCursorPosition(i, y2);
                lip(i + (y2 - y1));
            }
            //Kanan-Kiri
            for (j = y1; j <= y2; j++)
            {
                Console.SetCursorPosition(x2, j) ;
                lip((x2-x1) + j);
                Console.SetCursorPosition(x1, j);
                lip(j);
            }

            char x =c1;c1 = c2; c2 = x;
        }

        static  void lip(int i)
        {
            if (i % 2 == 0)
                Console.Write(c1);
            else Console.Write(c2);
        }

    }
}

Read More!