Posted in WIN_7

Visual Studio 2015 Update 2 released

Microsoft released Visual Studio 2015 Update 2. . with more improved IDE.

New features in Visual Studio 2015 Update 2

For VS Community 2015 update 2 ISO 

 

Posted in WIN_7

Send Email from GMail, Yahoo! And Hotmail Using C# in ASP.Net and WCF

 

Send Email from GMail, Yahoo! And Hotmail Using C# in ASP.Net and WCF

In this article we are going to see how to send email using C#.

Most of the applications we need to send mail to the user here I am going to explain how you will send mail using your Gmail, Yahoo and Hotmail account.

For sending mail we need the server details like smtp host name and port to configure SMTP.  See the list of server details for sending mail.

Name Host name Port
Gmail smtp.gmail.com 587
Yahoo! smtp.mail.yahoo.com 587
Hotmail smtp.live.com 587

Create new asp.net or WCF application according to your requirement. Then go to your code behind page and write the following code for example using Gmail.

public void SendEmail()

{

try

{

SmtpClient clientSMTP = new SmtpClient(“smtp.gmail.com”, 587);

 

clientSMTP.EnableSsl = true;

clientSMTP.DeliveryMethod = SmtpDeliveryMethod.Network;

clientSMTP.UseDefaultCredentials = false;

clientSMTP.Credentials = new NetworkCredential(“yourgmailid@gmail.com”,”password”);

using (MailMessage message = new MailMessage())

{

message.From = new MailAddress(“yourgmailid @gmail.com”);

message.Subject = “Subject”;

message.IsBodyHtml = true;

message.To.Add(“toemailid@gmail.com”);

message.Body=”Hi ” + “Suresh” + “!\n” +

“Welcome to C# Corner!” +

“Please <a href='” + ” https://windowsapptutorials.wordpress.com/ ” + “‘>click</a> here to activate your account. \nThanks!”;

clientSMTP.Send(message);

}

}

catch(Exception ex)

{

 

}

finally

{

 

}}

You can send email with attachment also using Attachment property. If you need to CC to someone or BC to someone use the following code

message.Cc.Add(“ccmailID”);

message.Bc.Add(“bcmailID”);

 

 

 

Posted in Windows 10 UWP, WIN_7

How to show image in circle shape

In this article we are going to see how to show the image in circular shape and decode the pixel in windows 10 UWP.

To perform this task we are going to use two controls Ellipse and ImageBrush.

The following code will show image we set to the ImageBrush as circular

<Ellipse Width="150" Height="150">
            <Ellipse.Fill>
                <ImageBrush ImageSource="Assets/w10.jpg" />
            </Ellipse.Fill>
   </Ellipse>

You can set the ImageSource as url like the following code

<Ellipse Width="150" Height="150">
       <Ellipse.Fill>
            <ImageBrush ImageSource="http://csharpcorner.mindcrackerinc.netdna-cdn.com/UploadFile/AuthorImage/2b876a20140602051459.png" />
       </Ellipse.Fill>
 </Ellipse>

Now run the app and looks the output like the following image

2015-12-31_1213

Posted in WIN_7

Introducing Xamarin Evolve Student Scholarships

evolve-650__x__178__blog-1-1024x280

 

Xamarin helps students to become cross-platform mobile C# developers – through Microsoft DreamSpark.

Now Xamarin Evolve 2016 is the place to be if you are a student interested in mobile development.

Students can get free licence and training

For more details see  https://blog.xamarin.com/introducing-xamarin-evolve-student-scholarships/

Mobile development skills are in demand, using Xamarin for Students, you can build native iOS, Android, and Windows apps with Xamarin Studio and Visual Studio, for free.

 

 

Posted in WIN_7

Microsoft Windows OS 30th birthday

1982–1985: Introducing Windows 1.0

On November 20, 1985, two years after the initial announcement, Microsoft ships Windows 1.0. Now, rather than typing MS‑DOS commands, you just move a mouse to point and click your way through screens, or “windows.” Bill Gates says, “It is unique software designed for the serious PC user.”

For more details

http://windows.microsoft.com/en-IN/windows/history#T1=era1history-of-microsoft-windows

Posted in WIN_7

Windows Phone Tips and Tricks

How to determine the installed OS version on Windows Phone?

Version InstalledVersion = System.Environment.OSVersion.Version;

How to check whether data connection is enabled on Windows phone device?

if (DeviceNetworkInformation.IsNetworkAvailable)

{

}

How to check whether Wi-Fi Connection is enabled on Windows phone device?

if (DeviceNetworkInformation.IsWiFiEnabled)

{

}

How to check whether Cellular Data Connection is enabled on Windows phone device?

if (DeviceNetworkInformation.IsCellularDataEnabled )

{

}

How to check whether location is enabled on windows phone device?

// First create the instance of “Windows.Devices.Geolocation.Geolocator” class

var geoLocator = new Geolocator();

if (geoLocator.LocationStatus == PositionStatus.Disabled)

{

// Location Service is turned OFF

}

else

{

// Location Service is already enabled.

}

How to display the Application list of your publisher name in Windows phone app?

//In this example the publisher name is Suresh

await Windows.System.Launcher.LaunchUriAsync(new Uri(“zune:search?publisher=Suresh”));

How to deduct the Back Button is pressed in Windows Phone 8 app?

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)

{

//back key is pressed

}

How to handle Back Key with Message Box Buttons Ok & Cancel?

MessageBoxResult msg = MessageBox.Show(“ConfirmExit_MSG”, “Notes”, MessageBoxButton.OKCancel);

if (msg == MessageBoxResult.OK)

{

}

else if (msg == MessageBoxResult.Cancel)

{

e.Cancel = true;

}

How to Remove Navigation Back Entry in Windows Phone?

// To Remove Single Entry

NavigationService.RemoveBackEntry();

//To remove all navigation back entry

while (NavigationService.CanGoBack)

NavigationService.RemoveBackEntry();

//Remove navigation back entry except MainPage

if (NavigationService.BackStack.Any())

{

var length = NavigationService.BackStack.Count() – 1;

var i = 0;

while (i < length)

{

NavigationService.RemoveBackEntry();

i++;

}

}

How to detect if Battery Saver is Currently Enabled on Windows Phone 8

if ((bool)typeof(PowerManager).GetProperty(“PowerSavingModeEnabled”).GetValue(null, null))

{

//Battery Saver enabled

}

How to open the Settings screen programmatically in Windows Phone?

ConnectionSettingsTask connectionTask = new ConnectionSettingsTask();

connectionTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;

connectionTask.Show();

How to opening Settings Screen using Launch URI in Windows Phone?

await Windows.System.Launcher.LaunchUriAsync(new Uri(“ms-settings-lock”));

Below is the list of Launch URI that can help in opening various settings from an App.

  1. ms-settings-airplanemode: .
    2. ms-settings-bluetooth:
    3. ms-settings-cellular:
    4. ms-settings-emailandaccounts:
    5. ms-settings-location:
    6. ms-settings-power:
    7. ms-settings-screenrotation:
    8. ms-settings-wifi:

 

How to hide the soft keyboard in Windows Phone by focusing the other UI element?

this.Focus();

How to determine the mobile operator in Windows Phone ?

string getMobileOperatorName = DeviceNetworkInformation.CellularMobileOperator;

How to get screen resolutions in Windows Phone 8?

int getResolution = App.Current.Host.Content.ScaleFactor;

How to get screen Height and width in Windows Phone 8?

double getHeight = App.Current.Host.Content.ActualHeight;

double getWidth = App.Current.Host.Content.ActualWidth;

How to Navigate Page in Windows Phone?

NavigationService.Navigate(new Uri(“/PageName.xaml”, UriKind.Relative));

How to get device battery level in Windows Phone?

string batterlvelinPercentage = Windows.Phone.Devices.Power.Battery.GetDefault().RemainingChargePercent.ToString();

How to get device battery remaining discharge time in Windows Phone?

string remainingTime=  Windows.Phone.Devices.Power.Battery.GetDefault().RemainingDischargeTime.ToString();

How to get Windows Phone Unique Device Id?

object uniqueId;

DeviceExtendedProperties.TryGetValue(“DeviceUniqueId”, out uniqueId);

var   hexString = BitConverter.ToString((byte[])uniqueId).Replace(“-“, string.Empty);

How to find how much space available and used in isolated storage?

IsolatedStorageFile getIsoInfo = IsolatedStorageFile.GetUserStoreForApplication();

long avilableBytes =  getIsoInfo.AvailableFreeSpace;

long usedBytes = getIsoInfo.Quota – getIsoInfo.AvailableFreeSpace;

How to terminate the current Windows Phone app?

Application.Current.Terminate();

How to get the string from AppResources file in Windows Phone?

string ApplicationTitle = AppResources.ApplicationTitle;

How to prevent the app deployment in SD card?

  1. Open the WMAppManifest.xml file. This will open the WMAppManifest.xml in GUI designer.
    2. Navigate to the Packaging tab.
    3. Enable “Prevent deployment to SD cards” and save the project.

How to increase the Windows Phone App limited memory?

Windows Phone App is limited to use 150 MB at maximum per app. But sometimes it is required to more than this limit at least to run in high spec devices. To solve this problem, you can define on your App to ensure you have high availability of application memory.

To increase the size of memory usage we add the following node to the Manifest file of Windows Phone App:

?

&lt;App&gt;

&lt;FunctionalCapabilities&gt;

&lt;FunctionalCapability Name=”ID_FUNCCAP_EXTEND_MEM”/&gt;

&lt;/FunctionalCapabilities&gt;

&lt;/App&gt;

There is another Functional Capability which will ensure the large memory is available before running the application and opt out the Low memory phones from running the app. If this is your requirement you can use:

?

&lt;App&gt;

&lt;Requirements&gt;

&lt;Requirements Name=”ID_REQ_MEMORY_300″/&gt;

&lt;/Requirements&gt;

&lt;/App&gt;

If you use the above capability, the App won’t appear in Windows Phone Store for lower memory phones and it can’t be installed in low end devices.

Based on your requirement, you can increase the size boundary from 150 MB to 300 MB or for some devices up to 1GB of application memory usage.

How to find if the user has tapped on the Screen in Windows Phone 8 App?

Touch.FrameReported += Touch_FrameReported;

void Touch_FrameReported(object sender, TouchFrameEventArgs e)

{

TouchPoint touchPoint = e.GetTouchPoints(this.Content).FirstOrDefault();

}

How to Get the Windows Phone App version from WMAppManifest file ?

string appVersionNumber = XDocument.Load(“WMAppManifest.xml”).Root.Element(“App”).Attribute(“Version”).Value;

How to detect the audio endpoint device in Windows Phone App?

AudioRoutingEndpoint currentEndpoint = AudioRoutingManager.GetDefault().GetAudioEndpoint();

 

The AudioRoutingEndpoint is enum which contains one of the following values

public enum AudioRoutingEndpoint

{

Default = 0,

//     An earpiece.

Earpiece = 1,

//     The speakerphone.

Speakerphone = 2,

//     A Bluetooth device.

Bluetooth = 3,

//     A wired headset.

WiredHeadset = 4,

//     A wired headset for output only; the input is received from the default microphone.

WiredHeadsetSpeakerOnly = 5,

//     A Bluetooth device with noise and echo cancellation.

BluetoothWithNoiseAndEchoCancellation = 6,

}

Note: You need to add the ID_CAP_VOIP capability in your WMAppManifest file.

How to test Windows Phone App on device without a Developer account?

Simply use your Microsoft account (live id) is enough for testing the app on device.

Only one device is allowed for per live id.

How many device can be allowed to unlock the device using Developer account?

You can have up to 3 devices to be developer unlocked for app development and testing.

How to Get the list of IP Address of the Windows Phone?

List<string> IPaddressList = new List<string>();

var Hosts = Windows.Networking.Connectivity.NetworkInformation.GetHostNames().ToList();

foreach (var Host in Hosts)

{

string IP = Host.DisplayName;

IPaddressList.Add(IP);

}

How to Get the Current Location in Windows Phone 8?

Geolocator geoLocator = new Geolocator();

Geoposition position = await geoLocator.GetGeopositionAsync();

Geocoordinate coordinate = position.Coordinate;

string Location = “Latitude = ” + coordinate.Latitude + ” Longitude = ” + coordinate.Longitude;

 

How to get the address of the location using latitude and longitude?

WebClient client = new WebClient();

client.DownloadStringCompleted += client_DownloadStringCompleted;

string Url = “http://maps.googleapis.com/maps/api/geocode/json?latlng=””123235.4″&#8221;,” + “7643643” + “&sensor=true”;

client.DownloadStringAsync(new System.Uri(Url, UriKind.RelativeOrAbsolute));

How to retrieve the Remaining time and percentage of the Windows Phone 8 device battery?

string remainingtime= Windows.Phone.Devices.Power.Battery.GetDefault().RemainingDischargeTime.TotalMinutes.ToString();

string remainingPercentage= Windows.Phone.Devices.Power.Battery.GetDefault().RemainingChargePercent.ToString();

The Battery class includes the property RemainingDischargeTime which is a read only property that gets the time left for the windows phone device battery to be fully discharged.

Get the access to the Battery instance with the Battery.GetDefault() and then use the property RemainingDischargeTime to retreive the time left and RemainingChargePercent percentage left.

How to Create a Toast Prompt in Windows Phone 8?

var toastPrompt = new ToastPrompt

{

Title = “Suresh M”,

TextOrientation = System.Windows.Controls.Orientation.Vertical,

Message = “https://windowsapptutorials.wordpress.com/&#8221;

};

toastPrompt.Show();

How to Vibrate the Windows Phone?

VibrateController vibrate = VibrateController.Default;

vibrate.Start(TimeSpan.FromMilliseconds(1000));

How to Format the String in XAML TextBlock Control in Windows Phone?

Text Formatting

<TextBlock>

<Run Text=”String with 5 characters length: “/>

<Run Text=”{Binding Text, StringFormat=\{0\,5\} }”/>

</TextBlock>

Number Formatting

<TextBlock>

<Run Text=”The number with 3 decimal point: “/>

<Run Text=”{Binding Number, StringFormat=\{0:n3\}}”/>

</TextBlock>

Date Formatting

<TextBlock  Text=”{Binding SendingDate,StringFormat=’dd/MM/yyyy HH:mm’}”/>

 How to run both 512MB and 256MB Windows Phone emulator simultaneously?

Some time we need to test the performance of the app in different version .So I tried to find out a way and share here.

  • Launch the app under 512 MB emulator
  • Stop the debugger (don’t close the emulator)
  • Change the debug target to 256 MB emulator and launch the app gain.
  • Now you can see both the emulators Up & Running.
  • Now do your testing.

How Windows Phone App Developer Getting Help to develop windows phone app?

http://www.c-sharpcorner.com/technologies/microsoft-phone

https://channel9.msdn.com/Series/Windows-Phone-7-Development-for-Absolute-Beginners

How to support Portrait and Landscape orientation in Windows Phone Screen? 

In your Xaml page change the default SupportedOrientations=”Portrait” to SupportedOrientations=”PortraitOrLandscape”

To set default Orientation set the orientation=”Landscape” or Portrait

 

How to get all the contact details in windows phone?

Contacts cons = new Contacts();

//Identify the method that runs after the asynchronous search completes.

cons.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(Contacts_SearchCompleted_Many);

//Start the asynchronous search.

cons.SearchAsync(String.Empty, FilterKind.None, “Contacts Test #3 Picture”);

void Contacts_SearchCompleted_Many(object sender, ContactsSearchEventArgs e)

{

 

}

 

How to get all pictures from Camera Roll in Windows Phone?

var mel = new MediaLibrary();

var Pictures = mel.Pictures;

PictureAlbumCollection picture = mel.RootPictureAlbum.Albums;

PictureAlbum cameraRoll = picture.Where(album => album.Name == “Camera Roll”).First();

var CameraRollPictures = cameraRoll.Pictures;

 

Windows Phone performance killers and tips

Don’t use too many Converters and Bindings they are Performance Killers

Converters are one of the most significant killers of performance (second perhaps to binding itself) in a XAML application.

 

Load only the content needed.

The smaller the content, the faster loading occurs.

Use DXT to compress textures.

Compressed the content is smaller, sometimes dramatically smaller. This reduces loading time.

Allocate memory for Reusable Objects.

Allocate a set of reusable objects and reinitialize them as needed. Reusable objects never need to be freed, and reduce the number of additional allocations.

Manually call GC.Collect()

Manually call the garbage collector at the time of loading screen.

Measuring Performance

There several tools available for analyzing the .NET garbage collection heap. One tool available from Microsoft is the CLR Profiler. The tool is free and it is available for download at

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=A362781C-3870-43BE-8926-862B40AA0CD0&displaylang=en.

Steps to run the CLR profiler

Download the CLR Profiler, and then extract the files.

Navigate to CLRProfiler\Binaries\x86 (or x64), and then run CLRProfiler.exe.

Click Start Application, and then select your application.

It will generates a graph that displays information about all objects in the garbage collection heap, and a references related to these structures.

Keep overall memory use under 90 MB.