├── .gitignore ├── Media ├── RestGuide_ALL.pdn ├── RestGuide_ALL.png ├── iphone_1.png ├── iphone_2.png ├── iphone_3.png ├── winphone_1.png ├── winphone_2.png └── winphone_3.png ├── README ├── RestGuide_Android ├── Activities │ ├── MainActivity.cs │ ├── MainListAdapter.cs │ └── RestaurantActivity.cs ├── Assets │ └── AboutAssets.txt ├── DataClasses │ └── Objects.cs ├── Main.cs ├── Properties │ ├── AndroidManifest.xml │ └── AssemblyInfo.cs ├── Resources │ ├── AboutResources.txt │ ├── Drawable │ │ └── icon.png │ ├── Layout │ │ ├── Main.axml │ │ ├── MainListItem.axml │ │ └── Restaurant.axml │ ├── Resource.Designer.cs │ ├── Values │ │ └── Strings.xml │ └── raw │ │ └── restaurants.xml ├── RestGuide_Android.csproj └── RestGuide_Android.sln ├── RestGuide_WP7 ├── App.xaml ├── App.xaml.cs ├── ApplicationIcon.png ├── Background.png ├── DataClasses │ └── Objects.cs ├── DetailsPage.xaml ├── DetailsPage.xaml.cs ├── MainPage.xaml ├── MainPage.xaml.cs ├── Properties │ ├── AppManifest.xml │ ├── AssemblyInfo.cs │ └── WMAppManifest.xml ├── ReferencedAssemblies │ ├── Clarity.Phone.dll │ └── Microsoft.Phone.Controls.Toolkit.dll ├── RestGuide.csproj ├── RestGuide.sln ├── RestaurantNameSelector.cs ├── SampleData │ ├── MainPage.xaml │ ├── MainViewModelSampleData.xaml │ └── restaurants.xml ├── SplashScreenImage.jpg └── ViewModels │ ├── ItemViewModel.cs │ └── MainViewModel.cs └── RestGuide_iOS ├── AppController.cs ├── DataClasses └── Objects.cs ├── Default.png ├── Icon.png ├── Info.plist ├── Main.cs ├── MainViewController.cs ├── RestGuide.csproj ├── RestGuide.sln ├── RestaurantViewController.cs └── restaurants.xml /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | *~ 3 | *.userprefs 4 | *.pidb 5 | obj 6 | *.suo -------------------------------------------------------------------------------- /Media/RestGuide_ALL.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/Media/RestGuide_ALL.pdn -------------------------------------------------------------------------------- /Media/RestGuide_ALL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/Media/RestGuide_ALL.png -------------------------------------------------------------------------------- /Media/iphone_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/Media/iphone_1.png -------------------------------------------------------------------------------- /Media/iphone_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/Media/iphone_2.png -------------------------------------------------------------------------------- /Media/iphone_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/Media/iphone_3.png -------------------------------------------------------------------------------- /Media/winphone_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/Media/winphone_1.png -------------------------------------------------------------------------------- /Media/winphone_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/Media/winphone_2.png -------------------------------------------------------------------------------- /Media/winphone_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/Media/winphone_3.png -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This is a very basic demo of similar 'back end' code (ie. XML file, corresponding c# class and serialization code) running on MonoTouch/iPhone, Windows Phone 7 and MonoDroid/Android. 2 | -------------------------------------------------------------------------------- /RestGuide_Android/Activities/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Android.App; 4 | using Android.Content; 5 | using Android.Runtime; 6 | using Android.Views; 7 | using Android.Widget; 8 | using Android.OS; 9 | using Android; 10 | 11 | namespace RestGuide 12 | { 13 | [Activity(Label = "Restaurant Guide", MainLauncher = true, Icon="@drawable/icon")] 14 | public class MainActivity : Activity 15 | { 16 | private ListView _list; 17 | 18 | protected override void OnCreate(Bundle bundle) 19 | { 20 | base.OnCreate(bundle); 21 | 22 | // Set our view from the "main" layout resource 23 | SetContentView(Resource.Layout.Main); 24 | 25 | _list = FindViewById(Resource.Id.List); 26 | _list.ItemClick += new System.EventHandler(_list_ItemClick); 27 | 28 | 29 | // Get our button from the layout resource, 30 | // and attach an event to it 31 | TextView heading = FindViewById(Resource.Id.Title); 32 | heading.Text = "Top 100"; 33 | } 34 | 35 | protected override void OnResume() 36 | { 37 | base.OnResume(); 38 | refreshRestaurants(); 39 | } 40 | 41 | private void refreshRestaurants() 42 | { 43 | var restaurants = ((RestGuideApplication)Application).Restaurants; 44 | _list.Adapter = new MainListAdapter(this, restaurants); 45 | } 46 | 47 | private void _list_ItemClick(object sender, ItemEventArgs e) 48 | { 49 | System.Console.WriteLine("[MainActivity] _list_ItemClick " + e.Position); 50 | 51 | var restaurant = ((MainListAdapter)_list.Adapter).GetCategory(e.Position); 52 | 53 | var intent = new Intent(); 54 | 55 | intent.SetClass(this, typeof(RestaurantActivity)); 56 | intent.PutExtra("Name", restaurant.Name); 57 | 58 | StartActivity(intent); 59 | } 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /RestGuide_Android/Activities/MainListAdapter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using Android.App; 7 | using Android.Content; 8 | using Android.OS; 9 | using Android.Runtime; 10 | using Android.Views; 11 | using Android.Widget; 12 | 13 | namespace RestGuide 14 | { 15 | public class MainListAdapter : BaseAdapter 16 | { 17 | private IEnumerable _restaurants; 18 | private Activity _context; 19 | private bool _showCount; 20 | 21 | /// 22 | /// Show Restaurant cells 23 | /// 24 | public MainListAdapter(Activity context, IEnumerable restaurants) 25 | { 26 | _context = context; 27 | _restaurants = restaurants; 28 | } 29 | 30 | public override View GetView(int position, View convertView, ViewGroup parent) 31 | { 32 | var view = (convertView 33 | ?? _context.LayoutInflater.Inflate( 34 | Resource.Layout.MainListItem, parent, false) 35 | ) as LinearLayout; 36 | var restaurant = _restaurants.ElementAt(position); 37 | 38 | view.FindViewById(Resource.Id.Title).Text = restaurant.Name; 39 | view.FindViewById(Resource.Id.Cuisine).Text = restaurant.Cuisine; 40 | 41 | return view; 42 | } 43 | 44 | public override int Count 45 | { 46 | get { return _restaurants.Count(); } 47 | } 48 | 49 | public Restaurant GetCategory(int position) 50 | { 51 | return _restaurants.ElementAt(position); 52 | } 53 | 54 | public override Java.Lang.Object GetItem(int position) 55 | { 56 | return null; 57 | } 58 | 59 | public override long GetItemId(int position) 60 | { 61 | return position; 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /RestGuide_Android/Activities/RestaurantActivity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Android.App; 5 | using Android.Content; 6 | using Android.Runtime; 7 | using Android.Views; 8 | using Android.Widget; 9 | using Android.OS; 10 | using Android; 11 | 12 | namespace RestGuide 13 | { 14 | [Activity(Label = "Restaurant Guide")] 15 | public class RestaurantActivity : Activity 16 | { 17 | string restaurantName; 18 | 19 | protected override void OnCreate(Bundle bundle) 20 | { 21 | base.OnCreate(bundle); 22 | 23 | restaurantName = Intent.GetStringExtra("Name"); 24 | 25 | // Set our view from the "main" layout resource 26 | SetContentView(Resource.Layout.Restaurant); 27 | 28 | var restaurants = ((RestGuideApplication)Application).Restaurants; 29 | 30 | var re = from rest in restaurants 31 | where rest.Name == restaurantName 32 | select rest; 33 | var restaurant = re.FirstOrDefault(); 34 | 35 | // Get our button from the layout resource, 36 | // and attach an event to it 37 | TextView heading = FindViewById(Resource.Id.Title); 38 | TextView cuisine = FindViewById(Resource.Id.Cuisine); 39 | TextView address = FindViewById(Resource.Id.Address); 40 | TextView telephone = FindViewById(Resource.Id.Telephone); 41 | TextView website = FindViewById(Resource.Id.Website); 42 | TextView description = FindViewById(Resource.Id.Description); 43 | 44 | TextView hours = FindViewById(Resource.Id.Hours); 45 | TextView creditCards = FindViewById(Resource.Id.CreditCards); 46 | TextView chef = FindViewById(Resource.Id.Chef); 47 | 48 | heading.Text = restaurant.Name; 49 | cuisine.Text = restaurant.Cuisine.ToUpper(); 50 | address.Text = restaurant.Address; 51 | telephone.Text = "T | " + restaurant.Phone; 52 | website.Text = "W | " + restaurant.Website; 53 | description.Text = restaurant.Text; 54 | 55 | hours.Text = restaurant.Hours; 56 | creditCards.Text = restaurant.CreditCards; 57 | chef.Text = restaurant.Chef; 58 | } 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /RestGuide_Android/Assets/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories) and given a Build Action of "AndroidAsset". 3 | 4 | These files will be deployed with you package and will be accessible using Android's 5 | AssetManager, like this: 6 | 7 | public class ReadAsset : Activity 8 | { 9 | protected override void OnCreate (Bundle bundle) 10 | { 11 | base.OnCreate (bundle); 12 | 13 | InputStream input = Assets.Open ("my_asset.txt"); 14 | } 15 | } 16 | 17 | Additionally, some Android functions will automatically load asset files: 18 | 19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); -------------------------------------------------------------------------------- /RestGuide_Android/DataClasses/Objects.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace RestGuide 5 | { 6 | public class Restaurant 7 | { 8 | public int Number {get;set;} 9 | public string Name {get;set;} 10 | public string Url {get; set;} 11 | 12 | 13 | public string Cuisine { get; set; } 14 | public string Address {get;set;} 15 | public string Phone {get;set;} 16 | public string Website {get;set;} 17 | public string Text {get;set;} 18 | 19 | public string Hours {get;set;} 20 | public string CreditCards { get; set; } 21 | public string Chef { get; set; } 22 | 23 | public override string ToString() 24 | { 25 | return String.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}" 26 | ,Number, Name, Url, Cuisine, Address, Phone, Website, Text, Hours, CreditCards, Chef); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /RestGuide_Android/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Android.App; 3 | 4 | using System.IO; 5 | using System.Threading; 6 | using Android.Widget; 7 | using Android.Content; 8 | using Android; 9 | using System.Xml.Serialization; 10 | using System.Collections.Generic; 11 | 12 | namespace RestGuide 13 | { 14 | [Application] 15 | public class RestGuideApplication : Application 16 | { 17 | public List Restaurants; 18 | 19 | public RestGuideApplication(IntPtr handle) 20 | : base(handle) 21 | { } 22 | 23 | public override void OnCreate() 24 | { 25 | base.OnCreate(); 26 | Console.WriteLine("[RestGuideApplication] OnCreate"); 27 | 28 | // I never said this was the best place for loading data 29 | // just that it works for now... 30 | var s = Resources.OpenRawResource(Resource.Raw.restaurants); 31 | using (TextReader reader = new StreamReader(s)) 32 | { 33 | XmlSerializer serializer = new XmlSerializer(typeof(List)); 34 | Restaurants = (List)serializer.Deserialize(reader); 35 | } 36 | Console.WriteLine("[RestGuideApplication] Loaded {0} restaurants", Restaurants.Count); 37 | } 38 | 39 | 40 | 41 | 42 | // readStream is the stream you need to read 43 | // writeStream is the stream you want to write to 44 | private void ReadWriteStream(Stream readStream, Stream writeStream) 45 | { 46 | int Length = 256; 47 | Byte[] buffer = new Byte[Length]; 48 | int bytesRead = readStream.Read(buffer, 0, Length); 49 | // write the required bytes 50 | while (bytesRead > 0) 51 | { 52 | writeStream.Write(buffer, 0, bytesRead); 53 | bytesRead = readStream.Read(buffer, 0, Length); 54 | } 55 | readStream.Close(); 56 | writeStream.Close(); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /RestGuide_Android/Properties/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /RestGuide_Android/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RestGuide")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RestGuide_Android")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a557ce8c-9dbe-4b93-8fc4-95ffc126cf14")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RestGuide_Android/Resources/AboutResources.txt: -------------------------------------------------------------------------------- 1 | Images, layout descriptions, binary blobs and string dictionaries can be included 2 | in your application as resource files. Various Android APIs are designed to 3 | operate on the resource IDs instead of dealing with images, strings or binary blobs 4 | directly. 5 | 6 | For example, a sample Android app that contains a user interface layout (Main.xml), 7 | an internationalization string table (Strings.xml) and some icons (drawable/Icon.png) 8 | would keep its resources in the "Resources" directory of the application: 9 | 10 | Resources/ 11 | Drawable/ 12 | Icon.png 13 | 14 | Layout/ 15 | Main.axml 16 | 17 | Values/ 18 | Strings.xml 19 | 20 | In order to get the build system to recognize Android resources, the build action should be set 21 | to "AndroidResource". The native Android APIs do not operate directly with filenames, but 22 | instead operate on resource IDs. When you compile an Android application that uses resources, 23 | the build system will package the resources for distribution and generate a class called 24 | "Resource" that contains the tokens for each one of the resources included. For example, 25 | for the above Resources layout, this is what the Resource class would expose: 26 | 27 | public class Resource { 28 | public class Drawable { 29 | public const int Icon = 0x123; 30 | } 31 | 32 | public class Layout { 33 | public const int Main = 0x456; 34 | } 35 | 36 | public class String { 37 | public const int FirstString = 0xabc; 38 | public const int SecondString = 0xbcd; 39 | } 40 | } 41 | 42 | You would then use Resource.Drawable.Icon to reference the Drawable/Icon.png file, or 43 | Resource.Layout.Main to reference the Layout/Main.axml file, or Resource.String.FirstString 44 | to reference the first string in the dictionary file Values/Strings.xml. -------------------------------------------------------------------------------- /RestGuide_Android/Resources/Drawable/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_Android/Resources/Drawable/icon.png -------------------------------------------------------------------------------- /RestGuide_Android/Resources/Layout/Main.axml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /RestGuide_Android/Resources/Layout/MainListItem.axml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 13 | 19 | 20 | -------------------------------------------------------------------------------- /RestGuide_Android/Resources/Layout/Restaurant.axml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 18 | 24 | 31 | 37 | 44 | 51 | 56 | 64 | 71 | 79 | 86 | 94 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /RestGuide_Android/Resources/Resource.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.4952 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace RestGuide 12 | { 13 | 14 | 15 | public partial class Resource 16 | { 17 | 18 | public partial class Attribute 19 | { 20 | 21 | private Attribute() 22 | { 23 | } 24 | } 25 | 26 | public partial class Drawable 27 | { 28 | 29 | // aapt resource value: 0x7f020000 30 | public const int icon = 2130837504; 31 | 32 | private Drawable() 33 | { 34 | } 35 | } 36 | 37 | public partial class Id 38 | { 39 | 40 | // aapt resource value: 0x7f060004 41 | public const int Address = 2131099652; 42 | 43 | // aapt resource value: 0x7f06000d 44 | public const int Chef = 2131099661; 45 | 46 | // aapt resource value: 0x7f06000c 47 | public const int ChefLabel = 2131099660; 48 | 49 | // aapt resource value: 0x7f06000b 50 | public const int CreditCards = 2131099659; 51 | 52 | // aapt resource value: 0x7f06000a 53 | public const int CreditCardsLabel = 2131099658; 54 | 55 | // aapt resource value: 0x7f060002 56 | public const int Cuisine = 2131099650; 57 | 58 | // aapt resource value: 0x7f060007 59 | public const int Description = 2131099655; 60 | 61 | // aapt resource value: 0x7f060009 62 | public const int Hours = 2131099657; 63 | 64 | // aapt resource value: 0x7f060008 65 | public const int HoursLabel = 2131099656; 66 | 67 | // aapt resource value: 0x7f060001 68 | public const int List = 2131099649; 69 | 70 | // aapt resource value: 0x7f060005 71 | public const int Telephone = 2131099653; 72 | 73 | // aapt resource value: 0x7f060000 74 | public const int Title = 2131099648; 75 | 76 | // aapt resource value: 0x7f060006 77 | public const int Website = 2131099654; 78 | 79 | // aapt resource value: 0x7f060003 80 | public const int scroller = 2131099651; 81 | 82 | private Id() 83 | { 84 | } 85 | } 86 | 87 | public partial class Layout 88 | { 89 | 90 | // aapt resource value: 0x7f030000 91 | public const int Main = 2130903040; 92 | 93 | // aapt resource value: 0x7f030001 94 | public const int MainListItem = 2130903041; 95 | 96 | // aapt resource value: 0x7f030002 97 | public const int Restaurant = 2130903042; 98 | 99 | private Layout() 100 | { 101 | } 102 | } 103 | 104 | public partial class Raw 105 | { 106 | 107 | // aapt resource value: 0x7f040000 108 | public const int restaurants = 2130968576; 109 | 110 | private Raw() 111 | { 112 | } 113 | } 114 | 115 | public partial class String 116 | { 117 | 118 | // aapt resource value: 0x7f050001 119 | public const int ApplicationName = 2131034113; 120 | 121 | // aapt resource value: 0x7f050000 122 | public const int Hello = 2131034112; 123 | 124 | private String() 125 | { 126 | } 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /RestGuide_Android/Resources/Values/Strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello World, Click Me! 4 | RestGuide_Android 5 | 6 | -------------------------------------------------------------------------------- /RestGuide_Android/Resources/raw/restaurants.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_Android/Resources/raw/restaurants.xml -------------------------------------------------------------------------------- /RestGuide_Android/RestGuide_Android.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {B1B980A0-11C2-40BF-9503-F309445CEAA7} 9 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10 | Library 11 | Properties 12 | RestGuide 13 | RestGuide_Android 14 | 512 15 | true 16 | Resources\Resource.Designer.cs 17 | armeabi 18 | 19 | Properties\AndroidManifest.xml 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | True 30 | None 31 | 32 | 33 | pdbonly 34 | true 35 | bin\Release\ 36 | TRACE 37 | prompt 38 | 4 39 | False 40 | Full 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | AndroidResource 64 | 65 | 66 | AndroidResource 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 92 | -------------------------------------------------------------------------------- /RestGuide_Android/RestGuide_Android.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestGuide_Android", "RestGuide_Android.csproj", "{B1B980A0-11C2-40BF-9503-F309445CEAA7}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {B1B980A0-11C2-40BF-9503-F309445CEAA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {B1B980A0-11C2-40BF-9503-F309445CEAA7}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {B1B980A0-11C2-40BF-9503-F309445CEAA7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 15 | {B1B980A0-11C2-40BF-9503-F309445CEAA7}.Release|Any CPU.ActiveCfg = Release|Any CPU 16 | {B1B980A0-11C2-40BF-9503-F309445CEAA7}.Release|Any CPU.Build.0 = Release|Any CPU 17 | {B1B980A0-11C2-40BF-9503-F309445CEAA7}.Release|Any CPU.Deploy.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /RestGuide_WP7/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /RestGuide_WP7/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Documents; 8 | using System.Windows.Input; 9 | using System.Windows.Media; 10 | using System.Windows.Media.Animation; 11 | using System.Windows.Navigation; 12 | using System.Windows.Shapes; 13 | using Microsoft.Phone.Controls; 14 | using Microsoft.Phone.Shell; 15 | 16 | namespace RestGuide 17 | { 18 | public partial class App : Application 19 | { 20 | private static MainViewModel viewModel = null; 21 | 22 | /// 23 | /// A static ViewModel used by the views to bind against. 24 | /// 25 | /// The MainViewModel object. 26 | public static MainViewModel ViewModel 27 | { 28 | get 29 | { 30 | // Delay creation of the view model until necessary 31 | if (viewModel == null) 32 | viewModel = new MainViewModel(); 33 | 34 | return viewModel; 35 | } 36 | } 37 | 38 | /// 39 | /// Provides easy access to the root frame of the Phone Application. 40 | /// 41 | /// The root frame of the Phone Application. 42 | public PhoneApplicationFrame RootFrame { get; private set; } 43 | 44 | /// 45 | /// Constructor for the Application object. 46 | /// 47 | public App() 48 | { 49 | // Global handler for uncaught exceptions. 50 | UnhandledException += Application_UnhandledException; 51 | 52 | // Show graphics profiling information while debugging. 53 | if (System.Diagnostics.Debugger.IsAttached) 54 | { 55 | // Display the current frame rate counters. 56 | Application.Current.Host.Settings.EnableFrameRateCounter = true; 57 | 58 | // Show the areas of the app that are being redrawn in each frame. 59 | //Application.Current.Host.Settings.EnableRedrawRegions = true; 60 | 61 | // Enable non-production analysis visualization mode, 62 | // which shows areas of a page that are being GPU accelerated with a colored overlay. 63 | //Application.Current.Host.Settings.EnableCacheVisualization = true; 64 | } 65 | 66 | // Standard Silverlight initialization 67 | InitializeComponent(); 68 | 69 | // Phone-specific initialization 70 | InitializePhoneApplication(); 71 | } 72 | 73 | // Code to execute when the application is launching (eg, from Start) 74 | // This code will not execute when the application is reactivated 75 | private void Application_Launching(object sender, LaunchingEventArgs e) 76 | { 77 | } 78 | 79 | // Code to execute when the application is activated (brought to foreground) 80 | // This code will not execute when the application is first launched 81 | private void Application_Activated(object sender, ActivatedEventArgs e) 82 | { 83 | // Ensure that application state is restored appropriately 84 | if (!App.ViewModel.IsDataLoaded) 85 | { 86 | App.ViewModel.LoadData(); 87 | } 88 | } 89 | 90 | // Code to execute when the application is deactivated (sent to background) 91 | // This code will not execute when the application is closing 92 | private void Application_Deactivated(object sender, DeactivatedEventArgs e) 93 | { 94 | // Ensure that required application state is persisted here. 95 | } 96 | 97 | // Code to execute when the application is closing (eg, user hit Back) 98 | // This code will not execute when the application is deactivated 99 | private void Application_Closing(object sender, ClosingEventArgs e) 100 | { 101 | } 102 | 103 | // Code to execute if a navigation fails 104 | private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) 105 | { 106 | if (System.Diagnostics.Debugger.IsAttached) 107 | { 108 | // A navigation has failed; break into the debugger 109 | System.Diagnostics.Debugger.Break(); 110 | } 111 | } 112 | 113 | // Code to execute on Unhandled Exceptions 114 | private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) 115 | { 116 | if (System.Diagnostics.Debugger.IsAttached) 117 | { 118 | // An unhandled exception has occurred; break into the debugger 119 | System.Diagnostics.Debugger.Break(); 120 | } 121 | } 122 | 123 | #region Phone application initialization 124 | 125 | // Avoid double-initialization 126 | private bool phoneApplicationInitialized = false; 127 | 128 | // Do not add any additional code to this method 129 | private void InitializePhoneApplication() 130 | { 131 | if (phoneApplicationInitialized) 132 | return; 133 | 134 | // Create the frame but don't set it as RootVisual yet; this allows the splash 135 | // screen to remain active until the application is ready to render. 136 | RootFrame = new PhoneApplicationFrame(); 137 | RootFrame.Navigated += CompleteInitializePhoneApplication; 138 | 139 | // Handle navigation failures 140 | RootFrame.NavigationFailed += RootFrame_NavigationFailed; 141 | 142 | // Ensure we don't initialize again 143 | phoneApplicationInitialized = true; 144 | } 145 | 146 | // Do not add any additional code to this method 147 | private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e) 148 | { 149 | // Set the root visual to allow the application to render 150 | if (RootVisual != RootFrame) 151 | RootVisual = RootFrame; 152 | 153 | // Remove this handler since it is no longer needed 154 | RootFrame.Navigated -= CompleteInitializePhoneApplication; 155 | } 156 | 157 | #endregion 158 | } 159 | } -------------------------------------------------------------------------------- /RestGuide_WP7/ApplicationIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_WP7/ApplicationIcon.png -------------------------------------------------------------------------------- /RestGuide_WP7/Background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_WP7/Background.png -------------------------------------------------------------------------------- /RestGuide_WP7/DataClasses/Objects.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace RestGuide 5 | { 6 | public class Restaurant 7 | { 8 | public int Number {get;set;} 9 | public string Name {get;set;} 10 | public string Url {get; set;} 11 | 12 | 13 | public string Cuisine { get; set; } 14 | public string Address {get;set;} 15 | public string Phone {get;set;} 16 | public string Website {get;set;} 17 | public string Text {get;set;} 18 | 19 | public string Hours {get;set;} 20 | public string CreditCards { get; set; } 21 | public string Chef { get; set; } 22 | 23 | public override string ToString() 24 | { 25 | return String.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}" 26 | ,Number, Name, Url, Cuisine, Address, Phone, Website, Text, Hours, CreditCards, Chef); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /RestGuide_WP7/DetailsPage.xaml: -------------------------------------------------------------------------------- 1 |  16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 47 | 48 | -------------------------------------------------------------------------------- /RestGuide_WP7/DetailsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Documents; 8 | using System.Windows.Input; 9 | using System.Windows.Media; 10 | using System.Windows.Media.Animation; 11 | using System.Windows.Shapes; 12 | using System.Windows.Navigation; 13 | using Microsoft.Phone.Controls; 14 | using System.Text; 15 | 16 | namespace RestGuide 17 | { 18 | public partial class DetailsPage : PhoneApplicationPage 19 | { 20 | // Constructor 21 | public DetailsPage() 22 | { 23 | InitializeComponent(); 24 | Web.Opacity = 0; 25 | Web.Loaded += new RoutedEventHandler(Web_Loaded); 26 | } 27 | 28 | void Web_Loaded(object sender, RoutedEventArgs e) 29 | { 30 | Web.NavigateToString(FormatHtml(r)); 31 | Web.Opacity = 1; 32 | } 33 | 34 | Restaurant r; 35 | // When page is navigated to set data context to selected item in list 36 | protected override void OnNavigatedTo(NavigationEventArgs e) 37 | { 38 | string selectedRestaurantName = ""; 39 | if (NavigationContext.QueryString.TryGetValue("selectedItemName", out selectedRestaurantName)) 40 | { 41 | selectedRestaurantName = selectedRestaurantName.Replace("%26", "&"); 42 | 43 | 44 | //int index = int.Parse(selectedRestaurantName); 45 | //DataContext = App.ViewModel.Items[index]; 46 | var re = from rest in App.ViewModel.Restaurants 47 | where rest.Name == selectedRestaurantName 48 | select rest; 49 | 50 | r = re.FirstOrDefault(); 51 | DataContext=r; 52 | } 53 | } 54 | 55 | string FormatHtml(Restaurant rest) 56 | { 57 | StringBuilder sb = new StringBuilder(); 58 | 59 | sb.Append(@""); 63 | //sb.Append("" + rest.Name + "" + Environment.NewLine); 64 | //sb.Append("#" + rest.Number + "" + Environment.NewLine); 65 | //sb.Append("
" + Environment.NewLine); 66 | sb.Append("" + rest.Cuisine.ToUpper() + "
" + Environment.NewLine); 67 | sb.Append("" + rest.Address + "
" + Environment.NewLine); 68 | sb.Append("T | " + Environment.NewLine); 69 | sb.Append(rest.Phone + "
" + Environment.NewLine); 70 | sb.Append("W | " + Environment.NewLine); 71 | sb.Append( 72 | String.Format("{1}
", rest.Website,rest.Website) 73 | + Environment.NewLine); 74 | 75 | sb.Append("
" + rest.Text + "

" + Environment.NewLine); 76 | 77 | sb.Append("
" + Environment.NewLine); 78 | sb.Append("
HOURS
" + Environment.NewLine); 79 | sb.Append(rest.Hours.Replace("\n","
") + "
" + Environment.NewLine); 80 | sb.Append("
CARD TYPES ACCEPTED
" + Environment.NewLine); 81 | sb.Append(rest.CreditCards.Replace("\n","
") + "
" + Environment.NewLine); 82 | sb.Append("
CHEF
" + Environment.NewLine); 83 | sb.Append(rest.Chef + "
" + Environment.NewLine); 84 | sb.Append("
" + Environment.NewLine); 85 | sb.Append("
"); 86 | sb.Append("
"); 87 | 88 | 89 | return sb.ToString(); 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /RestGuide_WP7/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 76 | 77 | -------------------------------------------------------------------------------- /RestGuide_WP7/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Documents; 8 | using System.Windows.Input; 9 | using System.Windows.Media; 10 | using System.Windows.Media.Animation; 11 | using System.Windows.Shapes; 12 | using Microsoft.Phone.Controls; 13 | 14 | namespace RestGuide 15 | { 16 | public partial class MainPage : PhoneApplicationPage 17 | { 18 | // Constructor 19 | public MainPage() 20 | { 21 | InitializeComponent(); 22 | 23 | // Set the data context of the listbox control to the sample data 24 | 25 | this.Loaded += new RoutedEventHandler(MainPage_Loaded); 26 | } 27 | 28 | // Handle selection changed on ListBox 29 | private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) 30 | { 31 | // If selected index is -1 (no selection) do nothing 32 | if (MainListBox.SelectedIndex == -1) 33 | return; 34 | 35 | // Navigate to the new page 36 | NavigationService.Navigate(new Uri("/DetailsPage.xaml?selectedItemName=" + ((Restaurant)MainListBox.SelectedItem).Name.Replace("&", "%26"), UriKind.Relative)); 37 | 38 | // Reset selected index to -1 (no selection) 39 | MainListBox.SelectedIndex = -1; 40 | } 41 | 42 | // Load data for the ViewModel Items 43 | private void MainPage_Loaded(object sender, RoutedEventArgs e) 44 | { 45 | if (!App.ViewModel.IsDataLoaded) 46 | { 47 | App.ViewModel.LoadData(); 48 | } 49 | DataContext = App.ViewModel.Restaurants; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /RestGuide_WP7/Properties/AppManifest.xml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /RestGuide_WP7/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("RestGuide")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("RestGuide")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("b390291f-e792-4db9-9d4f-8b73a54017b0")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /RestGuide_WP7/Properties/WMAppManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ApplicationIcon.png 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Background.png 25 | 0 26 | RestGuide 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /RestGuide_WP7/ReferencedAssemblies/Clarity.Phone.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_WP7/ReferencedAssemblies/Clarity.Phone.dll -------------------------------------------------------------------------------- /RestGuide_WP7/ReferencedAssemblies/Microsoft.Phone.Controls.Toolkit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_WP7/ReferencedAssemblies/Microsoft.Phone.Controls.Toolkit.dll -------------------------------------------------------------------------------- /RestGuide_WP7/RestGuide.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.20506 7 | 2.0 8 | {A7C6D292-553A-444E-B3C7-793821D9F4C3} 9 | {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 10 | Library 11 | Properties 12 | RestGuide 13 | RestGuide 14 | v4.0 15 | $(TargetFrameworkVersion) 16 | WindowsPhone 17 | Silverlight 18 | true 19 | 20 | 21 | true 22 | true 23 | RestGuide.xap 24 | Properties\AppManifest.xml 25 | RestGuide.App 26 | true 27 | true 28 | 29 | 30 | true 31 | full 32 | false 33 | Bin\Debug 34 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE 35 | true 36 | true 37 | prompt 38 | 4 39 | 40 | 41 | pdbonly 42 | true 43 | Bin\Release 44 | TRACE;SILVERLIGHT;WINDOWS_PHONE 45 | true 46 | true 47 | prompt 48 | 4 49 | 50 | 51 | 52 | ReferencedAssemblies\Clarity.Phone.dll 53 | 54 | 55 | 56 | ReferencedAssemblies\Microsoft.Phone.Controls.Toolkit.dll 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | App.xaml 69 | 70 | 71 | 72 | DetailsPage.xaml 73 | 74 | 75 | MainPage.xaml 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | Designer 85 | MSBuild:Compile 86 | 87 | 88 | MSBuild:Compile 89 | Designer 90 | 91 | 92 | Designer 93 | MSBuild:Compile 94 | 95 | 96 | MSBuild:Compile 97 | Designer 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | PreserveNewest 107 | 108 | 109 | Always 110 | 111 | 112 | 113 | PreserveNewest 114 | 115 | 116 | 117 | 118 | 125 | 126 | -------------------------------------------------------------------------------- /RestGuide_WP7/RestGuide.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 Express for Windows Phone 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestGuide", "RestGuide.csproj", "{A7C6D292-553A-444E-B3C7-793821D9F4C3}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {A7C6D292-553A-444E-B3C7-793821D9F4C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {A7C6D292-553A-444E-B3C7-793821D9F4C3}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {A7C6D292-553A-444E-B3C7-793821D9F4C3}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 15 | {A7C6D292-553A-444E-B3C7-793821D9F4C3}.Release|Any CPU.ActiveCfg = Release|Any CPU 16 | {A7C6D292-553A-444E-B3C7-793821D9F4C3}.Release|Any CPU.Build.0 = Release|Any CPU 17 | {A7C6D292-553A-444E-B3C7-793821D9F4C3}.Release|Any CPU.Deploy.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /RestGuide_WP7/RestaurantNameSelector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Documents; 6 | using System.Windows.Ink; 7 | using System.Windows.Input; 8 | using System.Windows.Media; 9 | using System.Windows.Media.Animation; 10 | using System.Windows.Shapes; 11 | 12 | using Microsoft.Phone.Controls; 13 | using Clarity.Phone.Controls; 14 | using System.Linq; 15 | 16 | /* 17 | * Source of the alphabet jump list 18 | * http://blogs.claritycon.com/blogs/kevin_marshall/archive/2010/10/06/wp7-quick-jump-grid-sample-code.aspx 19 | */ 20 | namespace RestGuide 21 | { 22 | public class RestaurantNameSelector : IQuickJumpGridSelector 23 | { 24 | public Func GetGroupBySelector() 25 | { 26 | return (p) => ((Restaurant)p).Name.FirstOrDefault(); 27 | } 28 | 29 | public Func GetOrderByKeySelector() 30 | { 31 | return (p) => ((Restaurant)p).Name; 32 | } 33 | 34 | public Func GetThenByKeySelector() 35 | { 36 | return (p) => (string.Empty); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /RestGuide_WP7/SampleData/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 56 | 57 | -------------------------------------------------------------------------------- /RestGuide_WP7/SampleData/MainViewModelSampleData.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 9 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /RestGuide_WP7/SampleData/restaurants.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_WP7/SampleData/restaurants.xml -------------------------------------------------------------------------------- /RestGuide_WP7/SplashScreenImage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_WP7/SplashScreenImage.jpg -------------------------------------------------------------------------------- /RestGuide_WP7/ViewModels/ItemViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Diagnostics; 4 | using System.Net; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Documents; 8 | using System.Windows.Ink; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Animation; 12 | using System.Windows.Shapes; 13 | 14 | namespace RestGuide 15 | { 16 | public class ItemViewModel : INotifyPropertyChanged 17 | { 18 | private string _lineOne; 19 | /// 20 | /// Sample ViewModel property; this property is used in the view to display its value using a Binding. 21 | /// 22 | /// 23 | public string LineOne 24 | { 25 | get 26 | { 27 | return _lineOne; 28 | } 29 | set 30 | { 31 | if (value != _lineOne) 32 | { 33 | _lineOne = value; 34 | NotifyPropertyChanged("LineOne"); 35 | } 36 | } 37 | } 38 | 39 | private string _lineTwo; 40 | /// 41 | /// Sample ViewModel property; this property is used in the view to display its value using a Binding. 42 | /// 43 | /// 44 | public string LineTwo 45 | { 46 | get 47 | { 48 | return _lineTwo; 49 | } 50 | set 51 | { 52 | if (value != _lineTwo) 53 | { 54 | _lineTwo = value; 55 | NotifyPropertyChanged("LineTwo"); 56 | } 57 | } 58 | } 59 | 60 | private string _lineThree; 61 | /// 62 | /// Sample ViewModel property; this property is used in the view to display its value using a Binding. 63 | /// 64 | /// 65 | public string LineThree 66 | { 67 | get 68 | { 69 | return _lineThree; 70 | } 71 | set 72 | { 73 | if (value != _lineThree) 74 | { 75 | _lineThree = value; 76 | NotifyPropertyChanged("LineThree"); 77 | } 78 | } 79 | } 80 | 81 | public event PropertyChangedEventHandler PropertyChanged; 82 | private void NotifyPropertyChanged(String propertyName) 83 | { 84 | PropertyChangedEventHandler handler = PropertyChanged; 85 | if (null != handler) 86 | { 87 | handler(this, new PropertyChangedEventArgs(propertyName)); 88 | } 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /RestGuide_WP7/ViewModels/MainViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.ObjectModel; 3 | using System.ComponentModel; 4 | using System.IO; 5 | using System.Windows; 6 | using System.Windows.Resources; 7 | using System.Xml.Serialization; 8 | using System.Collections.Generic; 9 | 10 | 11 | namespace RestGuide 12 | { 13 | public class MainViewModel : INotifyPropertyChanged 14 | { 15 | public MainViewModel() 16 | { 17 | this.Restaurants = new ObservableCollection(); 18 | } 19 | 20 | public ObservableCollection Restaurants { get; private set; } 21 | 22 | 23 | 24 | /// 25 | /// A collection for ItemViewModel objects. 26 | /// 27 | // public ObservableCollection Items { get; private set; } 28 | 29 | private string _sampleProperty = "Sample Runtime Property Value"; 30 | /// 31 | /// Sample ViewModel property; this property is used in the view to display its value using a Binding 32 | /// 33 | /// 34 | public string SampleProperty 35 | { 36 | get 37 | { 38 | return _sampleProperty; 39 | } 40 | set 41 | { 42 | if (value != _sampleProperty) 43 | { 44 | _sampleProperty = value; 45 | NotifyPropertyChanged("SampleProperty"); 46 | } 47 | } 48 | } 49 | 50 | public bool IsDataLoaded 51 | { 52 | get; 53 | private set; 54 | } 55 | 56 | /// 57 | /// Creates and adds a few ItemViewModel objects into the Items collection. 58 | /// 59 | public void LoadData() 60 | { 61 | #region load data from XML 62 | StreamResourceInfo sr = Application.GetResourceStream(new Uri(@"SampleData\restaurants.xml", UriKind.Relative)); 63 | using (TextReader reader = new StreamReader(sr.Stream)) 64 | { 65 | XmlSerializer serializer = new XmlSerializer(typeof(ObservableCollection)); 66 | var restaurants = (ObservableCollection)serializer.Deserialize(reader); 67 | 68 | 69 | var rt = new Rot13Table(); 70 | foreach (var r in restaurants) 71 | { 72 | Restaurants.Add(r); 73 | //r.Text = rt.Transform(r.Text); 74 | //r1.Add(r); 75 | } 76 | 77 | 78 | //var serializer1 = new XmlSerializer(typeof(List)); 79 | //var writer = new System.IO.StringWriter(); 80 | //serializer1.Serialize(writer, r1); 81 | //var a = writer.ToString(); 82 | } 83 | #endregion 84 | 85 | 86 | 87 | 88 | 89 | this.IsDataLoaded = true; 90 | } 91 | //List r1 = new List(); 92 | 93 | public event PropertyChangedEventHandler PropertyChanged; 94 | private void NotifyPropertyChanged(String propertyName) 95 | { 96 | PropertyChangedEventHandler handler = PropertyChanged; 97 | if (null != handler) 98 | { 99 | handler(this, new PropertyChangedEventArgs(propertyName)); 100 | } 101 | } 102 | } 103 | 104 | 105 | 106 | 107 | /// 108 | /// Contains the ROT13 text cipher code. 109 | /// 110 | class Rot13Table 111 | { 112 | /// 113 | /// Lookup table to shift characters. 114 | /// 115 | char[] _shift = new char[char.MaxValue]; 116 | 117 | /// 118 | /// Generates the lookup table. 119 | /// 120 | public Rot13Table() 121 | { 122 | // Set these as the same. 123 | for (int i = 0; i < char.MaxValue; i++) 124 | { 125 | _shift[i] = (char)i; 126 | } 127 | // Specify capital letters are shifted. 128 | for (char c = 'A'; c <= 'Z'; c++) 129 | { 130 | char x; 131 | if (c <= 'M') 132 | { 133 | x = (char)(c + 13); 134 | } 135 | else 136 | { 137 | x = (char)(c - 13); 138 | } 139 | _shift[(int)c] = x; 140 | } 141 | // Specify lowercase letters are shifted. 142 | for (char c = 'a'; c <= 'z'; c++) 143 | { 144 | char x; 145 | if (c <= 'm') 146 | { 147 | x = (char)(c + 13); 148 | } 149 | else 150 | { 151 | x = (char)(c - 13); 152 | } 153 | _shift[(int)c] = x; 154 | } 155 | } 156 | 157 | /// 158 | /// Rotate the specified text with ROT13. 159 | /// 160 | public string Transform(string value) 161 | { 162 | try 163 | { 164 | // Convert to char array. 165 | char[] a = value.ToCharArray(); 166 | // Shift each letter we need to shift. 167 | for (int i = 0; i < a.Length; i++) 168 | { 169 | int t = (int)a[i]; 170 | a[i] = _shift[t]; 171 | } 172 | // Return new string. 173 | return new string(a); 174 | } 175 | catch 176 | { 177 | // Just return original value on failure. 178 | return value; 179 | } 180 | } 181 | } 182 | } -------------------------------------------------------------------------------- /RestGuide_iOS/AppController.cs: -------------------------------------------------------------------------------- 1 | using MonoTouch.Foundation; 2 | using MonoTouch.UIKit; 3 | 4 | namespace RestGuide 5 | { 6 | /// 7 | /// ROOT of this application; referenced in "Main.cs" 8 | /// 9 | [Register ("AppController")] 10 | public class AppController : UIApplicationDelegate 11 | { 12 | UIWindow window; 13 | 14 | MonoTouch.UIKit.UINavigationController navigationController; 15 | 16 | public override bool FinishedLaunching (UIApplication app, NSDictionary options) 17 | { 18 | // Create the main view controller - the 'first' view in the app 19 | var vc = new MainViewController (); 20 | 21 | // Create a navigation controller, to which we'll add the view 22 | navigationController = new UINavigationController(); 23 | navigationController.PushViewController(vc, false); 24 | navigationController.TopViewController.Title ="RestGuide"; 25 | navigationController.NavigationBar.TintColor = UIColor.FromRGB(140/255f, 191/255f, 38/255f); 26 | navigationController.NavigationBar.BarStyle = UIBarStyle.Black; 27 | 28 | // Create the main window and add the navigation controller as a subview 29 | window = new UIWindow (UIScreen.MainScreen.Bounds); 30 | window.AddSubview(navigationController.View); 31 | window.MakeKeyAndVisible (); 32 | return true; 33 | } 34 | 35 | // This method is allegedly required in iPhoneOS 3.0 36 | public override void OnActivated (UIApplication application) 37 | { 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /RestGuide_iOS/DataClasses/Objects.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace RestGuide 5 | { 6 | public class Restaurant 7 | { 8 | public int Number {get;set;} 9 | public string Name {get;set;} 10 | public string Url {get; set;} 11 | 12 | public string Cuisine { get; set; } 13 | public string Address {get;set;} 14 | public string Phone {get;set;} 15 | public string Website {get;set;} 16 | public string Text {get;set;} 17 | 18 | public string Hours {get;set;} 19 | public string CreditCards { get; set; } 20 | public string Chef { get; set; } 21 | 22 | public string StartsWith 23 | { 24 | get 25 | { 26 | return Name[0].ToString(); 27 | } 28 | } 29 | 30 | public override string ToString() 31 | { 32 | return String.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}" 33 | ,Number, Name, Url, Cuisine, Address, Phone, Website, Text, Hours, CreditCards, Chef); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /RestGuide_iOS/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_iOS/Default.png -------------------------------------------------------------------------------- /RestGuide_iOS/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_iOS/Icon.png -------------------------------------------------------------------------------- /RestGuide_iOS/Info.plist: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /RestGuide_iOS/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MonoTouch.Foundation; 3 | using MonoTouch.UIKit; 4 | 5 | namespace RestGuide 6 | { 7 | public class Application 8 | { 9 | static void Main (string[] args) 10 | { 11 | try 12 | { 13 | UIApplication.Main (args, null, "AppController"); 14 | } 15 | catch (Exception ex) 16 | { // HACK: this is just here for debugging 17 | Console.WriteLine(ex); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /RestGuide_iOS/MainViewController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.IO; 5 | using System.Xml.Serialization; 6 | using MonoTouch.Foundation; 7 | using MonoTouch.UIKit; 8 | using System.Linq; 9 | 10 | namespace RestGuide 11 | { 12 | /// 13 | /// First view that users see - lists the top level of the hierarchy xml 14 | /// 15 | /// 16 | /// LOADS data from the xml files into public properties (deserialization) 17 | /// then we pass around references to the MainViewController so other 18 | /// ViewControllers can access the data. 19 | /// 20 | /// Added the new UITableViewSource 21 | [Register] 22 | public class MainViewController : UITableViewController 23 | { 24 | /// The main data-set of words by part-of-speech 25 | public List Restaurants; 26 | 27 | public override void ViewDidLoad () 28 | { 29 | base.ViewDidLoad (); 30 | 31 | #region load data from XML 32 | using (TextReader reader = new StreamReader("restaurants.xml")) 33 | { 34 | XmlSerializer serializer = new XmlSerializer(typeof(List)); 35 | Restaurants = (List)serializer.Deserialize(reader); 36 | } 37 | #endregion 38 | TableView.Source = new TableViewSource (Restaurants, this); 39 | TableView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight| 40 | UIViewAutoresizing.FlexibleWidth; 41 | TableView.BackgroundColor = UIColor.White; 42 | 43 | Console.WriteLine("Is you're using the simulator, switch to it now."); 44 | } 45 | 46 | /// 47 | /// Extends the new UITableViewSource in MonoTouch 1.2 (4-Nov-09) 48 | /// 49 | private class TableViewSource : UITableViewSource 50 | { 51 | static NSString kCellIdentifier = new NSString ("MyIdentifier"); 52 | private List list; 53 | private MainViewController mvc; 54 | 55 | List sectionTitles; 56 | Dictionary> sectionElements = new Dictionary>(); 57 | public TableViewSource (List list, MainViewController controller) 58 | { 59 | this.list = list; 60 | mvc = controller; 61 | sectionTitles = (from r in list 62 | orderby r.StartsWith 63 | select r.StartsWith).Distinct().ToList(); 64 | foreach (var restaurant in list) 65 | { // group elements together into 'alphabet' 66 | int sectionNumber = sectionTitles.IndexOf(restaurant.Name[0].ToString()); 67 | if (sectionElements.ContainsKey(sectionNumber)) 68 | sectionElements[sectionNumber].Add(restaurant); 69 | else 70 | sectionElements.Add(sectionNumber, new List {restaurant}); 71 | } 72 | } 73 | public override int NumberOfSections (UITableView tableView) 74 | { 75 | return sectionTitles.Count; 76 | } 77 | public override string TitleForHeader (UITableView tableView, int section) 78 | { 79 | return sectionTitles[section]; 80 | } 81 | public override string[] SectionIndexTitles (UITableView tableView) 82 | { 83 | return sectionTitles.ToArray(); 84 | } 85 | public override int RowsInSection (UITableView tableview, int section) 86 | { 87 | return sectionElements[section].Count(); //list.Count; 88 | } 89 | 90 | public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) 91 | { 92 | UITableViewCell cell = tableView.DequeueReusableCell (kCellIdentifier); 93 | if (cell == null) 94 | { 95 | cell = new UITableViewCell (UITableViewCellStyle.Subtitle, kCellIdentifier); 96 | } 97 | cell.TextLabel.Text = sectionElements[indexPath.Section][indexPath.Row].Name; 98 | cell.DetailTextLabel.Text = sectionElements[indexPath.Section][indexPath.Row].Cuisine; 99 | 100 | return cell; 101 | } 102 | 103 | /// 104 | /// If there are subsections in the hierarchy, navigate to those 105 | /// ASSUMES there are _never_ Categories hanging off the root in the hierarchy 106 | /// 107 | public override void RowSelected (UITableView tableView, NSIndexPath indexPath) 108 | { 109 | Console.WriteLine("MAIN TableViewDelegate.RowSelected: Label={0}", list[indexPath.Row].Name); 110 | 111 | var uivc = new RestaurantViewController(mvc, sectionElements[indexPath.Section][indexPath.Row]); 112 | uivc.Title = sectionElements[indexPath.Section][indexPath.Row].Name; 113 | mvc.NavigationController.PushViewController(uivc,true); 114 | } 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /RestGuide_iOS/RestGuide.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | iPhoneSimulator 6 | 9.0.21022 7 | 2.0 8 | {C126D133-851C-4E20-BE27-DBB3138EFFB5} 9 | {E613F3A2-FE9C-494F-B74E-F63BCB86FEA6};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10 | Exe 11 | RestGuide 12 | v3.5 13 | restguide 14 | RestGuide 15 | Icon.png 16 | 3.0 17 | 3.2 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\iPhoneSimulator\Debug 24 | DEBUG 25 | prompt 26 | 4 27 | None 28 | True 29 | 30 | RestGuide 31 | 32 | 33 | none 34 | false 35 | bin\iPhoneSimulator\Release 36 | prompt 37 | 4 38 | False 39 | RestGuide 40 | 41 | 42 | 43 | true 44 | full 45 | false 46 | bin\iPhone\Debug 47 | DEBUG 48 | prompt 49 | 4 50 | iPhone Developer 51 | True 52 | 53 | Roget 54 | 55 | 56 | none 57 | false 58 | bin\iPhone\Release 59 | prompt 60 | 4 61 | iPhone Developer 62 | False 63 | 64 | Roget 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /RestGuide_iOS/RestGuide.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestGuide", "RestGuide.csproj", "{C126D133-851C-4E20-BE27-DBB3138EFFB5}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|iPhoneSimulator = Debug|iPhoneSimulator 9 | Release|iPhoneSimulator = Release|iPhoneSimulator 10 | Debug|iPhone = Debug|iPhone 11 | Release|iPhone = Release|iPhone 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {C126D133-851C-4E20-BE27-DBB3138EFFB5}.Debug|iPhone.ActiveCfg = Debug|iPhone 15 | {C126D133-851C-4E20-BE27-DBB3138EFFB5}.Debug|iPhone.Build.0 = Debug|iPhone 16 | {C126D133-851C-4E20-BE27-DBB3138EFFB5}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator 17 | {C126D133-851C-4E20-BE27-DBB3138EFFB5}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator 18 | {C126D133-851C-4E20-BE27-DBB3138EFFB5}.Release|iPhone.ActiveCfg = Release|iPhone 19 | {C126D133-851C-4E20-BE27-DBB3138EFFB5}.Release|iPhone.Build.0 = Release|iPhone 20 | {C126D133-851C-4E20-BE27-DBB3138EFFB5}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator 21 | {C126D133-851C-4E20-BE27-DBB3138EFFB5}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator 22 | EndGlobalSection 23 | GlobalSection(MonoDevelopProperties) = preSolution 24 | StartupItem = GourmetTraveller.csproj 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /RestGuide_iOS/RestaurantViewController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Text; 5 | using MonoTouch.Foundation; 6 | using MonoTouch.UIKit; 7 | 8 | namespace RestGuide 9 | { 10 | /// 11 | /// Uses UIWebView since we want to format the text display (with HTML) 12 | /// 13 | public class RestaurantViewController : UIViewController 14 | { 15 | Restaurant rest; 16 | 17 | public RestaurantViewController (MainViewController mvc, Restaurant restaurant) : base() 18 | { 19 | rest = restaurant; 20 | } 21 | 22 | public UITextView textView; 23 | public UIWebView webView; 24 | 25 | public override void ViewDidLoad () 26 | { 27 | base.ViewDidLoad (); 28 | // no XIB ! 29 | webView = new UIWebView() 30 | { 31 | ScalesPageToFit = false 32 | }; 33 | webView.LoadHtmlString(FormatText(), new NSUrl()); 34 | 35 | // Set the web view to fit the width of the app. 36 | webView.SizeToFit(); 37 | 38 | // Reposition and resize the receiver 39 | webView.Frame = new RectangleF ( 40 | 0, 0, this.View.Bounds.Width, this.View.Bounds.Height); 41 | 42 | // Add the table view as a subview 43 | this.View.AddSubview(webView); 44 | 45 | } 46 | /// 47 | /// Format the restaurant text for UIWebView 48 | /// 49 | private string FormatText() 50 | { 51 | StringBuilder sb = new StringBuilder(); 52 | 53 | sb.Append(@""); 56 | sb.Append("" + rest.Name + "" + Environment.NewLine); 57 | //sb.Append("#" + rest.Number + "" + Environment.NewLine); 58 | sb.Append("
" + Environment.NewLine); 59 | sb.Append("" + rest.Cuisine.ToUpper() + "
" + Environment.NewLine); 60 | sb.Append("" + rest.Address + "
" + Environment.NewLine); 61 | sb.Append("T | " + Environment.NewLine); 62 | sb.Append(rest.Phone + "
" + Environment.NewLine); 63 | sb.Append("W | " + Environment.NewLine); 64 | sb.Append( 65 | String.Format("{1}
", rest.Website,rest.Website) 66 | + Environment.NewLine); 67 | 68 | sb.Append("
" + rest.Text + "

" + Environment.NewLine); 69 | 70 | sb.Append("
" + Environment.NewLine); 71 | sb.Append("
HOURS
" + Environment.NewLine); 72 | sb.Append(rest.Hours.Replace("\n","
") + "
" + Environment.NewLine); 73 | sb.Append("
CARD TYPES ACCEPTED
" + Environment.NewLine); 74 | sb.Append(rest.CreditCards.Replace("\n","
") + "
" + Environment.NewLine); 75 | sb.Append("
CHEF
" + Environment.NewLine); 76 | sb.Append(rest.Chef + "
" + Environment.NewLine); 77 | sb.Append("
" + Environment.NewLine); 78 | sb.Append("
"); 79 | sb.Append("
"); 80 | 81 | return sb.ToString(); 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /RestGuide_iOS/restaurants.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conceptdev/RestaurantGuide/153e0d538dada9be1871ada1a0a4a474cac4443d/RestGuide_iOS/restaurants.xml --------------------------------------------------------------------------------