bindable appbar

minor changes
cleanup
This commit is contained in:
2011-03-24 02:14:22 +02:00
parent 449dee4702
commit 8798abdd69
31 changed files with 1134 additions and 790 deletions
+40 -11
View File
@@ -1,4 +1,4 @@
<phone:PhoneApplicationPage x:Class="MyFriendsAround.WP7.MainPage"
<phone:PhoneApplicationPage xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 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"
@@ -14,7 +14,7 @@
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">
xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps" xmlns:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview">
<!--LayoutRoot contains the root grid where all other page content is placed-->
@@ -50,30 +50,36 @@
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentGrid"
Grid.Row="1">
Grid.Row="1"
Margin="0,0,0,70">
<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">
<!--<Button Content="Publish"
HorizontalAlignment="Left" Margin="6,0,0,6" Name="btnPublishLocation"
Width="468"
Height="72"
VerticalAlignment="Bottom">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cmd:EventToCommand Command="{Binding PublishLocationCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Button>-->
<TextBox Height="72" HorizontalAlignment="Left" Margin="6,471,0,0" Name="txtMyName" Text="{Binding Path=MyName, Mode=TwoWay}" VerticalAlignment="Top" Width="468" />
<TextBox Height="67" HorizontalAlignment="Left" Margin="6,0,0,6" Name="txtMyName" Text="{Binding Path=MyName, Mode=TwoWay}" VerticalAlignment="Bottom" Width="468" />
<my:Map x:Name="map"
Height="459"
Height="468"
HorizontalAlignment="Left"
Margin="6,6,0,0"
Margin="6,0,0,0"
VerticalAlignment="Top"
Width="468"
Center="{Binding Path=MapCenter, Mode=TwoWay}">
<my:MapItemsControl ItemsSource="{Binding PushPins}">
<my:MapItemsControl ItemsSource="{Binding PushPins}"
>
<my:MapItemsControl.ItemTemplate>
<DataTemplate>
<my:Pushpin Location="{Binding Location}"
@@ -83,9 +89,31 @@
</my:MapItemsControl.ItemTemplate>
</my:MapItemsControl>
</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>
<Preview:BindableApplicationBar x:Name="AppBar"
BarOpacity="0.5">
<Preview:BindableApplicationBarIconButton Command="{Binding PublishLocationCommand}"
IconUri="/icons/appbar.publish.png"
Text="{Binding AppBarTextPublish}" />
<Preview:BindableApplicationBarIconButton Command="{Binding DisplayAboutCommand}"
IconUri="/icons/appbar.questionmark.rest.png"
Text="{Binding AppBarTextAbout}" />
<Preview:BindableApplicationBar.MenuItems>
<Preview:BindableApplicationBarMenuItem Text="Settings"
Command="{Binding InputBoxCommand}" />
</Preview:BindableApplicationBar.MenuItems>
</Preview:BindableApplicationBar>
</Grid>
<!-- Sample code showing usage of ApplicationBar
<phone:PhoneApplicationPage.ApplicationBar>
@@ -100,5 +128,6 @@
</phone:PhoneApplicationPage.ApplicationBar>
-->
</phone:PhoneApplicationPage>
@@ -152,6 +152,12 @@
<Content Include="Background.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="icons\appbar.publish.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="icons\appbar.questionmark.rest.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="README_FIRST.txt" />
<Content Include="SplashScreenImage.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -165,6 +171,16 @@
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Libs\GpsEmulator\GpsEmulatorClient\GpsEmulatorClient.csproj">
<Project>{A128812A-1249-4562-BDF4-5E17951B8434}</Project>
<Name>GpsEmulatorClient</Name>
</ProjectReference>
<ProjectReference Include="..\Libs\Phone7.Fx.Preview\Phone7.Fx.Preview.csproj">
<Project>{B55A0F90-2B5A-4C4B-88F4-013AA1629866}</Project>
<Name>Phone7.Fx.Preview</Name>
</ProjectReference>
</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.
@@ -39,7 +39,7 @@ namespace MyFriendsAround.WP7.ViewModel
{
get
{
return "MVVM LIGHT";
return "MyFriendsAround";
}
}
@@ -47,8 +47,7 @@ namespace MyFriendsAround.WP7.ViewModel
{
get
{
//myfriendsservice
return "My page:";
return "Friends Map";
}
}
@@ -67,6 +66,9 @@ namespace MyFriendsAround.WP7.ViewModel
{
MyName = "Guest";
PublishLocationCommand = new RelayCommand(() => PublishLocationAction());
DisplayAboutCommand = new RelayCommand(() => DisplayAbout());
InputBoxCommand = new RelayCommand(() => InputBox());
if (IsInDesignMode)
{
// Code runs in Blend --> create design time data.
@@ -74,11 +76,24 @@ namespace MyFriendsAround.WP7.ViewModel
else
{
// Code runs "for real"
IsBusy = true;
ServiceAgent.GetFriends(this.GetFriendsResult);
}
}
private void InputBox()
{
MessageBox.Show("Input box");
}
private void DisplayAbout()
{
MessageBox.Show("About");
}
private void PopulatePushPins(List<Friend> list)
{
ObservableCollection<PushPinModel> result = new ObservableCollection<PushPinModel>();
@@ -92,7 +107,6 @@ namespace MyFriendsAround.WP7.ViewModel
});
});
PushPins = result;
}
@@ -103,6 +117,7 @@ namespace MyFriendsAround.WP7.ViewModel
myInfo.FriendName = MyName;
myInfo.LastUpdated = DateTime.UtcNow;
myInfo.LocationStr = string.Format("POINT({0} {1})", MapCenter.Latitude, MapCenter.Longitude);
IsBusy = true;
ServiceAgent.PublishLocation(myInfo, new EventHandler<PublishLocationEventArgs>(PublishLocationResult));
}
@@ -112,6 +127,7 @@ namespace MyFriendsAround.WP7.ViewModel
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
PopulatePushPins(list);
IsBusy = false;
}
);
}
@@ -146,8 +162,20 @@ namespace MyFriendsAround.WP7.ViewModel
}
public RelayCommand PublishLocationCommand { get; set; }
public RelayCommand DisplayAboutCommand { get; set; }
public RelayCommand InputBoxCommand { get; set; }
public string MyName { get; set; }
public string AppBarTextAbout {
get { return "About"; }
}
public string AppBarTextPublish
{
get { return "Publish"; }
}
////public override void Cleanup()
////{
//// // Clean up if needed
@@ -224,5 +252,38 @@ namespace MyFriendsAround.WP7.ViewModel
//RaisePropertyChanged(MapCenterPropertyName, oldValue, value, true);
}
}
/// <summary>
/// The <see cref="IsBusy" /> property's name.
/// </summary>
public const string IsBusyPropertyName = "IsBusy";
private bool _isBusy = false;
/// <summary>
/// Gets the IsBusy property.
/// </summary>
public bool IsBusy
{
get
{
return _isBusy;
}
set
{
if (_isBusy == value)
{
return;
}
var oldValue = _isBusy;
_isBusy = value;
// Update bindings, no broadcast
RaisePropertyChanged(IsBusyPropertyName);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B