S
H
A
R
E

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!

VB.net Create Simple Text Effect Following Mouse

This Program will displaying text on screen and following mouse with simple effect. Just a simple, have some conntrol mouse manipulation, and timer for animation.


This project using NetFramework 3.5, I write it with Visual studio 2008, Would you like to try??
Ok, lets make a new VB project in Visual studio. and then... copy the code bellow:



Public Class Form
    Dim str As String = ""
    Dim StrLen As Integer = 0
    Dim pos As Integer = 0
    Const TxWidth As Integer = 17
    Dim Lb(30) As Label
    Dim WithEvents tm As New Timer()
    Dim WithEvents TmIkuti As New Timer()


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        str = "This A Simple Mouse Effect"
        Me.ShowInTaskbar = False
        Me.TopMost = True
        StrLen = str.Length
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        Me.BackColor = Color.White
        Me.TransparencyKey = Color.White
        TataHuruf()
    End Sub

    Private Sub TataHuruf()
        For i = 0 To StrLen - 1
            Lb(i) = New Label
            Lb(i).Text = str(i)
            Lb(i).Width = TxWidth
            Lb(i).Font = New Font("Calibri", 12, FontStyle.Bold)
            Lb(i).Left = TxWidth * i
            Lb(i).Top = 5
            Lb(i).Parent = Me
            Lb(i).Show()
        Next
        Me.Height = Lb(0).Height + 5
        Me.Width = TxWidth * StrLen
        tm.Interval = 80
        tm.Start()
        TmIkuti.Interval = 10
        TmIkuti.Start()
    End Sub

    Private Sub Animasi() Handles tm.Tick
        Lb(pos).Top = 0
        Lb(pos).ForeColor = Color.Red
        Dim pr As Integer = PosMovPrev(pos)
        Lb(pr).Top = 5
        Lb(pr).ForeColor = Color.Black
        PosMoveNext()
    End Sub

    Private Sub IkutiMouse_x() Handles TmIkuti.Tick
        Try
            Me.Left = Control.MousePosition.X - (Me.Width \ 2)
            Me.Top = Control.MousePosition.Y
        Catch ex As Exception

        End Try
    End Sub

    Private Sub PosMoveNext()
        If pos >= (StrLen - 1) Then
            pos = 0
        Else
            pos += 1
        End If
        If Trim(Lb(pos).Text) = "" Then PosMoveNext()
    End Sub
    Private Function PosMovPrev(ByVal n As Integer) As Integer
        If n <= 0 Then
            n = StrLen - 1
        Else
            n -= 1
        End If
        If Trim(Lb(n).Text) = "" Then
            Return PosMovPrev(n)
        Else
            Return n
        End If
    End Function
End Class

Read More!

Sunday, April 17, 2011

VB.net DataGridView, Move Row Item By Draging






Download Source (VB.net 2010)


This a sample code how to moving DataGridView rows item with drag and droping, you can move item to every line, check it!

I using this code for get the index of rows where user droping a data:

Private Sub DataGridView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop

        Dim CP As Point = DataGridView1.PointToClient(New Point(e.X, e.Y))

        Dim RowDestination As Integer = DataGridView1.HitTest(CP.X, CP.Y).RowIndex

        Dim RowSource As Integer = e.Data.GetData("System.String")

        If RowDestination >= 0 Then

            Dim tmp(0 To DataGridView1.Rows(0).Cells.Count - 1)

            'saving Cells

            For i = 0 To tmp.Count - 1

                tmp(i) = DataGridView1.Rows.Item(RowSource).Cells(i).Value

            Next



            DataGridView1.Rows.RemoveAt(RowSource)

            DataGridView1.Rows.Insert(RowDestination, 1)

            'Aplly Saved Cells

            For i = 0 To tmp.Count - 1

                DataGridView1.Rows(RowDestination).Cells(i).Value = tmp(i)

            Next i

            DataGridView1.Rows(RowDestination).Selected = True

        End If

    End Sub
Read More!

Friday, April 08, 2011

C++ Delay Procedure

#include

void delay(unsigned int tick)
{ //klampok_child@yahoo.co.id
 int tmp = (clock()+tick);
 while (clock() <= tmp){};
};

Read More!

Java. Compile & Run Using Command Prompt

This a sample code, save as "app1.java":

public class app1 {
public static void main(String arg[]){
    System.out.println("Haiii haha.. \nThis Ur Java Code");
}
}


This Compiler created from cmd, save as "java_Compile&Run.cmd":

set c=C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar
echo off & cls
javac -Xbootclasspath:"%c%" -classpath . app1.java
java -Xbootclasspath:"%c%" -classpath . app1
pause
rem klampok_child@yahoo.co.id

Place app1.java & java_Compile&Run.cmd in one folder, and double click the cmd file (execute) and see it.
javac is the main java compiler, java is interprenter to running java program (byte-code).
Have problem, please read it:
>  Make sure you have jdk1.6.0_23 installed on your windows
>  Make sure you was write java code correctly (its case-sensitive)

Try it :-)
Read More!