public override void ReceivedForegroundNotification(NSDictionary userInfo, Action completionHandler)
        {
            // Application received a foreground notification
            Console.WriteLine("The application received a foreground notification");

            // iOS 10 - let foreground presentations options handle it
            if (NSProcessInfo.ProcessInfo.IsOperatingSystemAtLeastVersion(new NSOperatingSystemVersion(10, 0, 0)))
            {
                completionHandler();
                return;
            }

            if (!userInfo.ContainsKey(new NSString("aps")))
            {
                return;
            }

            NSDictionary apsDict = (NSDictionary)userInfo.ValueForKey(new NSString("aps"));

            if (!apsDict.ContainsKey(new NSString("alert")))
            {
                return;
            }
            NSDictionary alert = (NSDictionary)apsDict.ValueForKey(new NSString("alert"));

            NSString title = (NSString)alert.ValueForKey(new NSString("title"));
            NSString body  = (NSString)alert.ValueForKey(new NSString("body"));

            UIAlertController alertController = UIAlertController.Create(title: title,
                                                                         message: body,
                                                                         preferredStyle: UIAlertControllerStyle.Alert);

            UIAlertAction okAction = UIAlertAction.Create(title: "OK", style: UIAlertActionStyle.Default, handler: (UIAlertAction action) =>
            {
            });

            alertController.AddAction(okAction);

            UIViewController topController = UIApplication.SharedApplication.KeyWindow.RootViewController;

            alertController.PopoverPresentationController.SourceView = topController.View;

            topController.PresentViewController(alertController, true, null);

            completionHandler();
        }
예제 #2
0
 public void Add(string text, Action action, bool isCancel = false)
 {
     if (controller != null)
     {
         controller.AddAction(UIAlertAction.Create(text, isCancel ? UIAlertActionStyle.Cancel : UIAlertActionStyle.Default,
                                                   alert => { action?.Invoke(); }));
     }
     else
     {
         var index = (int)sheet.AddButton(text);
         dict[index] = action;
         if (isCancel)
         {
             sheet.CancelButtonIndex = index;
         }
     }
 }
        // Function to query map image sublayers when the query button is clicked.
        private void QuerySublayers_Click(object sender, EventArgs e)
        {
            // Clear selected features from the graphics overlay.
            _selectedFeaturesOverlay.Graphics.Clear();

            // Prompt the user for a query.
            UIAlertController prompt = UIAlertController.Create("Enter query", "Query for places with population(2000) > ", UIAlertControllerStyle.Alert);

            prompt.AddTextField(obj =>
            {
                _queryEntry      = obj;
                obj.Text         = "181000";
                obj.KeyboardType = UIKeyboardType.NumberPad;
            });
            prompt.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, submitQuery));
            PresentViewController(prompt, true, null);
        }
        private async void GetMyMaps_Clicked(object sender, EventArgs e)
        {
            try
            {
                // For UI popup.
                _myMapsLastClicked = true;

                await GetMyMaps();
            }
            catch (Exception ex)
            {
                UIAlertController alertController = UIAlertController.Create("There was a problem.", ex.ToString(),
                                                                             UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null));
                PresentViewController(alertController, true, null);
            }
        }
        private void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            // Hide keyboard if present.
            _bufferDistanceMilesTextField.ResignFirstResponder();

            try
            {
                // Get the location tapped by the user (a map point in the WebMercator projected coordinate system).
                MapPoint userTapPoint = e.Location;

                // Get the buffer distance (miles) entered in the text box.
                double bufferInMiles = Convert.ToDouble(_bufferDistanceMilesTextField.Text);

                // Call a helper method to convert the input distance to meters.
                double bufferInMeters = LinearUnits.Miles.ToMeters(bufferInMiles);

                // Create a planar buffer graphic around the input location at the specified distance.
                Geometry bufferGeometryPlanar = GeometryEngine.Buffer(userTapPoint, bufferInMeters);
                Graphic  planarBufferGraphic  = new Graphic(bufferGeometryPlanar);

                // Create a geodesic buffer graphic using the same location and distance.
                Geometry bufferGeometryGeodesic = GeometryEngine.BufferGeodetic(userTapPoint, bufferInMeters, LinearUnits.Meters, double.NaN, GeodeticCurveType.Geodesic);
                Graphic  geodesicBufferGraphic  = new Graphic(bufferGeometryGeodesic);

                // Create a graphic for the user tap location.
                Graphic locationGraphic = new Graphic(userTapPoint);

                // Get the graphics overlays.
                GraphicsOverlay planarBufferGraphicsOverlay   = _myMapView.GraphicsOverlays["PlanarPolys"];
                GraphicsOverlay geodesicBufferGraphicsOverlay = _myMapView.GraphicsOverlays["GeodesicPolys"];
                GraphicsOverlay tapPointGraphicsOverlay       = _myMapView.GraphicsOverlays["TapPoints"];

                // Add the buffer polygons and tap location graphics to the appropriate graphic overlays.
                planarBufferGraphicsOverlay.Graphics.Add(planarBufferGraphic);
                geodesicBufferGraphicsOverlay.Graphics.Add(geodesicBufferGraphic);
                tapPointGraphicsOverlay.Graphics.Add(locationGraphic);
            }
            catch (Exception ex)
            {
                // Display an error message if there is a problem generating the buffers.
                UIAlertController alertController = UIAlertController.Create("Error creating buffers", ex.Message, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alertController, true, null);
            }
        }
예제 #6
0
        private void InitUI()
        {
            nfloat startY = GetStatusBarHeight();

            nfloat      padding       = 10;
            UITextField nameTextField = new UITextField();

            nameTextField.Frame             = new CGRect(padding, padding, View.Frame.Width - padding * 2, 40);
            nameTextField.Placeholder       = "Name";
            nameTextField.Layer.BorderWidth = 1f;
            nameTextField.Layer.BorderColor = UIColor.LightGray.CGColor;
            nameTextField.LeftViewMode      = UITextFieldViewMode.Always;
            nameTextField.LeftView          = new UIView(new CGRect(0, 0, padding, 40));

            UITextView bodyTextField = new UITextView();

            bodyTextField.Frame = new CGRect(padding,
                                             nameTextField.Frame.Bottom + padding,
                                             View.Frame.Width - padding * 2,
                                             View.Frame.Height - (nameTextField.Frame.Bottom + padding * 2 + startY));
            bodyTextField.Layer.BorderWidth = 1f;
            bodyTextField.Layer.BorderColor = UIColor.LightGray.CGColor;


            View.AddSubview(nameTextField);
            View.AddSubview(bodyTextField);

            this.NavigationItem.SetRightBarButtonItem(
                new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, args) => {
                if (string.IsNullOrEmpty(nameTextField.Text) || string.IsNullOrEmpty(bodyTextField.Text))
                {
                    UIAlertController alertcontroller = new UIAlertController();
                    alertcontroller.Message           = "Please enter note Name and Body";
                    alertcontroller.Title             = "Error";
                    alertcontroller.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    PresentViewController(alertcontroller, true, null);
                }
                else
                {
                    _dialog = DialogHelper.ShowProgressDialog(new CGRect(0, 0, View.Frame.Width, View.Frame.Height), View);
                    Addnote(nameTextField.Text, bodyTextField.Text);
                }
            })
                , true);
        }
        private async void OnButton2Clicked(object sender, EventArgs e)
        {
            try
            {
                // Define the Uri to the WMTS service (NOTE: iOS applications require the use of Uri's to be https:// and not http://)
                var myUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS");

                // Define a new instance of the WMTS service
                WmtsService myWmtsService = new WmtsService(myUri);

                // Load the WMTS service
                await myWmtsService.LoadAsync();

                // Get the service information (i.e. metadata) about the WMTS service
                WmtsServiceInfo myWMTSServiceInfo = myWmtsService.ServiceInfo;

                // Obtain the read only list of WMTS layer info objects
                IReadOnlyList <WmtsLayerInfo> myWmtsLayerInfos = myWMTSServiceInfo.LayerInfos;

                // Create a new instance of a WMTS layer using the first item in the read only list of WMTS layer info objects
                WmtsLayer myWmtsLayer = new WmtsLayer(myWmtsLayerInfos[0]);

                // Create a new map
                Map myMap = new Map();

                // Get the basemap from the map
                Basemap myBasemap = myMap.Basemap;

                // Get the layer collection for the base layers
                LayerCollection myLayerCollection = myBasemap.BaseLayers;

                // Add the WMTS layer to the layer collection of the map
                myLayerCollection.Add(myWmtsLayer);

                // Assign the map to the MapView
                _myMapView.Map = myMap;
            }
            catch (Exception ex)
            {
                // Report error
                UIAlertController alert = UIAlertController.Create("Error", ex.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alert, true, null);
            }
        }
        public override void ReceivedNotificationResponse(UNNotificationResponse notificationResponse, Action completionHandler)
        {
            Console.WriteLine("The user selected the following action identifier::{0}", notificationResponse.ActionIdentifier);

            UNNotificationContent notificationContent = notificationResponse.Notification.Request.Content;

            String message   = String.Format("Action Identifier:{0}", notificationResponse.ActionIdentifier);
            String alertBody = notificationContent.Body;

            if (alertBody.Length > 0)
            {
                message += String.Format("\nAlert Body:\n{0}", alertBody);
            }

            if (notificationResponse is UNTextInputNotificationResponse)
            {
                String responseText = ((UNTextInputNotificationResponse)notificationResponse).UserText;

                if (responseText != null)
                {
                    message += String.Format("\nResponse:\n{0}", responseText);
                }
            }



            UIAlertController alertController = UIAlertController.Create(title: notificationContent.Title,
                                                                         message: alertBody,
                                                                         preferredStyle: UIAlertControllerStyle.Alert);

            UIAlertAction okAction = UIAlertAction.Create(title: "OK", style: UIAlertActionStyle.Default, handler: null);

            alertController.AddAction(okAction);

            UIViewController topController = UIApplication.SharedApplication.KeyWindow.RootViewController;

            if (alertController.PopoverPresentationController != null)
            {
                alertController.PopoverPresentationController.SourceView = topController.View;
            }

            topController.PresentViewController(alertController, true, null);

            completionHandler();
        }
        private async void OnDownloadMapAreaClicked(string selectedArea)
        {
            try
            {
                // Get the selected map area.
                PreplannedMapArea area = _preplannedMapAreas.First(mapArea => mapArea.PortalItem.Title.ToString() == selectedArea);

                // Download the map area.
                await DownloadMapAreaAsync(area);
            }
            catch (Exception ex)
            {
                // No match found.
                UIAlertController alertController = UIAlertController.Create("Downloading map area failed.", ex.Message, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alertController, true, null);
            }
        }
예제 #10
0
        private void OnShowBookmarksButtonClicked(object sender, EventArgs e)
        {
            // Create a new Alert Controller
            UIAlertController actionAlert = UIAlertController.Create("Bookmarks", string.Empty,
                                                                     UIAlertControllerStyle.Alert);

            // Add Bookmarks as Actions
            foreach (Bookmark myBookmark in _myMapView.Map.Bookmarks)
            {
                actionAlert.AddAction(UIAlertAction.Create(myBookmark.Name, UIAlertActionStyle.Default,
                                                           (action) => {
                    _myMapView.SetViewpoint(myBookmark.Viewpoint);
                }));
            }

            // Display the alert
            PresentViewController(actionAlert, true, null);
        }
        public void OnAuthenticationFailed(string message, Exception exception)
        {
            // SFSafariViewController doesn't dismiss itself
            DismissViewController(true, null);

            var alertController = new UIAlertController
            {
                Title   = message,
                Message = exception?.ToString()
            };

            alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Default, (UIAlertAction obj) =>
            {
            }));
            PresentViewController(alertController, true, null);

            DismissViewController(true, null);
        }
 public void PlayBtnOnClick(object sender, EventArgs ea)
 {
     if (timeLoggingController.WasNetworkAvailable)
     {
         timeLoggingController.StartTiming(task.Id);
         TdPauseBtn.SetImage(UIImage.FromBundle("pause-deactivated"), UIControlState.Normal);
         TdPauseBtn.Enabled = true;
         TdPlayBtn.SetImage(UIImage.FromBundle("play-activated"), UIControlState.Normal);
         TdPlayBtn.Enabled = false;
     }
     else
     {
         UIAlertController okAlertController = UIAlertController.Create("Oops", "The previous time log is not yet updated to the server. Please try again later.", UIAlertControllerStyle.Alert);
         okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
         PresentViewController(okAlertController, true, null);
         return;
     }
 }
        private async void RegisterSaveButton_TouchUpInside(object sender, EventArgs e)
        {
            bool success = await DeliveryPerson.Register(emailTextField.Text, passwordTextField.Text, confirmPasswordTextField.Text);

            UIAlertController alert = null;

            if (success)
            {
                alert = UIAlertController.Create("Success", "New user has been registered", UIAlertControllerStyle.Alert);
            }
            else
            {
                alert = UIAlertController.Create("Failure", "Something went wrong when registering the user, please try again", UIAlertControllerStyle.Alert);
            }

            alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
            PresentViewController(alert, true, null);
        }
예제 #14
0
        private void BasemapSelectionButtonClick(object sender, EventArgs e)
        {
            // Create the view controller that will present the list of basemaps
            UIAlertController basemapSelectionAlert = UIAlertController.Create("Select a basemap", "", UIAlertControllerStyle.ActionSheet);

            // Add an option for each basemap
            foreach (string item in _basemapOptions.Keys)
            {
                // Selecting a basemap will call the lambda method, which will apply the chosen basemap
                basemapSelectionAlert.AddAction(UIAlertAction.Create(item, UIAlertActionStyle.Default, action =>
                {
                    _myMapView.Map.Basemap = _basemapOptions[item];
                }));
            }

            // Show the alert
            PresentViewController(basemapSelectionAlert, true, null);
        }
예제 #15
0
        public void ProcessAuthenticationCanceled()
        {
            DismissViewController(true, null);

            var alertController = new UIAlertController
            {
                Title   = Constants.CancelAuth,
                Message = Constants.DidNotComplite
            };

            alertController.AddAction(UIAlertAction.Create(Constants.CancelAuth, UIAlertActionStyle.Default, (UIAlertAction obj) =>
            {
            }));

            PresentViewController(alertController, true, null);

            DismissViewController(true, null);
        }
        private void AddressSearch_ListButtonClicked(object sender, EventArgs e)
        {
            // Create the alert view.
            UIAlertController alert = UIAlertController.Create("Suggestions", "Location searches to try", UIAlertControllerStyle.Alert);

            // Populate the view with one action per address suggestion.
            foreach (string address in _addresses)
            {
                alert.AddAction(UIAlertAction.Create(address, UIAlertActionStyle.Default, obj =>
                {
                    _addressSearchBar.Text = address;
                    UpdateSearch();
                }));
            }

            // Show the alert view.
            PresentViewController(alert, true, null);
        }
 partial void BtnDeleteFile_TouchUpInside(UIButton sender)
 {
     if (txtFieldDeleteFile.Text != "")
     {
         var filename = Path.Combine(documentsPath, txtFieldDeleteFile.Text);
         if (File.Exists(filename))
         {
             File.Delete(filename);
         }
         else
         {
             UIAlertController alert         = UIAlertController.Create("File does not exists", "There is no file with name " + txtFieldDeleteFile.Text + ".", UIAlertControllerStyle.Alert);
             UIAlertAction     defaultAction = UIAlertAction.Create("OK", UIAlertActionStyle.Default, null);
             alert.AddAction(defaultAction);
             this.PresentViewController(alert, true, null);
         }
     }
 }
 partial void BtnAddFile_TouchUpInside(UIButton sender)
 {
     if (txtFieldAddFile.Text != "")
     {
         var filename = Path.Combine(documentsPath, txtFieldAddFile.Text);
         if (File.Exists(filename))
         {
             UIAlertController alert         = UIAlertController.Create("File Exists", "There is already a file with name " + txtFieldAddFile.Text + ". Please choose a new name.", UIAlertControllerStyle.Alert);
             UIAlertAction     defaultAction = UIAlertAction.Create("OK", UIAlertActionStyle.Default, null);
             alert.AddAction(defaultAction);
             this.PresentViewController(alert, true, null);
         }
         else
         {
             File.WriteAllText(filename, "Write this text into a file");
         }
     }
 }
예제 #19
0
        public void ProcessAuthenticationFailed(string message, Exception exception)
        {
            DismissViewController(true, null);

            var alertController = new UIAlertController
            {
                Title   = message,
                Message = exception?.ToString()
            };

            alertController.AddAction(UIAlertAction.Create(Constants.CancelAuth, UIAlertActionStyle.Default, (UIAlertAction obj) =>
            {
            }));

            PresentViewController(alertController, true, null);

            DismissViewController(true, null);
        }
예제 #20
0
        /// <summary>
        /// Shows an alert to the user with the specified message.
        /// </summary>
        /// <param name="message">The message to display to the user.</param>
        /// <param name="title">An optional title for the alert.</param>
        /// <param name="buttonText">Optional text for the button showed with the alert.</param>
        /// <param name="closed">Gets invoked when the alert has been closed.</param>
        public void ShowAlert(string message, string title, string buttonText, Action closed)
        {
            UIAlertController alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);

            alert.AddAction(
                UIAlertAction.Create(
                    buttonText,
                    UIAlertActionStyle.Default,
                    _ =>
            {
                if (closed != null)
                {
                    closed();
                }
            }));

            this.getPresentingController().PresentViewController(alert, true, null);
        }
        public void DidFailWithError(NMapLocationManager locationManager, NMapLocationManagerErrorType errorType)
        {
            string message = string.Empty;

            switch (errorType)
            {
            case NMapLocationManagerErrorType.Unknown:
            case NMapLocationManagerErrorType.Canceled:
                message = "일시적으로 내위치를 확인 할 수 없습니다.";
                break;

            case NMapLocationManagerErrorType.Denied:
                if (UIDevice.CurrentDevice.CheckSystemVersion(4, 0))
                {
                    message = "위치 정보를 확인 할 수 없습니다.\\n사용자의 위치 정보를 확인하도록 허용하시려면 위치서비스를 켜십시오.";
                }
                else
                {
                    message = "위치 정보를 확인 할 수 없습니다.";
                }
                break;

            case NMapLocationManagerErrorType.UnavailableArea:
                message = "현재 위치는 지도내에 표시 할 수 없습니다.";
                break;

            case NMapLocationManagerErrorType.Heading:
                message = "나침반 정보를 확인 할 수 없습니다.";
                break;
            }
            if (!string.IsNullOrEmpty(message))
            {
                UIAlertController alert = UIAlertController.Create("NMapViewer", message, UIAlertControllerStyle.Alert);
                UIAlertAction     ok    = UIAlertAction.Create("OK", UIAlertActionStyle.Default, null);

                alert.AddAction(ok);
                this.PresentViewController(alert, true, null);
                if (mapView.AutoRotateEnabled)
                {
                    mapView.SetAutoRotateEnabled(false, false);
                }
                mapView.MapOverlayManager.ClearMyLocationOverlay();
            }
        }
예제 #22
0
        private void _styleChoiceButton_ValueChanged(object sender, EventArgs e)
        {
            int styleSelection = (int)_styleChoiceButton.SelectedSegment;

            try
            {
                // Get the available styles from the first sublayer.
                IReadOnlyList <string> styles = _mnWmsLayer.Sublayers[0].SublayerInfo.Styles;

                // Apply the second style to the first sublayer.
                _mnWmsLayer.Sublayers[0].CurrentStyle = styles[styleSelection];
            }
            catch (Exception ex)
            {
                UIAlertController alert = UIAlertController.Create("Error", ex.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alert, true, null);
            }
        }
        private async void RegisterButton_TouchUpInside(object sender, EventArgs e)
        {
            var result = await User.Register(emailTextField.Text, passwordTextField.Text, confirmpasswordTextField.Text);

            UIAlertController alert = null;

            if (result)
            {
                alert = UIAlertController.Create("Success", "Gebruiker toegevoegd", UIAlertControllerStyle.Alert);
            }
            else
            {
                alert = UIAlertController.Create("Failure", "Probeer opnieuw", UIAlertControllerStyle.Alert);
            }

            alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

            PresentViewController(alert, true, null);
        }
예제 #24
0
        private void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
        {
            try
            {
                // Create a map point (in the WebMercator projected coordinate system) from the GUI screen coordinate.
                MapPoint userTappedMapPoint = _myMapView.ScreenToLocation(e.Position);

                // Get the buffer size (in miles) from the text field.
                double bufferDistanceInMiles = System.Convert.ToDouble(_bufferDistanceMilesUITextField.Text);

                // Create a variable to be the buffer size in meters. There are 1609.34 meters in one mile.
                double bufferDistanceInMeters = bufferDistanceInMiles * 1609.34;

                // Add the map point to the list that will be used by the GeometryEngine.Buffer operation.
                _bufferPointsList.Add(userTappedMapPoint);

                // Add the buffer distance to the list that will be used by the GeometryEngine.Buffer operation.
                _bufferDistancesList.Add(bufferDistanceInMeters);

                // Create a simple marker symbol to display where the user tapped/clicked on the map. The marker symbol will be a
                // solid, red circle.
                SimpleMarkerSymbol userTappedSimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Red, 10);

                // Create a new graphic for the spot where the user clicked on the map using the simple marker symbol.
                Graphic userTappedGraphic = new Graphic(userTappedMapPoint, userTappedSimpleMarkerSymbol);

                // Specify a ZIndex value on the user input map point graphic to assist with the drawing order of mixed geometry types
                // being added to a single GraphicCollection. The lower the ZIndex value, the lower in the visual stack the graphic is
                // drawn. Typically, Polygons would have the lowest ZIndex value (ex: 0), then Polylines (ex: 1), and finally MapPoints (ex: 2).
                userTappedGraphic.ZIndex = 2;

                // Add the user tapped/clicked map point graphic to the graphic overlay.
                _graphicsOverlay.Graphics.Add(userTappedGraphic);
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem generating the buffer polygon.
                UIAlertController alertController = UIAlertController.Create("Geometry Engine Failed!", ex.Message, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alertController, true, null);
                return;
            }
        }
예제 #25
0
        /// <summary>
        /// Called when the DetailDisclosureButton is touched.
        /// Does nothing if DetailDisclosureButton isn't in the cell
        /// </summary>
        public override void AccessoryButtonTapped(UITableView tableView, NSIndexPath indexPath)
        {
            if (tableItems[indexPath.Row].Heading == "Melt")
            {
                UIAlertController okAlertController = UIAlertController.Create("Melt", "To heat solid food (think butter) on stovetop, or in microwave until it becomes a liquid;", UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                owner.PresentViewController(okAlertController, true, null);

                tableView.DeselectRow(indexPath, true);
            }
            if (tableItems[indexPath.Row].Heading == "Heat until Shimmer")
            {
                UIAlertController okAlertController = UIAlertController.Create("Heat until Shimmer", "To heat oil in a pan until it begins to move slightly - which indicates oil is hot enough for cooking; if oil starts to smoke, it has been overheated, and you can start over with fresh oil;", UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                owner.PresentViewController(okAlertController, true, null);

                tableView.DeselectRow(indexPath, true);
            }
            if (tableItems[indexPath.Row].Heading == "Simmer")
            {
                UIAlertController okAlertController = UIAlertController.Create("Simmer", "To heat liquid until small bubbles gently break surface at a variable, infrequent rate - as when cooking a soup;", UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                owner.PresentViewController(okAlertController, true, null);

                tableView.DeselectRow(indexPath, true);
            }
            if (tableItems[indexPath.Row].Heading == "Boil")
            {
                UIAlertController okAlertController = UIAlertController.Create("Boil", "To heat liquid until large bubbles break surface at a rapid, constant rate - as when cooking pasta;", UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                owner.PresentViewController(okAlertController, true, null);

                tableView.DeselectRow(indexPath, true);
            }
            if (tableItems[indexPath.Row].Heading == "Toast")
            {
                UIAlertController okAlertController = UIAlertController.Create("Toast", "To heat food (nuts, bread) in a skillet, toaster, oven until golden brown, fragrant;", UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                owner.PresentViewController(okAlertController, true, null);

                tableView.DeselectRow(indexPath, true);
            }
        }
예제 #26
0
        private void CutButton_TouchUpInside(object sender, EventArgs e)
        {
            try
            {
                // Cut the polygon geometry with the polyline, expect two geometries.
                Geometry[] cutGeometries = GeometryEngine.Cut(_lakeSuperiorPolygonGraphic.Geometry, (Polyline)_countryBorderPolylineGraphic.Geometry);

                // Create a simple line symbol for the outline of the Canada side of Lake Superior.
                SimpleLineSymbol canadaSideSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Null, System.Drawing.Color.Blue, 0);

                // Create the simple fill symbol for the Canada side of Lake Superior graphic - comprised of a fill style, fill color and outline.
                SimpleFillSymbol canadaSideSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, System.Drawing.Color.Green, canadaSideSimpleLineSymbol);

                // Create the graphic for the Canada side of Lake Superior - comprised of a polygon shape and fill symbol.
                Graphic canadaSideGraphic = new Graphic(cutGeometries[0], canadaSideSimpleFillSymbol);

                // Add the Canada side of the Lake Superior graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(canadaSideGraphic);

                // Create a simple line symbol for the outline of the USA side of Lake Superior.
                SimpleLineSymbol usaSideSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Null, System.Drawing.Color.Blue, 0);

                // Create the simple fill symbol for the USA side of Lake Superior graphic - comprised of a fill style, fill color and outline.
                SimpleFillSymbol usaSideSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, System.Drawing.Color.Yellow, usaSideSimpleLineSymbol);

                // Create the graphic for the USA side of Lake Superior - comprised of a polygon shape and fill symbol.
                Graphic usaSideGraphic = new Graphic(cutGeometries[1], usaSideSimpleFillSymbol);

                // Add the USA side of the Lake Superior graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(usaSideGraphic);

                // Disable the button after has been used.
                _cutButton.Enabled = false;
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem generating cut operation.
                UIAlertController alertController = UIAlertController.Create("Geometry Engine Failed!", ex.Message, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alertController, true, null);
                return;
            }
        }
        private async void UriButton_Clicked(object sender, EventArgs e)
        {
            try
            {
                //Load the WMTS layer using Uri method.
                await LoadWMTSLayerAsync(true);

                // Disable and enable the appropriate buttons.
                _uriButton.Enabled  = false;
                _infoButton.Enabled = true;
            }
            catch (Exception ex)
            {
                // Report error.
                UIAlertController alert = UIAlertController.Create("Error", ex.Message, UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alert, true, null);
            }
        }
예제 #28
0
        private void ConvexHullButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Create a multi-point geometry from the user tapped input map points.
                Multipoint inputMultipoint = new Multipoint(_inputPointCollection);

                // Get the returned result from the convex hull operation.
                Geometry convexHullGeometry = GeometryEngine.ConvexHull(inputMultipoint);

                // Create a simple line symbol for the outline of the convex hull graphic(s).
                SimpleLineSymbol convexHullSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid,
                                                                                   System.Drawing.Color.Blue, 4);

                // Create the simple fill symbol for the convex hull graphic(s) - comprised of a fill style, fill
                // color and outline. It will be a hollow (i.e.. see-through) polygon graphic with a thick red outline.
                SimpleFillSymbol convexHullSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Null,
                                                                                   System.Drawing.Color.Red, convexHullSimpleLineSymbol);

                // Create the graphic for the convex hull - comprised of a polygon shape and fill symbol.
                Graphic convexHullGraphic = new Graphic(convexHullGeometry, convexHullSimpleFillSymbol);

                // Set the Z index for the convex hull graphic so that it appears below the initial input user
                // tapped map point graphics added earlier.
                convexHullGraphic.ZIndex = 0;

                // Add the convex hull graphic to the graphics overlay collection.
                _graphicsOverlay.Graphics.Add(convexHullGraphic);

                // Disable the button after has been used.
                _convexHullButton.Enabled = false;
                _convexHullButton.SetTitleColor(UIColor.Gray, UIControlState.Disabled);
            }
            catch (System.Exception ex)
            {
                // Display an error message if there is a problem generating convex hull operation.
                UIAlertController alertController = UIAlertController.Create("Geometry Engine Failed!", ex.Message, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alertController, true, null);
                return;
            }
        }
예제 #29
0
        // Recombinate selected elements
        public bool tryToMove()
        {
            if (canRecombine(selectedElem.posIndex, emptyElem.posIndex))
            {
                canSelect = false;

                CGRect elemRect1 = selectedElem.Frame;
                CGRect elemRect2 = emptyElem.Frame;

                CGPoint tmpPos = selectedElem.posIndex;
                selectedElem.posIndex = emptyElem.posIndex;
                emptyElem.posIndex    = tmpPos;

                int indexTemp = selectedElem.index;
                selectedElem.index = emptyElem.index;
                emptyElem.index    = indexTemp;

                UIView.Animate(0.5f, () => {
                    selectedElem.Frame = elemRect2;
                    emptyElem.Frame    = elemRect1;
                }, () => {
                    if (isAllElemsCombined())
                    {
                        UIAlertController okAlertController = UIAlertController.Create("Game Completed",
                                                                                       "You WIN!",
                                                                                       UIAlertControllerStyle.Alert);

                        okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

                        ownerController.PresentViewController(okAlertController, true, null);

                        endGame();
                    }

                    canSelect = true;
                });

                return(true);
            }

            return(false);
        }
예제 #30
0
 partial void LoginButton_TouchUpInside(UIButton sender)
 {
     //Validate our Username & Password.
     //This is usually a web service call.
     if (IsUserNameValid() && IsPasswordValid())
     {
         //We have successfully authenticated a the user,
         //Now fire our OnLoginSuccess Event.
         if (OnLoginSuccess != null)
         {
             OnLoginSuccess(sender, new EventArgs());
         }
     }
     else
     {
         UIAlertController okAlertController = UIAlertController.Create("Login Error", "Bad username or password.", UIAlertControllerStyle.Alert);
         okAlertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
         PresentViewController(okAlertController, true, null);
     }
 }
        void InputActionSheet(Action<SelectionItem> selection, List<SelectionItem> options, string cancelButton = "Cancel")
        {
            DismissAll();

            UIApplication.SharedApplication.InvokeOnMainThread(() => {

                alertController = new UIAlertController();
                //alertController.ModalPresentationStylePreferredStyle = UIAlertControllerStyle.ActionSheet;
                foreach (var option in options) {
                    var action = UIAlertAction.Create(option.Title, UIAlertActionStyle.Default, (a) => {
                        selection(options.FirstOrDefault(x => x.Title == a.Title));
                    });
                    alertController.AddAction(action);
                }

                //cancel
                var cancel = UIAlertAction.Create(cancelButton, UIAlertActionStyle.Default, (a) => {
                    selection(null);
                });
                alertController.AddAction(cancel);

                var topViewController = TopViewControllerWithRootViewController(UIApplication.SharedApplication.KeyWindow.RootViewController);
                topViewController.PresentViewController(alertController, true, null);
            });
        }
예제 #32
0
        /// <summary>
        /// Begins an asynchronous operation showing a dialog.
        /// </summary>
        /// <returns>An object that represents the asynchronous operation.
        /// For more on the async pattern, see Asynchronous programming in the Windows Runtime.</returns>
        /// <remarks>In some cases, such as when the dialog is closed by the system out of your control, your result can be an empty command.
        /// Returns either the command selected which destroyed the dialog, or an empty command.
        /// For example, a dialog hosted in a charms window will return an empty command if the charms window has been dismissed.</remarks>
        public Task<IUICommand> ShowAsync()
        {
            if (Commands.Count > MaxCommands)
            {
                throw new InvalidOperationException();
            }

#if __ANDROID__
            Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity);
            Android.App.AlertDialog dialog = builder.Create();
            dialog.SetTitle(Title);
            dialog.SetMessage(Content);
            if (Commands.Count == 0)
            {
                dialog.SetButton(-1, Resources.System.GetString(Android.Resource.String.Cancel), new EventHandler<Android.Content.DialogClickEventArgs>(Clicked));
            }
            else
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    dialog.SetButton(-1 - i, Commands[i].Label, new EventHandler<Android.Content.DialogClickEventArgs>(Clicked));
                }
            }
            dialog.Show();

            return Task.Run<IUICommand>(() =>
            {
                _handle.WaitOne();
                return _selectedCommand;
            });

#elif __IOS__ || __TVOS__
            uac = UIAlertController.Create(Title, Content, UIAlertControllerStyle.Alert);
            if (Commands.Count == 0)
            {
                uac.AddAction(UIAlertAction.Create("Close", UIAlertActionStyle.Cancel | UIAlertActionStyle.Default, ActionClicked));
            }
            else
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    UIAlertAction action = UIAlertAction.Create(Commands[i].Label, CancelCommandIndex == i ? UIAlertActionStyle.Cancel : UIAlertActionStyle.Default, ActionClicked);
                    uac.AddAction(action);
                }
            }
            UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController;
            while (currentController.PresentedViewController != null)
                currentController = currentController.PresentedViewController;
            
            currentController.PresentViewController(uac, true, null);

            return Task.Run<IUICommand>(() =>
            {
                _handle.WaitOne();
                return _selectedCommand;
            });

#elif __MAC__
            NSAlert alert = new NSAlert();
            alert.AlertStyle = NSAlertStyle.Informational;
            alert.InformativeText = Content;
            alert.MessageText = Title;

            foreach(IUICommand command in Commands)
            {
                var button = alert.AddButton(command.Label);
            }

            alert.BeginSheetForResponse(NSApplication.SharedApplication.MainWindow, NSAlert_onEnded);

            return Task.Run<IUICommand>(() =>
            {
                _handle.WaitOne();
                return _selectedCommand;
            });

#elif WINDOWS_PHONE
            List<string> buttons = new List<string>();
            foreach(IUICommand uic in this.Commands)
            {
                buttons.Add(uic.Label);
            }

            if (buttons.Count == 0)
            {
                buttons.Add("Close");
            }

            MessageDialogAsyncOperation asyncOperation = new MessageDialogAsyncOperation(this);

            string contentText = Content;

            // trim message body to 255 chars
            if (contentText.Length > 255)
            {
                contentText = contentText.Substring(0, 255);
            }
            
            while(Microsoft.Xna.Framework.GamerServices.Guide.IsVisible)
            {
                Thread.Sleep(250);
            }

            Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox(
                        string.IsNullOrEmpty(Title) ? " " : Title,
                        contentText,
                        buttons,
                        (int)DefaultCommandIndex, // can choose which button has the focus
                        Microsoft.Xna.Framework.GamerServices.MessageBoxIcon.None, // can play sounds
                        result =>
                        {
                            int? returned = Microsoft.Xna.Framework.GamerServices.Guide.EndShowMessageBox(result);
                            
                            // process and fire the required handler
                            if (returned.HasValue)
                            {
                                if (Commands.Count > returned.Value)
                                {
                                    IUICommand theCommand = Commands[returned.Value];
                                    asyncOperation.SetResults(theCommand);
                                    if (theCommand.Invoked != null)
                                    {
                                        theCommand.Invoked(theCommand);
                                    }
                                }
                                else
                                {
                                    asyncOperation.SetResults(null);
                                }
                            }
                            else
                            {
                                asyncOperation.SetResults(null);
                            }
                        }, null);

            return asyncOperation.AsTask<IUICommand>();
#elif WINDOWS_UWP
            if (Commands.Count < 3 && Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.UI.ApplicationSettings.ApplicationsSettingsContract", 1))
            {
                Windows.UI.Xaml.Controls.ContentDialog cd = new Windows.UI.Xaml.Controls.ContentDialog();
                cd.Title = Title;
                cd.Content = Content;
                if(Commands.Count == 0)
                {
                    cd.PrimaryButtonText = "Close";
                }
                else
                {
                    cd.PrimaryButtonText = Commands[0].Label;
                    cd.PrimaryButtonClick += Cd_PrimaryButtonClick;
                    if(Commands.Count > 1)
                    {
                        cd.SecondaryButtonText = Commands[1].Label;
                        cd.SecondaryButtonClick += Cd_SecondaryButtonClick;
                    }
                }
                
                return Task.Run<IUICommand>(async () => 
                {
                    ManualResetEvent mre = new ManualResetEvent(false);
                    IUICommand command = null;

                    await cd.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
                    {
                        ContentDialogResult dr = await cd.ShowAsync();
                        if (Commands.Count > 0)
                        {
                            switch (dr)
                            {
                                case ContentDialogResult.Primary:
                                    command = Commands[0];
                                    if(Commands[0].Invoked != null)
                                    {
                                        Commands[0].Invoked.Invoke(Commands[0]);
                                    }
                                    break;

                                case ContentDialogResult.Secondary:
                                    command = Commands[1];
                                    if (Commands[1].Invoked != null)
                                    {
                                        Commands[1].Invoked.Invoke(Commands[1]);
                                    }
                                    break;
                            }
                        }
                    });

                    mre.WaitOne();

                    return command;
                });
            }
            else
            {
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(Content, Title);
                foreach (IUICommand command in Commands)
                {
                    dialog.Commands.Add(new Windows.UI.Popups.UICommand(command.Label, (c)=> { command.Invoked(command); }, command.Id));
                }
                return Task.Run<IUICommand>(async () => {
                    Windows.UI.Popups.IUICommand command = await dialog.ShowAsync();
                    if (command != null)
                    {
                        int i = 0;
                        foreach(Windows.UI.Popups.IUICommand c in dialog.Commands)
                        {
                            if(command == c)
                            {
                                break;
                            }

                            i++;
                        }

                        return Commands[i];
                    }
                    return null;
                });
            }
#elif WIN32
            return Task.Run<IUICommand>(() =>
            {
                IUICommand cmd = ShowTaskDialog();
                if (cmd != null)
                {
                    cmd.Invoked?.Invoke(cmd);
                }

                return cmd;
            });
#else
            throw new PlatformNotSupportedException();
#endif
        }
예제 #33
0
        /// <summary>
        /// Shows the context menu in the preferred placement relative to the specified selection.
        /// </summary>
        /// <param name="selection">The coordinates (in DIPs) of the selected rectangle, relative to the window.</param>
        /// <param name="preferredPlacement">The preferred placement of the context menu relative to the selection rectangle.</param>
        /// <returns></returns>
        public Task<IUICommand> ShowForSelectionAsync(Rect selection, Placement preferredPlacement)
        { 
            if (Commands.Count > MaxCommands)
            {
                throw new InvalidOperationException();
            }

#if WINDOWS_UWP
            return Task.Run<IUICommand>(async () =>
            {
                foreach (IUICommand command in Commands)
                {
                    _menu.Commands.Add(new Windows.UI.Popups.UICommand(command.Label, new Windows.UI.Popups.UICommandInvokedHandler((c2) => { command.Invoked?.Invoke(command); }), command.Id));
                }
                Windows.Foundation.Rect r = new Windows.Foundation.Rect(selection.X, selection.Y, selection.Width, selection.Height);
                var c = await _menu.ShowForSelectionAsync(r, (Windows.UI.Popups.Placement)((int)preferredPlacement));
                return c == null ? null : new UICommand(c.Label, new UICommandInvokedHandler((c2) => { c2.Invoked?.Invoke(c2); }), c.Id);
            });
#elif __ANDROID__
            Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity);
            Android.App.AlertDialog dialog = builder.Create();
            dialog.SetTitle(Title);
            dialog.SetMessage(Content);
            if (Commands.Count == 0)
            {
                dialog.SetButton(-1, Resources.System.GetString(Android.Resource.String.Cancel), new EventHandler<Android.Content.DialogClickEventArgs>(Clicked));
            }
            else
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    dialog.SetButton(-1 - i, Commands[i].Label, new EventHandler<Android.Content.DialogClickEventArgs>(Clicked));
                }
            }
            dialog.Show();

            return Task.Run<IUICommand>(() =>
            {
                handle.WaitOne();
                return _selectedCommand;
            });

#elif __IOS__
            uac = UIAlertController.Create("", "", UIAlertControllerStyle.ActionSheet);
            if (Commands.Count == 0)
            {
                uac.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel | UIAlertActionStyle.Default, ActionClicked));
            }
            else
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    UIAlertAction action = UIAlertAction.Create(Commands[i].Label, UIAlertActionStyle.Default, ActionClicked);
                    uac.AddAction(action);
                }
            }

             

            UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController;
            while (currentController.PresentedViewController != null)
                currentController = currentController.PresentedViewController;

            // set layout requirements for iPad
            var popoverController = uac.PopoverPresentationController;
            if(popoverController != null)
            {
                popoverController.SourceView = currentController.View;
                popoverController.SourceRect = new CoreGraphics.CGRect(selection.X, selection.Y, selection.Width, selection.Height);
                popoverController.PermittedArrowDirections = PlacementHelper.ToArrowDirection(preferredPlacement);
            }

            currentController.PresentViewController(uac, true, null);

            return Task.Run<IUICommand>(() =>
            {
                handle.WaitOne();
                return _selectedCommand;
            });
#else
            throw new PlatformNotSupportedException();
#endif
        }
예제 #34
0
 protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style)
 {
     controller.AddAction(UIAlertAction.Create(opt.Text, style, x => opt.TryExecute()));
 }
예제 #35
0
        protected virtual void AddActionSheetOption(ActionSheetOption opt, UIAlertController controller, UIAlertActionStyle style, IBitmap image = null)
        {
            var alertAction = UIAlertAction.Create(opt.Text, style, x => opt.Action?.Invoke());

            if (opt.ItemIcon == null && image != null)
                opt.ItemIcon = image;

            if (opt.ItemIcon != null)
                alertAction.SetValueForKey(opt.ItemIcon.ToNative(), new Foundation.NSString("image"));

            controller.AddAction(alertAction);
        }