Ejemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Parameter is item ID
            Item = ItemViewModel.FromItem(ItemsDataSource.GetItemById((int)e.Parameter));

            var backStack      = Frame.BackStack;
            var backStackCount = backStack.Count;

            if (backStackCount > 0)
            {
                var masterPageEntry = backStack[backStackCount - 1];
                backStack.RemoveAt(backStackCount - 1);

                // Doctor the navigation parameter for the master page so it
                // will show the correct item in the side-by-side view.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    Item.ItemId,
                    masterPageEntry.NavigationTransitionInfo
                    );
                backStack.Add(modifiedEntry);
            }

            // Register for hardware and software back request from the system
            SystemNavigationManager.GetForCurrentView().BackRequested += DetailPage_BackRequested;
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var items = MasterListView.ItemsSource as List <ItemViewModel>;

            if (items == null)
            {
                items = new List <ItemViewModel>();

                foreach (var item in ItemsDataSource.GetAllItems())
                {
                    items.Add(ItemViewModel.FromItem(item));
                }

                MasterListView.ItemsSource = items;
            }

            if (e.Parameter != null)
            {
                // Parameter is item ID
                var id = (int)e.Parameter;
                _lastSelectedItem =
                    items.Where((item) => item.ItemId == id).FirstOrDefault();
            }

            UpdateForVisualState(AdaptiveStates.CurrentState);

            // Don't play a content transition for first item load.
            // Sometimes, this content will be animated as part of the page transition.
            DisableContentTransitions();
        }
Ejemplo n.º 3
0
        private void ListClick(object sender, ItemClickEventArgs e)
        {
            int index = ItemsDataSource.GetData().GetIndex(e.ClickedItem as Item);

            ItemSelected           = index;
            MainPage.Current.State = "Detail";
        }
Ejemplo n.º 4
0
 private void Create(object sender, RoutedEventArgs e)
 {
     if (textBoxTitle.Text == "" || textBoxDes.Text == "")
     {
         UtilTool.SendADialog("Create Fail", "Title and Description can not be empty!");
     }
     else if (DueDatePicker.Date < DateTime.Now.AddDays(-1))
     {
         UtilTool.SendADialog("Create Fail", "DueDate is late to Now!");
     }
     else
     {
         if (this.isCreateStatus == true)
         {
             SendAToast("Create Success", "You had create a event successfully.");
             ItemsDataSource.GetData().Add(GetCurrentData());
             ResetForm();
         }
         else if (editIndex != -1)
         {
             SendAToast("Update Success", "You had update a event successfully.");
             ItemsDataSource.GetData().Update(GetCurrentData(), editIndex);
         }
         else
         {
             UtilTool.SendADialog("Update Failed!", "You have to select one.");
         }
         if (MainPage.Current.State == "Detail")
         {
             MainPage.Current.State = "List";
         }
     }
 }
Ejemplo n.º 5
0
        protected void ShowItemsList(IEnumerable <ISitecoreItem> items)
        {
            BeginInvokeOnMainThread(delegate
            {
                this.CleanupTableViewBindingsSync();

                this.itemsDataSource    = new ItemsDataSource();
                this.itemsTableDelegate = new ItemCellSelectionHandler();


                ItemsDataSource dataSource = this.itemsDataSource;
                dataSource.SitecoreItems   = items;
                dataSource.TableView       = this.TableView;


                ItemCellSelectionHandler tableDelegate = this.itemsTableDelegate;
                tableDelegate.TableView     = this.TableView;
                tableDelegate.SitecoreItems = items;

                ItemCellSelectionHandler.TableViewDidSelectItemAtIndexPath onItemSelected =
                    delegate(UITableView tableView, ISitecoreItem item, NSIndexPath indexPath)
                {
                    this.selectedItem = item;
                    this.PerformSegue("showFieldsViewController", this);
                    //AlertHelper.ShowLocalizedAlertWithOkOption("Message", item.DisplayName);
                };
                tableDelegate.OnItemCellSelectedDelegate = onItemSelected;

                this.TableView.DataSource = dataSource;
                this.TableView.Delegate   = tableDelegate;
                this.TableView.ReloadData();
            });
        }
Ejemplo n.º 6
0
        private void MenuEdit_Click(object sender, RoutedEventArgs e)
        {
            var originalSource = e.OriginalSource as MenuFlyoutItem;
            int index          = ItemsDataSource.GetData().GetIndex(originalSource.DataContext as Item);

            ItemSelected           = index;
            MainPage.Current.State = "Detail";
        }
Ejemplo n.º 7
0
        private void DeleteItem_ItemInvoked(SwipeItem sender, SwipeItemInvokedEventArgs args)
        {
            Item data = (Item)args.SwipeControl.DataContext;

            if (data != null)
            {
                ItemsDataSource.GetData().Remove(data);
                ItemSelected = -1;
            }
        }
Ejemplo n.º 8
0
        public void ShowDetail()
        {
            Item data = ItemsDataSource.GetData().Get(editIndex);

            ImageBox.Source    = data.Icon;
            textBoxTitle.Text  = data.Title;
            textBoxDes.Text    = data.Des;
            DueDatePicker.Date = data.DueDate;
            imageByte          = data.ImageByte;
        }
Ejemplo n.º 9
0
        private void MenuDelete_Click(object sender, RoutedEventArgs e)
        {
            var  originalSource = e.OriginalSource as MenuFlyoutItem;
            Item data           = (Item)originalSource.DataContext;

            if (data != null)
            {
                ItemsDataSource.GetData().Remove(data);
                ItemSelected = -1;
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                return;
            }
            if (rootFrame.CanGoBack)
            {
                // Show UI in title bar if opted-in and in-app backstack is not empty.
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                    AppViewBackButtonVisibility.Visible;
            }
            else
            {
                // Remove the UI from the title bar if in-app back stack is empty.
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                    AppViewBackButtonVisibility.Collapsed;
            }
            var items = MasterListView.ItemsSource as List <ItemViewModel>;

            if (items == null)
            {
                items = new List <ItemViewModel>();

                foreach (var item in ItemsDataSource.GetAllItems())
                {
                    items.Add(ItemViewModel.FromItem(item));
                }

                MasterListView.ItemsSource = items;
            }

            if (e.Parameter != null)
            {
                // Parameter is item ID
                var id = (int)e.Parameter;
                _lastSelectedItem =
                    items.Where((item) => item.ItemId == id).FirstOrDefault();
            }

            UpdateForVisualState(AdaptiveStates.CurrentState);

            // Don't play a content transition for first item load.
            // Sometimes, this content will be animated as part of the page transition.
            DisableContentTransitions();
        }
Ejemplo n.º 11
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Parameter is item ID
            Item = ItemViewModel.FromItem(ItemsDataSource.GetItemById((int)e.Parameter));

            ReplaceLastBackStackEntryParameter(e.Parameter);

            // Register for hardware and software back request from the system
            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();

            systemNavigationManager.BackRequested += DetailPage_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
        }
Ejemplo n.º 12
0
        private void _Search()
        {
            if (IsSearching)
            {
                return;
            }

            SearchTextIsEnabled = false;

            WarmPack.Threading.Task.RunTask(() =>
            {
                CurrentItem = default(T);
                IsSearching = true;

                if (_LastSearch != SearchText)
                {
                    ItemsDataSource = null;

                    ItemsDataSource = _SearchAction(SearchText).ToObservableCollection();
                    _LastSearch     = SearchText;
                }
            })
            .Completed(() =>
            {
                _View.Dispatcher.Invoke(new Action(() =>
                {
                    _View.SearchItemsDataGridView.ItemsSource = ItemsDataSource;
                    CurrentItem = ItemsDataSource.FirstOrDefault();
                    _View.SearchItemsDataGridView.SelectedItem = CurrentItem;

                    if (ItemsDataSource?.Count == 1 && _firstShow)
                    {
                        _View.Close();
                    }

                    if (_firstShow)
                    {
                        _firstShow    = false;
                        _View.Opacity = 100;
                        _View.SearchText.SelectionStart = SearchText.Length;
                    }

                    SearchTextIsEnabled = true;
                    IsSearching         = false;
                }));
            });
        }
Ejemplo n.º 13
0
    protected void BtnInsert_Click(object sender, EventArgs e)
    {
        ItemsDataSource.InsertCommandType = SqlDataSourceCommandType.Text;
        try
        {
            ItemsDataSource.Insert();
            LblStatus.Text      = "Successfully Added Item";
            LblStatus.ForeColor = System.Drawing.Color.Green;
        }
        catch (Exception ex)
        {
            LblStatus.Text      = "Cannot Add This Item";
            LblStatus.ForeColor = System.Drawing.Color.Red;
        }

        TxtName.Text     = "";
        TxtQuantity.Text = "";
    }
Ejemplo n.º 14
0
        private void TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            var text = sender.Text;

            foreach (var item in ItemsDataSource.GetData().Source)
            {
                if (text.Equals(""))
                {
                    item.ShowIt = Visibility.Visible;
                    continue;
                }
                if (item.Title.Contains(text) ||
                    item.Des.Contains(text) ||
                    item.DueDate.ToString("D").Contains(text))
                {
                    item.ShowIt = Visibility.Visible;
                }
                else
                {
                    item.ShowIt = Visibility.Collapsed;
                }
            }
        }
Ejemplo n.º 15
0
 private void Button_DeleteItem(object sender, RoutedEventArgs e)
 {
     ItemsDataSource.GetData().Remove(ListPage.Current.ItemSelected);
     ListPage.Current.ItemSelected = -1;
     State = "List";
 }