コード例 #1
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            // Show the logo
            MessagingService.Current.SendMessage(MessageKeys.ChangeToolbar, true);

            // On Droid this wraps behind the other views.
            if (Device.RuntimePlatform == Device.Android)
            {
                Grid.SetRowSpan(mapView, 3);

                if (ToolbarItems.Count > 1)
                {
                    var firstItem = ToolbarItems.FirstOrDefault();
                    ToolbarItems.Remove(firstItem);
                }
            }

            try
            {
                // Set the map to your current location.
                var locator = CrossGeolocator.Current;
                Plugin.Geolocator.Abstractions.Position position = await locator.GetPositionAsync(TimeSpan.FromSeconds(5), null, true);

                if (position != null)
                {
                    mapView.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(position.Latitude, position.Longitude), Distance.FromMiles(10)).WithZoom(16));
                }
            }
            catch
            {
                // No biggie if you don't allow location, only here for show purposes.
            }
        }
コード例 #2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            BindingContext = ViewModel;

            // set Text
            PlateWeightLabel.Text = string.Format(AppResources.PlateWeightLabel, L10n.GetWeightUnit());
            var dayNames = AppResources.Culture.DateTimeFormat.DayNames;

            MonLabel.Text = dayNames[1];
            TueLabel.Text = dayNames[2];
            WedLabel.Text = dayNames[3];
            ThuLabel.Text = dayNames[4];
            FriLabel.Text = dayNames[5];
            SatLabel.Text = dayNames[6];
            SunLabel.Text = dayNames[0];

            // setup delete toolbar item
            var deleteItem = ToolbarItems.FirstOrDefault(x => x.Icon == "ic_action_discard");

            if (ViewModel.ExerciseId > 0 && deleteItem == null)
            {
                deleteItem = new ToolbarItem {
                    Order = ToolbarItemOrder.Primary, Icon = "ic_action_discard"
                };
                deleteItem.SetBinding <ExerciseDetailsViewModel> (MenuItem.CommandProperty, x => x.DeleteCommand);
                ToolbarItems.Insert(0, deleteItem);
            }
        }
コード例 #3
0
        private void UpdateSortButton()
        {
            ToolbarItem sortButton = ToolbarItems.FirstOrDefault(t => t.Text == "Sort");
            var         direction  = GetCurrentSortDirection();

            if (direction == SortDirection.Ascending)
            {
                sortButton.Icon = Device.OnPlatform <FileImageSource>(null, new FileImageSource()
                {
                    File = "ic_sort_descending.png"
                }, new FileImageSource()
                {
                    File = "Assets/AppBar/appbar.sort.alphabetical.descending.png"
                });
            }
            else
            {
                sortButton.Icon = Device.OnPlatform <FileImageSource>(null, new FileImageSource()
                {
                    File = "ic_sort_ascending.png"
                }, new FileImageSource()
                {
                    File = "Assets/AppBar/appbar.sort.alphabetical.ascending.png"
                });
            }
        }
コード例 #4
0
        public ContributionFormPage(IAnalyticsService analyticsService)
            : base(analyticsService)
        {
            InitializeComponent();

            if (Device.RuntimePlatform == Device.Android &&
                ToolbarItems.Any(x => x.Priority < 0))
            {
                var toolbarItems = ToolbarItems.FirstOrDefault(x => x.Priority < 0);
                ToolbarItems.Remove(toolbarItems);
            }
        }
コード例 #5
0
        public HomePage()
        {
            InitializeComponent();
            var temp = ToolbarItems.FirstOrDefault(m => m.Name == "Audio");

            if (Application.Current.Properties["AudioMuted"] as string == "True")
            {
                temp.Icon = "ic_volume_off_white_36dp.png";
            }
            else
            {
                temp.Icon = "ic_volume_up_white_36dp.png";
            }
        }
コード例 #6
0
        /// <summary>
        /// Nachdem der Benutzer eine Klasse ausgewählt hat, kann er ein neues Ereignis erstellen und die Ereignisse für die gewählte Klasse werden aufgelistet
        /// </summary>
        /// <param name="sender">Autogeneriert</param>
        /// <param name="args">Autogeneriert</param>
        async void OnClassSelectedClicked(object sender, EventArgs args)
        {
            try
            {
                //www.stackoverflow.com/questions/32313996/rendering-a-displayactionsheet-with-observablecollection-data-in-xamarin-cross-p?rq=1
                string action = await DisplayActionSheet("Klasse wählen:", "Cancel", null, classes.Select(SchoolClass => SchoolClass.ClassName).ToArray());

                // Hat der Benutzer die Klasse ausgewählt, werden die Ereignisse der Klasse aufgelistet
                if (action != "Cancel" && action != null)
                {
                    // Wenn der angemeldete Benutzer ein Lehrer ist, kann dieser ein neues Ereignis erstellen
                    if (App.UserLoggedIn.Role == 1 && ToolbarItems.FirstOrDefault(item => item.Text == "Ereignis erstellen") == null)
                    {
                        ToolbarItem toolBarItemCreateNewAppointment = new ToolbarItem
                        {
                            Text    = "Ereignis erstellen",
                            Order   = ToolbarItemOrder.Secondary,
                            Command = new Command(() => this.OnCallNewAppointmentPageClicked(null, null)),
                        };

                        this.ToolbarItems.Add(toolBarItemCreateNewAppointment);
                    }

                    // Nachdem eine Klasse ausgewählt wurde, kann der Benutzer die Daten aktualisieren
                    if (ToolbarItems.FirstOrDefault(item => item.Text == "Ereignisse aktualisieren") == null)
                    {
                        ToolbarItem toolBarItemRefresh = new ToolbarItem
                        {
                            Icon  = "refresh.png",
                            Text  = "Ereignisse aktualisieren",
                            Order = ToolbarItemOrder.Primary,

                            Command = new Command(() => this.OnRefreshClicked(null, null)),
                        };

                        this.ToolbarItems.Add(toolBarItemRefresh);
                    }

                    ToolbarItemClass.Text = action;
                    Selectedclass         = classes.Find(SchoolClass => SchoolClass.ClassName == action);
                    ShowAppointments();
                }
            }
            catch (Exception e)
            {
                await  DisplayAlert("Fehler", "Ein Fehler ist aufgetreten. Bitte wenden Sie sich an den Support: " + Environment.NewLine + e.Message, "OK");
            }
        }
コード例 #7
0
        private void Audio_Clicked(object sender, EventArgs e)
        {
            var temp = ToolbarItems.FirstOrDefault(m => m.Name == "Audio");

            if (Application.Current.Properties["AudioMuted"] as string == "True")
            {
                var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                player.Play();
                temp.Icon = "ic_volume_up_white_36dp.png";
                Application.Current.Properties["AudioMuted"] = "False";
            }
            else
            {
                var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                player.Pause();
                temp.Icon = "ic_volume_off_white_36dp.png";
                Application.Current.Properties["AudioMuted"] = "True";
            }
        }
コード例 #8
0
ファイル: LogMessages.cs プロジェクト: Irmanster/mngSentinel
 private void LoggerPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "NewEntries")
     {
         lock (Logger.NewEntries)
         {
             lock (pendingAdditions)
             {
                 foreach (ILogEntry entry in Logger.NewEntries)
                 {
                     pendingAdditions.Enqueue(entry);
                 }
             }
         }
     }
     else if (e.PropertyName == "Enabled")
     {
         var pauseButton = ToolbarItems.FirstOrDefault(c => c.Label == "Pause");
         pauseButton.IsChecked = !logger.Enabled;
     }
 }
コード例 #9
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();



            // On Droid this wraps behind the other views.
            if (Device.RuntimePlatform == Device.Android)
            {
                Grid.SetRowSpan(mapView, 3);

                if (ToolbarItems.Count > 1)
                {
                    var firstItem = ToolbarItems.FirstOrDefault();
                    ToolbarItems.Remove(firstItem);
                }
            }

            try
            {
                // Set the map to your current location.

                if (position != null)
                {
                    //var pin = new Pin()
                    //{
                    //    Position = new Xamarin.Forms.Maps.Position(position.Latitude, position.Longitude),
                    //    Label = location,
                    //    Address =openingLocation
                    //};
                    //mapView.Pins.Add(pin);



                    var pin = new CustomPin
                    {
                        Type     = PinType.Place,
                        Position = new Xamarin.Forms.Maps.Position(position.Latitude, position.Longitude),
                        Label    = location,
                        Address  = openingLocation,
                        Id       = "Xamarin",
                        Url      = "http://xamarin.com/about/"
                    };



                    mapView.CustomPins = new List <CustomPin> {
                        pin
                    };

                    mapView.Pins.Add(pin);


                    mapView.MoveToRegion(MapSpan.FromCenterAndRadius(
                                             new Xamarin.Forms.Maps.Position(position.Latitude, position.Longitude),
                                             Distance.FromMiles(1.0)).WithZoom(5));
                }
            }
            catch
            {
                // No biggie if you don't allow location, only here for show purposes.
            }
        }