Posted by admin | Posted in Programming | Posted on 02-02-2010-05-2008
0

Learning Programming
Every developer says that this language is the good programming language. I had a teacher before from my college days and he keep on saying that his programming language is really the good programming language but we heard that there are a lot of bugs from his program on the production. So, how can you tell that this language is the best programming language to learn? What is the most important to know when learning a program?
Posted by admin | Posted in C# | Posted on 01-02-2010-05-2008
0
Here is the code snippet:
add to your directives:
using Excel = Microsoft.Office.Interop.Excel;
——
Excel.Application xlApp = null;
Excel.Workbook xlWorkBook = null;
Excel.Worksheet xlWorkSheet = null;
Excel.Range range = null;
xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Open(“Excel FileName”, 0, true, 5, “”, “”, true, Excel.XlPlatform.xlWindows, “\t”, false, false, 0, true, 1, 0);
//Get the First Excell Sheet from WorkBook
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
var dt = new DataTable();
for (int rCnt = 1; rCnt <= 99; rCnt++)
{
range = xlWorkSheet.get_Range(“A” + rCnt.ToString(), “L” + rCnt.ToString());
Array myValues = (System.Array)range.Cells.get_Value(Type.Missing);
//Add the array to datatable
AddDataRow(dt, myValues);
}
happy coding…
Posted by admin | Posted in Sharepoint | Posted on 31-01-2010-05-2008
0
Here is a sample source code on how to add ajax on sharepoint webpart.
using System.Web.UI;
…….
private ScriptManager ajaxManager;
……….
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (!m_Error)
{
try
{
this.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None;
//prep ajax
this.ajaxManager = ScriptManager.GetCurrent(this.Page);
if (this.ajaxManager == null)
{
this.ajaxManager = new ScriptManager();
this.ajaxManager.EnablePartialRendering = true;
this.Page.ClientScript.RegisterStartupScript(this.GetType(), this.ID, “_spOriginalFormAction = document.forms[0].action;”, true);
if (this.Page.Form != null)
{
string str = this.Page.Form.Attributes["onsubmit"];
if (!(string.IsNullOrEmpty(str) || (str != “return _spFormOnSubmitWrapper();”)))
{
this.Page.Form.Attributes["onsubmit"] = “_spFormOnSubmitWrapper();”;
}
this.Page.Form.Controls.AddAt(0, this.ajaxManager);
}
}
}
catch (Exception ex)
{
//
}
}
}
Posted by admin | Posted in Sharepoint | Posted on 31-01-2010-05-2008
0
Code Snippet:
lblFolder = new Label();
SPFolderCollection folderCollection = SPContext.Current.Web.Folders;
foreach (SPFolder spfolder in folderCollection)
{
lblFolder.Text += spfolder.Name;
}
Useful Link:
Traversing SharePoint List Folder Hierarchies
Posted by admin | Posted in Windows 7 | Posted on 30-01-2010-05-2008
0
Introduction
Windows Vista has a new default theme called Aero glass. In Aero glass, the title bar of a window and the frame is drawn transculent. This gives the UI a clean and lightweight look. This nice feaure is provided by a service that is called the desktop window manager (DWM).
Extending the Glass
By default the blurry glass effect is only on the title bar and the frame, but the client area is drawn opaque. But there is a simple way to extend the glass into the client area by using the DWM’s API.
First thing you need to do is to include some Win32 functions from the dwmapi.dll library.
using System.Runtime.InteropServices;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows;
[StructLayout(LayoutKind.Sequential)]
struct MARGINS
{
public int cxLeftWidth;
public int cxRightWidth;
public int cyTopHeight;
public int cyBottomHeight;
}
[DllImport("dwmapi.dll")]
static extern int
DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
[DllImport("dwmapi.dll")]
extern static int DwmIsCompositionEnabled(ref int en);
I have written a helper method that does all the stuff to extend the glass by the specified amount of pixels on each border of the window.
/// <summary>
/// Extends the glass area into the client area of the window
/// </summary>
/// <param name="window"></param>
/// <param name="top"></param>
public static void ExtendGlass(Window window, Thickness thikness)
{
try
{
int isGlassEnabled = 0;
DwmIsCompositionEnabled(ref isGlassEnabled);
if (Environment.OSVersion.Version.Major > 5 && isGlassEnabled > 0)
{
// Get the window handle
WindowInteropHelper helper = new WindowInteropHelper(window);
HwndSource mainWindowSrc = (HwndSource)HwndSource.
FromHwnd(helper.Handle);
mainWindowSrc.CompositionTarget.BackgroundColor =
Colors.Transparent;
// Get the dpi of the screen
System.Drawing.Graphics desktop =
System.Drawing.Graphics.FromHwnd(mainWindowSrc.Handle);
float dpiX = desktop.DpiX / 96;
float dpiY = desktop.DpiY / 96;
// Set Margins
MARGINS margins = new MARGINS();
margins.cxLeftWidth = (int)(thikness.Left * dpiX);
margins.cxRightWidth = (int)(thikness.Right * dpiX);
margins.cyBottomHeight = (int)(thikness.Bottom * dpiY);
margins.cyTopHeight = (int)(thikness.Top * dpiY);
window.Background = Brushes.Transparent;
int hr = DwmExtendFrameIntoClientArea(mainWindowSrc.Handle,
ref margins);
}
else
{
window.Background = SystemColors.WindowBrush;
}
}
catch (DllNotFoundException)
{
}
}
Next thing you need to do is calling the ExtendGlass in the OnSourceInitialized callback. Because that is the time the window handle has been created.
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
GlassHelper.ExtendGlass(this, LayoutRoot.Margin);
}
Since the user (or the system) can enable or disable the glass effect while the application is running, we need to hook up a callback in the WndProc to undo or initialize the glass extension dynamically.
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam,
IntPtr lParam, ref bool handled)
{
if (msg == GlassHelper.WM_DWMCOMPOSITIONCHANGED)
{
GlassHelper.ExtendGlass(this, LayoutRoot.Margin);
handled = true;
}
return IntPtr.Zero;
}
Read Full Article [ click here ]
Posted by admin | Posted in WPF | Posted on 30-01-2010-05-2008
0
3D Graphic Basics
The basic idea of creating 3D graphics is to have a three dimensional
model of an object. Because our screen is only two dimensional, we define a
camera that takes a picture of the object. The picture is a projection of the object to a planar surface. This projection is rendered into an bitmap by the 3D rendering engine. The engine determines the color for every pixel by calculating the amount of light that is reflected by any
light sources to the projection surface by the objects in the 3D space.
All surfaces of objects have a
material and a brush. The material defines how much light is reflected for a specific angle and the brush defines the color. A brush can either be a simple color or a gradient or even an image called
texture.

A world of triangles
In the world of 3D graphics, all objects are described by a set of triangles. But why triangles? The reason for this is that a triangle is the most granular geometry to describe a planar surface. The rendering engine can calculate the color of each triangle depending on its material and angle to the lights in the scene. If we would build our world on rectangles, the points don’t need to be plane. The surface will be a lot more complex to calculate and render.
A surface of a 3D object is called a mesh. A mesh is defined by a number of 3D points. These points are called vertices. The vertices are joined together by a winding pattern to define the triangles. Every triangle has a front and a back side. Only the front side is rendered. The front side is defined by the winding order of the points. WPF uses a counter clockwise winding pattern. You can remember this with a simple mnemonic called the “right hand rule”. This means if you close your right hand to a thumb-up gesture, your finger make a counter clockwise move while the thumb shows up. The fingers show the winding order, while the thumb indicates the upper-side of the triangle.

Read Full Article [ click here ]