예제 #1
0
        //
        // 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);

            var servers = XDocument.Load ("Servers.xml");
            var server  = servers.Elements ("Servers").Elements ("Server").First ();

            // Perform any additional setup after loading the view, typically from a nib.
            Builder = new WebDavMethodBuilder {
                Server              = new Uri ((string) server.Attribute ("Uri")),
                NetworkCredential   = new NetworkCredential ((string) server.Attribute ("User"), (string) server.Attribute ("Password")),
            };

            // load the appropriate UI, depending on whether the app is running on an iPhone or iPad
            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
                var controller = new CollectionViewController (Builder);
                navigationController = new UINavigationController (controller);
                window.RootViewController = navigationController;
            } else {
                var masterViewController = new CollectionViewController (Builder);
                var masterNavigationController = new UINavigationController (masterViewController);
                PagingDetailViewController     = new PagingDetailViewController (masterViewController);
                var detailNavigationController = new UINavigationController (PagingDetailViewController);

                splitViewController = new UISplitViewController ();
                splitViewController.WeakDelegate = PagingDetailViewController;
                splitViewController.ViewControllers = new UIViewController[] {
                    masterNavigationController,
                    detailNavigationController
                };

                window.RootViewController = splitViewController;
            }

            // make the window visible
            window.MakeKeyAndVisible ();

            return true;
        }
 /*
 // Override to support conditional editing of the table view.
 public override bool CanEditRow (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
 {
     // Return false if you do not want the specified item to be editable.
     return true;
 }
 */
 /*
 // Override to support editing the table view.
 public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
 {
     if (editingStyle == UITableViewCellEditingStyle.Delete) {
         // Delete the row from the data source.
         controller.TableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
     } else if (editingStyle == UITableViewCellEditingStyle.Insert) {
         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
     }
 }
 */
 /*
 // Override to support rearranging the table view.
 public override void MoveRow (UITableView tableView, NSIndexPath sourceIndexPath, NSIndexPath destinationIndexPath)
 {
 }
 */
 /*
 // Override to support conditional rearranging of the table view.
 public override bool CanMoveRow (UITableView tableView, NSIndexPath indexPath)
 {
     // Return false if you do not want the item to be re-orderable.
     return true;
 }
 */
 public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
 {
     var e = collectionView.Entries [indexPath.Row];
     if (e.ResourceType == WebDavResourceType.Collection) {
         var c = new CollectionViewController (collectionView.Builder, e.Href);
         collectionView.NavigationController.PushViewController (c, true);
         c.NavigationController.NavigationBar.BackItem.Title = GetCollectionEntryName (collectionView.path);
         return;
     }
     if (UserInterfaceIdiomIsPhone) {
         var details = new PagingDetailViewController (collectionView, indexPath.Row);
         // Pass the selected object to the new view controller.
         collectionView.NavigationController.PushViewController (details, true);
     } else {
         AppDelegate.PagingDetailViewController.SetCurrentPageIndex (collectionView, indexPath.Row);
         // Navigation logic may go here -- for example, create and push another view controller.
     }
 }