map improvement
user picture image crop
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkAwarenessTest", "NetworkAwarenessTest\NetworkAwarenessTest.csproj", "{27C10B97-20D1-46F7-92BF-FC07037F900E}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkDetection", "NetworkDetection\NetworkDetection.csproj", "{794D79F0-E898-460D-BDB5-49FED553E0D5}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkNamespaces", "NetworkNamespaces\NetworkNamespaces.csproj", "{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{27C10B97-20D1-46F7-92BF-FC07037F900E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{27C10B97-20D1-46F7-92BF-FC07037F900E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{27C10B97-20D1-46F7-92BF-FC07037F900E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{27C10B97-20D1-46F7-92BF-FC07037F900E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{27C10B97-20D1-46F7-92BF-FC07037F900E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{27C10B97-20D1-46F7-92BF-FC07037F900E}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<Application
|
||||||
|
x:Class="NetworkAwarenessTest.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||||
|
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
|
||||||
|
|
||||||
|
<!--Application Resources-->
|
||||||
|
<Application.Resources>
|
||||||
|
</Application.Resources>
|
||||||
|
|
||||||
|
<Application.ApplicationLifetimeObjects>
|
||||||
|
<!--Required object that handles lifetime events for the application-->
|
||||||
|
<shell:PhoneApplicationService
|
||||||
|
Launching="Application_Launching" Closing="Application_Closing"
|
||||||
|
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
|
||||||
|
</Application.ApplicationLifetimeObjects>
|
||||||
|
|
||||||
|
</Application>
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Microsoft.Phone.Controls;
|
||||||
|
using Microsoft.Phone.Shell;
|
||||||
|
|
||||||
|
namespace NetworkAwarenessTest
|
||||||
|
{
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides easy access to the root frame of the Phone Application.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The root frame of the Phone Application.</returns>
|
||||||
|
public PhoneApplicationFrame RootFrame { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for the Application object.
|
||||||
|
/// </summary>
|
||||||
|
public App()
|
||||||
|
{
|
||||||
|
// Global handler for uncaught exceptions.
|
||||||
|
UnhandledException += Application_UnhandledException;
|
||||||
|
|
||||||
|
// Show graphics profiling information while debugging.
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// Display the current frame rate counters.
|
||||||
|
Application.Current.Host.Settings.EnableFrameRateCounter = true;
|
||||||
|
|
||||||
|
// Show the areas of the app that are being redrawn in each frame.
|
||||||
|
//Application.Current.Host.Settings.EnableRedrawRegions = true;
|
||||||
|
|
||||||
|
// Enable non-production analysis visualization mode,
|
||||||
|
// which shows areas of a page that are being GPU accelerated with a colored overlay.
|
||||||
|
//Application.Current.Host.Settings.EnableCacheVisualization = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standard Silverlight initialization
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
// Phone-specific initialization
|
||||||
|
InitializePhoneApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Code to execute when the application is launching (eg, from Start)
|
||||||
|
// This code will not execute when the application is reactivated
|
||||||
|
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is activated (brought to foreground)
|
||||||
|
// This code will not execute when the application is first launched
|
||||||
|
private void Application_Activated(object sender, ActivatedEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is deactivated (sent to background)
|
||||||
|
// This code will not execute when the application is closing
|
||||||
|
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is closing (eg, user hit Back)
|
||||||
|
// This code will not execute when the application is deactivated
|
||||||
|
private void Application_Closing(object sender, ClosingEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute if a navigation fails
|
||||||
|
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||||
|
{
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// A navigation has failed; break into the debugger
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute on Unhandled Exceptions
|
||||||
|
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// An unhandled exception has occurred; break into the debugger
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Phone application initialization
|
||||||
|
|
||||||
|
// Avoid double-initialization
|
||||||
|
private bool phoneApplicationInitialized = false;
|
||||||
|
|
||||||
|
// Do not add any additional code to this method
|
||||||
|
private void InitializePhoneApplication()
|
||||||
|
{
|
||||||
|
if (phoneApplicationInitialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Create the frame but don't set it as RootVisual yet; this allows the splash
|
||||||
|
// screen to remain active until the application is ready to render.
|
||||||
|
RootFrame = new PhoneApplicationFrame();
|
||||||
|
RootFrame.Navigated += CompleteInitializePhoneApplication;
|
||||||
|
|
||||||
|
// Handle navigation failures
|
||||||
|
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
|
||||||
|
|
||||||
|
// Ensure we don't initialize again
|
||||||
|
phoneApplicationInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not add any additional code to this method
|
||||||
|
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||||
|
{
|
||||||
|
// Set the root visual to allow the application to render
|
||||||
|
if (RootVisual != RootFrame)
|
||||||
|
RootVisual = RootFrame;
|
||||||
|
|
||||||
|
// Remove this handler since it is no longer needed
|
||||||
|
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,50 @@
|
|||||||
|
<phone:PhoneApplicationPage
|
||||||
|
x:Class="NetworkAwarenessTest.MainPage"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||||
|
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
|
||||||
|
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||||
|
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||||
|
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||||
|
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||||
|
shell:SystemTray.IsVisible="True">
|
||||||
|
|
||||||
|
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||||
|
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!--TitlePanel contains the name of the application and page title-->
|
||||||
|
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
|
||||||
|
<TextBlock x:Name="ApplicationTitle" Text="NETWORK AWARENESS AND ZUNE DETECTION" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!--ContentPanel - place additional content here-->
|
||||||
|
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||||
|
<ListBox Height="556" HorizontalAlignment="Left" Margin="6,134,0,0" Name="listBox1" VerticalAlignment="Top" Width="444" />
|
||||||
|
<Button Content="Refresh" Height="72" HorizontalAlignment="Left" Name="buttonRefresh" VerticalAlignment="Top" Width="220" Click="buttonRefresh_Click" />
|
||||||
|
<TextBlock Height="30" HorizontalAlignment="Left" Margin="6,78,0,0" Name="textBlock1" Text="UI Responsiveness Progressbar" VerticalAlignment="Top" />
|
||||||
|
<Button Content="Add Time" Height="72" HorizontalAlignment="Left" Margin="226,0,0,0" Name="buttonTime" VerticalAlignment="Top" Width="230" Click="buttonTime_Click" />
|
||||||
|
</Grid>
|
||||||
|
<ProgressBar IsIndeterminate="True" Height="27" HorizontalAlignment="Left" Margin="18,101,0,0" Name="progressBar1" VerticalAlignment="Top" Width="444" Grid.Row="1" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!--Sample code showing usage of ApplicationBar-->
|
||||||
|
<!--<phone:PhoneApplicationPage.ApplicationBar>
|
||||||
|
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
|
||||||
|
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
|
||||||
|
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
|
||||||
|
<shell:ApplicationBar.MenuItems>
|
||||||
|
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
|
||||||
|
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
|
||||||
|
</shell:ApplicationBar.MenuItems>
|
||||||
|
</shell:ApplicationBar>
|
||||||
|
</phone:PhoneApplicationPage.ApplicationBar>-->
|
||||||
|
|
||||||
|
</phone:PhoneApplicationPage>
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Microsoft.Phone.Controls;
|
||||||
|
|
||||||
|
namespace NetworkAwarenessTest
|
||||||
|
{
|
||||||
|
public partial class MainPage : PhoneApplicationPage
|
||||||
|
{
|
||||||
|
string NetType = "";
|
||||||
|
bool online = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public MainPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
Loaded += new RoutedEventHandler(MainPage_Loaded);
|
||||||
|
Unloaded += new RoutedEventHandler(MainPage_Unloaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainPage_Unloaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged -= new System.Net.NetworkInformation.NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainPage_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, ">>> Refresh Started " + System.DateTime.Now.ToString("T") + " >>>>>>>>");
|
||||||
|
Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType net = Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType;
|
||||||
|
NetType = net.ToString();
|
||||||
|
listBox1.Items.Insert(1," Refresh Ended " + System.DateTime.Now.ToString("T"));
|
||||||
|
listBox1.Items.Insert(2, " stored at Changed event: " + NetType);
|
||||||
|
listBox1.Items.Insert(3, " Current status: " + net.ToString());
|
||||||
|
if (net == Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Ethernet) listBox1.Items.Insert(4, "!!!!! Zune is Connected");
|
||||||
|
SetupNetworkChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "+++++ Changed started " + System.DateTime.Now.ToString("T") + " +++++");
|
||||||
|
if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
|
||||||
|
{
|
||||||
|
if (!online)
|
||||||
|
{
|
||||||
|
online = true;
|
||||||
|
// do what is needed to GoOnline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (online)
|
||||||
|
{
|
||||||
|
online = false;
|
||||||
|
listBox1.Items.Insert(0, "----- No network available. -----");
|
||||||
|
// do what is needed to GoOffline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
listBox1.Items.Insert(1, " Changed GetNetType " + System.DateTime.Now.ToString("T"));
|
||||||
|
Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType net = Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType;
|
||||||
|
NetType = net.ToString();
|
||||||
|
listBox1.Items.Insert(2, " Changed Ended " + System.DateTime.Now.ToString("T"));
|
||||||
|
listBox1.Items.Insert(3, " IsOnline : " + online.ToString());
|
||||||
|
listBox1.Items.Insert(4, " Current status: " + net.ToString());
|
||||||
|
if (net == Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Ethernet) listBox1.Items.Insert(5,"!!!!! Zune is Connected");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupNetworkChange()
|
||||||
|
{
|
||||||
|
// Get current network availalability and store the
|
||||||
|
// initial value of the online variable
|
||||||
|
if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
|
||||||
|
{
|
||||||
|
online = true;
|
||||||
|
// do what is needed to GoOnline();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
online = false;
|
||||||
|
// do what is needed to GoOffline();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now add a network change event handler to indicate
|
||||||
|
// network availability
|
||||||
|
System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += new System.Net.NetworkInformation.NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonRefresh_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, ">>> Refresh Started " + System.DateTime.Now.ToString("T") + " >>>>>>>>");
|
||||||
|
Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType net = Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType;
|
||||||
|
//MessageBox.Show("Current status: "+net.ToString(), "stored nettype:" + App.NetType, MessageBoxButton.OK);
|
||||||
|
listBox1.Items.Insert(1, " Refresh Ended " + System.DateTime.Now.ToString("T"));
|
||||||
|
listBox1.Items.Insert(2," stored at Changed event: " + NetType);
|
||||||
|
listBox1.Items.Insert(3, " Current status: " + net.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTime_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "<<<<< Current Time " + System.DateTime.Now.ToString("T") + " <<<<<<<<<");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>10.0.20506</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{27C10B97-20D1-46F7-92BF-FC07037F900E}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>NetworkAwarenessTest</RootNamespace>
|
||||||
|
<AssemblyName>NetworkAwarenessTest</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||||
|
<TargetFrameworkProfile>WindowsPhone</TargetFrameworkProfile>
|
||||||
|
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
|
||||||
|
<SilverlightApplication>true</SilverlightApplication>
|
||||||
|
<SupportedCultures>
|
||||||
|
</SupportedCultures>
|
||||||
|
<XapOutputs>true</XapOutputs>
|
||||||
|
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
|
||||||
|
<XapFilename>NetworkAwarenessTest.xap</XapFilename>
|
||||||
|
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
|
||||||
|
<SilverlightAppEntry>NetworkAwarenessTest.App</SilverlightAppEntry>
|
||||||
|
<ValidateXaml>true</ValidateXaml>
|
||||||
|
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>Bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>Bin\Release</OutputPath>
|
||||||
|
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Phone" />
|
||||||
|
<Reference Include="Microsoft.Phone.Interop" />
|
||||||
|
<Reference Include="System.Windows" />
|
||||||
|
<Reference Include="system" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Net" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="App.xaml.cs">
|
||||||
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MainPage.xaml.cs">
|
||||||
|
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ApplicationDefinition Include="App.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</ApplicationDefinition>
|
||||||
|
<Page Include="MainPage.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Properties\AppManifest.xml" />
|
||||||
|
<None Include="Properties\WMAppManifest.xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="ApplicationIcon.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Background.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="SplashScreenImage.jpg" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
<ProjectExtensions />
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
>
|
||||||
|
<Deployment.Parts>
|
||||||
|
</Deployment.Parts>
|
||||||
|
</Deployment>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("NetworkAwarenessTest")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("NetworkAwarenessTest")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("59705a9b-da65-482a-8c30-552b5622a972")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">
|
||||||
|
<App xmlns="" ProductID="{357f9fb2-82b9-4758-a63a-af9dcda19dc0}" Title="NetworkAwarenessTest" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="NetworkAwarenessTest author" Description="Sample description" Publisher="NetworkAwarenessTest">
|
||||||
|
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
|
||||||
|
<Capabilities>
|
||||||
|
<Capability Name="ID_CAP_GAMERSERVICES"/>
|
||||||
|
<Capability Name="ID_CAP_IDENTITY_DEVICE"/>
|
||||||
|
<Capability Name="ID_CAP_IDENTITY_USER"/>
|
||||||
|
<Capability Name="ID_CAP_LOCATION"/>
|
||||||
|
<Capability Name="ID_CAP_MEDIALIB"/>
|
||||||
|
<Capability Name="ID_CAP_MICROPHONE"/>
|
||||||
|
<Capability Name="ID_CAP_NETWORKING"/>
|
||||||
|
<Capability Name="ID_CAP_PHONEDIALER"/>
|
||||||
|
<Capability Name="ID_CAP_PUSH_NOTIFICATION"/>
|
||||||
|
<Capability Name="ID_CAP_SENSORS"/>
|
||||||
|
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
|
||||||
|
</Capabilities>
|
||||||
|
<Tasks>
|
||||||
|
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
|
||||||
|
</Tasks>
|
||||||
|
<Tokens>
|
||||||
|
<PrimaryToken TokenID="NetworkAwarenessTestToken" TaskName="_default">
|
||||||
|
<TemplateType5>
|
||||||
|
<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
|
||||||
|
<Count>0</Count>
|
||||||
|
<Title>NetworkAwarenessTest</Title>
|
||||||
|
</TemplateType5>
|
||||||
|
</PrimaryToken>
|
||||||
|
</Tokens>
|
||||||
|
</App>
|
||||||
|
</Deployment>
|
||||||
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,19 @@
|
|||||||
|
<Application
|
||||||
|
x:Class="NetworkDetection.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||||
|
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
|
||||||
|
|
||||||
|
<!--Application Resources-->
|
||||||
|
<Application.Resources>
|
||||||
|
</Application.Resources>
|
||||||
|
|
||||||
|
<Application.ApplicationLifetimeObjects>
|
||||||
|
<!--Required object that handles lifetime events for the application-->
|
||||||
|
<shell:PhoneApplicationService
|
||||||
|
Launching="Application_Launching" Closing="Application_Closing"
|
||||||
|
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
|
||||||
|
</Application.ApplicationLifetimeObjects>
|
||||||
|
|
||||||
|
</Application>
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Microsoft.Phone.Controls;
|
||||||
|
using Microsoft.Phone.Shell;
|
||||||
|
|
||||||
|
namespace NetworkDetection
|
||||||
|
{
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides easy access to the root frame of the Phone Application.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The root frame of the Phone Application.</returns>
|
||||||
|
public PhoneApplicationFrame RootFrame { get; private set; }
|
||||||
|
//NetworkDetector nd;
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for the Application object.
|
||||||
|
/// </summary>
|
||||||
|
public App()
|
||||||
|
{
|
||||||
|
// Global handler for uncaught exceptions.
|
||||||
|
UnhandledException += Application_UnhandledException;
|
||||||
|
|
||||||
|
// Show graphics profiling information while debugging.
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// Display the current frame rate counters.
|
||||||
|
Application.Current.Host.Settings.EnableFrameRateCounter = true;
|
||||||
|
|
||||||
|
// Show the areas of the app that are being redrawn in each frame.
|
||||||
|
//Application.Current.Host.Settings.EnableRedrawRegions = true;
|
||||||
|
|
||||||
|
// Enable non-production analysis visualization mode,
|
||||||
|
// which shows areas of a page that are being GPU accelerated with a colored overlay.
|
||||||
|
//Application.Current.Host.Settings.EnableCacheVisualization = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standard Silverlight initialization
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
// Phone-specific initialization
|
||||||
|
InitializePhoneApplication();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkDetector nd;
|
||||||
|
// Code to execute when the application is launching (eg, from Start)
|
||||||
|
// This code will not execute when the application is reactivated
|
||||||
|
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||||
|
{
|
||||||
|
nd = NetworkDetector.Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is activated (brought to foreground)
|
||||||
|
// This code will not execute when the application is first launched
|
||||||
|
private void Application_Activated(object sender, ActivatedEventArgs e)
|
||||||
|
{
|
||||||
|
nd = NetworkDetector.Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is deactivated (sent to background)
|
||||||
|
// This code will not execute when the application is closing
|
||||||
|
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is closing (eg, user hit Back)
|
||||||
|
// This code will not execute when the application is deactivated
|
||||||
|
private void Application_Closing(object sender, ClosingEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute if a navigation fails
|
||||||
|
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||||
|
{
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// A navigation has failed; break into the debugger
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute on Unhandled Exceptions
|
||||||
|
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// An unhandled exception has occurred; break into the debugger
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Phone application initialization
|
||||||
|
|
||||||
|
// Avoid double-initialization
|
||||||
|
private bool phoneApplicationInitialized = false;
|
||||||
|
|
||||||
|
// Do not add any additional code to this method
|
||||||
|
private void InitializePhoneApplication()
|
||||||
|
{
|
||||||
|
if (phoneApplicationInitialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Create the frame but don't set it as RootVisual yet; this allows the splash
|
||||||
|
// screen to remain active until the application is ready to render.
|
||||||
|
RootFrame = new PhoneApplicationFrame();
|
||||||
|
RootFrame.Navigated += CompleteInitializePhoneApplication;
|
||||||
|
|
||||||
|
// Handle navigation failures
|
||||||
|
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
|
||||||
|
|
||||||
|
// Ensure we don't initialize again
|
||||||
|
phoneApplicationInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not add any additional code to this method
|
||||||
|
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||||
|
{
|
||||||
|
// Set the root visual to allow the application to render
|
||||||
|
if (RootVisual != RootFrame)
|
||||||
|
RootVisual = RootFrame;
|
||||||
|
|
||||||
|
// Remove this handler since it is no longer needed
|
||||||
|
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,56 @@
|
|||||||
|
<phone:PhoneApplicationPage
|
||||||
|
x:Class="NetworkDetection.MainPage"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||||
|
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
|
||||||
|
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||||
|
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||||
|
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||||
|
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||||
|
shell:SystemTray.IsVisible="True">
|
||||||
|
|
||||||
|
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||||
|
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="44"/>
|
||||||
|
<RowDefinition Height="724*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!--TitlePanel contains the name of the application and page title-->
|
||||||
|
<StackPanel x:Name="TitlePanel" Margin="12,17,0,0">
|
||||||
|
<TextBlock x:Name="ApplicationTitle" Text="NETWORK AWARENESS AND ZUNE DETECTION" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!--ContentPanel - place additional content here-->
|
||||||
|
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||||
|
<ListBox Height="532" HorizontalAlignment="Left" Margin="6,186,0,0" Name="listBox1" VerticalAlignment="Top" Width="444" />
|
||||||
|
<Button Content="DF" Height="72" HorizontalAlignment="Left" Name="buttonMode" VerticalAlignment="Top" Width="102" Margin="290,64,0,0" Click="buttonMode_Click" />
|
||||||
|
<TextBlock Height="30" HorizontalAlignment="Left" Margin="6,130,0,0" Name="textBlock1" Text="UI Responsiveness Progressbar" VerticalAlignment="Top" />
|
||||||
|
<Button Content="T" Height="72" HorizontalAlignment="Left" Margin="374,0,0,0" Name="buttonTime" VerticalAlignment="Top" Width="82" Click="buttonTime_Click" />
|
||||||
|
<Button Content="Stop Poll" Height="72" HorizontalAlignment="Left" Margin="142,0,0,0" Name="buttonStoppPoll" VerticalAlignment="Top" Width="163" Click="buttonStoppPoll_Click" />
|
||||||
|
<Button Content="Start Poll" Height="72" HorizontalAlignment="Left" Name="buttonStartPoll" VerticalAlignment="Top" Width="161" Click="buttonStartPoll_Click" />
|
||||||
|
<Button Content="Clr" Height="72" HorizontalAlignment="Left" Margin="290,0,0,0" Name="buttonClear" VerticalAlignment="Top" Width="102" Click="buttonClear_Click" />
|
||||||
|
<Button Content="+ 100 mS" Height="72" HorizontalAlignment="Left" Margin="0,64,0,0" Name="buttonIncrease" VerticalAlignment="Top" Width="161" Click="buttonIncrease_Click" />
|
||||||
|
<Button Content="- 100 mS" Height="72" HorizontalAlignment="Left" Margin="142,64,0,0" Name="buttonDecrease" VerticalAlignment="Top" Width="163" Click="buttonDecrease_Click" />
|
||||||
|
<ProgressBar IsIndeterminate="True" Height="27" HorizontalAlignment="Left" Margin="6,153,0,0" Name="progressBar1" VerticalAlignment="Top" Width="444" />
|
||||||
|
<Button Content="R" Height="72" HorizontalAlignment="Left" Margin="374,64,0,0" Name="buttonRefresh" VerticalAlignment="Top" Width="81" Click="buttonRefresh_Click" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!--Sample code showing usage of ApplicationBar-->
|
||||||
|
<!--<phone:PhoneApplicationPage.ApplicationBar>
|
||||||
|
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
|
||||||
|
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
|
||||||
|
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
|
||||||
|
<shell:ApplicationBar.MenuItems>
|
||||||
|
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
|
||||||
|
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
|
||||||
|
</shell:ApplicationBar.MenuItems>
|
||||||
|
</shell:ApplicationBar>
|
||||||
|
</phone:PhoneApplicationPage.ApplicationBar>-->
|
||||||
|
|
||||||
|
</phone:PhoneApplicationPage>
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Microsoft.Phone.Controls;
|
||||||
|
|
||||||
|
namespace NetworkDetection
|
||||||
|
{
|
||||||
|
public partial class MainPage : PhoneApplicationPage
|
||||||
|
{
|
||||||
|
// Constructor
|
||||||
|
public MainPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
Loaded += new RoutedEventHandler(MainPage_Loaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkDetector nd = NetworkDetector.Instance;
|
||||||
|
int interval = 500;
|
||||||
|
|
||||||
|
void MainPage_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
nd.OnAsyncGetNetworkTypeCompleted += new EventHandler<NetworkDetectorEventArgs>(nd_OnAsyncGetNetworkTypeCompleted);
|
||||||
|
nd.OnConnectedBroadbandCdma += new EventHandler<NetworkDetectorEventArgs>(nd_OnConnectedBroadbandCdma);
|
||||||
|
nd.OnConnectedBroadbandGsm += new EventHandler<NetworkDetectorEventArgs>(nd_OnConnectedBroadbandGsm);
|
||||||
|
nd.OnConnectedEthernet += new EventHandler<NetworkDetectorEventArgs>(nd_OnConnectedEthernet);
|
||||||
|
nd.OnConnectedNone += new EventHandler<NetworkDetectorEventArgs>(nd_OnConnectedNone);
|
||||||
|
nd.OnConnectedOther += new EventHandler<NetworkDetectorEventArgs>(nd_OnConnectedOther);
|
||||||
|
nd.OnConnectedWifi += new EventHandler<NetworkDetectorEventArgs>(nd_OnConnectedWifi);
|
||||||
|
nd.OnNetworkChanged += new EventHandler<NetworkAvailableEventArgs>(nd_OnNetworkChanged);
|
||||||
|
nd.OnNetworkOFF += new EventHandler<NetworkAvailableEventArgs>(nd_OnNetworkOFF);
|
||||||
|
nd.OnNetworkON += new EventHandler<NetworkAvailableEventArgs>(nd_OnNetworkON);
|
||||||
|
nd.OnZuneConnected += new EventHandler<NetworkDetectorEventArgs>(nd_OnZuneConnected);
|
||||||
|
nd.OnZuneDisconnected += new EventHandler<NetworkDetectorEventArgs>(nd_OnZuneDisconnected);
|
||||||
|
nd.OnLostNetworkType += new EventHandler<NetworkDetectorEventArgs>(nd_OnLostNetworkType);
|
||||||
|
|
||||||
|
nd.SetNetworkPolling(0,0,interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnLostNetworkType(object sender, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnLostNetworkType ->previous Nettype:" + e.NetType.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnZuneDisconnected(object sender, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnZuneDisconnected ->Nettype:" + e.NetType.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnZuneConnected(object sender, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnZuneConnected ->Nettype:" + e.NetType.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnNetworkON(object sender, NetworkAvailableEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnNetworkON ->Online:" + e.IsOnline.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnNetworkOFF(object sender, NetworkAvailableEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnNetworkOFF ->Online:" + e.IsOnline.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnNetworkChanged(object sender, NetworkAvailableEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnNetworkChanged ->Online:" + e.IsOnline.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnConnectedWifi(object sender, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnConnectedWifi " + System.DateTime.Now.ToString("T") + " >>>>>>>>");
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnConnectedOther(object sender, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnConnectedOther " + System.DateTime.Now.ToString("T") + " >>>>>>>>");
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnConnectedNone(object sender, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnConnectedNone " + System.DateTime.Now.ToString("T") + " >>>>>>>>");
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnConnectedEthernet(object sender, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnConnectedEthernet " + System.DateTime.Now.ToString("T") + " >>>>>>>>");
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnConnectedBroadbandGsm(object sender, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnConnectedBroadbandGsm " + System.DateTime.Now.ToString("T") + " >>>>>>>>");
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnConnectedBroadbandCdma(object sender, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnConnectedBroadbandCdma " + System.DateTime.Now.ToString("T") + " >>>>>>>>");
|
||||||
|
}
|
||||||
|
|
||||||
|
void nd_OnAsyncGetNetworkTypeCompleted(object sender, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "OnAsyncGetNetworkTypeCompleted " + System.DateTime.Now.ToString("T") + " >>>>>>>>");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonMode_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
nd.DetailedMode = !nd.DetailedMode;
|
||||||
|
if (nd.DetailedMode) buttonMode.Content = "DT";
|
||||||
|
else buttonMode.Content = "DF";
|
||||||
|
listBox1.Items.Insert(0, " DetailedMode : " + nd.DetailedMode.ToString() + " <<<<<<<<<");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTime_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, "<<<<< Current Time " + System.DateTime.Now.ToString("T") + " <<<<<<<<<");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonStoppPoll_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
nd.DisableNetworkPolling();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonStartPoll_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
nd.SetNetworkPolling(0, 0, interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonIncrease_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
interval += 100;
|
||||||
|
//if (interval > 1000) interval = 1000;
|
||||||
|
nd.SetNetworkPolling(0, 0, interval);
|
||||||
|
listBox1.Items.Insert(0, " Current polling Time " + interval.ToString() + " <<<<<<<<<");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonClear_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDecrease_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
interval -= 100;
|
||||||
|
if (interval < 100) interval = 100;
|
||||||
|
nd.SetNetworkPolling(0, 0, interval);
|
||||||
|
listBox1.Items.Insert(0, " Current polling Time " + interval.ToString() + " <<<<<<<<<");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonRefresh_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
listBox1.Items.Insert(0, ">>> Refresh Started " + System.DateTime.Now.ToString("T") + " >>>>>>>>");
|
||||||
|
listBox1.Items.Insert(1, " Current status: " + nd.GetCurrentNetworkType().ToString());
|
||||||
|
nd.AsyncGetNetworkType();
|
||||||
|
listBox1.Items.Insert(2, " Refresh Ended " + System.DateTime.Now.ToString("T"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>10.0.20506</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{794D79F0-E898-460D-BDB5-49FED553E0D5}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>NetworkDetection</RootNamespace>
|
||||||
|
<AssemblyName>NetworkDetection</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||||
|
<TargetFrameworkProfile>WindowsPhone</TargetFrameworkProfile>
|
||||||
|
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
|
||||||
|
<SilverlightApplication>true</SilverlightApplication>
|
||||||
|
<SupportedCultures>
|
||||||
|
</SupportedCultures>
|
||||||
|
<XapOutputs>true</XapOutputs>
|
||||||
|
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
|
||||||
|
<XapFilename>NetworkDetection.xap</XapFilename>
|
||||||
|
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
|
||||||
|
<SilverlightAppEntry>NetworkDetection.App</SilverlightAppEntry>
|
||||||
|
<ValidateXaml>true</ValidateXaml>
|
||||||
|
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>Bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>Bin\Release</OutputPath>
|
||||||
|
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Phone" />
|
||||||
|
<Reference Include="Microsoft.Phone.Interop" />
|
||||||
|
<Reference Include="System.Windows" />
|
||||||
|
<Reference Include="system" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Net" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="App.xaml.cs">
|
||||||
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MainPage.xaml.cs">
|
||||||
|
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="NetworkDetector.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ApplicationDefinition Include="App.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</ApplicationDefinition>
|
||||||
|
<Page Include="MainPage.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Properties\AppManifest.xml" />
|
||||||
|
<None Include="Properties\WMAppManifest.xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="ApplicationIcon.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Background.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="SplashScreenImage.jpg" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
<ProjectExtensions />
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,387 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************/
|
||||||
|
/* Copyright of Gabor Dolhai @ 2010 */
|
||||||
|
/* under MS-Pl license */
|
||||||
|
/* can be used freely for anybody */
|
||||||
|
/* If you use this code please send me an */
|
||||||
|
/*email about your project to dolhaig at gmail*/
|
||||||
|
/*******************Thanks*********************/
|
||||||
|
namespace NetworkDetection
|
||||||
|
{
|
||||||
|
#region Custom Enums and EventArgs
|
||||||
|
public enum NetworkTypeRequestStatus
|
||||||
|
{
|
||||||
|
Default = 0,
|
||||||
|
Started,//represents BackgroundWorker started
|
||||||
|
Ended//BackgroundWorker Finished
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NetworkAvailableEventArgs : System.EventArgs
|
||||||
|
{
|
||||||
|
|
||||||
|
public NetworkAvailableEventArgs(bool isOnline)
|
||||||
|
{
|
||||||
|
IsOnline = isOnline;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsOnline { get; private set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NetworkDetectorEventArgs : System.EventArgs
|
||||||
|
{
|
||||||
|
|
||||||
|
public NetworkDetectorEventArgs(bool isOnline, Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType netType)
|
||||||
|
{
|
||||||
|
IsOnline = isOnline;
|
||||||
|
NetType = netType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsOnline { get; private set; }
|
||||||
|
public Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType NetType { get; private set; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public class NetworkDetector
|
||||||
|
{
|
||||||
|
private static readonly NetworkDetector _instance = new NetworkDetector();
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
public event EventHandler<NetworkAvailableEventArgs> OnNetworkON;
|
||||||
|
public event EventHandler<NetworkAvailableEventArgs> OnNetworkOFF;
|
||||||
|
public event EventHandler<NetworkAvailableEventArgs> OnNetworkChanged;
|
||||||
|
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnZuneConnected;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnZuneDisconnected;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedEthernet;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedWifi;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedNone;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedBroadbandGsm;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedBroadbandCdma;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedOther;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnLostNetworkType;
|
||||||
|
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnAsyncGetNetworkTypeCompleted;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Threading.DispatcherTimer updateTimer, pollTimer;
|
||||||
|
private Queue<long> requestQueue; //queue to store the requests timestemps
|
||||||
|
private BackgroundWorker networkWorker;
|
||||||
|
private bool online = false;
|
||||||
|
private Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType net;
|
||||||
|
private NetworkTypeRequestStatus requestStatus; //current status of the BackgroundWorker
|
||||||
|
private bool IsInstantRequestPresent;
|
||||||
|
private bool detailedMode;
|
||||||
|
private bool isZuneConnected;
|
||||||
|
|
||||||
|
private NetworkDetector()
|
||||||
|
{
|
||||||
|
requestQueue = new Queue<long>();
|
||||||
|
requestQueue.Clear();
|
||||||
|
requestStatus = NetworkTypeRequestStatus.Default;
|
||||||
|
updateTimer = new System.Windows.Threading.DispatcherTimer();
|
||||||
|
updateTimer.Tick += new EventHandler(updateTimer_Tick);
|
||||||
|
updateTimer.Interval = new TimeSpan(0, 0, 0, 0, 300);//there is no need to restart the BGWorker sooner then 300 millisec because the ~3request/sec requestlimit
|
||||||
|
//updateTimer.Start();
|
||||||
|
pollTimer = new System.Windows.Threading.DispatcherTimer();
|
||||||
|
pollTimer.Tick += new EventHandler(pollTimer_Tick);
|
||||||
|
networkWorker = new BackgroundWorker();
|
||||||
|
networkWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(networkWorker_RunWorkerCompleted);
|
||||||
|
networkWorker.DoWork += new DoWorkEventHandler(networkWorker_DoWork);
|
||||||
|
IsInstantRequestPresent = false;
|
||||||
|
detailedMode = false; //by default I hide the framework events for better Developer experience
|
||||||
|
isZuneConnected = false;
|
||||||
|
|
||||||
|
SetupNetworkChange(); //signing on the framework event
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NetworkDetector Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region BackgroundWorker
|
||||||
|
void networkWorker_DoWork(object sender, DoWorkEventArgs e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(">>>>> GetNetType started " + System.DateTime.Now.ToString("T") + " >>>>>");
|
||||||
|
e.Result = Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType;
|
||||||
|
}
|
||||||
|
//no need to lock the variables if We do everithing in the completed event handler
|
||||||
|
|
||||||
|
void networkWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
DetectOnlineStatus();
|
||||||
|
if ((detailedMode) || (net != (Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType)e.Result))
|
||||||
|
{
|
||||||
|
//there is no need to get events all the time, just when really changing something or the DetailedMode is true
|
||||||
|
if (net != (Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType)e.Result)
|
||||||
|
RaiseNotify(OnLostNetworkType, new NetworkDetectorEventArgs(online, net));
|
||||||
|
net = (Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType)e.Result;
|
||||||
|
Debug.WriteLine(" New NetType: " + net.ToString());
|
||||||
|
if (net == Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Ethernet) Debug.WriteLine("!!!!! Zune is Connected");
|
||||||
|
switch (net)
|
||||||
|
{
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Ethernet:
|
||||||
|
if (!isZuneConnected)
|
||||||
|
{
|
||||||
|
isZuneConnected = true;
|
||||||
|
RaiseNotify(OnZuneConnected, new NetworkDetectorEventArgs(online, net));
|
||||||
|
}
|
||||||
|
RaiseNotify(OnConnectedEthernet, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Wireless80211:
|
||||||
|
if (isZuneConnected)
|
||||||
|
{
|
||||||
|
isZuneConnected = false;
|
||||||
|
RaiseNotify(OnZuneDisconnected, new NetworkDetectorEventArgs(online, net));
|
||||||
|
}
|
||||||
|
RaiseNotify(OnConnectedWifi, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.MobileBroadbandCdma:
|
||||||
|
if (isZuneConnected)
|
||||||
|
{
|
||||||
|
isZuneConnected = false;
|
||||||
|
RaiseNotify(OnZuneDisconnected, new NetworkDetectorEventArgs(online, net));
|
||||||
|
}
|
||||||
|
RaiseNotify(OnConnectedBroadbandCdma, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.MobileBroadbandGsm:
|
||||||
|
if (isZuneConnected)
|
||||||
|
{
|
||||||
|
isZuneConnected = false;
|
||||||
|
RaiseNotify(OnZuneDisconnected, new NetworkDetectorEventArgs(online, net));
|
||||||
|
}
|
||||||
|
RaiseNotify(OnConnectedBroadbandGsm, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None:
|
||||||
|
if (!online)
|
||||||
|
{
|
||||||
|
if (isZuneConnected)
|
||||||
|
{
|
||||||
|
/*if we lost all network connection and the Zune was present before,
|
||||||
|
then we lost the Zune too. Normally when Zune is present and then we got
|
||||||
|
a None NetType, the PC just lost the internet connection but not the Zune sync*/
|
||||||
|
isZuneConnected = false;
|
||||||
|
RaiseNotify(OnZuneDisconnected, new NetworkDetectorEventArgs(online, net));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RaiseNotify(OnConnectedNone, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.AsymmetricDsl:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Atm:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.BasicIsdn:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Ethernet3Megabit:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.FastEthernetFx:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.FastEthernetT:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Fddi:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.GenericModem:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.GigabitEthernet:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.HighPerformanceSerialBus:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.IPOverAtm:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Isdn:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Loopback:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.MultiRateSymmetricDsl:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Ppp:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.PrimaryIsdn:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.RateAdaptDsl:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Slip:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.SymmetricDsl:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.TokenRing:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Tunnel:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Unknown:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.VeryHighSpeedDsl:
|
||||||
|
default://theoretically we can't get here but better be prepared
|
||||||
|
RaiseNotify(OnConnectedOther, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < requestQueue.Count; i++)
|
||||||
|
{
|
||||||
|
if (requestQueue.Peek() < System.DateTime.Now.Ticks) requestQueue.Dequeue();
|
||||||
|
//the requests before this moment just got answered
|
||||||
|
//if other requests are coming right after this, they will be served inside the next networkWorker_RunWorkerCompleted
|
||||||
|
}
|
||||||
|
if (requestQueue.Count == 0) updateTimer.Stop();
|
||||||
|
if (IsInstantRequestPresent) //the user requested a single poll
|
||||||
|
{
|
||||||
|
RaiseNotify(OnAsyncGetNetworkTypeCompleted, new NetworkDetectorEventArgs(online, net));
|
||||||
|
IsInstantRequestPresent = false;
|
||||||
|
}
|
||||||
|
requestStatus = NetworkTypeRequestStatus.Ended;
|
||||||
|
Debug.WriteLine("<<<<< GetNetType ended " + System.DateTime.Now.ToString("T") + " <<<<<");
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Functions
|
||||||
|
private void EnqueueRequest()
|
||||||
|
{
|
||||||
|
requestQueue.Enqueue(System.DateTime.Now.Ticks);
|
||||||
|
if (!updateTimer.IsEnabled) updateTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DetectOnlineStatus() //are we connected to any network or not
|
||||||
|
{
|
||||||
|
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
|
||||||
|
{
|
||||||
|
if (!online)
|
||||||
|
{
|
||||||
|
online = true; //the network just came back
|
||||||
|
RaiseNotify(OnNetworkON, new NetworkAvailableEventArgs(online));
|
||||||
|
// do what is needed to GoOnline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (online)
|
||||||
|
{
|
||||||
|
online = false; //we just lost all network connectivity
|
||||||
|
RaiseNotify(OnNetworkOFF, new NetworkAvailableEventArgs(online));
|
||||||
|
Debug.WriteLine("----- No network available. -----");
|
||||||
|
// do what is needed to GoOffline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pollTimer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EnqueueRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateTimer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (requestQueue.Count > 0)
|
||||||
|
{
|
||||||
|
if (!networkWorker.IsBusy)
|
||||||
|
{
|
||||||
|
requestStatus = NetworkTypeRequestStatus.Started;
|
||||||
|
networkWorker.RunWorkerAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Event Handling
|
||||||
|
private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("+++++ Changed started " + System.DateTime.Now.ToString("T") + " +++++");
|
||||||
|
DetectOnlineStatus();
|
||||||
|
if (detailedMode) RaiseNotify(OnNetworkChanged, new NetworkAvailableEventArgs(online));
|
||||||
|
Debug.WriteLine(" IsOnline : " + online.ToString());
|
||||||
|
Debug.WriteLine(" Current NetType: " + net.ToString());
|
||||||
|
Debug.WriteLine("+++++ Changed Ended " + System.DateTime.Now.ToString("T"));
|
||||||
|
Debug.WriteLine(" Changed GetNetType Launch" + System.DateTime.Now.ToString("T"));
|
||||||
|
EnqueueRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupNetworkChange()
|
||||||
|
{
|
||||||
|
// Get current network availalability and store the
|
||||||
|
// initial value of the online variable
|
||||||
|
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
|
||||||
|
{
|
||||||
|
online = true;
|
||||||
|
// do what is needed to GoOnline();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
online = false;
|
||||||
|
// do what is needed to GoOffline();
|
||||||
|
}
|
||||||
|
// Now add a network change event handler to indicate network availability
|
||||||
|
EnqueueRequest();
|
||||||
|
System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += new System.Net.NetworkInformation.NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void RaiseNotify(EventHandler<NetworkDetectorEventArgs> handler, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void RaiseNotify(EventHandler<NetworkAvailableEventArgs> handler, NetworkAvailableEventArgs e)
|
||||||
|
{
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Functions and Properties
|
||||||
|
public void AsyncGetNetworkType()
|
||||||
|
{
|
||||||
|
//requestQueue.Enqueue(System.DateTime.Now.Ticks);
|
||||||
|
IsInstantRequestPresent = true;
|
||||||
|
if (!networkWorker.IsBusy)
|
||||||
|
{
|
||||||
|
requestStatus = NetworkTypeRequestStatus.Started;
|
||||||
|
networkWorker.RunWorkerAsync();
|
||||||
|
}
|
||||||
|
if (!updateTimer.IsEnabled) updateTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetNetworkPolling(int Minutes, int Seconds, int Milliseconds)
|
||||||
|
{
|
||||||
|
pollTimer.Interval = new TimeSpan(0, 0, Minutes, Seconds, Milliseconds);
|
||||||
|
if (!pollTimer.IsEnabled) pollTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisableNetworkPolling()
|
||||||
|
{
|
||||||
|
if (pollTimer.IsEnabled) pollTimer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType GetCurrentNetworkType()
|
||||||
|
{
|
||||||
|
return net;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetworkTypeRequestStatus GetRequestStatus()
|
||||||
|
{
|
||||||
|
//NetworkTypeRequestStatus temp = requestStatus;
|
||||||
|
//if (requestStatus == NetworkTypeRequestStatus.Ended) requestStatus = NetworkTypeRequestStatus.Default;
|
||||||
|
//return temp;
|
||||||
|
return requestStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DetailedMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return detailedMode;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
detailedMode = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GetZuneStatus()
|
||||||
|
{
|
||||||
|
return isZuneConnected;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
>
|
||||||
|
<Deployment.Parts>
|
||||||
|
</Deployment.Parts>
|
||||||
|
</Deployment>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("NetworkDetection")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("NetworkDetection")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("2d90f1d3-7fb9-47d0-98c2-18ee1a63a5f5")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">
|
||||||
|
<App xmlns="" ProductID="{794d79f0-e898-460d-bdb5-49fed553e0d5}" Title="NetworkDetection" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="NetworkDetection author" Description="Sample description" Publisher="NetworkDetection">
|
||||||
|
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
|
||||||
|
<Capabilities>
|
||||||
|
<Capability Name="ID_CAP_GAMERSERVICES"/>
|
||||||
|
<Capability Name="ID_CAP_IDENTITY_DEVICE"/>
|
||||||
|
<Capability Name="ID_CAP_IDENTITY_USER"/>
|
||||||
|
<Capability Name="ID_CAP_LOCATION"/>
|
||||||
|
<Capability Name="ID_CAP_MEDIALIB"/>
|
||||||
|
<Capability Name="ID_CAP_MICROPHONE"/>
|
||||||
|
<Capability Name="ID_CAP_NETWORKING"/>
|
||||||
|
<Capability Name="ID_CAP_PHONEDIALER"/>
|
||||||
|
<Capability Name="ID_CAP_PUSH_NOTIFICATION"/>
|
||||||
|
<Capability Name="ID_CAP_SENSORS"/>
|
||||||
|
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
|
||||||
|
</Capabilities>
|
||||||
|
<Tasks>
|
||||||
|
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
|
||||||
|
</Tasks>
|
||||||
|
<Tokens>
|
||||||
|
<PrimaryToken TokenID="NetworkDetectionToken" TaskName="_default">
|
||||||
|
<TemplateType5>
|
||||||
|
<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
|
||||||
|
<Count>0</Count>
|
||||||
|
<Title>NetworkDetection</Title>
|
||||||
|
</TemplateType5>
|
||||||
|
</PrimaryToken>
|
||||||
|
</Tokens>
|
||||||
|
</App>
|
||||||
|
</Deployment>
|
||||||
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,19 @@
|
|||||||
|
<Application
|
||||||
|
x:Class="NetworkNamespaces.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||||
|
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
|
||||||
|
|
||||||
|
<!--Application Resources-->
|
||||||
|
<Application.Resources>
|
||||||
|
</Application.Resources>
|
||||||
|
|
||||||
|
<Application.ApplicationLifetimeObjects>
|
||||||
|
<!--Required object that handles lifetime events for the application-->
|
||||||
|
<shell:PhoneApplicationService
|
||||||
|
Launching="Application_Launching" Closing="Application_Closing"
|
||||||
|
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
|
||||||
|
</Application.ApplicationLifetimeObjects>
|
||||||
|
|
||||||
|
</Application>
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Microsoft.Phone.Controls;
|
||||||
|
using Microsoft.Phone.Shell;
|
||||||
|
|
||||||
|
namespace NetworkNamespaces
|
||||||
|
{
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides easy access to the root frame of the Phone Application.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The root frame of the Phone Application.</returns>
|
||||||
|
public PhoneApplicationFrame RootFrame { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for the Application object.
|
||||||
|
/// </summary>
|
||||||
|
public App()
|
||||||
|
{
|
||||||
|
// Global handler for uncaught exceptions.
|
||||||
|
UnhandledException += Application_UnhandledException;
|
||||||
|
|
||||||
|
// Show graphics profiling information while debugging.
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// Display the current frame rate counters.
|
||||||
|
Application.Current.Host.Settings.EnableFrameRateCounter = true;
|
||||||
|
|
||||||
|
// Show the areas of the app that are being redrawn in each frame.
|
||||||
|
//Application.Current.Host.Settings.EnableRedrawRegions = true;
|
||||||
|
|
||||||
|
// Enable non-production analysis visualization mode,
|
||||||
|
// which shows areas of a page that are being GPU accelerated with a colored overlay.
|
||||||
|
//Application.Current.Host.Settings.EnableCacheVisualization = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standard Silverlight initialization
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
// Phone-specific initialization
|
||||||
|
InitializePhoneApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is launching (eg, from Start)
|
||||||
|
// This code will not execute when the application is reactivated
|
||||||
|
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is activated (brought to foreground)
|
||||||
|
// This code will not execute when the application is first launched
|
||||||
|
private void Application_Activated(object sender, ActivatedEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is deactivated (sent to background)
|
||||||
|
// This code will not execute when the application is closing
|
||||||
|
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is closing (eg, user hit Back)
|
||||||
|
// This code will not execute when the application is deactivated
|
||||||
|
private void Application_Closing(object sender, ClosingEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute if a navigation fails
|
||||||
|
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||||
|
{
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// A navigation has failed; break into the debugger
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute on Unhandled Exceptions
|
||||||
|
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// An unhandled exception has occurred; break into the debugger
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Phone application initialization
|
||||||
|
|
||||||
|
// Avoid double-initialization
|
||||||
|
private bool phoneApplicationInitialized = false;
|
||||||
|
|
||||||
|
// Do not add any additional code to this method
|
||||||
|
private void InitializePhoneApplication()
|
||||||
|
{
|
||||||
|
if (phoneApplicationInitialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Create the frame but don't set it as RootVisual yet; this allows the splash
|
||||||
|
// screen to remain active until the application is ready to render.
|
||||||
|
RootFrame = new PhoneApplicationFrame();
|
||||||
|
RootFrame.Navigated += CompleteInitializePhoneApplication;
|
||||||
|
|
||||||
|
// Handle navigation failures
|
||||||
|
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
|
||||||
|
|
||||||
|
// Ensure we don't initialize again
|
||||||
|
phoneApplicationInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not add any additional code to this method
|
||||||
|
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||||
|
{
|
||||||
|
// Set the root visual to allow the application to render
|
||||||
|
if (RootVisual != RootFrame)
|
||||||
|
RootVisual = RootFrame;
|
||||||
|
|
||||||
|
// Remove this handler since it is no longer needed
|
||||||
|
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,53 @@
|
|||||||
|
<phone:PhoneApplicationPage
|
||||||
|
x:Class="NetworkNamespaces.MainPage"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||||
|
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
|
||||||
|
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||||
|
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||||
|
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||||
|
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||||
|
shell:SystemTray.IsVisible="True">
|
||||||
|
|
||||||
|
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||||
|
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="144"/>
|
||||||
|
<RowDefinition Height="624*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!--TitlePanel contains the name of the application and page title-->
|
||||||
|
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
|
||||||
|
<TextBlock x:Name="ApplicationTitle" Text="NETWORK NAMESPACE DIFFERENCES" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||||
|
<Button Content="Refresh" Height="71" Name="buttonRefresh" Width="160" Click="buttonRefresh_Click" />
|
||||||
|
</StackPanel>
|
||||||
|
<!--ContentPanel - place additional content here-->
|
||||||
|
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="0.5*" />
|
||||||
|
<ColumnDefinition Width="0.5*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ListBox Height="576" HorizontalAlignment="Stretch" Margin="0,42,0,0" Name="listBoxSilverlight" VerticalAlignment="Top" Width="211" VerticalContentAlignment="Stretch" />
|
||||||
|
<ListBox Grid.Column="1" Height="576" HorizontalAlignment="Left" Name="listBoxPhone" VerticalAlignment="Top" Width="240" Margin="0,42,0,0" />
|
||||||
|
<TextBlock Height="30" HorizontalAlignment="Left" Margin="6,0,0,0" Name="textBlock1" Text="Silverlight" VerticalAlignment="Top" />
|
||||||
|
<TextBlock Grid.Column="1" Height="30" HorizontalAlignment="Left" Name="textBlock2" Text="Phone" VerticalAlignment="Top" />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!--Sample code showing usage of ApplicationBar-->
|
||||||
|
<!--<phone:PhoneApplicationPage.ApplicationBar>
|
||||||
|
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
|
||||||
|
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
|
||||||
|
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
|
||||||
|
<shell:ApplicationBar.MenuItems>
|
||||||
|
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
|
||||||
|
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
|
||||||
|
</shell:ApplicationBar.MenuItems>
|
||||||
|
</shell:ApplicationBar>
|
||||||
|
</phone:PhoneApplicationPage.ApplicationBar>-->
|
||||||
|
|
||||||
|
</phone:PhoneApplicationPage>
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Microsoft.Phone.Controls;
|
||||||
|
|
||||||
|
namespace NetworkNamespaces
|
||||||
|
{
|
||||||
|
public partial class MainPage : PhoneApplicationPage
|
||||||
|
{
|
||||||
|
// Constructor
|
||||||
|
public MainPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += new System.Net.NetworkInformation.NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
listBoxPhone.Items.Insert(0,Microsoft.Phone.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable().ToString());
|
||||||
|
listBoxSilverlight.Items.Insert(0,System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable().ToString());
|
||||||
|
if (listBoxSilverlight.Items.Count > 21) listBoxSilverlight.Items.RemoveAt(listBoxSilverlight.Items.Count-1);
|
||||||
|
if (listBoxPhone.Items.Count > 21) listBoxPhone.Items.RemoveAt(listBoxPhone.Items.Count - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonRefresh_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
listBoxPhone.Items.Insert(0,Microsoft.Phone.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable().ToString());
|
||||||
|
listBoxSilverlight.Items.Insert(0,System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable().ToString());
|
||||||
|
if (listBoxSilverlight.Items.Count > 21) listBoxSilverlight.Items.RemoveAt(listBoxSilverlight.Items.Count - 1);
|
||||||
|
if (listBoxPhone.Items.Count > 21) listBoxPhone.Items.RemoveAt(listBoxPhone.Items.Count - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>10.0.20506</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>NetworkNamespaces</RootNamespace>
|
||||||
|
<AssemblyName>NetworkNamespaces</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||||
|
<TargetFrameworkProfile>WindowsPhone</TargetFrameworkProfile>
|
||||||
|
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
|
||||||
|
<SilverlightApplication>true</SilverlightApplication>
|
||||||
|
<SupportedCultures>
|
||||||
|
</SupportedCultures>
|
||||||
|
<XapOutputs>true</XapOutputs>
|
||||||
|
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
|
||||||
|
<XapFilename>NetworkNamespaces.xap</XapFilename>
|
||||||
|
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
|
||||||
|
<SilverlightAppEntry>NetworkNamespaces.App</SilverlightAppEntry>
|
||||||
|
<ValidateXaml>true</ValidateXaml>
|
||||||
|
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>Bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>Bin\Release</OutputPath>
|
||||||
|
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Phone" />
|
||||||
|
<Reference Include="Microsoft.Phone.Interop" />
|
||||||
|
<Reference Include="System.Windows" />
|
||||||
|
<Reference Include="system" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Net" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="App.xaml.cs">
|
||||||
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MainPage.xaml.cs">
|
||||||
|
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ApplicationDefinition Include="App.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</ApplicationDefinition>
|
||||||
|
<Page Include="MainPage.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Properties\AppManifest.xml" />
|
||||||
|
<None Include="Properties\WMAppManifest.xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="ApplicationIcon.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Background.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="SplashScreenImage.jpg" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
<ProjectExtensions />
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
>
|
||||||
|
<Deployment.Parts>
|
||||||
|
</Deployment.Parts>
|
||||||
|
</Deployment>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("NetworkNamespaces")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("NetworkNamespaces")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("e86f4db7-5169-481a-88c2-7afd0f470c2e")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">
|
||||||
|
<App xmlns="" ProductID="{8a7d2a0b-f2ff-417f-aae7-56e8cf14a061}" Title="NetworkNamespaces" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="NetworkNamespaces author" Description="Sample description" Publisher="NetworkNamespaces">
|
||||||
|
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
|
||||||
|
<Capabilities>
|
||||||
|
<Capability Name="ID_CAP_GAMERSERVICES"/>
|
||||||
|
<Capability Name="ID_CAP_IDENTITY_DEVICE"/>
|
||||||
|
<Capability Name="ID_CAP_IDENTITY_USER"/>
|
||||||
|
<Capability Name="ID_CAP_LOCATION"/>
|
||||||
|
<Capability Name="ID_CAP_MEDIALIB"/>
|
||||||
|
<Capability Name="ID_CAP_MICROPHONE"/>
|
||||||
|
<Capability Name="ID_CAP_NETWORKING"/>
|
||||||
|
<Capability Name="ID_CAP_PHONEDIALER"/>
|
||||||
|
<Capability Name="ID_CAP_PUSH_NOTIFICATION"/>
|
||||||
|
<Capability Name="ID_CAP_SENSORS"/>
|
||||||
|
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
|
||||||
|
</Capabilities>
|
||||||
|
<Tasks>
|
||||||
|
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
|
||||||
|
</Tasks>
|
||||||
|
<Tokens>
|
||||||
|
<PrimaryToken TokenID="NetworkNamespacesToken" TaskName="_default">
|
||||||
|
<TemplateType5>
|
||||||
|
<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
|
||||||
|
<Count>0</Count>
|
||||||
|
<Title>NetworkNamespaces</Title>
|
||||||
|
</TemplateType5>
|
||||||
|
</PrimaryToken>
|
||||||
|
</Tokens>
|
||||||
|
</App>
|
||||||
|
</Deployment>
|
||||||
|
After Width: | Height: | Size: 9.2 KiB |
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MyFriendsAround.Common.Entities
|
||||||
|
{
|
||||||
|
public class PictureInfo
|
||||||
|
{
|
||||||
|
public virtual string UserId { get; set; }
|
||||||
|
public virtual string Picture { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,6 +63,7 @@
|
|||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>MyFriends.Model.tt</DependentUpon>
|
<DependentUpon>MyFriends.Model.tt</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Entities\PictureInfo.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
|
|||||||
@@ -3,14 +3,28 @@ using System.Collections.Generic;
|
|||||||
using System.Data.Objects;
|
using System.Data.Objects;
|
||||||
using System.Data.SqlTypes;
|
using System.Data.SqlTypes;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.SqlServer.Types;
|
using Microsoft.SqlServer.Types;
|
||||||
|
using Microsoft.WindowsAzure;
|
||||||
|
using Microsoft.WindowsAzure.StorageClient;
|
||||||
using MyFriendsAround.Common.Entities;
|
using MyFriendsAround.Common.Entities;
|
||||||
|
using System.IO;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
namespace MyFriendsAround.Data.BLL
|
namespace MyFriendsAround.Data.BLL
|
||||||
{
|
{
|
||||||
public static class FriendsRepository
|
public static class FriendsRepository
|
||||||
{
|
{
|
||||||
|
private static string profilesContainerName = string.Empty;
|
||||||
|
private static string profileImageFormat = string.Empty;
|
||||||
|
|
||||||
|
static FriendsRepository()
|
||||||
|
{
|
||||||
|
profilesContainerName = ConfigurationManager.AppSettings["azureProfilesContainer"];
|
||||||
|
profileImageFormat = ConfigurationManager.AppSettings["profileImageFormat"];
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Friend> GetFriends()
|
public static List<Friend> GetFriends()
|
||||||
{
|
{
|
||||||
return GetFriends(0, 50);
|
return GetFriends(0, 50);
|
||||||
@@ -32,6 +46,11 @@ namespace MyFriendsAround.Data.BLL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Publish user info
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="friend">friend obj</param>
|
||||||
|
/// <returns>true if success</returns>
|
||||||
public static bool PublishLocation(Friend friend)
|
public static bool PublishLocation(Friend friend)
|
||||||
{
|
{
|
||||||
using (MyFriendsModelContainer ctx = new MyFriendsModelContainer())
|
using (MyFriendsModelContainer ctx = new MyFriendsModelContainer())
|
||||||
@@ -55,7 +74,7 @@ namespace MyFriendsAround.Data.BLL
|
|||||||
bool success = ctx.SaveChanges() > 0;
|
bool success = ctx.SaveChanges() > 0;
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
//update gegraphy field
|
//update geography field
|
||||||
ctx.ExecuteFunction("UpdateFriendLocationById", new ObjectParameter[]
|
ctx.ExecuteFunction("UpdateFriendLocationById", new ObjectParameter[]
|
||||||
{
|
{
|
||||||
new ObjectParameter("FriendID", friend.Id),
|
new ObjectParameter("FriendID", friend.Id),
|
||||||
@@ -65,10 +84,78 @@ namespace MyFriendsAround.Data.BLL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool storageInitialized = false;
|
||||||
|
private static object gate = new Object();
|
||||||
|
private static CloudBlobClient blobStorage;
|
||||||
|
|
||||||
public static bool UpdatePicture(string userId, byte[] userPicture)
|
public static bool UpdatePicture(string userId, byte[] userPicture)
|
||||||
{
|
{
|
||||||
|
bool success = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InitializeStorage();
|
||||||
|
|
||||||
return false;
|
// upload the image to blob storage
|
||||||
|
CloudBlobContainer container = blobStorage.GetContainerReference(profilesContainerName);
|
||||||
|
string uniqueBlobName = string.Format(profileImageFormat, userId);
|
||||||
|
CloudBlockBlob blob = container.GetBlockBlobReference(uniqueBlobName);
|
||||||
|
blob.DeleteIfExists();
|
||||||
|
blob.Properties.ContentType = "image/jpeg";
|
||||||
|
using (MemoryStream ms = new MemoryStream(userPicture))
|
||||||
|
{
|
||||||
|
blob.UploadFromStream(ms);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
System.Diagnostics.Trace.TraceInformation("Uploaded image '{0}' to blob storage as '{1}'", userId, uniqueBlobName);
|
||||||
|
//
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitializeStorage()
|
||||||
|
{
|
||||||
|
if (storageInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (gate)
|
||||||
|
{
|
||||||
|
if (storageInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// read account configuration settings
|
||||||
|
var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
|
||||||
|
|
||||||
|
// create blob container for images
|
||||||
|
blobStorage = storageAccount.CreateCloudBlobClient();
|
||||||
|
CloudBlobContainer container = blobStorage.GetContainerReference(profilesContainerName);
|
||||||
|
container.CreateIfNotExist();
|
||||||
|
|
||||||
|
// configure container for public access
|
||||||
|
var permissions = container.GetPermissions();
|
||||||
|
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
|
||||||
|
container.SetPermissions(permissions);
|
||||||
|
}
|
||||||
|
catch (WebException)
|
||||||
|
{
|
||||||
|
throw new WebException("Storage services initialization failure. "
|
||||||
|
+ "Check your storage account configuration settings. If running locally, "
|
||||||
|
+ "ensure that the Development Storage service is running.");
|
||||||
|
}
|
||||||
|
|
||||||
|
storageInitialized = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,9 @@
|
|||||||
<HintPath>..\Libs\Sql\Microsoft.SqlServer.Types.dll</HintPath>
|
<HintPath>..\Libs\Sql\Microsoft.SqlServer.Types.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Data.Entity" />
|
<Reference Include="System.Data.Entity" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
<my:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1" />
|
<my:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1" />
|
||||||
<my1:InvertValueConverter x:Key="InvertValueConverter1" />
|
<my1:InvertValueConverter x:Key="InvertValueConverter1" />
|
||||||
|
|
||||||
|
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|
||||||
<Application.ApplicationLifetimeObjects>
|
<Application.ApplicationLifetimeObjects>
|
||||||
|
|||||||
@@ -1,21 +1,26 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Microsoft.Phone;
|
||||||
using Microsoft.Phone.Controls;
|
using Microsoft.Phone.Controls;
|
||||||
using Microsoft.Phone.Shell;
|
using Microsoft.Phone.Shell;
|
||||||
using MyFriendsAround.WP7.ViewModel;
|
using MyFriendsAround.WP7.ViewModel;
|
||||||
using MyFriendsAround.WP7.Utils;
|
using MyFriendsAround.WP7.Utils;
|
||||||
using GalaSoft.MvvmLight.Threading;
|
using GalaSoft.MvvmLight.Threading;
|
||||||
using MyFriendsAround.WP7.Views;
|
using MyFriendsAround.WP7.Views;
|
||||||
|
using NetworkDetection;
|
||||||
|
|
||||||
|
|
||||||
namespace MyFriendsAround.WP7
|
namespace MyFriendsAround.WP7
|
||||||
@@ -39,6 +44,9 @@ namespace MyFriendsAround.WP7
|
|||||||
// Phone-specific initialization
|
// Phone-specific initialization
|
||||||
InitializePhoneApplication();
|
InitializePhoneApplication();
|
||||||
|
|
||||||
|
//init NetworkDetector
|
||||||
|
var dummy = NetworkDetector.Instance;
|
||||||
|
|
||||||
//register ViewModelLocator
|
//register ViewModelLocator
|
||||||
Container.Instance.RegisterInstance(typeof(ViewModelLocator), "ViewModelLocator");
|
Container.Instance.RegisterInstance(typeof(ViewModelLocator), "ViewModelLocator");
|
||||||
}
|
}
|
||||||
@@ -83,23 +91,29 @@ namespace MyFriendsAround.WP7
|
|||||||
MainViewModel mainModel = this.RetrieveFromIsolatedStorage<MainViewModel>();
|
MainViewModel mainModel = this.RetrieveFromIsolatedStorage<MainViewModel>();
|
||||||
if (mainModel != null)
|
if (mainModel != null)
|
||||||
{
|
{
|
||||||
|
mainModel.IsLoaded = true;
|
||||||
|
mainModel.IsBusy = false;
|
||||||
Container.Instance.RegisterInstance<MainViewModel>(mainModel, "MainViewModel");
|
Container.Instance.RegisterInstance<MainViewModel>(mainModel, "MainViewModel");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Container.Instance.RegisterInstance<MainViewModel>(new MainViewModel(), "MainViewModel");
|
Container.Instance.RegisterInstance<MainViewModel>(new MainViewModel(), "MainViewModel");
|
||||||
}
|
}
|
||||||
|
//
|
||||||
SettingsViewModel settingsModel = this.RetrieveFromIsolatedStorage<SettingsViewModel>();
|
SettingsViewModel settingsModel = this.RetrieveFromIsolatedStorage<SettingsViewModel>();
|
||||||
if (settingsModel != null)
|
if (settingsModel != null)
|
||||||
{
|
{
|
||||||
|
settingsModel.IsLoaded = true;
|
||||||
Container.Instance.RegisterInstance<SettingsViewModel>(settingsModel, "SettingsViewModel");
|
Container.Instance.RegisterInstance<SettingsViewModel>(settingsModel, "SettingsViewModel");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Container.Instance.RegisterInstance<SettingsViewModel>(new SettingsViewModel(), "SettingsViewModel");
|
Container.Instance.RegisterInstance<SettingsViewModel>(new SettingsViewModel(), "SettingsViewModel");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void SaveModel()
|
private void SaveModel()
|
||||||
{
|
{
|
||||||
this.SaveToIsolatedStorage<MainViewModel>(Container.Instance.Resolve<MainViewModel>("MainViewModel"));
|
this.SaveToIsolatedStorage<MainViewModel>(Container.Instance.Resolve<MainViewModel>("MainViewModel"));
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 5.0 KiB |
@@ -135,6 +135,9 @@
|
|||||||
<Compile Include="..\MyFriendsAround.Common\Entities\FriendExt.cs">
|
<Compile Include="..\MyFriendsAround.Common\Entities\FriendExt.cs">
|
||||||
<Link>Entities\FriendExt.cs</Link>
|
<Link>Entities\FriendExt.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\MyFriendsAround.Common\Entities\PictureInfo.cs">
|
||||||
|
<Link>Entities\PictureInfo.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="App.xaml.cs">
|
<Compile Include="App.xaml.cs">
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -145,6 +148,10 @@
|
|||||||
<Compile Include="Utils\LittleWatson.cs">
|
<Compile Include="Utils\LittleWatson.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Utils\NetworkDetector.cs" />
|
||||||
|
<Compile Include="Views\CropPage.xaml.cs">
|
||||||
|
<DependentUpon>CropPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\SettingsPage.xaml.cs">
|
<Compile Include="Views\SettingsPage.xaml.cs">
|
||||||
<DependentUpon>SettingsPage.xaml</DependentUpon>
|
<DependentUpon>SettingsPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -177,6 +184,10 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\CropPage.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\SettingsPage.xaml">
|
<Page Include="Views\SettingsPage.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
@@ -211,6 +222,9 @@
|
|||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="icons\appbar.sync.rest.png" />
|
<Content Include="icons\appbar.sync.rest.png" />
|
||||||
|
<Content Include="icons\Penguins.jpg">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="SplashScreenImage.jpg">
|
<Content Include="SplashScreenImage.jpg">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
using Hammock;
|
using Hammock;
|
||||||
using Hammock.Web;
|
using Hammock.Web;
|
||||||
using MyFriendsAround.Common.Entities;
|
using MyFriendsAround.Common.Entities;
|
||||||
@@ -11,7 +12,7 @@ namespace MyFriendsAround.WP7.Service
|
|||||||
{
|
{
|
||||||
|
|
||||||
private static int _timeOut = 10;
|
private static int _timeOut = 10;
|
||||||
private static string baseUrl;
|
public static string baseUrl;
|
||||||
|
|
||||||
static ServiceAgent()
|
static ServiceAgent()
|
||||||
{
|
{
|
||||||
@@ -115,5 +116,58 @@ namespace MyFriendsAround.WP7.Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region PublishMyPicture
|
||||||
|
|
||||||
|
|
||||||
|
public static EventHandler<PublishLocationEventArgs> publishmypicturecallback;
|
||||||
|
public static void PublishMyPicture(string userId, byte[] picture, EventHandler<PublishLocationEventArgs> callback)
|
||||||
|
{
|
||||||
|
var serializer = new Hammock.Serialization.HammockDataContractJsonSerializer();
|
||||||
|
RestClient client = new RestClient
|
||||||
|
{
|
||||||
|
Authority = baseUrl,
|
||||||
|
Timeout = new TimeSpan(0, 0, 0, _timeOut),
|
||||||
|
Serializer = serializer,
|
||||||
|
Deserializer = serializer
|
||||||
|
};
|
||||||
|
RestRequest request = new RestRequest
|
||||||
|
{
|
||||||
|
Timeout = new TimeSpan(0, 0, 0, _timeOut),
|
||||||
|
Method = WebMethod.Post,
|
||||||
|
Path = "UpdatePicture",
|
||||||
|
Entity = new PictureInfo()
|
||||||
|
{
|
||||||
|
UserId = userId,
|
||||||
|
Picture = Convert.ToBase64String(picture)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
publishmypicturecallback = callback;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
client.BeginRequest(request, new RestCallback<bool>(PublishMyPictureCallback));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
publishmypicturecallback.Invoke(null, new PublishLocationEventArgs() { IsSuccess = false, Error = ex });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PublishMyPictureCallback(RestRequest request, RestResponse<bool> response, object userState)
|
||||||
|
{
|
||||||
|
if (response.StatusCode == HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
bool success = response.ContentEntity;
|
||||||
|
publishmypicturecallback.Invoke(null, new PublishLocationEventArgs() { IsSuccess = success });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
publishmypicturecallback.Invoke(null, new PublishLocationEventArgs() { IsSuccess = false, Error = new Exception("Communication Error!") });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 71 KiB |
@@ -45,11 +45,36 @@ namespace MyFriendsAround.WP7.Utils
|
|||||||
isoFile.CreateDirectory(imageFolder);
|
isoFile.CreateDirectory(imageFolder);
|
||||||
}
|
}
|
||||||
string filePath = Path.Combine(imageFolder, imageFileName);
|
string filePath = Path.Combine(imageFolder, imageFileName);
|
||||||
|
if (!isoFile.FileExists(filePath))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
using (var imageStream = isoFile.OpenFile(filePath, FileMode.Open, FileAccess.Read))
|
using (var imageStream = isoFile.OpenFile(filePath, FileMode.Open, FileAccess.Read))
|
||||||
{
|
{
|
||||||
var imageSource = PictureDecoder.DecodeJpeg(imageStream);
|
var imageSource = PictureDecoder.DecodeJpeg(imageStream);
|
||||||
return imageSource;
|
return imageSource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] LoadFromLocalStorageArray(string imageFileName, string imageFolder)
|
||||||
|
{
|
||||||
|
var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
|
||||||
|
if (!isoFile.DirectoryExists(imageFolder))
|
||||||
|
{
|
||||||
|
isoFile.CreateDirectory(imageFolder);
|
||||||
|
}
|
||||||
|
string filePath = Path.Combine(imageFolder, imageFileName);
|
||||||
|
if (!isoFile.FileExists(filePath))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using (var imageStream = isoFile.OpenFile(filePath, FileMode.Open, FileAccess.Read))
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[imageStream.Length];
|
||||||
|
imageStream.Read(buffer, 0, buffer.Length);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,387 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************/
|
||||||
|
/* Copyright of Gabor Dolhai @ 2010 */
|
||||||
|
/* under MS-Pl license */
|
||||||
|
/* can be used freely for anybody */
|
||||||
|
/* If you use this code please send me an */
|
||||||
|
/*email about your project to dolhaig at gmail*/
|
||||||
|
/*******************Thanks*********************/
|
||||||
|
namespace NetworkDetection
|
||||||
|
{
|
||||||
|
#region Custom Enums and EventArgs
|
||||||
|
public enum NetworkTypeRequestStatus
|
||||||
|
{
|
||||||
|
Default = 0,
|
||||||
|
Started,//represents BackgroundWorker started
|
||||||
|
Ended//BackgroundWorker Finished
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NetworkAvailableEventArgs : System.EventArgs
|
||||||
|
{
|
||||||
|
|
||||||
|
public NetworkAvailableEventArgs(bool isOnline)
|
||||||
|
{
|
||||||
|
IsOnline = isOnline;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsOnline { get; private set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NetworkDetectorEventArgs : System.EventArgs
|
||||||
|
{
|
||||||
|
|
||||||
|
public NetworkDetectorEventArgs(bool isOnline, Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType netType)
|
||||||
|
{
|
||||||
|
IsOnline = isOnline;
|
||||||
|
NetType = netType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsOnline { get; private set; }
|
||||||
|
public Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType NetType { get; private set; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public class NetworkDetector
|
||||||
|
{
|
||||||
|
private static readonly NetworkDetector _instance = new NetworkDetector();
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
public event EventHandler<NetworkAvailableEventArgs> OnNetworkON;
|
||||||
|
public event EventHandler<NetworkAvailableEventArgs> OnNetworkOFF;
|
||||||
|
public event EventHandler<NetworkAvailableEventArgs> OnNetworkChanged;
|
||||||
|
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnZuneConnected;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnZuneDisconnected;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedEthernet;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedWifi;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedNone;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedBroadbandGsm;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedBroadbandCdma;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnConnectedOther;
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnLostNetworkType;
|
||||||
|
|
||||||
|
public event EventHandler<NetworkDetectorEventArgs> OnAsyncGetNetworkTypeCompleted;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Threading.DispatcherTimer updateTimer, pollTimer;
|
||||||
|
private Queue<long> requestQueue; //queue to store the requests timestemps
|
||||||
|
private BackgroundWorker networkWorker;
|
||||||
|
private bool online = false;
|
||||||
|
private Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType net;
|
||||||
|
private NetworkTypeRequestStatus requestStatus; //current status of the BackgroundWorker
|
||||||
|
private bool IsInstantRequestPresent;
|
||||||
|
private bool detailedMode;
|
||||||
|
private bool isZuneConnected;
|
||||||
|
|
||||||
|
private NetworkDetector()
|
||||||
|
{
|
||||||
|
requestQueue = new Queue<long>();
|
||||||
|
requestQueue.Clear();
|
||||||
|
requestStatus = NetworkTypeRequestStatus.Default;
|
||||||
|
updateTimer = new System.Windows.Threading.DispatcherTimer();
|
||||||
|
updateTimer.Tick += new EventHandler(updateTimer_Tick);
|
||||||
|
updateTimer.Interval = new TimeSpan(0, 0, 0, 0, 300);//there is no need to restart the BGWorker sooner then 300 millisec because the ~3request/sec requestlimit
|
||||||
|
//updateTimer.Start();
|
||||||
|
pollTimer = new System.Windows.Threading.DispatcherTimer();
|
||||||
|
pollTimer.Tick += new EventHandler(pollTimer_Tick);
|
||||||
|
networkWorker = new BackgroundWorker();
|
||||||
|
networkWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(networkWorker_RunWorkerCompleted);
|
||||||
|
networkWorker.DoWork += new DoWorkEventHandler(networkWorker_DoWork);
|
||||||
|
IsInstantRequestPresent = false;
|
||||||
|
detailedMode = false; //by default I hide the framework events for better Developer experience
|
||||||
|
isZuneConnected = false;
|
||||||
|
|
||||||
|
SetupNetworkChange(); //signing on the framework event
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NetworkDetector Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region BackgroundWorker
|
||||||
|
void networkWorker_DoWork(object sender, DoWorkEventArgs e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(">>>>> GetNetType started " + System.DateTime.Now.ToString("T") + " >>>>>");
|
||||||
|
e.Result = Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType;
|
||||||
|
}
|
||||||
|
//no need to lock the variables if We do everithing in the completed event handler
|
||||||
|
|
||||||
|
void networkWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
DetectOnlineStatus();
|
||||||
|
if ((detailedMode) || (net != (Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType)e.Result))
|
||||||
|
{
|
||||||
|
//there is no need to get events all the time, just when really changing something or the DetailedMode is true
|
||||||
|
if (net != (Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType)e.Result)
|
||||||
|
RaiseNotify(OnLostNetworkType, new NetworkDetectorEventArgs(online, net));
|
||||||
|
net = (Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType)e.Result;
|
||||||
|
Debug.WriteLine(" New NetType: " + net.ToString());
|
||||||
|
if (net == Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Ethernet) Debug.WriteLine("!!!!! Zune is Connected");
|
||||||
|
switch (net)
|
||||||
|
{
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Ethernet:
|
||||||
|
if (!isZuneConnected)
|
||||||
|
{
|
||||||
|
isZuneConnected = true;
|
||||||
|
RaiseNotify(OnZuneConnected, new NetworkDetectorEventArgs(online, net));
|
||||||
|
}
|
||||||
|
RaiseNotify(OnConnectedEthernet, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Wireless80211:
|
||||||
|
if (isZuneConnected)
|
||||||
|
{
|
||||||
|
isZuneConnected = false;
|
||||||
|
RaiseNotify(OnZuneDisconnected, new NetworkDetectorEventArgs(online, net));
|
||||||
|
}
|
||||||
|
RaiseNotify(OnConnectedWifi, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.MobileBroadbandCdma:
|
||||||
|
if (isZuneConnected)
|
||||||
|
{
|
||||||
|
isZuneConnected = false;
|
||||||
|
RaiseNotify(OnZuneDisconnected, new NetworkDetectorEventArgs(online, net));
|
||||||
|
}
|
||||||
|
RaiseNotify(OnConnectedBroadbandCdma, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.MobileBroadbandGsm:
|
||||||
|
if (isZuneConnected)
|
||||||
|
{
|
||||||
|
isZuneConnected = false;
|
||||||
|
RaiseNotify(OnZuneDisconnected, new NetworkDetectorEventArgs(online, net));
|
||||||
|
}
|
||||||
|
RaiseNotify(OnConnectedBroadbandGsm, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None:
|
||||||
|
if (!online)
|
||||||
|
{
|
||||||
|
if (isZuneConnected)
|
||||||
|
{
|
||||||
|
/*if we lost all network connection and the Zune was present before,
|
||||||
|
then we lost the Zune too. Normally when Zune is present and then we got
|
||||||
|
a None NetType, the PC just lost the internet connection but not the Zune sync*/
|
||||||
|
isZuneConnected = false;
|
||||||
|
RaiseNotify(OnZuneDisconnected, new NetworkDetectorEventArgs(online, net));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RaiseNotify(OnConnectedNone, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.AsymmetricDsl:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Atm:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.BasicIsdn:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Ethernet3Megabit:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.FastEthernetFx:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.FastEthernetT:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Fddi:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.GenericModem:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.GigabitEthernet:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.HighPerformanceSerialBus:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.IPOverAtm:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Isdn:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Loopback:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.MultiRateSymmetricDsl:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Ppp:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.PrimaryIsdn:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.RateAdaptDsl:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Slip:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.SymmetricDsl:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.TokenRing:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Tunnel:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.Unknown:
|
||||||
|
case Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.VeryHighSpeedDsl:
|
||||||
|
default://theoretically we can't get here but better be prepared
|
||||||
|
RaiseNotify(OnConnectedOther, new NetworkDetectorEventArgs(online, net));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < requestQueue.Count; i++)
|
||||||
|
{
|
||||||
|
if (requestQueue.Peek() < System.DateTime.Now.Ticks) requestQueue.Dequeue();
|
||||||
|
//the requests before this moment just got answered
|
||||||
|
//if other requests are coming right after this, they will be served inside the next networkWorker_RunWorkerCompleted
|
||||||
|
}
|
||||||
|
if (requestQueue.Count == 0) updateTimer.Stop();
|
||||||
|
if (IsInstantRequestPresent) //the user requested a single poll
|
||||||
|
{
|
||||||
|
RaiseNotify(OnAsyncGetNetworkTypeCompleted, new NetworkDetectorEventArgs(online, net));
|
||||||
|
IsInstantRequestPresent = false;
|
||||||
|
}
|
||||||
|
requestStatus = NetworkTypeRequestStatus.Ended;
|
||||||
|
Debug.WriteLine("<<<<< GetNetType ended " + System.DateTime.Now.ToString("T") + " <<<<<");
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Functions
|
||||||
|
private void EnqueueRequest()
|
||||||
|
{
|
||||||
|
requestQueue.Enqueue(System.DateTime.Now.Ticks);
|
||||||
|
if (!updateTimer.IsEnabled) updateTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DetectOnlineStatus() //are we connected to any network or not
|
||||||
|
{
|
||||||
|
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
|
||||||
|
{
|
||||||
|
if (!online)
|
||||||
|
{
|
||||||
|
online = true; //the network just came back
|
||||||
|
RaiseNotify(OnNetworkON, new NetworkAvailableEventArgs(online));
|
||||||
|
// do what is needed to GoOnline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (online)
|
||||||
|
{
|
||||||
|
online = false; //we just lost all network connectivity
|
||||||
|
RaiseNotify(OnNetworkOFF, new NetworkAvailableEventArgs(online));
|
||||||
|
Debug.WriteLine("----- No network available. -----");
|
||||||
|
// do what is needed to GoOffline();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pollTimer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EnqueueRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateTimer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (requestQueue.Count > 0)
|
||||||
|
{
|
||||||
|
if (!networkWorker.IsBusy)
|
||||||
|
{
|
||||||
|
requestStatus = NetworkTypeRequestStatus.Started;
|
||||||
|
networkWorker.RunWorkerAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Event Handling
|
||||||
|
private void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("+++++ Changed started " + System.DateTime.Now.ToString("T") + " +++++");
|
||||||
|
DetectOnlineStatus();
|
||||||
|
if (detailedMode) RaiseNotify(OnNetworkChanged, new NetworkAvailableEventArgs(online));
|
||||||
|
Debug.WriteLine(" IsOnline : " + online.ToString());
|
||||||
|
Debug.WriteLine(" Current NetType: " + net.ToString());
|
||||||
|
Debug.WriteLine("+++++ Changed Ended " + System.DateTime.Now.ToString("T"));
|
||||||
|
Debug.WriteLine(" Changed GetNetType Launch" + System.DateTime.Now.ToString("T"));
|
||||||
|
EnqueueRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupNetworkChange()
|
||||||
|
{
|
||||||
|
// Get current network availalability and store the
|
||||||
|
// initial value of the online variable
|
||||||
|
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
|
||||||
|
{
|
||||||
|
online = true;
|
||||||
|
// do what is needed to GoOnline();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
online = false;
|
||||||
|
// do what is needed to GoOffline();
|
||||||
|
}
|
||||||
|
// Now add a network change event handler to indicate network availability
|
||||||
|
EnqueueRequest();
|
||||||
|
System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += new System.Net.NetworkInformation.NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void RaiseNotify(EventHandler<NetworkDetectorEventArgs> handler, NetworkDetectorEventArgs e)
|
||||||
|
{
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void RaiseNotify(EventHandler<NetworkAvailableEventArgs> handler, NetworkAvailableEventArgs e)
|
||||||
|
{
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Functions and Properties
|
||||||
|
public void AsyncGetNetworkType()
|
||||||
|
{
|
||||||
|
//requestQueue.Enqueue(System.DateTime.Now.Ticks);
|
||||||
|
IsInstantRequestPresent = true;
|
||||||
|
if (!networkWorker.IsBusy)
|
||||||
|
{
|
||||||
|
requestStatus = NetworkTypeRequestStatus.Started;
|
||||||
|
networkWorker.RunWorkerAsync();
|
||||||
|
}
|
||||||
|
if (!updateTimer.IsEnabled) updateTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetNetworkPolling(int Minutes, int Seconds, int Milliseconds)
|
||||||
|
{
|
||||||
|
pollTimer.Interval = new TimeSpan(0, 0, Minutes, Seconds, Milliseconds);
|
||||||
|
if (!pollTimer.IsEnabled) pollTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisableNetworkPolling()
|
||||||
|
{
|
||||||
|
if (pollTimer.IsEnabled) pollTimer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType GetCurrentNetworkType()
|
||||||
|
{
|
||||||
|
return net;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetworkTypeRequestStatus GetRequestStatus()
|
||||||
|
{
|
||||||
|
//NetworkTypeRequestStatus temp = requestStatus;
|
||||||
|
//if (requestStatus == NetworkTypeRequestStatus.Ended) requestStatus = NetworkTypeRequestStatus.Default;
|
||||||
|
//return temp;
|
||||||
|
return requestStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DetailedMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return detailedMode;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
detailedMode = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GetZuneStatus()
|
||||||
|
{
|
||||||
|
return isZuneConnected;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,11 +6,13 @@ using System.IO;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Security;
|
using System.Security;
|
||||||
using System.ServiceModel.Channels;
|
using System.ServiceModel.Channels;
|
||||||
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
using Coding4Fun.Phone.Controls;
|
using Coding4Fun.Phone.Controls;
|
||||||
using GalaSoft.MvvmLight;
|
using GalaSoft.MvvmLight;
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
@@ -25,6 +27,7 @@ using MyFriendsAround.Common.Entities;
|
|||||||
using MyFriendsAround.WP7.Service;
|
using MyFriendsAround.WP7.Service;
|
||||||
using MyFriendsAround.WP7.Utils;
|
using MyFriendsAround.WP7.Utils;
|
||||||
using MyFriendsAround.WP7.Views;
|
using MyFriendsAround.WP7.Views;
|
||||||
|
using NetworkDetection;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Microsoft.Phone.Tasks;
|
using Microsoft.Phone.Tasks;
|
||||||
|
|
||||||
@@ -68,12 +71,21 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string PageNameCropping
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Crop";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the MainViewModel class.
|
/// Initializes a new instance of the MainViewModel class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MainViewModel()
|
public MainViewModel()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
MainLoadCommand = new RelayCommand(() => MainLoad());
|
||||||
PublishLocationCommand = new RelayCommand(() => PublishLocationAction());
|
PublishLocationCommand = new RelayCommand(() => PublishLocationAction());
|
||||||
DisplayAboutCommand = new RelayCommand(() => DisplayAbout());
|
DisplayAboutCommand = new RelayCommand(() => DisplayAbout());
|
||||||
NavigateToSettingsCommand = new RelayCommand(() => NavigateToSettings());
|
NavigateToSettingsCommand = new RelayCommand(() => NavigateToSettings());
|
||||||
@@ -82,6 +94,8 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
SaveMySettingsCommand = new RelayCommand(() => SaveMySettings());
|
SaveMySettingsCommand = new RelayCommand(() => SaveMySettings());
|
||||||
CancelMySettingsCommand = new RelayCommand(() => CancelMySettings());
|
CancelMySettingsCommand = new RelayCommand(() => CancelMySettings());
|
||||||
ChoosePhotoCommand = new RelayCommand(() => ChoosePhoto());
|
ChoosePhotoCommand = new RelayCommand(() => ChoosePhoto());
|
||||||
|
CropSaveCommand = new RelayCommand(() => CropSave());
|
||||||
|
CropCancelCommand = new RelayCommand(() => CropCancel());
|
||||||
|
|
||||||
if (IsInDesignMode)
|
if (IsInDesignMode)
|
||||||
{
|
{
|
||||||
@@ -94,17 +108,75 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CropCancel()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
this.PageNav.GoBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CropSave()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void MainLoad()
|
||||||
|
{
|
||||||
|
if (IsLoaded)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ThreadPool.QueueUserWorkItem(LoadMyPicture);
|
||||||
|
//
|
||||||
|
IsLoaded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadMyPicture(object param) //Background thread
|
||||||
|
{
|
||||||
|
Thread.Sleep(500);
|
||||||
|
byte[] img = IsolatedStorageHelper.LoadFromLocalStorageArray("myphoto.jpg", "profiles");
|
||||||
|
if (img != null)
|
||||||
|
{
|
||||||
|
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||||
|
{
|
||||||
|
using (MemoryStream ms = new MemoryStream(img))
|
||||||
|
{
|
||||||
|
Container.Instance.Resolve<MainViewModel>("MainViewModel").MyPicture = PictureDecoder.DecodeJpeg(ms);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||||
|
{
|
||||||
|
Container.Instance.Resolve<MainViewModel>("MainViewModel").MyPicture = new BitmapImage(new Uri("/icons/anonymousIcon.png", UriKind.RelativeOrAbsolute));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ChoosePhoto()
|
private void ChoosePhoto()
|
||||||
{
|
{
|
||||||
//choose photo
|
//choose photo
|
||||||
ShowCameraCaptureTask();
|
//ShowCameraCaptureTask();
|
||||||
//ShowPhotoChooserTask();
|
//ShowPhotoChooserTask();
|
||||||
|
if (!NetworkDetector.Instance.GetZuneStatus())
|
||||||
|
{
|
||||||
|
this.PageNav.NavigateTo(new Uri("/Views/CropPage.xaml", UriKind.RelativeOrAbsolute));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Please disconnect from Zune!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PhotoChooserTask photoChooserTask = new PhotoChooserTask();
|
||||||
private void ShowPhotoChooserTask()
|
private void ShowPhotoChooserTask()
|
||||||
{
|
{
|
||||||
var photoChooserTask = new PhotoChooserTask();
|
|
||||||
photoChooserTask.Completed += cameraTask_Completed;
|
photoChooserTask.Completed += cameraTask_Completed;
|
||||||
|
//photoChooserTask.PixelHeight = 100;
|
||||||
|
//photoChooserTask.PixelWidth = 100;
|
||||||
|
photoChooserTask.ShowCamera = true;
|
||||||
photoChooserTask.Show();
|
photoChooserTask.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +189,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
|
|
||||||
private void cameraTask_Completed(object sender, PhotoResult e)
|
private void cameraTask_Completed(object sender, PhotoResult e)
|
||||||
{
|
{
|
||||||
if (e.TaskResult == TaskResult.OK)
|
if (e.ChosenPhoto!=null && e.ChosenPhoto.Length>0) // e.TaskResult == TaskResult.OK)
|
||||||
{
|
{
|
||||||
// Get the image temp file from e.OriginalFileName.
|
// Get the image temp file from e.OriginalFileName.
|
||||||
// Get the image temp stream from e.ChosenPhoto.
|
// Get the image temp stream from e.ChosenPhoto.
|
||||||
@@ -127,10 +199,11 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
// Store the image bytes.
|
// Store the image bytes.
|
||||||
byte[] _imageBytes = new byte[e.ChosenPhoto.Length];
|
byte[] _imageBytes = new byte[e.ChosenPhoto.Length];
|
||||||
e.ChosenPhoto.Read(_imageBytes, 0, _imageBytes.Length);
|
e.ChosenPhoto.Read(_imageBytes, 0, _imageBytes.Length);
|
||||||
|
//save
|
||||||
|
IsolatedStorageHelper.SaveToLocalStorage("myphoto.jpg", "profiles", _imageBytes);
|
||||||
|
|
||||||
// Seek back so we can create an image.
|
// Seek back so we can create an image.
|
||||||
e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
|
e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
// Create an image from the stream.
|
// Create an image from the stream.
|
||||||
var imageSource = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
|
var imageSource = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
|
||||||
MyPicture = imageSource;
|
MyPicture = imageSource;
|
||||||
@@ -141,12 +214,12 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
/// The <see cref="MyPicture" /> property's name.
|
/// The <see cref="MyPicture" /> property's name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string MyPicturePropertyName = "MyPicture";
|
public const string MyPicturePropertyName = "MyPicture";
|
||||||
private BitmapSource _myPicture = new BitmapImage(new Uri("/icons/anonymousIcon.png", UriKind.RelativeOrAbsolute));
|
private ImageSource _myPicture = new BitmapImage(new Uri("/icons/anonymousIcon.png", UriKind.RelativeOrAbsolute));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the MyPicture property.
|
/// Gets the MyPicture property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BitmapSource MyPicture
|
public ImageSource MyPicture
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -221,7 +294,9 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
result.Add(new PushPinModel()
|
result.Add(new PushPinModel()
|
||||||
{
|
{
|
||||||
PinSource = "/ApplicationIcon.png",
|
PinSource = "/ApplicationIcon.png",
|
||||||
Location = new GeoCoordinate(f.Latitude, f.Longitude)
|
Location = new GeoCoordinate(f.Latitude, f.Longitude),
|
||||||
|
PinUserName = f.FriendName,
|
||||||
|
PinImageUrl = string.Format("https://myfriendsaround.blob.core.windows.net/profiles/profile_{0}.jpg", f.Id)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
PushPins = result;
|
PushPins = result;
|
||||||
@@ -290,13 +365,60 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
Messenger.Default.Send(message);
|
Messenger.Default.Send(message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//
|
else
|
||||||
//update
|
{
|
||||||
ServiceAgent.GetFriends(this.GetFriendsResult);
|
//update also the picture
|
||||||
|
byte[] img = IsolatedStorageHelper.LoadFromLocalStorageArray("myphoto.jpg", "profiles");
|
||||||
|
if (img != null)
|
||||||
|
{
|
||||||
|
ServiceAgent.PublishMyPicture(Identification.GetDeviceId(), img, new EventHandler<PublishLocationEventArgs>(PublishMyPictureResult));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//update friends list
|
||||||
|
ServiceAgent.GetFriends(this.GetFriendsResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PublishMyPictureResult(object sender, PublishLocationEventArgs args)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (args.Error != null)
|
||||||
|
{
|
||||||
|
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||||
|
{
|
||||||
|
IsBusy = false;
|
||||||
|
var exception = new ExceptionPrompt();
|
||||||
|
exception.Show(args.Error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!args.IsSuccess)
|
||||||
|
{
|
||||||
|
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
||||||
|
{
|
||||||
|
var message = new DialogMessage(
|
||||||
|
"Communication error!", DialogMessageCallback)
|
||||||
|
{
|
||||||
|
Button = MessageBoxButton.OK,
|
||||||
|
Caption = "Error!"
|
||||||
|
};
|
||||||
|
|
||||||
|
Messenger.Default.Send(message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//update friends list
|
||||||
|
ServiceAgent.GetFriends(this.GetFriendsResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void DialogMessageCallback(MessageBoxResult result)
|
private void DialogMessageCallback(MessageBoxResult result)
|
||||||
{
|
{
|
||||||
if (result == MessageBoxResult.OK)
|
if (result == MessageBoxResult.OK)
|
||||||
@@ -309,6 +431,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICommand MainLoadCommand { get; set; }
|
||||||
public ICommand PublishLocationCommand { get; set; }
|
public ICommand PublishLocationCommand { get; set; }
|
||||||
public ICommand DisplayAboutCommand { get; set; }
|
public ICommand DisplayAboutCommand { get; set; }
|
||||||
public ICommand NavigateToSettingsCommand { get; set; }
|
public ICommand NavigateToSettingsCommand { get; set; }
|
||||||
@@ -317,6 +440,9 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
public ICommand SaveMySettingsCommand { get; set; }
|
public ICommand SaveMySettingsCommand { get; set; }
|
||||||
public ICommand CancelMySettingsCommand { get; set; }
|
public ICommand CancelMySettingsCommand { get; set; }
|
||||||
public ICommand ChoosePhotoCommand { get; set; }
|
public ICommand ChoosePhotoCommand { get; set; }
|
||||||
|
public ICommand CropSaveCommand { get; set; }
|
||||||
|
public ICommand CropCancelCommand { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -408,7 +534,6 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldValue = _PushPins;
|
|
||||||
_PushPins = value;
|
_PushPins = value;
|
||||||
|
|
||||||
// Update bindings, no broadcast
|
// Update bindings, no broadcast
|
||||||
@@ -420,6 +545,35 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="MapZoom" /> property's name.
|
||||||
|
/// </summary>
|
||||||
|
public const string MapZoomPropertyName = "MapZoom";
|
||||||
|
|
||||||
|
private int _mapZoom = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the MapZoom property.
|
||||||
|
/// </summary>
|
||||||
|
public int MapZoom
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _mapZoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_mapZoom == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_mapZoom = value;
|
||||||
|
|
||||||
|
// Update bindings, no broadcast
|
||||||
|
RaisePropertyChanged(MapZoomPropertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -487,5 +641,6 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
RaisePropertyChanged(IsBusyPropertyName);
|
RaisePropertyChanged(IsBusyPropertyName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,39 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private string _pinUserName;
|
||||||
|
|
||||||
|
public string PinUserName
|
||||||
|
{
|
||||||
|
get { return _pinUserName; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_pinUserName != value)
|
||||||
|
{
|
||||||
|
_pinUserName = value;
|
||||||
|
OnPropertyChanged("PinUserName");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private string _pinImageUrl;
|
||||||
|
|
||||||
|
public string PinImageUrl
|
||||||
|
{
|
||||||
|
get { return _pinImageUrl; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_pinImageUrl != value)
|
||||||
|
{
|
||||||
|
_pinImageUrl = value;
|
||||||
|
OnPropertyChanged("PinImageUrl");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
public void OnPropertyChanged(string propertyName)
|
public void OnPropertyChanged(string propertyName)
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
{
|
{
|
||||||
public class ViewModelBase : GalaSoft.MvvmLight.ViewModelBase
|
public class ViewModelBase : GalaSoft.MvvmLight.ViewModelBase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public bool IsLoaded { get; set; }
|
||||||
|
|
||||||
private object context;
|
private object context;
|
||||||
public object Context
|
public object Context
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using MyFriendsAround.WP7.Helpers.Navigation;
|
using MyFriendsAround.WP7.Helpers.Navigation;
|
||||||
|
using NetworkDetection;
|
||||||
|
|
||||||
namespace MyFriendsAround.WP7.ViewModel
|
namespace MyFriendsAround.WP7.ViewModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<phone:PhoneApplicationPage x:Class="MyFriendsAround.WP7.Views.CropPage"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||||
|
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:binding="clr-namespace:Coding4Fun.Phone.Controls.Binding;assembly=Coding4Fun.Phone.Controls" xmlns:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7" FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||||
|
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||||
|
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||||
|
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||||
|
DataContext="{Binding Main, Source={StaticResource Locator}}"
|
||||||
|
mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
|
||||||
|
shell:SystemTray.IsVisible="True">
|
||||||
|
|
||||||
|
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||||
|
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!--TitlePanel contains the name of the application and page title-->
|
||||||
|
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,12,0,12">
|
||||||
|
<TextBlock x:Name="ApplicationTitle" Text="{Binding Path=ApplicationTitle}" Style="{StaticResource PhoneTextNormalStyle}"
|
||||||
|
Foreground="{StaticResource PhoneAccentBrush}" />
|
||||||
|
<TextBlock x:Name="PageTitle"
|
||||||
|
Text="{Binding Path=PageNameCropping}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Grid x:Name="ImageContainer"
|
||||||
|
Background="Transparent"
|
||||||
|
Grid.Row="1" HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Margin="0"
|
||||||
|
Name="image1"
|
||||||
|
Stretch="Uniform"
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<phone:PhoneApplicationPage.ApplicationBar>
|
||||||
|
<shell:ApplicationBar IsVisible="True" Opacity="0.8"
|
||||||
|
IsMenuEnabled="True">
|
||||||
|
<shell:ApplicationBarIconButton IconUri="/Toolkit.Content/ApplicationBar.Check.png"
|
||||||
|
Text="Accept"
|
||||||
|
Click="Accept_Click" />
|
||||||
|
<shell:ApplicationBarIconButton IconUri="/Toolkit.Content/ApplicationBar.Cancel.png"
|
||||||
|
Text="Cancel"
|
||||||
|
Click="Cancel_Click" />
|
||||||
|
</shell:ApplicationBar>
|
||||||
|
</phone:PhoneApplicationPage.ApplicationBar>
|
||||||
|
|
||||||
|
</phone:PhoneApplicationPage>
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Microsoft.Phone;
|
||||||
|
using Microsoft.Phone.Controls;
|
||||||
|
using Microsoft.Phone.Tasks;
|
||||||
|
using MyFriendsAround.WP7.Utils;
|
||||||
|
using MyFriendsAround.WP7.ViewModel;
|
||||||
|
using NetworkDetection;
|
||||||
|
|
||||||
|
namespace MyFriendsAround.WP7.Views
|
||||||
|
{
|
||||||
|
public partial class CropPage : PhoneApplicationPage
|
||||||
|
{
|
||||||
|
private int imageSize = 200;
|
||||||
|
|
||||||
|
public CropPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.Loaded += new RoutedEventHandler(CropPage_Loaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
//private BitmapImage imageSrc;
|
||||||
|
void CropPage_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!NetworkDetector.Instance.GetZuneStatus())
|
||||||
|
{
|
||||||
|
PhotoChooserTask task = new PhotoChooserTask();
|
||||||
|
task.Show();
|
||||||
|
task.Completed += new EventHandler<PhotoResult>(task_Completed);
|
||||||
|
|
||||||
|
//TEST
|
||||||
|
//imageSrc = new BitmapImage(new Uri("/icons/Penguins.jpg", UriKind.RelativeOrAbsolute));
|
||||||
|
//image1.Source = imageSrc;
|
||||||
|
|
||||||
|
SetPicture();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NavigateBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NavigateBack()
|
||||||
|
{
|
||||||
|
Container.Instance.Resolve<MainViewModel>("MainViewModel").CropCancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void task_Completed(object sender, PhotoResult e)
|
||||||
|
{
|
||||||
|
if (e.TaskResult == TaskResult.OK)
|
||||||
|
{
|
||||||
|
BitmapImage image = new BitmapImage();
|
||||||
|
image.SetSource(e.ChosenPhoto);
|
||||||
|
//
|
||||||
|
image1.Width = this.Width/2;
|
||||||
|
image1.Height = image1.Width*image.PixelHeight/image.PixelWidth;
|
||||||
|
image1.Source = image;
|
||||||
|
|
||||||
|
SetPicture();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NavigateBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Rectangle rect;
|
||||||
|
void SetPicture()
|
||||||
|
{
|
||||||
|
rect = new Rectangle();
|
||||||
|
rect.Opacity = .5;
|
||||||
|
rect.Fill = new SolidColorBrush(Colors.White);
|
||||||
|
rect.Height = imageSize;
|
||||||
|
rect.MaxHeight = imageSize;
|
||||||
|
rect.MaxWidth = imageSize;
|
||||||
|
rect.Width = imageSize;
|
||||||
|
rect.Stroke = new SolidColorBrush(Colors.Red);
|
||||||
|
rect.StrokeThickness = 2;
|
||||||
|
rect.Margin = new Thickness(0);
|
||||||
|
ImageContainer.ManipulationDelta += new EventHandler<ManipulationDeltaEventArgs>(rect_ManipulationDelta);
|
||||||
|
|
||||||
|
ImageContainer.Children.Add(rect);
|
||||||
|
ImageContainer.Height = this.ActualWidth;
|
||||||
|
ImageContainer.Width = this.ActualWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
int trX = 0;
|
||||||
|
int trY = 0;
|
||||||
|
double scale = 1;
|
||||||
|
|
||||||
|
void rect_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (e.DeltaManipulation.Scale.X > 0 && e.DeltaManipulation.Scale.Y > 0)
|
||||||
|
{
|
||||||
|
scale = scale*(e.DeltaManipulation.Scale.X + e.DeltaManipulation.Scale.Y)/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
trX += (int) ((double) e.DeltaManipulation.Translation.X /scale);
|
||||||
|
trY += (int) ((int) e.DeltaManipulation.Translation.Y /scale);
|
||||||
|
e.Handled = true;
|
||||||
|
|
||||||
|
TransformGroup tg = new TransformGroup();
|
||||||
|
|
||||||
|
ScaleTransform st = new ScaleTransform();
|
||||||
|
st.CenterX = ImageContainer.ActualWidth / 2 - trX;
|
||||||
|
st.CenterY = ImageContainer.ActualHeight / 2 - trY;
|
||||||
|
st.ScaleX = scale;
|
||||||
|
st.ScaleY = scale;
|
||||||
|
tg.Children.Add(st);
|
||||||
|
|
||||||
|
TranslateTransform tr = new TranslateTransform();
|
||||||
|
tr.X = trX;
|
||||||
|
tr.Y = trY;
|
||||||
|
tg.Children.Add(tr);
|
||||||
|
|
||||||
|
|
||||||
|
image1.RenderTransform = tg;
|
||||||
|
|
||||||
|
//croppingRectangle
|
||||||
|
GeneralTransform gt = image1.TransformToVisual(ImageContainer);
|
||||||
|
Point p = gt.Transform(new Point( 0, 0));
|
||||||
|
RectangleGeometry geo = new RectangleGeometry();
|
||||||
|
geo.Rect = new Rect(-p.X / scale, -p.Y / scale, ImageContainer.ActualWidth / scale, ImageContainer.ActualHeight / scale);
|
||||||
|
image1.Clip = geo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Save()
|
||||||
|
{
|
||||||
|
WriteBitmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteBitmap()
|
||||||
|
{
|
||||||
|
Rectangle r = (Rectangle)(from c in ImageContainer.Children where c.Opacity == .5 select c).First();
|
||||||
|
GeneralTransform gt = r.TransformToVisual(image1);
|
||||||
|
//
|
||||||
|
WriteableBitmap wbm = new WriteableBitmap(imageSize, imageSize);
|
||||||
|
wbm.Render(image1, gt.Inverse as Transform);
|
||||||
|
wbm.Invalidate();
|
||||||
|
|
||||||
|
using (MemoryStream stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
wbm.SaveJpeg(stream, imageSize, imageSize, 0, 100);
|
||||||
|
//
|
||||||
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
byte[] _imageBytes = new byte[stream.Length];
|
||||||
|
stream.Read(_imageBytes, 0, _imageBytes.Length);
|
||||||
|
//save
|
||||||
|
IsolatedStorageHelper.SaveToLocalStorage("myphoto.jpg", "profiles", _imageBytes);
|
||||||
|
//
|
||||||
|
Container.Instance.Resolve<MainViewModel>("MainViewModel").MyPicture = wbm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Accept_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Save();
|
||||||
|
NavigateBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Cancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
NavigateBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,13 +36,38 @@
|
|||||||
<Image Source="{Binding PinSource}" />
|
<Image Source="{Binding PinSource}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
<ControlTemplate x:Key="PushpinControlTemplate2"
|
||||||
|
TargetType="my:Pushpin">
|
||||||
|
<Grid x:Name="ContentGrid">
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<Grid Background="{TemplateBinding Background}"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
MinHeight="10"
|
||||||
|
MinWidth="29">
|
||||||
|
<Image x:Name="imgFriend"
|
||||||
|
Source="{Binding PinImageUrl, Mode=OneWay}"
|
||||||
|
Margin="2, 2, 2, 24" Width="48" Height="48"
|
||||||
|
Stretch="Fill">
|
||||||
|
</Image>
|
||||||
|
<TextBlock HorizontalAlignment="Left" Text="{Binding PinUserName}" VerticalAlignment="Bottom"
|
||||||
|
Margin="1" Width="48" Height="24" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Polygon Fill="{TemplateBinding Background}"
|
||||||
|
Points="0,0 29,0 0,29"
|
||||||
|
Width="29"
|
||||||
|
Height="29"
|
||||||
|
HorizontalAlignment="Left" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
</phone:PhoneApplicationPage.Resources>
|
</phone:PhoneApplicationPage.Resources>
|
||||||
|
|
||||||
<!--<i:Interaction.Triggers>
|
<i:Interaction.Triggers>
|
||||||
<i:EventTrigger EventName="Loaded">
|
<i:EventTrigger EventName="Loaded">
|
||||||
<cmd:EventToCommand Command="{Binding RefreshFriendsCommand}" />
|
<cmd:EventToCommand Command="{Binding MainLoadCommand}" />
|
||||||
</i:EventTrigger>
|
</i:EventTrigger>
|
||||||
</i:Interaction.Triggers>-->
|
</i:Interaction.Triggers>
|
||||||
|
|
||||||
<Grid x:Name="LayoutRoot"
|
<Grid x:Name="LayoutRoot"
|
||||||
Background="Transparent">
|
Background="Transparent">
|
||||||
@@ -71,28 +96,24 @@
|
|||||||
</Button>-->
|
</Button>-->
|
||||||
|
|
||||||
<my:Map x:Name="map"
|
<my:Map x:Name="map"
|
||||||
HorizontalAlignment="Stretch"
|
CredentialsProvider="AkCiPfQt9YM0cCkZlltdR3mnFQRkV41l4f-eXFmf3qcBBhBC-EkvD8MuazOkMnE_"
|
||||||
|
HorizontalAlignment="Stretch" ZoomBarVisibility="Visible"
|
||||||
Margin="6,0,6,0"
|
Margin="6,0,6,0"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Center="{Binding Path=MapCenter, Mode=TwoWay}">
|
Center="{Binding Path=MapCenter, Mode=TwoWay}"
|
||||||
|
ZoomLevel="{Binding Path=MapZoom, Mode=TwoWay}"
|
||||||
|
>
|
||||||
<my:MapItemsControl ItemsSource="{Binding PushPins}">
|
<my:MapItemsControl ItemsSource="{Binding PushPins}">
|
||||||
<my:MapItemsControl.ItemTemplate>
|
<my:MapItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<my:Pushpin Location="{Binding Location}"
|
<my:Pushpin Location="{Binding Location}"
|
||||||
Template="{StaticResource PushpinControlTemplate1}">
|
Background="{StaticResource PhoneAccentBrush}"
|
||||||
|
Template="{StaticResource PushpinControlTemplate2}">
|
||||||
</my:Pushpin>
|
</my:Pushpin>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</my:MapItemsControl.ItemTemplate>
|
</my:MapItemsControl.ItemTemplate>
|
||||||
</my:MapItemsControl>
|
</my:MapItemsControl>
|
||||||
</my:Map>
|
</my:Map>
|
||||||
<toolkit:PerformanceProgressBar HorizontalAlignment="Left"
|
|
||||||
Margin="0,-151,0,0"
|
|
||||||
Name="performanceProgressBar1"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
Height="18"
|
|
||||||
Width="480"
|
|
||||||
ActualIsIndeterminate="{Binding Path=IsBusy}"
|
|
||||||
IsIndeterminate="{Binding Path=IsBusy}" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
@@ -107,7 +128,7 @@
|
|||||||
<TextBlock x:Name="ApplicationTitle"
|
<TextBlock x:Name="ApplicationTitle"
|
||||||
Margin="12, 12, 0, 0"
|
Margin="12, 12, 0, 0"
|
||||||
Text="{Binding ApplicationTitle}"
|
Text="{Binding ApplicationTitle}"
|
||||||
Foreground="#00fffc"
|
Foreground="{StaticResource PhoneAccentBrush}"
|
||||||
Style="{StaticResource PhoneTextNormalStyle}" />
|
Style="{StaticResource PhoneTextNormalStyle}" />
|
||||||
<Grid Margin="0,6,6,6"
|
<Grid Margin="0,6,6,6"
|
||||||
Height="80">
|
Height="80">
|
||||||
@@ -118,9 +139,9 @@
|
|||||||
Opacity="1"
|
Opacity="1"
|
||||||
>
|
>
|
||||||
<Image x:Name="imgMine"
|
<Image x:Name="imgMine"
|
||||||
Source="{Binding MyPicture}">
|
Source="{Binding MyPicture, Mode=OneWay}" Margin="0" Stretch="Fill" >
|
||||||
</Image>
|
</Image>
|
||||||
<Border Background="#00fffc"
|
<Border Background="{StaticResource PhoneAccentBrush}"
|
||||||
Width="80"
|
Width="80"
|
||||||
Height="25"
|
Height="25"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
@@ -133,10 +154,18 @@
|
|||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Margin="2"
|
Margin="2"
|
||||||
Text="{Binding MyName}" />
|
Text="{Binding MyName, Mode=OneWay}" />
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<toolkit:PerformanceProgressBar HorizontalAlignment="Left"
|
||||||
|
Margin="0,0,0,0"
|
||||||
|
Name="performanceProgressBar1"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Height="18"
|
||||||
|
Width="480"
|
||||||
|
ActualIsIndeterminate="{Binding Path=IsBusy}"
|
||||||
|
IsIndeterminate="{Binding Path=IsBusy}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -13,6 +13,12 @@
|
|||||||
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
|
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
|
||||||
shell:SystemTray.IsVisible="True">
|
shell:SystemTray.IsVisible="True">
|
||||||
|
|
||||||
|
<i:Interaction.Triggers>
|
||||||
|
<i:EventTrigger EventName="Loaded">
|
||||||
|
<cmd:EventToCommand Command="{Binding MainLoadCommand}" />
|
||||||
|
</i:EventTrigger>
|
||||||
|
</i:Interaction.Triggers>
|
||||||
|
|
||||||
<!--LayoutRoot is the root grid where all page content is placed-->
|
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@@ -21,8 +27,9 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!--TitlePanel contains the name of the application and page title-->
|
<!--TitlePanel contains the name of the application and page title-->
|
||||||
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
|
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,12,0,12">
|
||||||
<TextBlock x:Name="ApplicationTitle" Text="{Binding Path=ApplicationTitle}" Style="{StaticResource PhoneTextNormalStyle}"/>
|
<TextBlock x:Name="ApplicationTitle" Text="{Binding Path=ApplicationTitle}" Style="{StaticResource PhoneTextNormalStyle}"
|
||||||
|
Foreground="{StaticResource PhoneAccentBrush}" />
|
||||||
<TextBlock x:Name="PageTitle"
|
<TextBlock x:Name="PageTitle"
|
||||||
Text="{Binding Path=PageNameSettings}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
|
Text="{Binding Path=PageNameSettings}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -35,7 +42,8 @@
|
|||||||
Margin="6,0,0,6"
|
Margin="6,0,0,6"
|
||||||
>
|
>
|
||||||
<TextBlock Text="My Name"
|
<TextBlock Text="My Name"
|
||||||
Style="{StaticResource PhoneTextTitle3Style}" />
|
Style="{StaticResource PhoneTextTitle3Style}"
|
||||||
|
/>
|
||||||
<TextBox Height="67"
|
<TextBox Height="67"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Name="txtMyName"
|
Name="txtMyName"
|
||||||
@@ -48,14 +56,15 @@
|
|||||||
Margin="0, 24, 0, 24"
|
Margin="0, 24, 0, 24"
|
||||||
Width="200"
|
Width="200"
|
||||||
Height="200"
|
Height="200"
|
||||||
Background="#00fffc"
|
Background="{StaticResource PhoneAccentBrush}"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
Padding="0"
|
Padding="0"
|
||||||
>
|
>
|
||||||
<Image x:Name="myPicture"
|
<Image x:Name="myPicture"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Margin="3"
|
Stretch="Uniform"
|
||||||
|
Margin="1"
|
||||||
Source="{Binding MyPicture}"></Image>
|
Source="{Binding MyPicture}"></Image>
|
||||||
<i:Interaction.Triggers>
|
<i:Interaction.Triggers>
|
||||||
<i:EventTrigger EventName="Click">
|
<i:EventTrigger EventName="Click">
|
||||||
|
|||||||
|
After Width: | Height: | Size: 760 KiB |
@@ -41,6 +41,13 @@ namespace MyFriendsAround.Web
|
|||||||
|
|
||||||
protected void Application_Start()
|
protected void Application_Start()
|
||||||
{
|
{
|
||||||
|
//setup azure
|
||||||
|
Microsoft.WindowsAzure.CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
|
||||||
|
{
|
||||||
|
configSetter(Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(configName));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
AreaRegistration.RegisterAllAreas();
|
AreaRegistration.RegisterAllAreas();
|
||||||
|
|
||||||
RegisterGlobalFilters(GlobalFilters.Filters);
|
RegisterGlobalFilters(GlobalFilters.Filters);
|
||||||
|
|||||||
@@ -56,6 +56,9 @@
|
|||||||
<HintPath>..\Libs\Sql\Microsoft.SqlServer.Types.dll</HintPath>
|
<HintPath>..\Libs\Sql\Microsoft.SqlServer.Types.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||||
|
<Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||||
|
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||||
<Reference Include="System.Data.Entity" />
|
<Reference Include="System.Data.Entity" />
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="System.Security" />
|
<Reference Include="System.Security" />
|
||||||
@@ -97,6 +100,7 @@
|
|||||||
<DependentUpon>myfriends.svc</DependentUpon>
|
<DependentUpon>myfriends.svc</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="WebRole.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Global.asax" />
|
<Content Include="Global.asax" />
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
<add key="ClientValidationEnabled" value="true" />
|
<add key="ClientValidationEnabled" value="true" />
|
||||||
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
|
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
|
||||||
<add key="takeTopFriends" value="20" />
|
<add key="takeTopFriends" value="20" />
|
||||||
|
<add key="azureProfilesContainer" value="profiles"/>
|
||||||
|
<add key="profileImageFormat" value="profile_{0}.jpg"/>
|
||||||
</appSettings>
|
</appSettings>
|
||||||
|
|
||||||
<system.web>
|
<system.web>
|
||||||
@@ -98,5 +100,12 @@
|
|||||||
</behavior>
|
</behavior>
|
||||||
</serviceBehaviors>
|
</serviceBehaviors>
|
||||||
</behaviors>
|
</behaviors>
|
||||||
|
<bindings>
|
||||||
|
<webHttpBinding>
|
||||||
|
<binding maxBufferSize="965536" maxBufferPoolSize="965536" maxReceivedMessageSize="965536">
|
||||||
|
<readerQuotas maxStringContentLength="965536"/>
|
||||||
|
</binding>
|
||||||
|
</webHttpBinding>
|
||||||
|
</bindings>
|
||||||
</system.serviceModel>
|
</system.serviceModel>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.WindowsAzure;
|
||||||
|
using Microsoft.WindowsAzure.Diagnostics;
|
||||||
|
using Microsoft.WindowsAzure.ServiceRuntime;
|
||||||
|
|
||||||
|
namespace MyFriendsAround.Web
|
||||||
|
{
|
||||||
|
public class WebRole : RoleEntryPoint
|
||||||
|
{
|
||||||
|
private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool OnStart()
|
||||||
|
{
|
||||||
|
DiagnosticMonitor.Start("DataConnectionString");
|
||||||
|
|
||||||
|
// For information on handling configuration changes
|
||||||
|
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
|
||||||
|
|
||||||
|
|
||||||
|
#region Setup CloudStorageAccount Configuration Setting Publisher
|
||||||
|
|
||||||
|
// This code sets up a handler to update CloudStorageAccount instances when their corresponding
|
||||||
|
// configuration settings change in the service configuration file.
|
||||||
|
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
|
||||||
|
{
|
||||||
|
// Provide the configSetter with the initial value
|
||||||
|
configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
|
||||||
|
|
||||||
|
RoleEnvironment.Changed += (sender, arg) =>
|
||||||
|
{
|
||||||
|
if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
|
||||||
|
.Any((change) => (change.ConfigurationSettingName == configName)))
|
||||||
|
{
|
||||||
|
// The corresponding configuration setting has changed, propagate the value
|
||||||
|
if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
|
||||||
|
{
|
||||||
|
// In this case, the change to the storage account credentials in the
|
||||||
|
// service configuration is significant enough that the role needs to be
|
||||||
|
// recycled in order to use the latest settings. (for example, the
|
||||||
|
// endpoint has changed)
|
||||||
|
RoleEnvironment.RequestRecycle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// For information on handling configuration changes
|
||||||
|
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
|
||||||
|
RoleEnvironment.Changing += RoleEnvironmentChanging;
|
||||||
|
|
||||||
|
|
||||||
|
return base.OnStart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,7 +30,7 @@ namespace MyFriendsAround.Web
|
|||||||
|
|
||||||
[OperationContract]
|
[OperationContract]
|
||||||
[WebGet(ResponseFormat = WebMessageFormat.Json)]
|
[WebGet(ResponseFormat = WebMessageFormat.Json)]
|
||||||
public List<Friend> GetFriends(int skip)
|
public List<Friend> GetFriendsSkip(int skip)
|
||||||
{
|
{
|
||||||
int take = Convert.ToInt32(WebConfigurationManager.AppSettings["takeTopFriends"]);
|
int take = Convert.ToInt32(WebConfigurationManager.AppSettings["takeTopFriends"]);
|
||||||
return FriendsRepository.GetFriends(skip, take);
|
return FriendsRepository.GetFriends(skip, take);
|
||||||
@@ -46,9 +46,9 @@ namespace MyFriendsAround.Web
|
|||||||
|
|
||||||
[OperationContract]
|
[OperationContract]
|
||||||
[WebInvoke(ResponseFormat = WebMessageFormat.Json, Method = "POST")]
|
[WebInvoke(ResponseFormat = WebMessageFormat.Json, Method = "POST")]
|
||||||
public bool UpdatePicture(string userId, byte[] userPicture)
|
public bool UpdatePicture(PictureInfo pictureInfo)
|
||||||
{
|
{
|
||||||
return FriendsRepository.UpdatePicture(userId, userPicture);
|
return FriendsRepository.UpdatePicture(pictureInfo.UserId, Convert.FromBase64String(pictureInfo.Picture));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicroIoc.Core", "Libs\Micro
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{CC5FD16D-436D-48AD-A40C-5A424C6E3E79}") = "MyFriendsAroundWindowsAzure", "MyFriendsAroundWindowsAzure\MyFriendsAroundWindowsAzure.ccproj", "{C656965D-5A6E-4BD4-9945-9C906B89128D}"
|
Project("{CC5FD16D-436D-48AD-A40C-5A424C6E3E79}") = "MyFriendsAroundWindowsAzure", "MyFriendsAroundWindowsAzure\MyFriendsAroundWindowsAzure.ccproj", "{C656965D-5A6E-4BD4-9945-9C906B89128D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkNamespaces", "Libs\NetworkAwarenessTest\NetworkNamespaces\NetworkNamespaces.csproj", "{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkDetection", "Libs\NetworkAwarenessTest\NetworkDetection\NetworkDetection.csproj", "{794D79F0-E898-460D-BDB5-49FED553E0D5}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -256,6 +260,48 @@ Global
|
|||||||
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|Mixed Platforms.ActiveCfg = Release|Any CPU
|
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|Mixed Platforms.Build.0 = Release|Any CPU
|
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|x86.ActiveCfg = Release|Any CPU
|
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Debug|Mixed Platforms.Deploy.0 = Debug|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Release|Mixed Platforms.Deploy.0 = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Tests|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Tests|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Tests|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Tests|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Tests|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Tests|Mixed Platforms.Deploy.0 = Release|Any CPU
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF}.Tests|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Debug|Mixed Platforms.Deploy.0 = Debug|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Release|Mixed Platforms.Deploy.0 = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Tests|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Tests|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Tests|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Tests|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Tests|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Tests|Mixed Platforms.Deploy.0 = Release|Any CPU
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5}.Tests|x86.ActiveCfg = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -266,5 +312,7 @@ Global
|
|||||||
{BF7316A8-A2C5-4176-8D7F-672AD12F474D} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
||||||
{B55A0F90-2B5A-4C4B-88F4-013AA1629866} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
{B55A0F90-2B5A-4C4B-88F4-013AA1629866} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
||||||
{23F63AE9-A436-4B27-9113-4142C09ADD08} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
{23F63AE9-A436-4B27-9113-4142C09ADD08} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
||||||
|
{41A5C85F-7E30-418B-BAD2-AB2F40FF22CF} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
||||||
|
{794D79F0-E898-460D-BDB5-49FED553E0D5} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<Instances count="1" />
|
<Instances count="1" />
|
||||||
<ConfigurationSettings>
|
<ConfigurationSettings>
|
||||||
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myfriendsaround;AccountKey=q6VfarAitAElTN+u0GD/F3kS3f+CGFdNNoJnZltTbFJnv7VEDZHwWX99JG6ZEUzQNjtdL9uLg8uske+ls8/uPg==" />
|
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myfriendsaround;AccountKey=q6VfarAitAElTN+u0GD/F3kS3f+CGFdNNoJnZltTbFJnv7VEDZHwWX99JG6ZEUzQNjtdL9uLg8uske+ls8/uPg==" />
|
||||||
|
<Setting name="DataConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myfriendsaround;AccountKey=q6VfarAitAElTN+u0GD/F3kS3f+CGFdNNoJnZltTbFJnv7VEDZHwWX99JG6ZEUzQNjtdL9uLg8uske+ls8/uPg==" />
|
||||||
</ConfigurationSettings>
|
</ConfigurationSettings>
|
||||||
</Role>
|
</Role>
|
||||||
</ServiceConfiguration>
|
</ServiceConfiguration>
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
<Import moduleName="Diagnostics" />
|
<Import moduleName="Diagnostics" />
|
||||||
</Imports>
|
</Imports>
|
||||||
<ConfigurationSettings>
|
<ConfigurationSettings>
|
||||||
|
<Setting name="DataConnectionString" />
|
||||||
</ConfigurationSettings>
|
</ConfigurationSettings>
|
||||||
</WebRole>
|
</WebRole>
|
||||||
</ServiceDefinition>
|
</ServiceDefinition>
|
||||||