public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			
			// make the window visible
			window.MakeKeyAndVisible ();
			
			// create our nav controller
			navController = new UINavigationController ();

			// create our home controller based on the device
			if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
				homeViewController = new Screens.HomeScreen();
			} else {
// sample does not contain an iPad UI
//				homeViewController = new Screens.iPadHomeScreen ();
			}
			
			// push the view controller onto the nav controller and show the window
			navController.PushViewController(homeViewController, false);
			window.RootViewController = navController;
			window.MakeKeyAndVisible ();
			
			return true;
		}
Пример #2
0
		public virtual bool WillFinishLaunching (UIApplication application, MonoTouch.Foundation.NSDictionary launchOptions){
			UIViewController leftSideDrawerViewController = new MMExampleLeftSideDrawerViewController ();
			UIViewController centerViewController = new MMExampleCenterTableViewController ();
			UIViewController rightSideDrawerViewController = new UIViewController ();// new MMExampleRightSideDrawerViewController ();

			UINavigationController navigationController = new MMNavigationController ();
			navigationController.ViewControllers = new UIViewController[]{ centerViewController };
			navigationController.RestorationIdentifier = "MMExampleCenterNavigationControllerRestorationKey";

			UINavigationController leftSideNavController = new MMNavigationController ();
			leftSideNavController.ViewControllers = new UIViewController[]{ leftSideDrawerViewController };
			leftSideNavController.RestorationIdentifier = "MMExampleLeftNavigationControllerRestorationKey";

			this.DrawerController = new MMDrawerController.MMDrawerController ();
			DrawerController.CenterViewController = navigationController;
			DrawerController.LeftDrawerViewController = leftSideNavController;

			DrawerController.RestorationIdentifier = "MMDrawer";
			DrawerController.MaximumRightDrawerWidth = 200.0F;
			DrawerController.OpenDrawerGestureModeMask = MMOpenDrawerGestureMode.BezelPanningCenterView;
			DrawerController.CloseDrawerGestureModeMask = MMCloseDrawerGestureMode.BezelPanningCenterView;

			//DrawerController.DrawerVisualStateBlock = new Action (DrawerAction (DrawerController, new MMDrawerSide(), 100F));

			this.Window = new UIWindow (UIScreen.MainScreen.Bounds);
			UIColor tintColor = new UIColor (29.0F / 255.0F, 173.0F / 255.0F, 234.0F / 255.0F, 1.0F);
			this.Window.TintColor = tintColor;

			this.Window.RootViewController = this.DrawerController;

			return true;
		}
        //
        // 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)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }
Пример #4
0
        public override void DidEnterBackground(UIApplication application)
        {
            ourTask = application.BeginBackgroundTask(delegate
            {    //this is the action that will run when the task expires
                if (ourTask != 0) //this check is because we want to avoid ending the same task twice
                {
                    application.EndBackgroundTask(ourTask); //end the task
                    ourTask = 0; //reset the id
                }
            });

            //we start an asynchronous operation
            //so that we make sure that DidEnterBackground
            //executes normally
            new System.Action(delegate
            {
                MonoGameGame.EnterBackground();

                //Since we are in an asynchronous method,
                //we have to make sure that EndBackgroundTask
                //will run on the application's main thread
                //or we might have unexpected behavior.
                application.BeginInvokeOnMainThread(delegate
                {
                        if (ourTask != 0) //same as above
                        {
                            application.EndBackgroundTask(ourTask);
                            ourTask = 0;
                        }
                   });
            }).BeginInvoke(null, null);
        }
Пример #5
0
 public override void OnResignActivation(UIApplication application)
 {
     // Invoked when the application is about to move from active to inactive state.
     // This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
     // or when the user quits the application and it begins the transition to the background state.
     // Games should use this method to pause the game.
 }
Пример #6
0
 public override void FinishedLaunching(UIApplication app)
 {
     Instance = this;
     Application application = new Application ();
     kernel = new Kernel (application);
     kernel.Run ();
 }
Пример #7
0
		public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
		{
			// Override point for customization after application launch.
			// If not required for your application you can safely delete this method

			return true;
		}
Пример #8
0
		public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
		{
			Current = this;

			// SQL
//			var sqliteFilename = "TaskDB.db3";
//			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
//			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
//			var path = Path.Combine(libraryPath, sqliteFilename);
//			var conn = new Connection(path);
//			TaskMgr = new TodoItemManager(conn);

			// AZURE
			TaskMgr = new TodoItemManager(AzureStorageImplementation.DefaultService);


			// PUSH
			//var settings = UIUserNotificationSettings.GetSettingsForTypes (
			//	UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
			//	, null);
			//UIApplication.SharedApplication.RegisterUserNotificationSettings (settings);

			//UIRemoteNotificationType notificationTypes = 
			//	 UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
			//UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); 

			return true;
		}
Пример #9
0
		public override bool FinishedLaunching(UIApplication app, NSDictionary options)
		{
			window = new UIWindow(UIScreen.MainScreen.Bounds);

			var controller = new UIViewController();
			var view = new UIView (UIScreen.MainScreen.Bounds);
			view.BackgroundColor = UIColor.White;
			controller.View = view;

			controller.NavigationItem.Title = "SignalR Client";

			var textView = new UITextView(new CGRect(0, 0, 320, view.Frame.Height - 0));
			view.AddSubview (textView);


			navController = new UINavigationController (controller);

			window.RootViewController = navController;
			window.MakeKeyAndVisible();

			if (SIGNALR_DEMO_SERVER == "http://YOUR-SERVER-INSTANCE-HERE") {
				textView.Text = "You need to configure the app to point to your own SignalR Demo service.  Please see the Getting Started Guide for more information!";
				return true;
			}
			
			var traceWriter = new TextViewWriter(SynchronizationContext.Current, textView);

			var client = new CommonClient(traceWriter);
			client.RunAsync(SIGNALR_DEMO_SERVER);

			return true;
		}
Пример #10
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// create our window
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			window.MakeKeyAndVisible ();
			
			// are we running an iPhone or an iPad?
			DetermineCurrentDevice ();

			// instantiate our main navigatin controller and add it's view to the window
			mainNavController = new UINavigationController ();
			
			switch (CurrentDevice)
			{
				case DeviceType.iPhone:
					iPhoneHome = new HandlingRotation.Screens.iPhone.Home.HomeScreen ();
					mainNavController.PushViewController (iPhoneHome, false);
					break;
				
				case DeviceType.iPad:
					iPadHome = new HandlingRotation.Screens.iPad.Home.HomeScreenPad ();
					mainNavController.PushViewController (iPadHome, false);
					break;
			}

			window.RootViewController = mainNavController;

			return true;
		}
Пример #11
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            //UserDialogs.Init();
            global::Xamarin.Forms.Forms.Init();
            Insights.Initialize("0d729b1f8027a9219421908d521e3af664ae52fc");
            PushNotificationManager pushmanager = PushNotificationManager.PushManager;
            pushmanager.Delegate = this;

            if (options != null)
            {
                if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                { 
                    pushmanager.HandlePushReceived(options);
                }
            }

            pushmanager.RegisterForPushNotifications();

            try
            {
                var token = PushNotificationManager.PushManager.GetPushToken;
                
                if (!String.IsNullOrEmpty(token))
                    App.PushWooshToken = token;
            }
            catch (Exception ex)
            {
                Insights.Report(ex);
            }

            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }
Пример #12
0
        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            SensusServiceHelper.Initialize(() => new iOSSensusServiceHelper());

            // facebook settings
            Settings.AppID = "873948892650954";
            Settings.DisplayName = "Sensus";

            Forms.Init();
            FormsMaps.Init();
            MapExtendRenderer.Init();

            // toasts for iOS
            DependencyService.Register<ToastNotificatorImplementation>();
            ToastNotificatorImplementation.Init();

            LoadApplication(new App());

            uiApplication.RegisterUserNotificationSettings(UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert, new NSSet()));

            #if UNIT_TESTING
            Forms.ViewInitialized += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                    e.NativeView.AccessibilityIdentifier = e.View.StyleId;
            };

            Calabash.Start();
            #endif

            return base.FinishedLaunching(uiApplication, launchOptions);
        }
Пример #13
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)
        {
			Current = this;

			var log = new LoggerConfiguration().CreateLogger();

			log.Information("Loading");

            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;

            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            // If you have defined a view, add it here:
            // window.RootViewController  = navigationController;

			var rootNavigationController = Utilities.BuildNavigationController();
            rootNavigationController.PushViewController(new ViewControllers.Login(), false);
            window.RootViewController = rootNavigationController;

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

            Utilities.SetTintColor();

            autoSuspendHelper.FinishedLaunching(app, options);

            return true;
        }
Пример #14
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			Forms.Init ();


			// http://forums.xamarin.com/discussion/21148/calabash-and-xamarin-forms-what-am-i-missing
			Forms.ViewInitialized += (object sender, ViewInitializedEventArgs e) => {

				// http://developer.xamarin.com/recipes/testcloud/set-accessibilityidentifier-ios/
				if (null != e.View.StyleId) {
					e.NativeView.AccessibilityIdentifier = e.View.StyleId;
					Console.WriteLine("Set AccessibilityIdentifier: " + e.View.StyleId);
				}
			};


			window = new UIWindow (UIScreen.MainScreen.Bounds);
			
			window.RootViewController = App.GetMainPage ().CreateViewController ();
			window.MakeKeyAndVisible ();


			#if DEBUG
			// requires Xamarin Test Cloud Agent component
			Xamarin.Calabash.Start();
			#endif


			return true;
		}
Пример #15
0
        public override void WillTerminate(UIApplication application)
        {
            var geo = this.GetService<WshLst.Core.Interfaces.IGeolocator>();
            geo.StopTracking();

            base.WillTerminate(application);
        }
 public bool IsCommandAvailable(UIApplication a, CategorySet b)
 {
     if (a.ActiveUIDocument == null) return false;
     if (a.ActiveUIDocument.Document == null) return false;
     if (a.ActiveUIDocument.Document.IsFamilyDocument) return false;
     return true;
 }
		//
		// 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);
			
			// 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 RootViewController ();
				navigationController = new UINavigationController (controller);
				window.RootViewController = navigationController;
			} else {
				var masterViewController = new RootViewController ();
				var masterNavigationController = new UINavigationController (masterViewController);
				var detailViewController = new DetailViewController ();
				var detailNavigationController = new UINavigationController (detailViewController);
				
				splitViewController = new UISplitViewController ();
				splitViewController.WeakDelegate = detailViewController;
				splitViewController.ViewControllers = new UIViewController[] {
					masterNavigationController,
					detailNavigationController
				};
				
				window.RootViewController = splitViewController;
			}

			// make the window visible
			window.MakeKeyAndVisible ();
			
			return true;
		}
Пример #18
0
        public override void FinishedLaunching(UIApplication app)
        {
            CCApplication application = new CCApplication();
            application.ApplicationDelegate = new AppDelegate();

            application.StartGame();
        }
        // This method is invoked when the application has loaded its UI and its ready to run
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window.AddSubview (navigationController.View);
            window.MakeKeyAndVisible ();

            return true;
        }
Пример #20
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)
        {
            //
            // ENTER YOUR LICENSE INFO HERE
            //
            PXEngine.LicenseKeyForUser("SERIAL NUMBER", "USER NAME");

            // create a new window instance based on the screen size
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            window.RootViewController = new MyViewController();

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

            PXEngine shared = PXEngine.SharedInstance();

            // Print the version an build date
            Console.WriteLine("Pixate Engine v{0} {1}", shared.Version, shared.BuildDate);

            // Print the location of the current application-level stylesheet
            Console.WriteLine("CSS File location: {0}", PXStylesheet.CurrentApplicationStylesheet().FilePath);

            // Monitor for changes in the stylesheet and update styles live
            PXStylesheet.CurrentApplicationStylesheet().MonitorChanges = true;

            return true;
        }
		// This method is invoked when the application has loaded its UI and its ready to run
		public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
		{
			window.RootViewController = viewController;
			window.MakeKeyAndVisible ();

			return true;
		}
Пример #22
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)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);
            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackTranslucent;
            viewController = new FlyOutNavigationController ();
            viewController.NavigationRoot = new RootElement ("")
            {
                new Section ("Section 1"){
                    new StringElement ("View 1"),
                    new ImageStringElement("View 2",UIImage.FromFile("jhill.jpeg")),
                    new StringElement ("View 3"),
                },
                new Section ("Section 2"){
                    new StringElement ("View 1"),
                    new StringElement ("View 2"),
                }
            };
            viewController.ViewControllers = new UIViewController[]{
                 new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 1"){new Section (){new StringElement ("View 1")}}))
                ,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 1"){new Section (){new StringElement ("View 2")}}))
                ,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 1"){new Section (){new StringElement ("View 3")}}))
                ,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 2"){new Section (){new StringElement ("View 1")}}))
                ,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 2"){new Section (){new StringElement ("View 2")}}))
            };
            window.RootViewController = viewController;
            window.MakeKeyAndVisible ();

            return true;
        }
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			
			// make the window visible
			window.MakeKeyAndVisible ();
			
			// create our nav controller
			navController = new UINavigationController ();

			// create our home controller based on the device
			if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
				homeViewController = new Tasky.Screens.iPhone.Home.controller_iPhone();
			} else {
//				homeViewController = new Hello_UniversalViewController ("Hello_UniversalViewController_iPad", null);
			}
			
			// Styling
			UINavigationBar.Appearance.TintColor = UIColor.FromRGB (38, 117 ,255); // nice blue
			UITextAttributes ta = new UITextAttributes();
			ta.Font = UIFont.FromName ("AmericanTypewriter-Bold", 0f);
			UINavigationBar.Appearance.SetTitleTextAttributes(ta);
			ta.Font = UIFont.FromName ("AmericanTypewriter", 0f);
			UIBarButtonItem.Appearance.SetTitleTextAttributes(ta, UIControlState.Normal);
			

			// push the view controller onto the nav controller and show the window
			navController.PushViewController(homeViewController, false);
			window.RootViewController = navController;
			window.MakeKeyAndVisible ();
			
			return true;
		}
Пример #24
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options) {
            UserDialogs.Init();
            Forms.Init();
            this.LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }
 public GraphCodeWindowRegistrar(Lifetime lifetime, ToolWindowManager toolWindowManager,
                                     GraphCodeToolWindow descriptor, UIApplication environment)
 {
     _environment = environment;
     _lifetime = lifetime;
     
     _toolWindowClass = toolWindowManager.Classes[descriptor];
     //_toolWindowClass.RegisterEmptyContent(
     //  lifetime,
     //  lt =>
     //  {
     //      var graphs = (new GraphLoader()).Load();
     //      var tabControl = new System.Windows.Controls.TabControl();
     //      var zcontrols = new List<ZoomControl>();
     //      foreach (var graph in graphs)
     //      {
     //          var gArea = InitializeGraphArea.Initialize(graph);
     //          var zcontrol = new ZoomControl();
     //          zcontrol.Content = gArea;
     //          zcontrols.Add(zcontrol);
     //      }
     //      tabControl.ItemsSource = zcontrols;
     //      return (new EitherControl(tabControl)).BindToLifetime(lt);
     //  });
 }
Пример #26
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			runner = new TouchRunner (window);

			// tests can be inside the main assembly
			runner.Add (Assembly.GetExecutingAssembly ());
#if false
			// you can use the default or set your own custom writer (e.g. save to web site and tweet it ;-)
			runner.Writer = new TcpTextWriter ("10.0.1.2", 16384);
			// start running the test suites as soon as the application is loaded
			runner.AutoStart = true;
			// crash the application (to ensure it's ended) and return to springboard
			runner.TerminateAfterExecution = true;
#endif
#if false
			// you can get NUnit[2-3]-style XML reports to the console or server like this
			// replace `null` (default to Console.Out) to a TcpTextWriter to send data to a socket server
			// replace `NUnit2XmlOutputWriter` with `NUnit3XmlOutputWriter` for NUnit3 format
			runner.Writer = new NUnitOutputTextWriter (runner, null, new NUnitLite.Runner.NUnit2XmlOutputWriter ());
			// the same AutoStart and TerminateAfterExecution can be used for build automation
#endif
			window.RootViewController = new UINavigationController (runner.GetViewController ());
			window.MakeKeyAndVisible ();
			return true;
		}
 public override void OnActivated(UIApplication application)
 {
     // FBSample logic
     // We need to properly handle activation of the application with regards to SSO
     //  (e.g., returning from iOS 6.0 authorization dialog or from fast app switching).
     FBSession.ActiveSession.HandleDidBecomeActive();
 }
        public override void DetectWebViewLoadFinishedEvent(UIApplication application, NSDictionary launchOptions)
        {
            UIApplicationState applicationState = application.ApplicationState;
            ((UnityUI_iOSViewController_UIWebView) MainViewController ()).webView.LoadFinished += delegate {
                #if DEBUG
            log ("************** WEBVIEW LOAD FINISHED");
                #endif

                if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
                    UIView.AnimationsEnabled = true;  //enable again animation in all view  (see UnityUI_iOSViewController_UIWebView#loadWebView for details)
                }

                // inform other weak delegates (if exist) about the web view finished event
                IPhoneServiceLocator.WebViewLoadingFinished(applicationState, launchOptions);

                // The NSDictionary options variable would contain any notification data if the user clicked the 'view' button on the notification
                // to launch the application.
                // This method processes these options from the FinishedLaunching.
                processLaunchOptions (launchOptions, true, applicationState);

                // Processing extra data received when launched externally (using custom scheme url)
                processLaunchData ();

            };
        }
Пример #29
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);

            InvokeOnMainThread(delegate {
                TwitterAccount.getAccount();
            });

            flyoutController = new FlyOutNavigationController();
            tl = new Timeline(flyoutController);
            flyoutController.NavigationRoot = new RootElement("")
            {
                new Section("Navigation")
                {
                    new StringElement("Timeline")
                }
            };

            flyoutController.ViewControllers = new UIViewController[]
            {
                new UINavigationController(tl)
            };

            window.AddSubview(flyoutController.View);

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

            return true;
        }
Пример #30
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// check is it 64bit or 32bit
			Console.WriteLine (IntPtr.Size);

			// Main app do nothing
			// Go to Photo > Edit then choose PhotoFilter to start app extension

			window = new UIWindow (UIScreen.MainScreen.Bounds);
			window.BackgroundColor = UIColor.White;

			note = new UILabel ();
			note.Text = "Note that the app in this sample only serves as a host for the extension. To use the sample extension, edit a photo or video using the Photos app, and tap the extension icon";
			note.Lines = 0;
			note.LineBreakMode = UILineBreakMode.WordWrap;
			var frame = note.Frame;
			note.Frame = new CGRect (0, 0, UIScreen.MainScreen.Bounds.Width * 0.75f, 0);
			note.SizeToFit ();

			window.AddSubview (note);
			note.Center = window.Center;

			window.MakeKeyAndVisible ();
			return true;
		}
Пример #31
0
 static void Main(string[] args)
 {
     UIApplication.Main(args, null, "AppDelegate");
 }
Пример #32
0
 public override void WillTerminate(UIApplication application)
 {
     // Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
 }
Пример #33
0
 public override void OnActivated(UIApplication application)
 {
     // Restart any tasks that were paused (or not yet started) while the application was inactive.
     // If the application was previously in the background, optionally refresh the user interface.
 }
Пример #34
0
 public override void WillEnterForeground(UIApplication application)
 {
     // Called as part of the transiton from background to active state.
     // Here you can undo many of the changes made on entering the background.
 }
Пример #35
0
 public override void DidEnterBackground(UIApplication application)
 {
     // Use this method to release shared resources, save user data, invalidate timers and store the application state.
     // If your application supports background exection this method is called instead of WillTerminate when the user quits.
 }
Пример #36
0
 public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
 {
     // Override point for customization after application launch.
     // If not required for your application you can safely delete this method
     return(true);
 }
 // 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");
 }
Пример #38
0
 public override void OnActivated(UIApplication uiApplication)
 {
     connectFCM();
     base.OnActivated(uiApplication);
 }
Пример #39
0
		public override bool OpenUrl (UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
		{
			// Functionality to test preview containers of Google Tag Manager
			Analytics.HandleOpenUrl (url);
			return true;
		}
Пример #40
0
        public static ResultDTO CreateDraft(RequestTransfer[] transferRequest, User user)
        {
            var          result       = new ResultDTO();
            string       transitWhs   = String.Empty;
            var          objectCode   = BoObjectTypes.oInventoryTransferRequest;
            var          item         = String.Empty;
            FoodPlantDAO foodPlantDAO = new FoodPlantDAO();

            try {
                var oStockTransferDraft = (Documents)DIApplication.Company.GetBusinessObject(BoObjectTypes.oDrafts); //ODRF

                oStockTransferDraft.CardCode      = transferRequest[0].Code;
                oStockTransferDraft.DocObjectCode = BoObjectTypes.oStockTransfer;
                oStockTransferDraft.UserFields.Fields.Item("U_GLO_BusinessPartner").Value = transferRequest[0].Code;
                oStockTransferDraft.UserFields.Fields.Item("U_PL_WhsReq").Value           = transferRequest[0].FromWhs;
                oStockTransferDraft.Series   = user.Series;
                oStockTransferDraft.Comments = transferRequest[0].Observations;

                foreach (var line in transferRequest)
                {
                    transitWhs = foodPlantDAO.GetAvailableTransitWarehouse(line.Item);
                    if (String.IsNullOrEmpty(transitWhs))
                    {
                        item = line.Item;
                        break;
                    }

                    oStockTransferDraft.Lines.ItemCode      = line.Item;
                    oStockTransferDraft.Lines.BaseEntry     = line.Folio;
                    oStockTransferDraft.Lines.BaseLine      = line.LineNum;
                    oStockTransferDraft.Lines.WarehouseCode = foodPlantDAO.GetAvailableTransitWarehouse(line.Item);
                    oStockTransferDraft.Lines.Quantity      = line.Quantity;
                    oStockTransferDraft.Lines.BaseType      = (int)objectCode;
                    oStockTransferDraft.Lines.CostingCode   = user.Area;
                    oStockTransferDraft.Lines.Add();
                }

                if (String.IsNullOrEmpty(transitWhs))
                {
                    return(new ResultDTO()
                    {
                        Success = false, Message = String.Format("Error: No hay almacenes de transito disponibles para este artículo {0}", item)
                    });
                }

                if (oStockTransferDraft.Add() != 0)
                {
                    UIApplication.ShowMessageBox(string.Format("Exception: {0}", DIApplication.Company.GetLastErrorDescription()));
                    QsLog.WriteError("TransferDI (Draft) " + DIApplication.Company.GetLastErrorDescription());
                    result.Success = false;
                    result.Message = "Error: " + DIApplication.Company.GetLastErrorDescription();
                }
                else
                {
                    result.Success = true;
                    result.Message = DIApplication.Company.GetNewObjectKey();
                }
            }
            catch (AggregateException ae) {
                ae.Handle(e => {
                    HandleException(e, "TransferDI(Draft)");
                    result.Message = "Error: " + e.Message;
                    result.Success = false;
                    return(true);
                });
            }
            catch (Exception ex) {
                HandleException(ex, "TransferDI(Draft)");
                result.Message = "Error: " + ex.Message;
                result.Success = false;
            }

            return(result);
        }
Пример #41
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;

            // Get the current Document
            Document curDoc = uiapp.ActiveUIDocument.Document;

            //Get the current View
            View curView = uidoc.Document.ActiveView;

            BoundingBoxXYZ curViewBoundary = curView.CropBox;


            FilteredElementCollector viewCollector = new FilteredElementCollector(curDoc);

            viewCollector.OfClass(typeof(View3D));
            List <View3D> view3dList = viewCollector.ToElements().Cast <View3D>().Where(x => x.IsTemplate == false).ToList();

            //TaskDialog.Show("test", view3dList.First().ViewName.ToString());


            //Build eyeLevel and eyeLevel sketchplane
            double eyeLevel  = 5;
            XYZ    eyeNormal = new XYZ(0, 0, 1);
            XYZ    xAxis     = new XYZ(1, 0, 0);
            XYZ    yAxis     = new XYZ(0, 1, 0);

            //Isovist variables
            int    numRays       = 600;
            double isoRadius     = 300;
            double isoStartAngle = 0;
            double isoEndAngle   = 360;

            //Convert to radians
            double radIsoStartAngle = (Math.PI / 180) * isoStartAngle;
            double radIsoEndAngle   = (Math.PI / 180) * isoEndAngle;


            //Get all walls
            FilteredElementCollector wallCollector = new FilteredElementCollector(curDoc, curView.Id);

            wallCollector.OfCategory(BuiltInCategory.OST_Walls);


            //Get all stacked walls
            FilteredElementCollector stackedWallCollector = new FilteredElementCollector(curDoc, curView.Id);

            stackedWallCollector.OfCategory(BuiltInCategory.OST_StackedWalls);

            stackedWallCollector.UnionWith(wallCollector).WhereElementIsNotElementType();


            //TaskDialog.Show("Test", stackedWallCollector.Count().ToString() + " Walls");


            List <Face>  wallFaces  = new List <Face>();
            double       totalArea  = 0;
            List <Solid> wallSolids = new List <Solid>();

            foreach (Element curWall in stackedWallCollector)
            {
                Options         opt      = new Options();
                GeometryElement geomElem = curWall.get_Geometry(opt);


                foreach (GeometryObject geomObj in geomElem)
                {
                    Solid geomSolid = geomObj as Solid;
                    wallSolids.Add(geomSolid);


                    if (null != geomSolid)
                    {
                        foreach (Face geomFace in geomSolid.Faces)
                        {
                            totalArea += geomFace.Area;
                            wallFaces.Add(geomFace);
                        }
                    }
                }
            }

            //TaskDialog.Show("test", wallFaces.Count().ToString() + "  Faces");



            //Determine All Defaults for stuff later
            ElementId defaultView3d = curDoc.GetDefaultElementTypeId(ElementTypeGroup.ViewType3D);

            ElementId defaultTxtId = curDoc.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType);
            ElementId defaultFRId  = curDoc.GetDefaultElementTypeId(ElementTypeGroup.FilledRegionType);



            //Create View Boundary filter for roomCollector

            Outline outline = new Outline(new XYZ(curViewBoundary.Min.X, curViewBoundary.Min.Y, -100), new XYZ(curViewBoundary.Max.X, curViewBoundary.Max.Y, 100));
            BoundingBoxIsInsideFilter bbFilter = new BoundingBoxIsInsideFilter(outline);

            //FilteredElementCollector roomList = roomCollector.WherePasses(bbFilter);


            // Get all rooms; Divide into point grid; Return points in curPointList
            RoomFilter filter = new RoomFilter();

            FilteredElementCollector roomCollector = new FilteredElementCollector(curDoc, curView.Id);

            roomCollector.WherePasses(filter).WherePasses(bbFilter);

            TaskDialog.Show("Magic View Region Drawing Machine", "Be sure to set the crop region around the rooms you would like to test, encompassing at least one exterior wall and all bounding elements." +
                            "Only rooms located fully within the bounds of the view range will be calculated.");
            TaskDialog.Show("Magic View Region Drawing Machine", roomCollector.Count().ToString() + " rooms fully visible in current view. The more rooms you run, the longer this will take!");

            Transaction t = new Transaction(curDoc, "Draw Some Lines");

            t.Start();

            View3D curView3d = View3D.CreateIsometric(curDoc, defaultView3d);

            IEnumerable <Element> extWalls = GetExteriorWalls(curDoc, curView);

            //TaskDialog.Show("test", extWalls.Count().ToString() +"  Exterior Walls");

            List <XYZ> somePoints = new List <XYZ>();

            foreach (Element wall in extWalls)
            {
                List <XYZ> pointsList = new List <XYZ>();


                pointsList = GetWallOpenings(wall, eyeLevel, curView3d);

                somePoints.AddRange(pointsList);
            }

            //TaskDialog.Show("test", somePoints.Count.ToString()+" points");


            List <List <Curve> > viewCones = new List <List <Curve> >();



            foreach (XYZ curPoint in somePoints)
            {
                Plane       eyePlane       = Plane.CreateByNormalAndOrigin(eyeNormal, curPoint);
                SketchPlane eyeSketchPlane = SketchPlane.Create(curDoc, eyePlane);

                //Arc arc = Arc.Create(curPoint, 2, 0, 360, xAxis, yAxis);
                //ModelCurve newArc = curDoc.Create.NewModelCurve(arc, eyeSketchPlane);



                List <Curve> outLineList = createIsovist(curPoint, numRays, isoRadius, radIsoStartAngle, radIsoEndAngle, curView, curDoc, eyeSketchPlane, wallFaces, defaultFRId);


                viewCones.Add(outLineList);
            }

            //Convert to polygons in int values
            Polygons polys = GetBoundaryLoops(viewCones);
            //TaskDialog.Show("test", polys.Count.ToString()+ " Polygons");


            //Calculate Intersection
            Polygons union = new Polygons();

            Clipper c = new Clipper();

            c.AddPath(polys[0], PolyType.ptSubject, true);

            for (int i = 1; i < polys.Count - 1; i++)
            {
                c.AddPath(polys[i], PolyType.ptClip, true);
            }

            c.Execute(ClipType.ctUnion, union, PolyFillType.pftPositive);

            /*
             *
             *          TaskDialog.Show("test", union.Count.ToString()+ " Polygons");
             *
             *          if (0 < union.Count)
             *          {
             *                  List<CurveLoop>regionLoops = new List<CurveLoop>();
             *
             *                  for (int p = 0; p < union.Count -1; p++)
             *                  {
             *                          List<Curve> unionLineList = new List<Curve>();
             *                          Polygon poly = union[p];
             *
             *                          for (int i = 1; i <= poly.Count-1; i++)
             *                          {
             *                                  unionLineList.Add(Line.CreateBound(GetXyzPoint(poly[i-1]), GetXyzPoint(poly[i])));
             *
             *                          }
             *                          unionLineList.Add(Line.CreateBound(GetXyzPoint(poly[poly.Count-1]), GetXyzPoint(poly[0])));
             *
             *                          CurveLoop regionLoop = CurveLoop.Create(unionLineList);
             *
             *                          regionLoops.Add(regionLoop);
             *
             *                  }
             *
             *                  FilledRegion region = FilledRegion.Create(curDoc, defaultFRId, curView.Id, regionLoops);
             *
             *
             *          }
             */


            foreach (Room curRoom in roomCollector)
            {
                SpatialElementBoundaryOptions bo = new SpatialElementBoundaryOptions();

                List <Curve> roomCurves = new List <Curve>();
                foreach (List <BoundarySegment> lstBs in curRoom.GetBoundarySegments(bo))
                {
                    foreach (BoundarySegment bs in lstBs)
                    {
                        roomCurves.Add(bs.GetCurve());
                    }
                }

                XYZ sketchPoint = new XYZ(0, 0, 0);

                Plane       eyePlane       = Plane.CreateByNormalAndOrigin(eyeNormal, sketchPoint);
                SketchPlane eyeSketchPlane = SketchPlane.Create(curDoc, eyePlane);


                List <List <Curve> > roomLoops = new List <List <Curve> >();

                roomLoops.Add(roomCurves);

                //Convert to polygon in int values
                Polygon roomPoly = GetBoundaryLoop(roomCurves);


                //Calculate Intersection
                Polygons intersection = new Polygons();

                Clipper c2 = new Clipper();

                c2.AddPath(roomPoly, PolyType.ptClip, true);
                c2.AddPaths(union, PolyType.ptSubject, true);

                c2.Execute(ClipType.ctIntersection, intersection, PolyFillType.pftPositive);

                //TaskDialog.Show("test", intersection.Count.ToString());


                if (0 < intersection.Count)
                {
                    List <CurveLoop> regionLoops          = new List <CurveLoop>();
                    List <Curve>     intersectionLineList = new List <Curve>();
                    Polygon          poly = intersection[0];

                    IntPoint?p0 = null;
                    IntPoint?p  = null;

                    foreach (IntPoint q in poly)
                    {
                        if (null == p0)
                        {
                            p0 = q;
                        }
                        if (null != p)
                        {
                            intersectionLineList.Add(Line.CreateBound(GetXyzPoint(p.Value), GetXyzPoint(q)));
                        }
                        p = q;
                    }

                    intersectionLineList.Add(Line.CreateBound(GetXyzPoint(poly[poly.Count - 1]), GetXyzPoint(poly[0])));

                    foreach (Curve cur in intersectionLineList)
                    {
                        //ModelCurve newArc = curDoc.Create.NewModelCurve(cur, eyeSketchPlane);
                    }


                    CurveLoop regionLoop = CurveLoop.Create(intersectionLineList);

                    regionLoops.Add(regionLoop);


                    //TaskDialog.Show("test", intersectionLineList.Count.ToString());



                    FilledRegion region = FilledRegion.Create(curDoc, defaultFRId, curView.Id, regionLoops);
                }
            }

            t.Commit();



            TaskDialog.Show("Magic View Region Drawing Machine", "Always double check the results, sometimes walls are missed. Tip: Curtain wall is prone to gliches and watch your door openings... Enjoy!");

            return(Result.Succeeded);
        }
Пример #42
0
 public override void DidEnterBackground(UIApplication uiApplication)
 {
     Messaging.SharedInstance.Disconnect();
 }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            Debug.Print("Start");

            //categories selected by default
            List <string> defaultSelectedCategories = new List <string>()
            {
                "Air Terminals", "Cable Trays", "Casework", "Ceilings",
                "Duct Accessories", "Duct Fittings", "Duct Systems", "Floors", "Wires"
            };

            //categories in the current model excluding tags and analytical
            List <string> documentCategories = new List <string>();

            foreach (Category item in doc.Settings.Categories)
            {
                if (!item.Name.Contains("Tags") && !item.Name.Contains("Analytical"))
                {
                    documentCategories.Add(item.Name);
                }
            }

            using (var form = new CreateParamsForm(documentCategories, defaultSelectedCategories))
            {
                form.ShowDialog();

                if (form.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                {
                    return(Result.Cancelled);
                }

                StringBuilder sb = new StringBuilder();

                List <Category> selectedCategories = new List <Category>();

                Dictionary <string, string> parametersNamesAndValues = new Dictionary <string, string>();


                Categories allCategories = doc.Settings.Categories;


                foreach (string item in form.SelectedCategories)
                {
                    sb.AppendLine(item);

                    selectedCategories.Add(allCategories.get_Item(item));
                }

                for (int i = 0; i < form.ParametersNames.Count; i++)
                {
                    //sb.AppendLine($"{form.ParametersNames[i]} : {form.ParametersValues[i]}");
                    sb.AppendLine($"{form.ParametersNames[i]}");
                    if (form.ParametersNames[i].Length > 3)
                    {
                        parametersNamesAndValues.Add(form.ParametersNames[i], form.ParametersValues[i]);
                    }
                }


                //if a parameter with the same is already in the project, throw an error

                int count = 0;

                using (Transaction t = new Transaction(doc, "Add parameters"))
                {
                    t.Start();

                    count = CreateProjectParameters(app, doc, selectedCategories, parametersNamesAndValues.Keys.ToList(), "WPA-Data");

                    t.Commit();
                }

                TaskDialog.Show("Result", $"{count} parameters added");

                using (Transaction t = new Transaction(doc, "Set parameters"))
                {
                    t.Start();

                    foreach (string categoryName in form.SelectedCategories)
                    {
                        Category cat = doc.Settings.Categories.get_Item(categoryName);

                        IList <Element> allElements = new FilteredElementCollector(doc).OfCategoryId(cat.Id).WhereElementIsNotElementType().ToElements();

                        foreach (Element element in allElements)
                        {
                            foreach (string param in parametersNamesAndValues.Keys)
                            {
                                //check that the parameter exists first!
                                element.LookupParameter(param).Set(parametersNamesAndValues[param]);
                            }
                        }
                    }

                    t.Commit();
                }



                //TaskDialog.Show("r", sb.ToString());
            }



            return(Result.Succeeded);
        }
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app   = commandData.Application;
            UIDocument    uidoc = app.ActiveUIDocument;
            Document      doc   = uidoc.Document;

            List <Element> a = new List <Element>();

            if (!Util.GetSelectedElementsOrAll(a, uidoc,
                                               typeof(FamilyInstance)))
            {
                Selection sel = uidoc.Selection;
                message = (0 < sel.GetElementIds().Count)
          ? "Please select some family instances."
          : "No family instances found.";
                return(Result.Failed);
            }
            FamilyInstance inst = a[0] as FamilyInstance;

            // Here are two ways to traverse the nested instance geometry.
            // The first way can get the right position, but can't get the right structure.
            // The second way can get the right structure, but can't get the right position.
            // What I want is the right structure and right position.

            // First way:

            // In the current project project1.rvt, I can get myFamily3 instance via API,
            // the class is Autodesk.Revit.Elements.FamilyInstance.
            // Then i try to get its geometry:

            Options         opt        = app.Application.Create.NewGeometryOptions();
            GeometryElement geoElement = inst.get_Geometry(opt);

            //GeometryObjectArray a1 = geoElement.Objects; // 2012
            //int n = a1.Size; // 2012

            int n = geoElement.Count <GeometryObject>(); // 2013

            Debug.Print(
                "Family instance geometry has {0} geometry object{1}{2}",
                n, Util.PluralSuffix(n), Util.DotOrColon(n));

            int i = 0;

            //foreach( GeometryObject o1 in a1 ) // 2012
            foreach (GeometryObject o1 in geoElement) // 2013
            {
                GeometryInstance geoInstance = o1 as GeometryInstance;
                if (null != geoInstance)
                {
                    // geometry includes one instance, so get its geometry:

                    GeometryElement symbolGeo = geoInstance.SymbolGeometry;

                    //GeometryObjectArray a2 = symbolGeo.Objects; // 2012
                    //foreach( GeometryObject o2 in a2 ) // 2012

                    // the symbol geometry contains five solids.
                    // how can I find out which solid belongs to which column?
                    // how to relate the solid to the family instance?

                    foreach (GeometryObject o2 in symbolGeo)
                    {
                        Solid s = o2 as Solid;
                        if (null != s && 0 < s.Edges.Size)
                        {
                            List <XYZ> vertices = new List <XYZ>();
                            GetVertices(vertices, s);
                            n = vertices.Count;

                            Debug.Print("Solid {0} has {1} vertices{2} {3}",
                                        i++, n, Util.DotOrColon(n),
                                        Util.PointArrayString(vertices));
                        }
                    }
                }
            }

            // In the Revit 2009 API, we can use
            // FamilyInstance.Symbol.Family.Components
            // to obtain the nested family instances
            // within the top level family instance.

            // In the Revit 2010 API, this property has been
            // removed, since we can iterate through the elements
            // of a family just like any other document;
            // cf. What's New in the RevitAPI.chm:


#if REQUIRES_REVIT_2009_API
            ElementSet components = inst.Symbol.Family.Components;
            n = components.Size;
#endif // REQUIRES_REVIT_2009_API

            Document fdoc = doc.EditFamily(inst.Symbol.Family);

#if REQUIRES_REVIT_2010_API
            List <Element> components = new List <Element>();
            fdoc.get_Elements(typeof(FamilyInstance), components);
            n = components.Count;
#endif // REQUIRES_REVIT_2010_API

            FilteredElementCollector collector
                = new FilteredElementCollector(fdoc);

            collector.OfClass(typeof(FamilyInstance));
            IList <Element> components = collector.ToElements();

            Debug.Print(
                "Family instance symbol family has {0} component{1}{2}",
                n, Util.PluralSuffix(n), Util.DotOrColon(n));

            foreach (Element e in components)
            {
                // there are 3 FamilyInstance: Column, myFamily1, myFamily2
                // then we can loop myFamily1, myFamily2 also.
                // then get all the Column geometry
                // But all the Column's position is the same,
                // because the geometry is defined by the Symbol.
                // Not the actually position in project1.rvt

                LocationPoint lp = e.Location as LocationPoint;
                Debug.Print("{0} at {1}",
                            Util.ElementDescription(e),
                            Util.PointString(lp.Point));
            }
            return(Result.Failed);
        }
Пример #45
0
 // This method is called when the application is about to terminate. Save data, if needed.
 public override void WillTerminate(UIApplication application)
 {
 }
Пример #46
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            // obtain the current selection and pick
            // out all walls from it:

            //Selection sel = uidoc.Selection; // 2014

            ICollection <ElementId> ids = uidoc.Selection
                                          .GetElementIds(); // 2015

            List <Wall> walls = new List <Wall>(2);

            //foreach( Element e in sel.Elements ) // 2014

            foreach (ElementId id in ids) // 2015
            {
                Element e = doc.GetElement(id);

                if (e is Wall)
                {
                    walls.Add(e as Wall);
                }
            }

            if (2 != walls.Count)
            {
                message = _prompt;
                return(Result.Failed);
            }

            // ensure the two selected walls are straight and
            // parallel; determine their mutual normal vector
            // and a point on each wall for distance
            // calculations:

            List <Line> lines     = new List <Line>(2);
            List <XYZ>  midpoints = new List <XYZ>(2);
            XYZ         normal    = null;

            foreach (Wall wall in walls)
            {
                LocationCurve lc    = wall.Location as LocationCurve;
                Curve         curve = lc.Curve;

                if (!(curve is Line))
                {
                    message = _prompt;
                    return(Result.Failed);
                }

                Line l = curve as Line;
                lines.Add(l);
                midpoints.Add(Util.Midpoint(l));

                if (null == normal)
                {
                    normal = Util.Normal(l);
                }
                else
                {
                    if (!Util.IsParallel(normal, Util.Normal(l)))
                    {
                        message = _prompt;
                        return(Result.Failed);
                    }
                }
            }

            // find the two closest facing faces on the walls;
            // they are vertical faces that are parallel to the
            // wall curve and closest to the other wall.

            Options opt = app.Create.NewGeometryOptions();

            opt.ComputeReferences = true;

            List <Face> faces = new List <Face>(2);

            faces.Add(GetClosestFace(walls[0], midpoints[1], normal, opt));
            faces.Add(GetClosestFace(walls[1], midpoints[0], normal, opt));

            // create the dimensioning:

            CreateDimensionElement(doc.ActiveView,
                                   midpoints[0], faces[0].Reference,
                                   midpoints[1], faces[1].Reference);

            return(Result.Succeeded);
        }
Пример #47
0
 // This method should be used to release shared resources and it should store the application state.
 // If your application supports background exection this method is called instead of WillTerminate
 // when the user quits.
 public override void DidEnterBackground(UIApplication application)
 {
 }
Пример #48
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            // Get the access to the top most objects.
            // Notice that we have UI and DB versions for application and Document.
            // (We list them both here to show two versions.)

            UIApplication uiApp = commandData.Application;
            UIDocument    uiDoc = uiApp.ActiveUIDocument;

            _app = uiApp.Application;
            _doc = uiDoc.Document;

            // (1) select an object on a screen. (We'll come back to the selection in the UI Lab later.)
            Reference r = uiDoc.Selection.PickObject(ObjectType.Element, "Pick an element");

            // We have picked something.
            Element e = uiDoc.Document.GetElement(r);

            // (2) let's see what kind of element we got.
            // Key properties that we need to check are: Class, Category and if an element is ElementType or not.

            ShowBasicElementInfo(e);

            // (3) now, we are going to identify each major types of element.
            IdentifyElement(e);

            // Now look at other properties - important ones are parameters, locations and geometry.

            // (4) first parameters.

            ShowParameters(e, "Element Parameters: ");

            // Check to see its type parameter as well

            ElementId elemTypeId = e.GetTypeId();
            //ElementType elemType = (ElementType)_doc.get_Element(elemTypeId); // 2012
            ElementType elemType = (ElementType)_doc.GetElement(elemTypeId); // since 2013

            ShowParameters(elemType, "Type Parameters: ");

            // Okay. we saw a set or parameters for a given element or element type.
            // How can we access to each parameters. For example, how can we get the value of "length" information?
            // Here is how:

            RetrieveParameter(e, "Element Parameter (by Name and BuiltInParameter): ");
            // The same logic applies to the type parameter.
            RetrieveParameter(elemType, "Type Parameter (by Name and BuiltInParameter): ");

            // (5) location
            ShowLocation(e);

            // (6) geometry - the last piece. (Optional)
            ShowGeometry(e);

            // These are the common proerties.
            // There may be more properties specific to the given element class,
            // such as Wall.Width, .Flipped and Orientation. Expore using RevitLookup and RevitAPI.chm.

            // We are done.

            return(Result.Succeeded);
        }
Пример #49
0
 public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
 {
     return(base.FinishedLaunching(application, launchOptions));
 }
Пример #50
0
 // This method is called as part of the transiton from background to active state.
 public override void WillEnterForeground(UIApplication application)
 {
 }
Пример #51
0
 public override void PerformActionForShortcutItem(UIApplication application, UIApplicationShortcutItem shortcutItem, UIOperationHandler completionHandler)
 {
     Xamarin.Essentials.Platform.PerformActionForShortcutItem(application, shortcutItem, completionHandler);
 }
Пример #52
0
 //
 // This method is invoked when the application is about to move from active to inactive state.
 //
 // OpenGL applications should use this method to pause.
 //
 public override void OnResignActivation(UIApplication application)
 {
 }
Пример #53
0
 public override void FinishedLaunching(UIApplication app)
 {
     RunGame();
 }
Пример #54
0
        public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
        {
            if (userActivity.ActivityType == CSSearchableItem.ActionType)
            {
                #region Spotlight
                var uuid = userActivity.UserInfo.ObjectForKey(CSSearchableItem.ActivityIdentifier);
                Xamarin.Insights.Track("SearchResult", new Dictionary <string, string> {
                    { "Type", "CoreSpotlight" }
                });
                System.Console.WriteLine("Show the page for " + uuid);

                var restaurantName = SearchModel.Lookup(uuid.ToString());

                System.Console.WriteLine("which is " + restaurantName);

                MessagingCenter.Send <RestaurantGuide.App, string>
                    (App.Current as RestaurantGuide.App, "show", restaurantName);
                #endregion
            }
            else
            {
                #region NSUserActivity
                // dang it, the userInfo is blank unless I hack the UserActivity_iOS.Start() method
                // https://forums.developer.apple.com/thread/9690
                if (userActivity.ActivityType == ActivityTypes.View)
                {
                    Xamarin.Insights.Track("SearchResult", new Dictionary <string, string> {
                        { "Type", "NSUserActivity" }
                    });
                    var uid = "0";
                    if (userActivity.UserInfo.Count == 0)
                    {
                        // new item
                    }
                    else
                    {
                        uid = userActivity.UserInfo.ObjectForKey(ActivityKeys.Id).ToString();
                        if (uid == "0")
                        {
                            Console.WriteLine("No userinfo found for " + ActivityTypes.View);
                        }
                        else
                        {
                            Console.WriteLine("Should display id " + uid);
                            // handled in DetailViewController.RestoreUserActivityState
                        }
                    }
                    ContinueNavigation(uid);
                }
                if (userActivity.ActivityType == CSSearchableItem.ActionType)
                {
                    Xamarin.Insights.Track("SearchResult", new Dictionary <string, string> {
                        { "Type", "CoreSpotlight" }
                    });
                    var uid = userActivity.UserInfo.ObjectForKey(CSSearchableItem.ActivityIdentifier).ToString();

                    System.Console.WriteLine("Show the detail for id:" + uid);

                    ContinueNavigation(uid);
                }
                completionHandler(null);                 // TODO: display UI in Forms somehow
                #endregion
            }
            return(true);
        }
Пример #55
0
        // This method is invoked when the application has loaded its UI and its ready to run
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            JsonElement sampleJson;
            var         Last = new DateTime(2010, 10, 7);

            Console.WriteLine(Last);

            var p = Path.GetFullPath("background.png");

            var menu = new RootElement("Demos")
            {
                new Section("Element API")
                {
                    new StringElement("iPhone Settings Sample", DemoElementApi),
                    new StringElement("Dynamically load data", DemoDynamic),
                    new StringElement("Add/Remove demo", DemoAddRemove),
                    new StringElement("Assorted cells", DemoDate),
                    new StyledStringElement("Styled Elements", DemoStyled)
                    {
                        BackgroundUri = new Uri("file://" + p)
                    },
                    new StringElement("Load More Sample", DemoLoadMore),
                    new StringElement("Row Editing Support", DemoEditing),
                    new StringElement("Advanced Editing Support", DemoAdvancedEditing),
                    new StringElement("Owner Drawn Element", DemoOwnerDrawnElement),
                    new StringElement("UIViewElement insets", DemoInsets),
                },
                new Section("Container features")
                {
                    new StringElement("Pull to Refresh", DemoRefresh),
                    new StringElement("Headers and Footers", DemoHeadersFooters),
                    new StringElement("Root Style", DemoContainerStyle),
                    new StringElement("Index sample", DemoIndex),
                },
                new Section("Json")
                {
                    (sampleJson = JsonElement.FromFile("sample.json")),
                    // Notice what happens when I close the paranthesis at the end, in the next line:
                    new JsonElement("Load from URL", "file://" + Path.GetFullPath("sample.json"))
                },
                new Section("Auto-mapped", footer)
                {
                    new StringElement("Reflection API", DemoReflectionApi)
                },
            };

            //
            // Lookup elements by ID:
            //
            var jsonSection = sampleJson ["section-1"] as Section;

            Console.WriteLine("The section has {0} elements", jsonSection.Count);
            var booleanElement = sampleJson ["first-boolean"] as BooleanElement;

            Console.WriteLine("The state of the first-boolean value is {0}", booleanElement.Value);

            //
            // Create our UI and add it to the current toplevel navigation controller
            // this will allow us to have nice navigation animations.
            //
            var dv = new DialogViewController(menu)
            {
                Autorotate = true
            };

            navigation = new UINavigationController();
            navigation.PushViewController(dv, true);

            // On iOS5 we use the new window.RootViewController, on older versions, we add the subview
            window = new UIWindow(UIScreen.MainScreen.Bounds);
            window.MakeKeyAndVisible();
            if (UIDevice.CurrentDevice.CheckSystemVersion(5, 0))
            {
                window.RootViewController = navigation;
            }
            else
            {
                window.AddSubview(navigation.View);
            }

            return(true);
        }
            Transform.CreateTranslation(_offset); // 2014
#endif // CREATE_MODEL_CURVES_FOR_TOP_FACE_EDGES

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            Options opt = app.Create.NewGeometryOptions();

            XyzEqualityComparer comparer
                = new XyzEqualityComparer(1e-6);

#if CREATE_MODEL_CURVES_FOR_TOP_FACE_EDGES
            Creator creator = new Creator(doc);

            Transaction t = new Transaction(doc);

            t.Start("Create model curve copies of top face edges");
#endif // CREATE_MODEL_CURVES_FOR_TOP_FACE_EDGES

            IList <Face> topFaces = new List <Face>();

            int n;
            int nWalls = 0;

            //foreach( Element e in uidoc.Selection.Elements ) // 2014

            foreach (ElementId id in uidoc.Selection.GetElementIds()) // 2015
            {
                Element e = doc.GetElement(id);

                Wall wall = e as Wall;

                if (null == wall)
                {
                    Debug.Print("Skipped "
                                + Util.ElementDescription(e));
                    continue;
                }

                // Get the side faces

                IList <Reference> sideFaces
                    = HostObjectUtils.GetSideFaces(wall,
                                                   ShellLayerType.Exterior);

                // Access the first side face

                Element e2 = doc.GetElement(sideFaces[0]);

                Debug.Assert(e2.Id.Equals(e.Id),
                             "expected side face element to be the wall itself");

                Face face = e2.GetGeometryObjectFromReference(
                    sideFaces[0]) as Face;

                if (null == face)
                {
                    Debug.Print("No side face found for "
                                + Util.ElementDescription(e));
                    continue;
                }

                // When there are opening such as doors or
                // windows in the wall, we need to find the
                // outer loop.
                // For one possible approach to extract the
                // outermost loop, please refer to
                // http://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html

                // Determine the outer loop of the side face
                // by finding the polygon with the largest area

                XYZ       normal;
                double    area, dist, maxArea = 0;
                EdgeArray outerLoop = null;

                foreach (EdgeArray ea in face.EdgeLoops)
                {
                    if (CmdWallProfileArea.GetPolygonPlane(
                            ea.GetPolygon(), out normal, out dist, out area) &&
                        Math.Abs(area) > Math.Abs(maxArea))
                    {
                        maxArea   = area;
                        outerLoop = ea;
                    }
                }

                n = 0;

#if GET_FACES_FROM_OUTER_LOOP
                // With the outermost loop, calculate the top faces

                foreach (Edge edge in outerLoop)
                {
                    // For each edge, get the neighbouring
                    // face and check its normal

                    for (int i = 0; i < 2; ++i)
                    {
                        PlanarFace pf = edge.get_Face(i)
                                        as PlanarFace;

                        if (null == pf)
                        {
                            Debug.Print("Skipped non-planar face on "
                                        + Util.ElementDescription(e));
                            continue;
                        }

                        if (Util.PointsUpwards(pf.Normal, 0.9))
                        {
                            if (topFaces.Contains(pf))
                            {
                                Debug.Print("Duplicate face on "
                                            + Util.ElementDescription(e));
                            }
                            else
                            {
                                topFaces.Add(pf);
                                ++n;
                            }
                        }
                    }
                }
#endif // GET_FACES_FROM_OUTER_LOOP

                List <XYZ> sideVertices = outerLoop.GetPolygon();

                // Go over all the faces of the wall and
                // determine which ones fulfill the following
                // two criteria: (i) planar face pointing
                // upwards, and (ii) neighbour of the side
                // face outer loop.

                Solid solid = wall.get_Geometry(opt)
                              .OfType <Solid>()
                              .First <Solid>(sol => null != sol);

                foreach (Face f in solid.Faces)
                {
                    if (IsTopFace(f))
                    {
                        IList <XYZ> faceVertices
                            = f.Triangulate().Vertices;

                        //if( sideVertices.Exists( v
                        //  => faceVertices.Contains<XYZ>( v, comparer ) ) )
                        //{
                        //  topFaces.Add( f );
                        //  ++n;
                        //}

                        foreach (XYZ v in faceVertices)
                        {
                            if (sideVertices.Contains <XYZ>(
                                    v, comparer))
                            {
                                topFaces.Add(f);
                                ++n;

#if CREATE_MODEL_CURVES_FOR_TOP_FACE_EDGES
                                // Display face for debugging purposes

                                foreach (EdgeArray ea in f.EdgeLoops)
                                {
                                    IEnumerable <Curve> curves
                                        = ea.Cast <Edge>()
                                          .Select <Edge, Curve>(
                                              x => x.AsCurve());

                                    foreach (Curve curve in curves)
                                    {
                                        //creator.CreateModelCurve( curve.get_Transformed( _t ) ); // 2013
                                        creator.CreateModelCurve(curve.CreateTransformed(_t)); // 2014
                                    }
                                }
#endif // CREATE_MODEL_CURVES_FOR_TOP_FACE_EDGES

                                break;
                            }
                        }
                    }
                }

                Debug.Print(string.Format(
                                "{0} top face{1} found on {2} ({3})",
                                n, Util.PluralSuffix(n),
                                Util.ElementDescription(e)),
                            nWalls++);
            }

#if CREATE_MODEL_CURVES_FOR_TOP_FACE_EDGES
            t.Commit();
#endif // CREATE_MODEL_CURVES_FOR_TOP_FACE_EDGES

            string s = string.Format(
                "{0} wall{1} successfully processed",
                nWalls, Util.PluralSuffix(nWalls));

            n = topFaces.Count;

            TaskDialog.Show("Wall Top Faces",
                            string.Format(
                                "{0} with {1} top face{2}.",
                                s, n, Util.PluralSuffix(n)));

            return(Result.Succeeded);
        }
Пример #57
0
 public override void FinishedLaunching(UIApplication app)
 {
     // Fun begins..
     game = new GameStateManagementGame();
     game.Run();
 }
Пример #58
0
 static void Main(string[] args)
 {
     UIApplication.Main(args);
 }
Пример #59
0
 public override bool FinishedLaunching(UIApplication uiApplication, Foundation.NSDictionary launchOptions)
 {
     Microsoft.UI.Xaml.Application.Start(_ => new App());
     return(base.FinishedLaunching(uiApplication, launchOptions));
 }
Пример #60
0
 // This method is required in iPhoneOS 3.0
 public override void OnActivated(UIApplication application)
 {
 }