Example #1
0
        private void CalendarListView_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            all_events modelObj = e.Item as all_events;

            //  Navigation.PushAsync(new CalendarDetailPage(modelObj));
            Navigation.PushPopupAsync(new CalendarDetailPage(modelObj));
        }
Example #2
0
        public CalendarPopupPage(all_events obj)
        {
            InitializeComponent();

            update_stack.IsVisible = true;
            create_stack.IsVisible = false;

            attnListView.IsVisible = true;
            //  attList = obj.attendees;

            foreach (var attobj in obj.attendees)
            {
                attList.Add(new AttendeesList(attobj.name));
                int cusid = App.cusdict.FirstOrDefault(x => x.Value == attobj.name).Key;
                atnIdsList.Add(cusid);
            }

            meeting_subject.Text = obj.meeting_subject;
            loc.Text             = obj.location;
            dur.Text             = obj.duration;

            updateId = obj.id;

            start_dateTime = DateTime.ParseExact(obj.start, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
            string start_datestring = start_dateTime.ToString("yyyy-MM-dd");
            string start_timestring = start_dateTime.ToLocalTime().ToString("HH:mm");

            start_fullTime = start_datestring + " " + start_timestring;
            TimeSpan start_timespan = TimeSpan.Parse(start_timestring);

            st_date.Date    = start_dateTime;
            st_poptime.Time = start_timespan;

            if (obj.allday == true)
            {
                check1.Checked = true;

                stoplabelStack.IsVisible  = true;
                stoplabelStack1.IsVisible = true;
                durStack.IsVisible        = false;
                //DateTime startDate1 = start_dateTime.AddHours(Convert.ToDouble(obj.duration));
                //string startstring1 = startDate1.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");
            }

            stop_dateTime = DateTime.ParseExact(obj.stop, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
            string stop_datestring = stop_dateTime.ToString("yyyy-MM-dd");
            string stop_timestring = stop_dateTime.ToLocalTime().ToString("HH:mm");

            stop_fullTime = stop_datestring + " " + stop_timestring;
            TimeSpan stop_timespan = TimeSpan.Parse(stop_timestring);


            stop_date.Date    = stop_dateTime;
            stop_poptime.Time = stop_timespan;

            //stop_date.Date = start_dateTime;
            //stop_poptime.Time = start_timespan;

            attnListView.ItemsSource   = attList;
            attnListView.RowHeight     = 40;
            attnListView.HeightRequest = 40 * attList.Count;
            mainstack.HeightRequest    = mainstack.HeightRequest + attnListView.HeightRequest;

            foreach (var attobj in obj.tags)
            {
                tagsList.Add(new TagsList(attobj.name));
                int cusid = App.tagsDict.FirstOrDefault(x => x.Value == attobj.name).Key;
                tagIdsList.Add(cusid);
            }

            tagsListView.ItemsSource   = tagsList;
            tagsListView.RowHeight     = 40;
            tagsListView.HeightRequest = 40 * tagsList.Count;

            mainstack.HeightRequest = mainstack.HeightRequest + tagsListView.HeightRequest;

            attspicker1.ItemsSource   = App.cusdict.Select(x => x.Value).ToList();
            attspicker1.SelectedIndex = -1;
            attspicker1.Title         = "Select";

            tagspicker1.ItemsSource   = App.tagsDict.Select(x => x.Value).ToList();
            attspicker1.SelectedIndex = -1;
            attspicker1.Title         = "Select";

            var AirConImgRecognizer = new TapGestureRecognizer();

            AirConImgRecognizer.Tapped += (s, e) => {
                // handle the tap
                attnListView.IsVisible = true;
                Addbtn.IsVisible       = false;
                pickergrid.IsVisible   = true;
            };
            AddAirCon1.GestureRecognizers.Add(AirConImgRecognizer);

            var AirConImgRecognizer1 = new TapGestureRecognizer();

            AirConImgRecognizer1.Tapped += (s, e) => {
                // handle the tap
                tagsListView.IsVisible = true;
                Addbtn1.IsVisible      = false;
                tagsgrid.IsVisible     = true;
            };
            AddAirCon2.GestureRecognizers.Add(AirConImgRecognizer1);

            var overallcloseImgRecognizer = new TapGestureRecognizer();

            overallcloseImgRecognizer.Tapped += (s, e) => {
                // handle the tap
                Navigation.PopAllPopupAsync();
            };
            overall_close.GestureRecognizers.Add(overallcloseImgRecognizer);
        }
Example #3
0
        public CalendarDetailPage(all_events obj)
        {
            InitializeComponent();

            NavigationPage.SetHasNavigationBar(this, false);

            editobj = obj;

            var backRecognizer = new TapGestureRecognizer();

            backRecognizer.Tapped += async(s, e) => {
                App.Current.MainPage = new MasterPage(new CalendarPage());

                var currentpage = new LoadingAlert();
                await PopupNavigation.PushAsync(currentpage);

                Loadingalertcall();
                // PopupNavigation.PopAsync();
                //    Navigation.PopAllPopupAsync();
                //   Navigation.PushAsync(new CalendarPage());
                //  App.Current.MainPage = new MasterPage(new CalendarPage());
            };
            backImg.GestureRecognizers.Add(backRecognizer);


            var toolRecognizer = new TapGestureRecognizer();

            toolRecognizer.Tapped += (s, e) => {
                Navigation.PushPopupAsync(new CalendarPopupPage(editobj));
            };
            toolImg.GestureRecognizers.Add(toolRecognizer);


            if (editobj.sign_in == true)
            {
                signin_loc.IsVisible    = false;
                cancel_signin.IsVisible = true;

                //  sign_time.Text = "25/06/2019 15:45";

                //  DateTime gt =    DateTime.ParseExact(obj.sign_in_time, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);

                //   DateTime lt = gt.ToUniversalTime();

                sign_time.Text = obj.sign_in_time;

                MyMap.MoveToRegion(
                    MapSpan.FromCenterAndRadius(
                        new Position(editobj.sign_in_lat, editobj.sign_in_long), Distance.FromMiles(0.05)));

                var position1 = new Position(editobj.sign_in_lat, editobj.sign_in_long);

                var pin1 = new Pin
                {
                    Type     = PinType.Place,
                    Position = position1,
                    Label    = "Your Address",
                    Address  = "",
                };

                MyMap.Pins.Add(pin1);
            }


            if (editobj.sign_out == true)
            {
                signout_loc.IsVisible    = false;
                cancel_signout.IsVisible = true;

                signout_time.Text = obj.sign_out_time;

                MyMap1.MoveToRegion(
                    MapSpan.FromCenterAndRadius(
                        new Position(editobj.sign_out_lat, editobj.sign_out_long), Distance.FromMiles(0.05)));

                var position2 = new Position(editobj.sign_out_lat, editobj.sign_out_long);

                var pin2 = new Pin
                {
                    Type     = PinType.Place,
                    Position = position2,
                    Label    = "Your Address",
                    Address  = "",
                };

                MyMap1.Pins.Add(pin2);
            }

            List <EventsAtts> test = new List <EventsAtts>();

            List <TagsList> tagsstring = new List <TagsList>();

            metsub.Text = obj.meeting_subject;
            try
            {
                DateTime dateTime = DateTime.ParseExact(obj.starting_at, "yyyy-MM-dd HH:mm:ss",
                                                        CultureInfo.InvariantCulture);
                sat.Text = dateTime.ToLocalTime().ToString("dd/MM/yyyy HH:mm");
            }

            catch (Exception ea)
            {
                sat.Text = "";
            }

            dur.Text   = obj.duration;
            loc.Text   = obj.location;
            des.Text   = obj.description;
            test       = obj.attendees;
            tagsstring = obj.tags;

            int cnt = 0;

            try
            {
                foreach (var attobj in test)
                {
                    for (int row = 0; row < test.Count; row++)
                    {
                        attGrid.IsVisible = true;
                        if (cnt == test.Count)
                        {
                            break;
                        }

                        if (test.Count == 1)
                        {
                            attGrid.VerticalOptions   = LayoutOptions.Center;
                            attGrid.VerticalOptions   = LayoutOptions.Center;
                            attGrid.HorizontalOptions = LayoutOptions.Center;
                            attGrid.HorizontalOptions = LayoutOptions.Center;
                        }

                        for (int col = 0; col < 3; col++)
                        {
                            if (cnt == test.Count)
                            {
                                break;
                            }

                            EventsAtts tmpObj = test.ElementAt(cnt++);

                            StackLayout nestedStackLayout = new StackLayout
                            {
                                Orientation       = StackOrientation.Vertical,
                                HorizontalOptions = LayoutOptions.CenterAndExpand,
                                VerticalOptions   = LayoutOptions.Center,
                            };

                            var Pic = new CircleImage()
                            {
                                WidthRequest  = 50,
                                HeightRequest = 50,
                                //CacheDuration = TimeSpan.FromDays(1),
                                //DownsampleToViewSize = true,
                                //BitmapOptimizations = false,
                                Aspect = Aspect.AspectFit,
                            };

                            Label imageLabel = new Label
                            {
                                Margin         = new Thickness(0, 0, 0, 0),
                                Text           = tmpObj.name,
                                FontSize       = Device.GetNamedSize(NamedSize.Micro, typeof(Label)),
                                FontAttributes = FontAttributes.Bold,
                                //TextColor = Color.FromHex("#9EA09F"),
                                HorizontalOptions       = LayoutOptions.CenterAndExpand,
                                HorizontalTextAlignment = TextAlignment.Center,
                                TextColor = Color.Black,
                            };

                            byte[] imageAsBytes = Encoding.UTF8.GetBytes(tmpObj.image_small);

                            byte[] decodedByteArray = System.Convert.FromBase64String(Encoding.UTF8.GetString(imageAsBytes, 0, imageAsBytes.Length));
                            var    stream           = new MemoryStream(decodedByteArray);
                            Pic.Source = ImageSource.FromStream(() => stream);

                            nestedStackLayout.Children.Add(Pic);
                            nestedStackLayout.Children.Add(imageLabel);

                            attGrid.Children.Add(nestedStackLayout, col, row);
                        }
                    }
                }
            }

            catch (Exception ea)
            { System.Diagnostics.Debug.WriteLine("Warning Message : " + ea.Message); }

            //tags strted

            try
            {
                int cnt1 = 0;

                for (int row = 0; row < tagsstring.Count; row++)
                {
                    tagsGrid.IsVisible = true;
                    if (cnt1 == tagsstring.Count)
                    {
                        break;
                    }

                    if (test.Count == 1)
                    {
                        attGrid.VerticalOptions   = LayoutOptions.Center;
                        attGrid.VerticalOptions   = LayoutOptions.Center;
                        attGrid.HorizontalOptions = LayoutOptions.Center;
                        attGrid.HorizontalOptions = LayoutOptions.Center;
                    }

                    for (int col = 0; col < 3; col++)
                    {
                        if (cnt1 == tagsstring.Count)
                        {
                            break;
                        }

                        TagsList modelobj = tagsstring.ElementAt(cnt1++);
                        //  cnt = cnt + 1;

                        StackLayout nestedStackLayout = new StackLayout
                        {
                            Orientation       = StackOrientation.Vertical,
                            HorizontalOptions = LayoutOptions.CenterAndExpand,
                            VerticalOptions   = LayoutOptions.CenterAndExpand,
                            //  Padding = 10
                            // HeightRequest = 20
                        };

                        Label tagsLabel = new Label
                        {
                            //  Margin = new Thickness(5, 5, 5, 5),
                            Text           = modelobj.name,
                            FontSize       = Device.GetNamedSize(NamedSize.Micro, typeof(Label)),
                            FontAttributes = FontAttributes.Bold,
                            //TextColor = Color.FromHex("#9EA09F"),
                            HorizontalOptions       = LayoutOptions.Start,
                            HorizontalTextAlignment = TextAlignment.Center,
                            TextColor             = Color.Black,
                            VerticalOptions       = LayoutOptions.Start,
                            VerticalTextAlignment = TextAlignment.Center,
                            //HeightRequest =10,
                        };

                        //TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer
                        //{
                        //    Command = new Command(OnSquareTapped),
                        //    CommandParameter = tmpObj
                        //};
                        //tagsLabel.GestureRecognizers.Add(tapGestureRecognizer);

                        Frame lblframe = new Frame()
                        {
                            CornerRadius    = 6,
                            BackgroundColor = Color.FromHex(modelobj.colour.Replace(" ", "")),
                            Padding         = new Thickness(5),
                            HeightRequest   = 15,
                            Margin          = new Thickness(3, 3, 3, 3),
                        };

                        lblframe.Content = tagsLabel;

                        nestedStackLayout.Children.Add(lblframe);

                        tagsGrid.Children.Add(nestedStackLayout, col, row);
                    }
                }
            }

            catch (Exception ea)
            { System.Diagnostics.Debug.WriteLine("Warning Message : " + ea.Message); }
        }