Пример #1
0
        public void ScrollViewSyncer(HorizontalScrollView scrollView, HorizontalScrollView scrollview2)
        {
            bool  initialRun  = true;
            int   currentTime = (DateTime.Now.Hour - 1) * 5 * 60 + DateTime.Now.Minute * 5;
            int   scrolledAt  = 0;
            int   TimerWait   = 30;
            Timer _timer;

            Thread t = new Thread(() => {
                _timer = new Timer(o => {
                    if (scrollView.ScrollX < currentTime && initialRun == true)
                    {
                        RunOnUiThread(() =>
                        {
                            scrollView.ScrollTo(scrolledAt  += 12, 0);
                            scrollview2.ScrollTo(scrolledAt += 12, 0);
                        });
                    }
                    else
                    {
                        initialRun = false;
                        scrollview2.ScrollTo(scrollView.ScrollX, 0);
                    }
                },
                                   null, 0, TimerWait);
            });

            t.Start();
        }
Пример #2
0
        public void ScrollToItem(int itemIndex)
        {
            var index = itemIndex;

            if (itemIndex < 0)
            {
                index = 0;
            }

            if (itemIndex > _itemsSource.Count())
            {
                index = _itemsSource.Count() - 1;
            }

            LinearLayout linearLayout = (LinearLayout)_horizontalScrollView.GetChildAt(0);

            if (linearLayout != null)
            {
                View itemAtIndex = linearLayout.GetChildAt(index);
                if (itemAtIndex != null)
                {
                    _horizontalScrollView.ScrollTo(itemAtIndex.Left, 0);
                }
            }
        }
Пример #3
0
 private void ClearPressed(object sender, EventArgs e)
 {
     _twOut.Text                   = string.Empty;
     _pointPressed                 = false;
     _operationPressed             = false;
     _result                       = 0;
     _twOut.LayoutParameters.Width = 100;
     _scrollView.ScrollTo(0, 0);
 }
        public override void Draw(Canvas canvas)
        {
            base.Draw(canvas);
            if (_initialized)
            {
                return;
            }
            _initialized = true;
            var carouselLayout = (CarouselLayout)this.Element;

            _scrollView.ScrollTo(carouselLayout.SelectedIndex * Width, 0);
        }
Пример #5
0
        public override void Draw(Canvas canvas)
        {
            Log.Debug(tag, "~ Renderer - Draw (override method) started");

            base.Draw(canvas);
            if (_initialized)
            {
                return;
            }
            _initialized = true;
            var carouselLayout = (CarouselLayout)this.Element;

            _scrollView.ScrollTo(carouselLayout.SelectedIndex * Width, 0);
        }
Пример #6
0
 public override void Draw(Canvas canvas)
 {
     try{
         base.Draw(canvas);
         if (_initialized)
         {
             return;
         }
         _initialized = true;
         var cxCarouselView = (cxCarouselView)this.Element;
         _scrollView.ScrollTo(cxCarouselView.SelectedIndex * Width, 0);
     }
     catch (System.Exception ex)
     {
         Insights.Send("Draw", ex);
     }
 }
Пример #7
0
        private bool scrollToPageBtn(ViewerPageButton b)
        {
            if (_scrollContentLayout.Width > _pageScroll.Width)
            {
                int scrollX = 0;

                if (b.Left >= (_pageScroll.Width / 2.0f))
                {
                    scrollX = (int)((b.Left + (b.Width / 2.0f)) - (_pageScroll.Width / 2.0f));
                }

                _pageScroll.ScrollTo(scrollX, 0);

                return(scrollX != _pageScroll.ScrollX);
            }

            return(false);
        }
Пример #8
0
        async void OnScrollToRequested(object sender, ScrollToRequestedEventArgs e)
        {
            if (!_isAttached)
            {
                return;
            }

            // 99.99% of the time simply queuing to the end of the execution queue should handle this case.
            // However it is possible to end a layout cycle and STILL be layout requested. We want to
            // back off until all are done, even if they trigger layout storms over and over. So we back off
            // for 10ms tops then move on.
            var cycle = 0;

            while (IsLayoutRequested)
            {
                await Task.Delay(TimeSpan.FromMilliseconds(1));

                cycle++;

                if (cycle >= 10)
                {
                    break;
                }
            }

            var x        = (int)Forms.Context.ToPixels(e.ScrollX);
            var y        = (int)Forms.Context.ToPixels(e.ScrollY);
            int currentX = _view.Orientation == ScrollOrientation.Horizontal ? _hScrollView.ScrollX : ScrollX;
            int currentY = _view.Orientation == ScrollOrientation.Horizontal ? _hScrollView.ScrollY : ScrollY;

            if (e.Mode == ScrollToMode.Element)
            {
                Point itemPosition = Controller.GetScrollPositionForElement(e.Element as VisualElement, e.Position);

                x = (int)Forms.Context.ToPixels(itemPosition.X);
                y = (int)Forms.Context.ToPixels(itemPosition.Y);
            }
            if (e.ShouldAnimate)
            {
                ValueAnimator animator = ValueAnimator.OfFloat(0f, 1f);
                animator.SetDuration(1000);
                animator.Update += (o, animatorUpdateEventArgs) =>
                {
                    var v     = (double)animatorUpdateEventArgs.Animation.AnimatedValue;
                    int distX = GetDistance(currentX, x, v);
                    int distY = GetDistance(currentY, y, v);

                    if (_view == null)
                    {
                        // This is probably happening because the page with this Scroll View
                        // was popped off the stack during animation
                        animator.Cancel();
                        return;
                    }

                    if (_view.Orientation == ScrollOrientation.Horizontal)
                    {
                        _hScrollView.ScrollTo(distX, distY);
                    }
                    else
                    {
                        ScrollTo(distX, distY);
                    }
                };
                animator.AnimationEnd += delegate
                {
                    if (Controller == null)
                    {
                        return;
                    }
                    Controller.SendScrollFinished();
                };

                animator.Start();
            }
            else
            {
                if (_view.Orientation == ScrollOrientation.Horizontal)
                {
                    _hScrollView.ScrollTo(x, y);
                }
                else
                {
                    ScrollTo(x, y);
                }
                Controller.SendScrollFinished();
            }
        }
Пример #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.ReservaSalaJuntasLayout);
            Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetActionBar(toolbar);
            ActionBar.Title = Resources.GetString(Resource.String.str_meeting_room_reservation);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            /*_viewPager = FindViewById<ViewPager>(Resource.Id.vpSucursal);*/
            salas = SalasController.GetSalaJuntas(Intent.GetStringExtra("sucursal_id"));

            /*niveles = SalasController.GetNivelesSucursal(Intent.GetStringExtra("sucursal_id"));
             * _viewPager.Adapter = new SalaJuntasAdapter(this, salas);*/
            //tlSalasJuntas = FindViewById<TableLayout>(Resource.Id.tlSalasJuntas);
            Horarios.Add(fecha_seleccionada, new List <double>());
            ListView lvSalasJuntas = FindViewById <ListView>(Resource.Id.lvSalasJuntas);

            lvSalasJuntas.Adapter       = new SalasJuntasListAdapter(salas);
            lvSalasJuntas.ChoiceMode    = ChoiceMode.Single;
            lvSalasJuntas.ItemSelected += (sender, e) =>
            {
                Console.WriteLine(((ListView)sender).ChildCount);
            };

            /*salas.ForEach(sala =>
             * {
             *  LayoutInflater liView = LayoutInflater;
             *  View SucursalView = liView.Inflate(Resource.Layout.SalasJuntasLayout, null, true);
             *  SucursalView.FindViewById<LinearLayout>(Resource.Id.llSalaJunta).Click += delegate
             *  {
             *      SucursalView.FindViewById<LinearLayout>(Resource.Id.llReserva).Visibility = ViewStates.Visible;
             *  };
             *  SucursalView.FindViewById<TextView>(Resource.Id.lblSalaJunta).Text = sala.Sala_Descripcion;
             *  SucursalView.FindViewById<TextView>(Resource.Id.tvCapacidad).Text = sala.Sala_Capacidad + "-" + (Convert.ToInt32(sala.Sala_Capacidad) + 2).ToString();
             *  SucursalView.FindViewById<TextView>(Resource.Id.tvNivel).Text = "Nivel " + Convert.ToInt32(sala.Sala_Nivel).ToString("00");
             *  TableRow row = new TableRow(this);
             *  row.AddView(SucursalView);
             *  tlSalasJuntas.AddView(row);
             * });*/
            FindViewById <TextView>(Resource.Id.lblCreditosDisponibles).Text   = SalasController.GetCreditosDisponibles(storage.Get("Usuario_Id")).ToString();
            FindViewById <LinearLayout>(Resource.Id.llSeleccionarFecha).Click += (sender, e) =>
            {
                DatePickerMinFragment frag = DatePickerMinFragment.NewInstance(delegate(DateTime time)
                {
                    FindViewById <TextView>(Resource.Id.lblDiaFecha).Text  = time.DayOfWeek.ToString().Substring(0, 3);
                    FindViewById <TextView>(Resource.Id.lblDiaNumero).Text = time.Day.ToString();
                    fecha_seleccionada = time.ToString("d");
                    Horarios.Clear();
                    Horarios.Add(fecha_seleccionada, new List <double>());
                    UpdateHorasNoDisponibles();
                });
                frag.Show(FragmentManager, Resources.GetString(Resource.String.str_meeting_room_reservation));
            };
            FindViewById <TextView>(Resource.Id.lblDiaFecha).Text       = DateTime.Parse(fecha_seleccionada).DayOfWeek.ToString().Substring(0, 3);
            FindViewById <TextView>(Resource.Id.lblDiaNumero).Text      = DateTime.Parse(fecha_seleccionada).Day.ToString();
            FindViewById <TextView>(Resource.Id.lblHorasTotal).Text     = Horarios[fecha_seleccionada].Count.ToString();
            FindViewById <TextView>(Resource.Id.lblCreditosUsados).Text = creditos.ToString();

            /*Spinner spNivel = FindViewById<Spinner>(Resource.Id.spNivel);
             * spNivel.Adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, niveles.Keys.ToList());
             * spNivel.SetSelection(niveles.Count - 1);
             * spNivel.ItemSelected += (sender, e) =>
             * {
             *  salas = SalasController.GetSalaJuntas(Intent.GetStringExtra("sucursal_id"), niveles[((Spinner)sender).SelectedItem.ToString()]);
             *  _viewPager.Adapter = new SalaJuntasAdapter(this, salas);
             * };*/
            llhHorario = FindViewById <LinearLayout>(Resource.Id.llhHorario);
            SalasController.GetHorasNoDisponibles(fecha_seleccionada, salas[SalaSeleccionada].Sala_Id).ForEach(horas =>
            {
                HorasNoDisponibles.Add(DateTime.Parse(horas.Sala_Hora_Fin).Hour);
                UpdateHorasNoDisponibles();
            });

            /*_viewPager.PageSelected += (sender, e) =>
             * {
             *  HorasNoDisponibles.Clear();
             *  SalasController.GetHorasNoDisponibles(fecha_seleccionada, salas[_viewPager.CurrentItem].Sala_Id).ForEach(horas =>
             *  {
             *      HorasNoDisponibles.Add(DateTime.Parse(horas.Sala_Hora_Fin).Hour);
             *  });
             *  if (!Horarios.ContainsKey(salas[_viewPager.CurrentItem].Sala_Id))
             *      Horarios.Add(salas[_viewPager.CurrentItem].Sala_Id, new Dictionary<string, List<double>>());
             *  if (!Horarios[salas[_viewPager.CurrentItem].Sala_Id].ContainsKey(fecha_seleccionada))
             *      Horarios[salas[_viewPager.CurrentItem].Sala_Id].Add(fecha_seleccionada, new List<double>());
             *  UpdateHorasNoDisponibles();
             *  FillHorario();
             * };*/
            FindViewById <RelativeLayout>(Resource.Id.rlAgendar).Click += (sender, e) => ShowConfirmacion();
            UpdateHorasNoDisponibles();
            FillHorario();
            HorizontalScrollView scrollHoras = FindViewById <HorizontalScrollView>(Resource.Id.hsvHorario);

            scrollHoras.PostDelayed(delegate
            {
                if (Convert.ToInt32(Build.VERSION.Sdk) < 23)
                {
                    scrollHoras.ScrollTo(DateTime.Now.Hour * 200, 0);
                }
                else
                {
                    scrollHoras.ScrollTo(DateTime.Now.Hour * 400, 0);
                }
            }, 100);
        }