Exemple #1
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="txt">The text.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        internal void Search(string txt)
        {
            if (String.IsNullOrEmpty(txt))
            {
                VisualStateManager.GoToElementState(this.Content as FrameworkElement, "ChooseState", true);
                isSearchMode = false;
                SetCurrent(null);
                return;
            }
            else
            {
                VisualStateManager.GoToElementState(this.Content as FrameworkElement, "SearchState", true);
                isSearchMode = true;
            }

            IsBusy = true;
            Action action = new Action(() =>
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    CityData.SearchResult        = Agent.SearchCity(txt);
                    searchDataGrid.SelectedIndex = 0;
                    searchDataGrid.Focus();
                }));
            });

            AsynHelper.Invoke(action, (ex) =>
            {
                Logger.WriteLog(LogType.ERROR, ex.Message, ex);
            }).ContinueWith((task) =>
            {
                InvokeSetBusy(false);
            });
        }
Exemple #2
0
        void CitysControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (CityData != null || IsBusy)
            {
                return;
            }

            IsBusy = true;

            var loadAction = new Action(() =>
            {
                var tempData = new CityData();
                List <CityCategory> tempCategory = new List <CityCategory>();
                tempCategory.Add(GetCategoryHotCity("热门"));
                tempCategory.Add(GetCategoryEx("ABC"));
                tempCategory.Add(GetCategoryEx("DEFG"));
                tempCategory.Add(GetCategoryEx("HI"));
                tempCategory.Add(GetCategoryEx("JK"));
                tempCategory.Add(GetCategoryEx("LM"));
                tempCategory.Add(GetCategoryEx("NOPQR"));
                tempCategory.Add(GetCategoryEx("ST"));
                tempCategory.Add(GetCategoryEx("UVWX"));
                tempCategory.Add(GetCategoryEx("YZ"));
                tempData.CityCategory = tempCategory;

                Dispatcher.Invoke(new Action(() =>
                {
                    CityData = tempData;
                }));
            });

            AsynHelper.Invoke(loadAction, (ex) =>
            {
                Logger.WriteLog(LogType.ERROR, ex.Message, ex);
            }).ContinueWith((task) =>
            {
                InvokeSetBusy(false);
            });
        }
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="txt">The text.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        internal void Search(string txt)
        {
            if (String.IsNullOrEmpty(txt))
            {
                VisualStateManager.GoToElementState(this.Content as FrameworkElement, "ChooseState", true);
                isSearchMode = false;
                SetCurrent(null);
                return;
            }
            else
            {
                VisualStateManager.GoToElementState(this.Content as FrameworkElement, "SearchState", true);
                isSearchMode = true;
            }

            IsBusy = true;
            Action action = new Action(() =>
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    if (PassengerData == null)
                    {
                        PassengerData = new PassengerData();
                    }
                    PassengerData.SearchResult = Agent.SearchPassenger(txt);
                    // searchDataGrid.SelectedIndex = 0;
                    // searchDataGrid.Focus();
                }));
            });

            AsynHelper.Invoke(action, (ex) =>
            {
            }).ContinueWith((task) =>
            {
                InvokeSetBusy(false);
            });
        }