init commit

This commit is contained in:
2011-03-23 11:58:56 +02:00
commit 356079222a
315 changed files with 71380 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
<Application x:Class="MyFriendsAround.WP7.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"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:vm="clr-namespace:MyFriendsAround.WP7.ViewModel">
<!--Application Resources-->
<Application.Resources>
<vm:ViewModelLocator x:Key="Locator"
d:IsDataSource="True" />
</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>
+120
View File
@@ -0,0 +1,120 @@
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;
using MyFriendsAround.WP7.ViewModel;
namespace MyFriendsAround.WP7
{
public partial class App : Application
{
// Easy access to the root frame
public PhoneApplicationFrame RootFrame { get; private set; }
// Constructor
public App()
{
// Global handler for uncaught exceptions.
// Note that exceptions thrown by ApplicationBarItem.Click will not get caught here.
UnhandledException += Application_UnhandledException;
// 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)
{
ViewModelLocator.Cleanup();
}
// Code to execute if a navigation fails
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
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

+104
View File
@@ -0,0 +1,104 @@
<phone:PhoneApplicationPage x:Class="MyFriendsAround.WP7.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" 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"
mc:Ignorable="d"
d:DesignWidth="480"
d:DesignHeight="768"
shell:SystemTray.IsVisible="True"
DataContext="{Binding Main, Source={StaticResource Locator}}"
xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps">
<!--LayoutRoot contains the root grid where all other page content is placed-->
<phone:PhoneApplicationPage.Resources>
<ControlTemplate x:Key="PushpinControlTemplate1"
TargetType="my:Pushpin">
<Grid Height="32"
Width="32" Margin="-16,-16,0,0">
<Ellipse Fill="#FFA3A3BE"
Stroke="Black"
Margin="0" />
<Image Source="{Binding PinSource}" />
</Grid>
</ControlTemplate>
</phone:PhoneApplicationPage.Resources>
<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="24,24,0,12">
<TextBlock x:Name="ApplicationTitle"
Text="{Binding ApplicationTitle}"
Style="{StaticResource PhoneTextNormalStyle}" />
<TextBlock x:Name="PageTitle" Text="{Binding PageName}" Margin="-3,-8,0,0" Style="{StaticResource PhoneTextTitle1Style}" />
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentGrid"
Grid.Row="1">
<TextBlock Text="{Binding Welcome}"
Style="{StaticResource PhoneTextNormalStyle}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="40" />
<Button Content="Publish" Height="72" HorizontalAlignment="Left" Margin="6,539,0,0" Name="btnPublishLocation" VerticalAlignment="Top" Width="468">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cmd:EventToCommand Command="{Binding PublishLocationCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<TextBox Height="72" HorizontalAlignment="Left" Margin="6,471,0,0" Name="txtMyName" Text="{Binding Path=MyName, Mode=TwoWay}" VerticalAlignment="Top" Width="468" />
<my:Map x:Name="map"
Height="459"
HorizontalAlignment="Left"
Margin="6,6,0,0"
VerticalAlignment="Top"
Width="468"
Center="{Binding Path=MapCenter, Mode=TwoWay}">
<my:MapItemsControl ItemsSource="{Binding PushPins}">
<my:MapItemsControl.ItemTemplate>
<DataTemplate>
<my:Pushpin Location="{Binding Location}"
Template="{StaticResource PushpinControlTemplate1}">
</my:Pushpin>
</DataTemplate>
</my:MapItemsControl.ItemTemplate>
</my:MapItemsControl>
</my:Map>
</Grid>
</Grid>
<!-- Sample code showing usage of ApplicationBar
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton x:Name="appbar_button1" IconUri="/Images/appbar_button1.png" Text="Button 1"></shell:ApplicationBarIconButton>
<shell:ApplicationBarIconButton x:Name="appbar_button2" IconUri="/Images/appbar_button2.png" Text="Button 2"></shell:ApplicationBarIconButton>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem x:Name="menuItem1" Text="MenuItem 1"></shell:ApplicationBarMenuItem>
<shell:ApplicationBarMenuItem x:Name="menuItem2" Text="MenuItem 2"></shell:ApplicationBarMenuItem>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
-->
</phone:PhoneApplicationPage>
+58
View File
@@ -0,0 +1,58 @@
using System;
using System.Windows;
using GalaSoft.MvvmLight.Messaging;
using GalaSoft.MvvmLight.Threading;
using Microsoft.Phone.Controls;
using Microsoft.Silverlight.Testing;
namespace MyFriendsAround.WP7
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
DispatcherHelper.Initialize();
InitializeComponent();
Messenger.Default.Register<DialogMessage>(
this,
msg =>
{
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
var result = MessageBox.Show(
msg.Content,
msg.Caption,
msg.Button);
// Send callback
msg.ProcessCallback(result);
});
});
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
#if TESTING
DoTests();
#endif
}
private void DoTests()
{
var testPage = UnitTestSystem.CreateTestPage();
IMobileTestPage imobileTPage = testPage as IMobileTestPage;
BackKeyPress += (s, arg) =>
{
bool navigateBackSuccessfull = imobileTPage.NavigateBack(); arg.Cancel = navigateBackSuccessfull;
}; (Application.Current.RootVisual as PhoneApplicationFrame).Content = testPage;
}
}
}
@@ -0,0 +1,178 @@
<?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>{B690843F-9163-4292-9450-8855AAA3FD5B}</ProjectGuid>
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MyFriendsAround.WP7</RootNamespace>
<AssemblyName>MyFriendsAround.WP7</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>MyFriendsAround.WP7.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>MyFriendsAround.WP7.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</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Tests|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Tests\</OutputPath>
<DefineConstants>TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE;TESTING</DefineConstants>
<NoStdLib>true</NoStdLib>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisLogFile>Bin\Debug\MyFriendsAround.WP7.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
</PropertyGroup>
<ItemGroup>
<Reference Include="GalaSoft.MvvmLight.WP7">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WP7\GalaSoft.MvvmLight.WP7.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras.WP7">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WP7\GalaSoft.MvvmLight.Extras.WP7.dll</HintPath>
</Reference>
<Reference Include="Hammock.WindowsPhone">
<HintPath>..\Libs\Hammock-Binaries\.NET 4.0\Windows Phone 7\Hammock.WindowsPhone.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib.WindowsPhone">
<HintPath>..\Libs\Hammock-Binaries\.NET 4.0\Windows Phone 7\ICSharpCode.SharpZipLib.WindowsPhone.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Phone.Controls.Maps, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e" />
<Reference Include="Microsoft.Phone.Controls.Toolkit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b772ad94eb9ca604, processorArchitecture=MSIL">
<HintPath>..\packages\SilverlightToolkitWP.4.2011.2.1\lib\sl4\Microsoft.Phone.Controls.Toolkit.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Silverlight.Testing">
<HintPath>..\Libs\SL3_UTF_May\Microsoft.Silverlight.Testing.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight">
<HintPath>..\Libs\SL3_UTF_May\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json.WindowsPhone, Version=4.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\Libs\Json40r1\WindowsPhone\Newtonsoft.Json.WindowsPhone.dll</HintPath>
</Reference>
<Reference Include="System.Device" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Windows.Interactivity">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WP7\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Phone" />
<Reference Include="Microsoft.Phone.Interop" />
<Reference Include="System.Windows" />
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\MyFriendsAround.Common\Entities\Friend.cs">
<Link>Entities\Friend.cs</Link>
</Compile>
<Compile Include="..\MyFriendsAround.Common\Entities\FriendExt.cs">
<Link>Entities\FriendExt.cs</Link>
</Compile>
<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" />
<Compile Include="Service\FriendsListEventArgs.cs" />
<Compile Include="Service\PublishLocationEventArgs.cs" />
<Compile Include="Service\ServiceAgent.cs" />
<Compile Include="Tests\Tests1.cs" />
<Compile Include="Utils\Identification.cs" />
<Compile Include="Utils\SerializationHelper.cs" />
<Compile Include="ViewModel\MainViewModel.cs" />
<Compile Include="ViewModel\PushPinModel.cs" />
<Compile Include="ViewModel\ViewModelLocator.cs" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<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="README_FIRST.txt" />
<Content Include="SplashScreenImage.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="Toolkit.Content\ApplicationBar.Cancel.png" />
<Resource Include="Toolkit.Content\ApplicationBar.Check.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Model\" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</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("MyFriendsAround.WP7")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyFriendsAround.WP7")]
[assembly: AssemblyCopyright("Copyright © 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("a0a54828-3abd-482f-a7ef-2f416a2a4ebb")]
// 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="{ac5b5d62-573c-4134-b290-0ad4f678ad7f}" Title="MyFriendsAround.WP7" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="MyFriendsAround.WP7 author" Description="Sample description" Publisher="MyFriendsAround.WP7 publisher">
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_LOCATION" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_MICROPHONE" />
<Capability Name="ID_CAP_MEDIALIB" />
<Capability Name="ID_CAP_GAMERSERVICES" />
<Capability Name="ID_CAP_PHONEDIALER" />
<Capability Name="ID_CAP_PUSH_NOTIFICATION" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
<Capability Name="ID_CAP_IDENTITY_DEVICE"/>
<Capability Name="ID_CAP_IDENTITY_USER" />
</Capabilities>
<Tasks>
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
</Tasks>
<Tokens>
<PrimaryToken TokenID="MyFriendsAround.WP7Token" TaskName="_default">
<TemplateType5>
<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
<Count>0</Count>
<Title>MyFriendsAround.WP7</Title>
</TemplateType5>
</PrimaryToken>
</Tokens>
</App>
</Deployment>
@@ -0,0 +1,3 @@
For the Silverlight for Windows Phone Toolkit make sure that you have
marked the icons in the "Toolkit.Content" folder as content. That way they
can be used as the icons for the ApplicationBar control.
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
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 MyFriendsAround.Common.Entities;
namespace MyFriendsAround.WP7.Service
{
public class FriendsListEventArgs: EventArgs
{
public List<Friend> Friends { get; set; }
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyFriendsAround.WP7.Service
{
public class PublishLocationEventArgs: EventArgs
{
public bool IsSuccess { get; set; }
}
}
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
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 Hammock;
using Hammock.Streaming;
using Hammock.Tasks;
using Hammock.Web;
using MyFriendsAround.Common.Entities;
using Hammock.Caching;
using CacheMode = Hammock.Caching.CacheMode;
namespace MyFriendsAround.WP7.Service
{
public static class ServiceAgent
{
#region GetFriends
private static EventHandler<FriendsListEventArgs> friendscallback;
public static void GetFriends(EventHandler<FriendsListEventArgs> callback)
{
var serializer = new Hammock.Serialization.HammockDataContractJsonSerializer();
RestClient client = new RestClient
{
Authority = "http://localhost.:55672/myfriends",
Serializer = serializer,
Deserializer = serializer
};
RestRequest request = new RestRequest
{
Path = "GetFriends" + "?timestamp=" + DateTime.Now.Ticks.ToString()
};
friendscallback = callback;
client.BeginRequest(request, new RestCallback<List<Friend>>(GetFriendsCallback));
}
public static void GetFriendsCallback(RestRequest request, RestResponse<List<Friend>> response, object userState)
{
if (response.StatusCode == HttpStatusCode.OK)
{
List<Friend> list = response.ContentEntity;
friendscallback.Invoke(null, new FriendsListEventArgs() { Friends = list });
}
}
#endregion
#region PublishLocation
public static EventHandler<PublishLocationEventArgs> publishlocationcallback;
public static void PublishLocation(Friend friend, EventHandler<PublishLocationEventArgs> callback)
{
var serializer = new Hammock.Serialization.HammockDataContractJsonSerializer();
RestClient client = new RestClient
{
Authority = "http://localhost.:55672/myfriends",
Serializer = serializer,
Deserializer = serializer
};
RestRequest request = new RestRequest
{
Method = WebMethod.Post,
Path = "PublishLocation",
Entity = friend
};
publishlocationcallback = callback;
client.BeginRequest(request, new RestCallback<bool>(PublishLocationCallback));
}
public static void PublishLocationCallback(RestRequest request, RestResponse<bool> response, object userState)
{
if (response.StatusCode == HttpStatusCode.OK)
{
bool success = response.ContentEntity;
publishlocationcallback.Invoke(null, new PublishLocationEventArgs() { IsSuccess = success });
}
}
#endregion
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

+32
View File
@@ -0,0 +1,32 @@
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 Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MyFriendsAround.WP7.Tests
{
[TestClass]
public class Tests1
{
[TestMethod]
public void Test_If_This_One_Is_Correct()
{
Assert.IsTrue(true, "this method always pass");
}
[TestMethod]
[ExpectedException(typeof(Exception))]
public void Test_Must_Throw_Error()
{
//
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

@@ -0,0 +1,68 @@
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 Microsoft.Phone.Info;
namespace MyFriendsAround.WP7.Utils
{
public class Identification
{
public static String GetDeviceId()
{
byte[] id = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
return Convert.ToBase64String(id);
}
private static readonly int ANIDLength = 32;
private static readonly int ANIDOffset = 2;
public static string GetManufacturer()
{
string result = string.Empty;
object manufacturer;
if (DeviceExtendedProperties.TryGetValue("DeviceManufacturer", out manufacturer))
result = manufacturer.ToString();
return result;
}
//Note: to get a result requires ID_CAP_IDENTITY_DEVICE
// to be added to the capabilities of the WMAppManifest
// this will then warn users in marketplace
public static byte[] GetDeviceUniqueID()
{
byte[] result = null;
object uniqueId;
if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
result = (byte[])uniqueId;
return result;
}
// NOTE: to get a result requires ID_CAP_IDENTITY_USER
// to be added to the capabilities of the WMAppManifest
// this will then warn users in marketplace
public static string GetWindowsLiveAnonymousID()
{
string result = string.Empty;
object anid;
if (UserExtendedProperties.TryGetValue("ANID", out anid))
{
if (anid != null && anid.ToString().Length >= (ANIDLength + ANIDOffset))
{
result = anid.ToString().Substring(ANIDOffset, ANIDLength);
}
}
return result;
}
}
}
@@ -0,0 +1,32 @@
using System;
using System.IO;
using System.Net;
using System.Text;
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 Newtonsoft.Json;
namespace MyFriendsAround.WP7.Utils
{
public static class SerializationHelper
{
public static T Deserialize<T>(string serialized)
{
if (string.IsNullOrEmpty(serialized))
return default(T);
return JsonConvert.DeserializeObject<T>(serialized);
}
public static string Serialize<T>(T obj)
{
return JsonConvert.SerializeObject(obj);
}
}
}
@@ -0,0 +1,228 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Device.Location;
using System.Net;
using System.ServiceModel.Channels;
using System.Windows;
using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using GalaSoft.MvvmLight.Threading;
using Hammock;
using Hammock.Serialization;
using Microsoft.Phone.Controls;
using Microsoft.Silverlight.Testing;
using MyFriendsAround.Common.Entities;
using MyFriendsAround.WP7.Service;
using MyFriendsAround.WP7.Utils;
using Newtonsoft.Json;
namespace MyFriendsAround.WP7.ViewModel
{
/// <summary>
/// This class contains properties that the main View can data bind to.
/// <para>
/// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
/// </para>
/// <para>
/// You can also use Blend to data bind with the tool's support.
/// </para>
/// <para>
/// See http://www.galasoft.ch/mvvm/getstarted
/// </para>
/// </summary>
public class MainViewModel : ViewModelBase
{
public string ApplicationTitle
{
get
{
return "MVVM LIGHT";
}
}
public string PageName
{
get
{
//myfriendsservice
return "My page:";
}
}
public string Welcome
{
get
{
return "Welcome to MVVM Light";
}
}
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
public MainViewModel()
{
MyName = "Guest";
PublishLocationCommand = new RelayCommand(() => PublishLocationAction());
if (IsInDesignMode)
{
// Code runs in Blend --> create design time data.
}
else
{
// Code runs "for real"
ServiceAgent.GetFriends(this.GetFriendsResult);
}
}
private void PopulatePushPins(List<Friend> list)
{
ObservableCollection<PushPinModel> result = new ObservableCollection<PushPinModel>();
list.ForEach((f) =>
{
//f.LocationStr
result.Add(new PushPinModel()
{
PinSource = "ApplicationIcon.png",
Location = new GeoCoordinate(f.Latitude, f.Longitude)
});
});
PushPins = result;
}
private void PublishLocationAction()
{
Friend myInfo = new Friend();
myInfo.Id = Identification.GetDeviceId();
myInfo.FriendName = MyName;
myInfo.LastUpdated = DateTime.UtcNow;
myInfo.LocationStr = string.Format("POINT({0} {1})", MapCenter.Latitude, MapCenter.Longitude);
ServiceAgent.PublishLocation(myInfo, new EventHandler<PublishLocationEventArgs>(PublishLocationResult));
}
public void GetFriendsResult(object sender, FriendsListEventArgs args)
{
List<Friend> list = args.Friends;
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
PopulatePushPins(list);
}
);
}
public void PublishLocationResult(object sender, PublishLocationEventArgs args)
{
if (!args.IsSuccess)
{
var message = new DialogMessage("Communication error!", DialogMessageCallback)
{
Button = MessageBoxButton.OK,
Caption = "Error!"
};
Messenger.Default.Send(message);
}
//
//update
ServiceAgent.GetFriends(this.GetFriendsResult);
}
private void DialogMessageCallback(MessageBoxResult result)
{
if (result == MessageBoxResult.OK)
{
//Message = "Continue";
}
else
{
//Message = "Stop";
}
}
public RelayCommand PublishLocationCommand { get; set; }
public string MyName { get; set; }
////public override void Cleanup()
////{
//// // Clean up if needed
//// base.Cleanup();
////}
/// <summary>
/// The <see cref="PushPins" /> property's name.
/// </summary>
public const string PushPinsPropertyName = "PushPins";
private ObservableCollection<PushPinModel> _PushPins = new ObservableCollection<PushPinModel>();
/// <summary>
/// Gets the PushPins property.
/// </summary>
public ObservableCollection<PushPinModel> PushPins
{
get
{
return _PushPins;
}
set
{
if (_PushPins == value)
{
return;
}
var oldValue = _PushPins;
_PushPins = value;
// Update bindings, no broadcast
RaisePropertyChanged(PushPinsPropertyName);
//// Update bindings and broadcast change using GalaSoft.MvvmLight.Messenging
//RaisePropertyChanged(PushPinsPropertyName, oldValue, value, true);
}
}
/// <summary>
/// The <see cref="MapCenter" /> property's name.
/// </summary>
public const string MapCenterPropertyName = "MapCenter";
private GeoCoordinate _mapCenter = new GeoCoordinate(0,0);
/// <summary>
/// Gets the MapCenter property.
/// </summary>
public GeoCoordinate MapCenter
{
get
{
return _mapCenter;
}
set
{
if (_mapCenter == value)
{
return;
}
var oldValue = _mapCenter;
_mapCenter = value;
// Update bindings, no broadcast
RaisePropertyChanged(MapCenterPropertyName);
//// Update bindings and broadcast change using GalaSoft.MvvmLight.Messenging
//RaisePropertyChanged(MapCenterPropertyName, oldValue, value, true);
}
}
}
}
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Device.Location;
using System.Linq;
using System.Text;
namespace MyFriendsAround.WP7.ViewModel
{
public class PushPinModel : INotifyPropertyChanged
{
public PushPinModel() { ; }
private GeoCoordinate _location;
private string _pinSource;
public string PinSource
{
get { return _pinSource; }
set
{
if (_pinSource != value)
{
_pinSource = value;
OnPropertyChanged("PinSource");
}
}
}
public GeoCoordinate Location
{
get { return _location; }
set
{
if (_location != value)
{
_location = value;
OnPropertyChanged("Location");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
@@ -0,0 +1,135 @@
/*
In App.xaml:
<Application.Resources>
<vm:ViewModelLocatorTemplate xmlns:vm="clr-namespace:MyFriendsAround.WP7.ViewModel"
x:Key="Locator" />
</Application.Resources>
In the View:
DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"
OR (WPF only):
xmlns:vm="clr-namespace:MyFriendsAround.WP7.ViewModel"
DataContext="{Binding Source={x:Static vm:ViewModelLocatorTemplate.ViewModelNameStatic}}"
*/
namespace MyFriendsAround.WP7.ViewModel
{
/// <summary>
/// This class contains static references to all the view models in the
/// application and provides an entry point for the bindings.
/// <para>
/// Use the <strong>mvvmlocatorproperty</strong> snippet to add ViewModels
/// to this locator.
/// </para>
/// <para>
/// In Silverlight and WPF, place the ViewModelLocatorTemplate in the App.xaml resources:
/// </para>
/// <code>
/// &lt;Application.Resources&gt;
/// &lt;vm:ViewModelLocatorTemplate xmlns:vm="clr-namespace:MyFriendsAround.WP7.ViewModel"
/// x:Key="Locator" /&gt;
/// &lt;/Application.Resources&gt;
/// </code>
/// <para>
/// Then use:
/// </para>
/// <code>
/// DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"
/// </code>
/// <para>
/// You can also use Blend to do all this with the tool's support.
/// </para>
/// <para>
/// See http://www.galasoft.ch/mvvm/getstarted
/// </para>
/// <para>
/// In <strong>*WPF only*</strong> (and if databinding in Blend is not relevant), you can delete
/// the Main property and bind to the ViewModelNameStatic property instead:
/// </para>
/// <code>
/// xmlns:vm="clr-namespace:MyFriendsAround.WP7.ViewModel"
/// DataContext="{Binding Source={x:Static vm:ViewModelLocatorTemplate.ViewModelNameStatic}}"
/// </code>
/// </summary>
public class ViewModelLocator
{
private static MainViewModel _main;
/// <summary>
/// Initializes a new instance of the ViewModelLocator class.
/// </summary>
public ViewModelLocator()
{
////if (ViewModelBase.IsInDesignModeStatic)
////{
//// // Create design time view models
////}
////else
////{
//// // Create run time view models
////}
CreateMain();
}
/// <summary>
/// Gets the Main property.
/// </summary>
public static MainViewModel MainStatic
{
get
{
if (_main == null)
{
CreateMain();
}
return _main;
}
}
/// <summary>
/// Gets the Main property.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
"CA1822:MarkMembersAsStatic",
Justification = "This non-static member is needed for data binding purposes.")]
public MainViewModel Main
{
get
{
return MainStatic;
}
}
/// <summary>
/// Provides a deterministic way to delete the Main property.
/// </summary>
public static void ClearMain()
{
_main.Cleanup();
_main = null;
}
/// <summary>
/// Provides a deterministic way to create the Main property.
/// </summary>
public static void CreateMain()
{
if (_main == null)
{
_main = new MainViewModel();
}
}
/// <summary>
/// Cleans up all the resources.
/// </summary>
public static void Cleanup()
{
ClearMain();
}
}
}
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SilverlightToolkitWP" version="4.2011.2.1" />
</packages>