Monday, December 3, 2012

Differences of Desktop Applications and Metro Applications in Windows 8


Modern UI was introduced tend to Tablet users, but this assumption is only from SOT. That’s why Windows 8 is provided in two versions, which are Pro and also RT. Its application is also available in two versions, desktop and also Metro. Do you know the difference between both? If you haven’t found out, SOT now will discuss about the difference between desktop and metro applications in Windows 8.

#1 Metro UI Application Design Display

In the beginning, we have discussed about Windows 8 display renewal with its Modern UI. What do you think about this Modern UI from Windows 8, do you like or hate it? In the first time Windows 8 appeared, actually this Modern UI design named Metro UI, since it is focused on image typography which appeared in Traffic sign. The average of Metro UI applications run in full screen display and hide Option display which made us focused on the application.

#2 Application is always in Windows Store

If you want Windows 8 with Metro UI or Modern UI applications, you can get it in Windows Store. By visiting Windows Store, then searching for applications you wanted and install it, then you have already enjoy this Metro UI design application. It surely different with desktop application you commonly download and install easily. But it is more profitable for user, since by this way, malware and viruses would be filtered first by Microsoft.

#3 Sandboxed

In Windows with desktop application, we know what we called as User Account Control, it means that application can be run as Administrator. So, this application would be able to access files or system they needed. Does it endanger your privacy? But it is different with Metro UI application. This Metro UI application is similar like Android, you can read what the application needed to be installed. So, if you feel disturbed because this application accessing your privacy too much, you don’t need to install it. This feature is called as Sandboxed.

#4 Always active and cannot be terminated

This metro application is similar like mobile application, so you cannot close the application when you come out from the application. The application will be run in background and doesn’t consume too much memory. If you think you can use Task Manager to close the Metro application, that’s definitely wrong. Microsoft makes an unclear reason so that user wouldn’t be able to close Metro application. That’s why you wouldn’t be able to see close button on upper right of Metro application exists.

#5 Applications cannot run at the same time

Not similar as desktop application which is able to run many application at once, whether application which seemed with various window or run in background, Metro UI application is only able to run by using two applications, the first application run on ¾ of screen, while the second apps run on ¼ screen. This feature is called as Snap. It surely different with Windows 7 which has Aero display with 50/50 snap when we do apps multitasking from the screen.

#6 Metro UI Application programming

In Metro application, developers are able to create it using C/C++ or .NET, JavaScript and HTML5 language programming. Here, Microsoft expects that there would be so many developers would be interested in creating Windows 8 apps according to language programming they understood. Metro UI application also support x86 and ARM devices, makes it possible to run in Windows 8 Pro and Windows 8 RT.


Reference from spyontech

Friday, November 30, 2012

Delegates in C#.Net


Delegate is a type which  holds the method(s) reference in an object. It is also referred to as a type safe function pointer.

Advantages

  • Encapsulating the method's call from caller
  • Effective use of delegate improves the performance of application
  • Used to call a method asynchronously

Declaration:

public delegate type_of_delegate delegate_name()

Example:
public delegate int mydelegate(int delvar1,int delvar2)

Note

  • You can use delegates without parameters or with parameter list
  • You should follow the same syntax as in the method
    (If you are referring to the method with two int parameters and int return type, the delegate which you are declaring should be in the same format. This is why it is referred to as type safe function pointer.)

Sample Program using Delegate

public delegate double Delegate_Prod(int a,int b);
class Class1
{
    static double fn_Prodvalues(int val1,int val2)
    {
        return val1*val2;
    }
    static void Main(string[] args)
    {
        //Creating the Delegate Instance
        Delegate_Prod delObj = new Delegate_Prod(fn_Prodvalues);
        Console.Write("Please Enter Values");
        int v1 = Int32.Parse(Console.ReadLine());
        int v2 = Int32.Parse(Console.ReadLine());
        //use a delegate for processing
        double res = delObj(v1,v2);
        Console.WriteLine ("Result :"+res);
        Console.ReadLine();
    }
}

Explanation

Here I have used a small program which demonstrates the use of delegate.
The delegate "Delegate_Prod" is declared with double return type and accepts only two integer parameters.
Inside the class, the method named fn_Prodvalues is defined with double return type and two integer parameters. (The delegate and method have the same signature and parameter type.)
Inside the Main method, the delegate instance is created and the function name is passed to the delegate instance as follows:
Delegate_Prod delObj = new Delegate_Prod(fn_Prodvalues);
After this, we are accepting the two values from the user and passing those values to the delegate as we do using method:
delObj(v1,v2);
Here delegate object encapsulates the method functionalities and returns the result as we specified in the method.


Example 2:


1. Defining the delegate
  public delegate int Calculate (int value1, int value2);

 2. Creating methods which will be assigned to delegate object
//a method, that will be assigned to delegate objects
//having the EXACT signature of the delegatepublic int add(int value1, int value2)
{
    return value1 + value2;            
}
//a method, that will be assigned to delegate objects
//having the EXACT signature of the delegatepublic int sub( int value1, int value2)
{
    return value1 - value2;            
}
 3. Creating the delegate object and assigning methods to those delegate objects
 
//creating the class which contains the methods 
//that will be assigned to delegate objectsMyClass mc = new MyClass();

//creating delegate objects and assigning appropriate methods
//having the EXACT signature of the delegateCalculate add = new Calculate(mc.add);
Calculate sub = new Calculate(mc.sub);
 4. Calling the methods via delegate objects
 
//using the delegate objects to call the assigned methods Console.WriteLine("Adding two values: " + add(10, 6));
Console.WriteLine("Subtracting two values: " + sub(10,4));



Thanks...

--Reference from codeproject,...

Saturday, September 8, 2012

Defining Ping Response


"ping XXX.XXX.XXX.XXX"  in run command

Pinging www.some-domain.com [XXX.XXX.XXX.XXX] with 32 bytes of


Reply from XXX.XXX.XXX.XXX: bytes=32 time=564ms TTL=237
Reply from XXX.XXX.XXX.XXX: bytes=32 time=555ms TTL=237
Reply from XXX.XXX.XXX.XXX: bytes=32 time=554ms TTL=237
Reply from XXX.XXX.XXX.XXX: bytes=32 time=548ms TTL=237


Ping statistics for XXX.XXX.XXX.XXX:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)
Approximate round trip times in milli-seconds:
Minimum = 548ms, Maximum = 564ms, Average = 555ms

TTL?

Every IP packet that gets sent out has a TTL field which is set to a relatively high number (in the case of ping a TTL of 255). As the packet traverses the network, the TTL field gets decreased by one by each router it goes through; when the TTL drops to 0, the packet is discarded by the router. The IP spec says that the TTL should be set to 60 (though it's 255 for ping packets). The main purpose of this is so that a packet doesn't live forever on the network and will eventually die when it is deemed "lost." But for ping purposes, it provides additional information. The TTL can be used to determine approximately how many router hops the packet has gone through. If the TTL field varies in successive pings, it could indicate that the successive reply packets are going via different routes, which isn't a great thing.




'ping time'?
"Ping time" refers to the amount of time it takes for a small "packet" of data to travel over the internet from one computer to another computer and back to the first computer. It is usually reported in milliseconds (ms).


(Referred in blogs)


Friday, July 27, 2012

Creating Dynamic Menu Bar C#.Net


Here is the example for the Dynamic Menu creation..
U need to create css for the static and dynamic styles,
Important thing is the menu id , Menu ID should be minimum (maintain around 10 charaters) , I spent lot of time to identify the Issue which created by menu id , I was given over 30+ character which makes effect on total Controls which is available on the page..

private Panel CreateDynamicMenuBar(List<string> Permissions, string GroupName)
    {
        Menu MyMenu = new Menu();
        MyMenu.ID = "menu";
        MyMenu.Orientation = Orientation.Vertical;
        MyMenu.StaticDisplayLevels = 1;
        MyMenu.Width = Unit.Percentage(100);
        MyMenu.StaticMenuStyle.BorderWidth = Unit.Pixel(0);
        MyMenu.StaticMenuItemStyle.HorizontalPadding = Unit.Pixel(0);
        MyMenu.CssClass = "treemenustyle2";
        MyMenu.StaticMenuItemStyle.CssClass = "StaticItem1";
        MyMenu.StaticHoverStyle.CssClass = "StaticHighlight1";
        MyMenu.DynamicMenuStyle.CssClass = "ie8fix";
        MyMenu.DynamicMenuItemStyle.CssClass = "DynamicItem1";
        MyMenu.DynamicHoverStyle.CssClass = "DynamicHighlight1";
        MyMenu.DynamicSelectedStyle.CssClass = "DyanamicSelected1";
        MyMenu.StaticSelectedStyle.CssClass = "StaticSelected1";
        MyMenu.MenuItemClick += new MenuEventHandler(this.Menutasks_SelectedItemChanged);
        MyMenu.Items.Clear();
   
        foreach (var v in Permissions)
        {
            string permissions = v;
            MenuItem item = null;
            item = new MenuItem( permissions );
            item.ToolTip = permissions[1];
            MyMenu.Items.Add(item);
        }
     
        Panel menupannel = new Panel();
        menupannel.Controls.Add(MyMenu);
        return menupannel;
    }

Thursday, July 12, 2012

Response.Redirect vs Server.Transfer

Server.Transfer does a server side transfer.

Response.Redirect does a client side redirect - the server informs thebrowser to redirect.
So here's the flow:


Server.Transfer
1. Client Request Page HelloWorld.ASPX2. Server.Transfer -> Server send a different page to the client3. Client Receives Page still thinking it's HelloWorld.ASPX.4. Client's URL (Address bar) remains HelloWorld.ASPX since the page wassent on the server side and the client doesn't know a different page wassent.


Response.Redirect
1. Client Requests Page HelloWorld.ASPX2. Response.Redirect -> Server sends a HTTP header informing that theuser should redirect. 3. Client sees the redirect notice and requestsAnotherPage.ASPX 4. Server sends AnotherPage.ASPX5. Client's URL (address bar) shows AnotherPage.ASPX
Technically speaking, Server.Trasfer is faster since there 1 lessroundtrip, but you lose the URL of the page. Server.Transfer also allowsfor more flexibilty since you can use HTTPContext.Items to passvariables beteen pages

Thursday, July 5, 2012

.cs files got corrupted?

If your .cs file got currupted then we have one chance to recover those files.

You need to have the assembly dll related to that currupted file which was build previously.
you need to do Disassembler using .Net Reflector


Solution to recover .cs file 
1. Just Download the .Net Reflector and Install. http://www.reflector.net/
2. Open File -> ' Export Assembly source code'

3. In that Export dialogue show the dll related to corrupted file by 'Browse' option and Click 'Start'

Show any other related dll's if required while processing.


Your files will be Generated in the specified 'Output Directory' 


--Thank You

Monday, July 2, 2012

Sorting Alphanumeric


Sorting Alphanumeric:
IComparer interface
public class AlphanumComparatorFast : IComparer
{
    public int Compare(object x, object y)
    {
 string s1 = x as string;
 if (s1 == null)
 {
     return 0;
 }
 string s2 = y as string;
 if (s2 == null)
 {
     return 0;
 }

 int len1 = s1.Length;
 int len2 = s2.Length;
 int marker1 = 0;
 int marker2 = 0;
 while (marker1 < len1 && marker2 < len2)
 {
     char ch1 = s1[marker1];
     char ch2 = s2[marker2];
     char[] space1 = new char[len1];
     int loc1 = 0;
     char[] space2 = new char[len2];
     int loc2 = 0;
     do
     {
  space1[loc1++] = ch1;
  marker1++;

  if (marker1 < len1)
  {
      ch1 = s1[marker1];
  }
  else
  {
      break;
  }
     } while (char.IsDigit(ch1) == char.IsDigit(space1[0]));

     do
     {
  space2[loc2++] = ch2;
  marker2++;

  if (marker2 < len2)
  {
      ch2 = s2[marker2];
  }
  else
  {
      break;
  }
     } while (char.IsDigit(ch2) == char.IsDigit(space2[0]));

     string str1 = new string(space1);
     string str2 = new string(space2);

     int result;

     if (char.IsDigit(space1[0]) && char.IsDigit(space2[0]))
     {
  int thisNumericChunk = int.Parse(str1);
  int thatNumericChunk = int.Parse(str2);
  result = thisNumericChunk.CompareTo(thatNumericChunk);
     }
     else
     {
  result = str1.CompareTo(str2);
     }

     if (result != 0)
     {
  return result;
     }
 }
 return len1 - len2;
    }
}

//Main method
using System;
using System.Collections;

class Program
{
    static void Main()
    {
 string[] highways = new string[]
 {
     "100F",
     "50F",
     "SR100",
     "SR9"
 };
 
 Array.Sort(highways, new AlphanumComparatorFast());
 
 foreach (string h in highways)
 {
     Console.WriteLine(h);
 }
    }
}
Output:
50F
100F
SR9
SR100

How to set selectedIndex of select element using JavaScript



Example:

<input id="AnimalToFind" type="text" />
<select id="Animals">
    <option value="0">Chicken</option>
    <option value="1">Crocodile</option>
    <option value="2">Monkey</option>
</select>
<input type="button" onclick="SelectAnimal()" />
<script type="text/javascript">
    function SelectAnimal()
    {
        //Set selected option of Animals based on AnimalToFind value...
    }
 </script>
function SelectAnimal() {
    var sel = document.getElementById('Animals');
    var val = document.getElementById('AnimalToFind').value;
    for(var i = 0, j = sel.options.length; i < j; ++i) {
        if(sel.options[i].innerHTML === val) {
           sel.selectedIndex = i;
           break;
        }
    }
}

Tuesday, June 26, 2012

Error : Cannot open database requested by the login. The login failed. Login failed for user 'IIS APPPOOL\

Issue : Cannot open database  requested by the login. The login failed. Login failed for user 'IIS APPPOOL\.
This type of issues will get if u connecting to database using Windows Authentication mode you have to give permission individually if u install SQL server in Windows Authentication mode.

If u install  SQL server in window authentication by default If you do not choose mixed authentication at the time of SQL Server installation. However these modes can be changed even after installation of SQL Server.


How to Change Windows Authentication To Mixed Mode In SQL Server:
http://vijayraju-ourworld.blogspot.in/2012/06/change-windows-authentication-to-mixed.html

then restart ur Application if possible restart ur Machine then ur issue will clear

Monday, June 25, 2012

Error : How do I change the default developement environment in Visual Studio

Issue : If u selected VB or any other language as the default lDE, but now u want to change to C# or any other,
then proceed the following steps.


1. Choose Tools -> Import and Export Settings...
2. Select Reset All Settings and click Next
3. Select whether you would like to save the current settings and click Next
4. Select the settings you want to use and click Finish

Change Windows Authentication To Mixed Mode In SQL Server


When you install SQL Server by default window authentication is installed If you do not choose mixed authentication at the time of SQL Server installation. However these modes can be changed even after installation of SQL Server. 

Step 1 : Start SQL Server Management Studio
In Object Explorer Right Click In ServerName and Select Properties As Can be seen in following image.
image
Step 2 : You will Get Server Property Dialogue Box.
In Property Dialogue Box Select Security Option and under Server authentication Select “SQL Server and Window Authentication mode” and Click OK.
image
Step 3  : Enable “sa” login (Optional)
sa login is disabled by default when SQL Server is installed with window authentication. So when you choose mixed authentication you can also enable sa login (which is disabled by default).
Goto  ServerName in Object Explorer –> Security –> Logins –> Choose sa login name. Right Click on login name (sa) and click properties option see following screen shot.
image
you get following dialogue box  (login property), Under General Page. You need to set strong password and can choose option like “Enforce Password policy” making you password more secure.
image
Goto Status Page : See Following Screen Shot and Select Enable. Click Ok.  Now Re-Start SQL Server Service and login with SQL Server Authentication.
image

Note : Changing Mode From Window To Mixed Or Visa Versa Requires SQL Server Service Restart.

Sunday, June 24, 2012

Does your Visual Studio run slow?


Here are some of the good ones I found that worked.

Window > Close All Documents

Disable the customer feedback component

In some scenarios Visual Studio may try to collect anonymous statistics about your code when closing a project, even if you opted out of the customer feedback program. To stop this time-consuming behaviour, find this registry key:
?
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\{2DC9DAA9-7F2D-11d2-9BFC-00C04F9901D1}
and rename it to something invalid:
?
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\Disabled-{2DC9DAA9-7F2D-11d2-9BFC-00C04F9901D1}

Clear Visual Studio temp files

Deleting the contents of the following temp directories can fix a lot of performance issues with Visual Studio and web projects:
?
C:\Users\richardd\AppData\Local\Microsoft\WebsiteCache
C:\Users\richardd\AppData\Local\Temp\Temporary ASP.NET Files\siteName

Clear out the project MRU list

Apparently Visual Studio sometimes accesses the files in your your recent projects list at random times, e.g. when saving a file. I have no idea why it does this, but it can have a big performance hit, especially if some are on a network share that is no longer available.
To clear your recent project list out, delete any entries from the following path in the registry:
?
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList

Disable AutoRecover

In nearly four years, I have never used Visual Studio’s AutoRecover feature to recover work. These days, source control and saving regularly almost entirely eliminates the need for it.
To disable it and gain some performance (particularly with large solutions), go to Tools >Options > Environment > AutoRecover and uncheck Save AutoRecovery information. (Cheers Jake for the tip)