Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 3c5be6ac0d2be204ed76c2d37d2634d06b534428 @Clancey committed Apr 4, 2012
53 .gitignore
@@ -0,0 +1,53 @@
+
+#ignore thumbnails created by windows
+Thumbs.db
+#Ignore files build by Visual Studio
+*.obj
+*.pdb
+*.user
+*.userprefs
+*.aps
+*.pch
+*.vspscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.cache
+*.ilk
+*.log
+*.pidb
+.svn
+[Bb]in
+[Dd]ebug*/
+*.lib
+*.sbr
+obj/
+tozip/
+test-results/
+Build/Output/
+Build/output/
+[Rr]elease*/
+_ReSharper*/
+[Tt]est[Rr]esult*
+Examples*/
+SerializerTest*/
+*.csproj.user
+*.resharper*
+*.rdl.data
+#ignore files created by TortoiseGit when resolving conflicts
+/ToZip
+LOCAL.*/
+REMOTE.*/
+BASE.*/
+LOCAL.*
+REMOTE.*
+BASE.*
+
+/nunit-result.xml
+/test-results
+*.DS_Store
+*.ipa
26 ChannelGuide.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChannelGuide", "ChannelGuide\ChannelGuide.csproj", "{547F6111-9F95-4B7A-B62D-A1D4C7C7337E}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|iPhoneSimulator = Debug|iPhoneSimulator
+ Release|iPhoneSimulator = Release|iPhoneSimulator
+ Debug|iPhone = Debug|iPhone
+ Release|iPhone = Release|iPhone
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {547F6111-9F95-4B7A-B62D-A1D4C7C7337E}.Debug|iPhone.ActiveCfg = Debug|iPhone
+ {547F6111-9F95-4B7A-B62D-A1D4C7C7337E}.Debug|iPhone.Build.0 = Debug|iPhone
+ {547F6111-9F95-4B7A-B62D-A1D4C7C7337E}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
+ {547F6111-9F95-4B7A-B62D-A1D4C7C7337E}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
+ {547F6111-9F95-4B7A-B62D-A1D4C7C7337E}.Release|iPhone.ActiveCfg = Release|iPhone
+ {547F6111-9F95-4B7A-B62D-A1D4C7C7337E}.Release|iPhone.Build.0 = Release|iPhone
+ {547F6111-9F95-4B7A-B62D-A1D4C7C7337E}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
+ {547F6111-9F95-4B7A-B62D-A1D4C7C7337E}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = ChannelGuide\ChannelGuide.csproj
+ EndGlobalSection
+EndGlobal
92 ChannelGuide/AppDelegate.cs
@@ -0,0 +1,92 @@
+//
+// Copyright 2012 Xamarin Inc (http://www.xamarin.com)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using MonoTouch.Foundation;
+using MonoTouch.UIKit;
+using MonoTouch.Dialog;
+
+namespace ChannelGuide
+{
+ // The UIApplicationDelegate for the application. This class is responsible for launching the
+ // User Interface of the application, as well as listening (and optionally responding) to
+ // application events from iOS.
+ [Register ("AppDelegate")]
+ public partial class AppDelegate : UIApplicationDelegate
+ {
+ // class-level declarations
+ UIWindow window;
+ DialogViewController dvc;
+
+ //
+ // This method is invoked when the application has loaded and is ready to run. In this
+ // method you should instantiate the window, load the UI into it and then make the window
+ // visible.
+ //
+ // You have 17 seconds to return from this method, or iOS will terminate your application.
+ //
+ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
+ {
+ // create a new window instance based on the screen size
+ window = new UIWindow (UIScreen.MainScreen.Bounds);
+
+ dvc = new DialogViewController(UITableViewStyle.Plain,CreateRoot());
+ window.RootViewController = dvc;
+
+ // make the window visible
+ window.MakeKeyAndVisible ();
+
+ return true;
+ }
+
+ private RootElement CreateRoot ()
+ {
+ List<Channel> Channels = new List<Channel> (){
+ new Channel{
+ Name = "MYST",
+ Shows = new List<Show>{
+ new Show{Title = "Law & Order",X= 0,Width = .25f},
+ new Show{Title = "Haven",X= .25f,Width = .25f},
+ new Show{Title = "Desperate Escape",X= .5f,Width = .5f},
+ }
+ },
+ new Channel{
+ Name = "MTV2CAN",
+ Shows = new List<Show>{
+ new Show{Title = "Instant Star",X= 0,Width = .125f},
+ new Show{Title = "Instant Star",X= .125f,Width = .125f},
+ new Show{Title = "Whistler",X= .25f,Width = .25f},
+ new Show{Title = "Peak Season",X= .5f,Width = .125f},
+ new Show{Title = "Ridiculousn...",X= .625f,Width = .125f},
+ new Show{Title = "Awkward.",X= .75f,Width = .125f},
+ new Show{Title = "The Hard Times of RJ Berger",X= .875f,Width = .125f},
+ }
+ }
+ };
+
+ var section = new Section ();
+ foreach (var channel in Channels) {
+ section.Add (new ChannelElement (channel));
+ }
+ RootElement root = new RootElement ("Guide"){
+ section
+ };
+ return root;
+ }
+ }
+}
+
77 ChannelGuide/ChannelGuide.csproj
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{547F6111-9F95-4B7A-B62D-A1D4C7C7337E}</ProjectGuid>
+ <ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>ChannelGuide</RootNamespace>
+ <AssemblyName>ChannelGuide</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <WarningLevel>4</WarningLevel>
+ <MtouchLink>None</MtouchLink>
+ <ConsolePause>false</ConsolePause>
+ <MtouchProfiling>true</MtouchProfiling>
+ <MtouchDebug>true</MtouchDebug>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\iPhoneSimulator\Release</OutputPath>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ <MtouchLink>None</MtouchLink>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\iPhone\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <WarningLevel>4</WarningLevel>
+ <MtouchProfiling>true</MtouchProfiling>
+ <ConsolePause>false</ConsolePause>
+ <MtouchDebug>true</MtouchDebug>
+ <CodesignKey>iPhone Developer</CodesignKey>
+ <MtouchArch>ARMv7</MtouchArch>
+ <MtouchI18n />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\iPhone\Release</OutputPath>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ <CodesignKey>iPhone Developer</CodesignKey>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Core" />
+ <Reference Include="monotouch" />
+ <Reference Include="MonoTouch.Dialog-1" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <None Include="Info.plist" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Main.cs" />
+ <Compile Include="AppDelegate.cs" />
+ <Compile Include="CustomElements.cs" />
+ <Compile Include="Model\Channel.cs" />
+ <Compile Include="Model\Show.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Model\" />
+ </ItemGroup>
+</Project>
136 ChannelGuide/CustomElements.cs
@@ -0,0 +1,136 @@
+//
+// Copyright 2012 Xamarin Inc (http://www.xamarin.com)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+using System;
+using MonoTouch.Dialog;
+using MonoTouch.UIKit;
+using MonoTouch.Foundation;
+using System.Collections.Generic;
+using System.Drawing;
+
+namespace ChannelGuide
+{
+ public class ChannelElement : Element
+ {
+ public const string Key = "ChannelElement";
+ Channel Channel;
+ public ChannelElement(Channel channel) : base ("")
+ {
+ Channel = channel;
+ }
+ public override UITableViewCell GetCell (UITableView tv)
+ {
+ ChannelCell cell = tv.DequeueReusableCell (Key) as ChannelCell;
+ if (cell == null) {
+ cell = new ChannelCell(Channel);
+ }
+ else
+ {
+ cell.UpdateCell(Channel);
+ }
+ return cell;
+ }
+
+ public class ChannelCell : UITableViewCell
+ {
+ // Create the UIViews that we will use here, layout happens in LayoutSubviews
+ public Channel Channel;
+ ChannelView ChannelView;
+ public ChannelCell (Channel channel) : base (UITableViewCellStyle.Default, ChannelElement.Key)
+ {
+
+ UpdateCell (channel);
+ }
+
+ public void UpdateCell (Channel channel)
+ {
+ if(channel == Channel)
+ return;
+ Channel = channel;
+ if(ChannelView == null)
+ ChannelView = new ChannelView();
+ ChannelView.Update(Channel);
+ this.ContentView.AddSubview(ChannelView);
+ SetNeedsDisplay ();
+ }
+ public override void LayoutSubviews ()
+ {
+ base.LayoutSubviews ();
+ ChannelView.Frame = this.Bounds;
+ }
+ }
+ public class ChannelView : UIView
+ {
+ List<UIButton> buttons;
+ Channel Channel;
+ public ChannelView()
+ {
+ buttons = new List<UIButton>();
+ }
+ public void Update (Channel channel)
+ {
+ Channel = channel;
+ SetButton();
+ }
+ private void SetButton()
+ {
+ //Clear out old buttons
+ if(buttons.Count > Channel.Shows.Count)
+ {
+ var showCount = Channel.Shows.Count;
+ var excess = buttons.Count - showCount;
+ var oldButtons = buttons.GetRange(showCount - 1,excess);
+ foreach(var button in oldButtons)
+ {
+ button.RemoveFromSuperview();
+ buttons.Remove(button);
+ button.Dispose();
+ }
+
+
+
+ }
+ // Set buttons
+ for(int i = 0; i < Channel.Shows.Count;i++)
+ {
+ UIButton btn;
+ if(buttons.Count >= i +1)
+ btn = buttons[i];
+ else
+ {
+ btn = UIButton.FromType(UIButtonType.RoundedRect);
+ btn.SetTitleColor(UIColor.Black,UIControlState.Normal);
+ buttons.Add(btn);
+ }
+ this.AddSubview(btn);
+ }
+
+ }
+
+ public override void LayoutSubviews ()
+ {
+ for(int i = 0; i< Channel.Shows.Count ; i++)
+ {
+ var show = Channel.Shows[i];
+ var btn = buttons[i];
+ btn.SetTitle(show.Title,UIControlState.Normal);
+ //TODO: change this to be dynamic and figure it out based on times
+ var frame = new RectangleF(show.X * this.Bounds.Width,0,show.Width * this.Bounds.Width,this.Bounds.Height);
+ btn.Frame = frame;
+ }
+ }
+ }
+ }
+}
+
18 ChannelGuide/Info.plist
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>UIDeviceFamily</key>
+ <array>
+ <integer>1</integer>
+ <integer>2</integer>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
34 ChannelGuide/Main.cs
@@ -0,0 +1,34 @@
+//
+// Copyright 2012 Xamarin Inc (http://www.xamarin.com)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using MonoTouch.Foundation;
+using MonoTouch.UIKit;
+
+namespace ChannelGuide
+{
+ public class Application
+ {
+ // This is the main entry point of the application.
+ static void Main (string[] args)
+ {
+ // if you want to use a different Application Delegate class from "AppDelegate"
+ // you can specify it here.
+ UIApplication.Main (args, null, "AppDelegate");
+ }
+ }
+}
31 ChannelGuide/Model/Channel.cs
@@ -0,0 +1,31 @@
+//
+// Copyright 2012 Xamarin Inc (http://www.xamarin.com)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+using System;
+using System.Collections.Generic;
+
+namespace ChannelGuide
+{
+ public class Channel
+ {
+ public string Name {get;set;}
+ public List<Show> Shows {get;set;}
+
+ public Channel ()
+ {
+ Shows = new List<Show>();
+ }
+ }
+}
+
39 ChannelGuide/Model/Show.cs
@@ -0,0 +1,39 @@
+//
+// Copyright 2012 Xamarin Inc (http://www.xamarin.com)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+using System;
+
+namespace ChannelGuide
+{
+ public class Show
+ {
+ public Show ()
+ {
+ }
+ public string Title {get;set;}
+
+ //TODO change this to all be dynamic based on start/end time
+ public float X {get;set;}
+ public float Width {get;set;}
+
+ public event EventHandler Clicked;
+
+ public void TouchDown(object sender)
+ {
+ if(Clicked != null)
+ Clicked(sender,new EventArgs());
+ }
+ }
+}
+

0 comments on commit 3c5be6a

Please sign in to comment.