コード例 #1
0
        public async void SendMessageAsync()
        {
            if (string.IsNullOrWhiteSpace(Message))
            {
                return;
            }
            var item = new UserMessage
            {
                Message      = Message,
                ReceiverId   = ReceiverUserId,
                ReceiverName = ReceiverName,
                SenderId     = AppSecurity.CurrentUser.UserId,
                SenderName   = AppSecurity.CurrentUser.GetFullName(),
                IsIncoming   = false,
                isSend       = false,
            };

            MessagingCenter.Send <object>(this, MessageCenterKeys.NewMessageAdded);
            IsBusy = true;
            var result = await App.AccountManager.SendMessageAsync(ReceiverName, Message, ReceiverUserId);

            if (!result.IsSuccess)
            {
                item.isSend = false;
                item.Image  = "close.png";
                await Application.Current.MainPage.DisplayAlert("Error", result.Message, "OK");
            }
            else
            {
                item.isSend = true;
                item.Image  = "tick.png";
            }

            AddNewMessagItem(item);
            IsBusy = false;
            Data.Repository.SaveOrUpdate(item);
            Message = string.Empty;
            IKeyboardInteractions keyboardInteractions = DependencyService.Get <IKeyboardInteractions>();

            keyboardInteractions.HideKeyboard();
        }
コード例 #2
0
ファイル: RedirectApp.cs プロジェクト: galoch-s/OMShopMobile
        /// <summary>
        /// Метод перенаправляет на другую страницу и изменяет индикатор текущей страницы
        /// </summary>
        /// <param name="item">Item.</param>
        /// <param name="isHistory">If set to <c>true</c> is history.</param>
        /// <param name="IsRedirectToBack">If set to <c>true</c> is redirect to back.</param>
        /// <param name="isLoadAllCategories">If set to <c>true</c> is load all categories.</param>
        public void RedirectToPage(PageName page, bool isHistory, bool IsRedirectToBack, bool isLoadAllCategories)
        {
            IKeyboardInteractions keyboardInteractions = DependencyService.Get <IKeyboardInteractions>();

            keyboardInteractions.HideKeyboard();

            StackLayout layoutContent = OnePage.bodyLayout;


            History history = GetCurrentTransition();

            if (history != null && history.Page == PageName.Order)
            {
                CrearHistory();
            }
            if (history != null && history.Page == PageName.Catalog && history.Step == HistoryStep.FilterProduct)
            {
                DeleteLastTransition();
            }

            //if (newView == catalogView && catalogView != null)
            //	catalogView.StopLoad();

            switch (page)
            {
            case PageName.Main:
                if (!isHistory && !AddTransition(page, "Главная"))
                {
                    return;
                }
                ShowIndicator(layoutContent);
                //if (mainPageView == null)
                mainPageView = new MainPageView();

                newView = mainPageView;
                break;

            case PageName.Info:
                if (!isHistory && !AddTransition(page, "Инфо"))
                {
                    return;
                }
                ShowIndicator(layoutContent);
                newView = new InfoView();
                break;

            case PageName.Catalog:
                if (!isHistory && !AddTransition(page, "Каталог"))
                {
                    return;
                }
                ShowIndicator(layoutContent);

                if (catalogView != null)
                {
                    catalogView.StopLoad();
                }

                if (catalogView == null)
                {
                    catalogView             = new CatalogView(isLoadAllCategories);
                    catalogView.filterParam = filterParam;
                }
                newView = catalogView;
                break;

            case PageName.Login:
                string text;
                if (User.Singleton == null)
                {
                    text = "Вход";
                }
                else
                {
                    text = "Мой профиль";
                }
                if (!isHistory && !AddTransition(page, text, IsRedirectToBack))
                {
                    return;
                }
                if (newView != basketView)
                {
                    ShowIndicator(layoutContent);
                }

                loginView.GotoPage(history.Step);
                newView = loginView;
                break;

            case PageName.Search:
                if (!isHistory && !AddTransition(page, "Поиск", IsRedirectToBack))
                {
                    return;
                }
                ShowIndicator(layoutContent);

                newView = searchView;
                searchView.ClearText();
                break;

            case PageName.Basket:
                if (!isHistory && !AddTransition(page, "Корзина", false, true))
                {
                    return;
                }
                ShowIndicator(layoutContent);

                basketView = new BasketView();
                newView    = basketView;
                break;

            case PageName.Image:
                if (catalogView != null)
                {
                    filterParam = catalogView.filterParam;
                }
                if (!isHistory && !AddTransition(page, "Просмотр", false, true))
                {
                    return;
                }
                ShowIndicator(layoutContent);

                newView = imageView;
                break;

            default:
                break;
            }

            //if (catalogView != null)
            //	catalogView.StopLoad();

            Device.BeginInvokeOnMainThread(() => {
                if (layoutContent.Children.Count > 0)
                {
                    layoutContent.Children.RemoveAt(0);
                }
                layoutContent.Children.Insert(0, newView);
            });
        }