Exemplo n.º 1
0
        private void AddNotificationsTab()
        {
            AddContentTab("Notifications", "icon_notifications.png");
            ListView notificationList = currentTab.AddListView(typeof(NotificationViewCell), null, (sender, e) => {
                Notification note = (Notification)e.Item;
                EntityPageBuilderFactory.ShowEntityPage <Notification>(Phoenix.Application.NotificationManager, note.Id);
            });

            notificationList.IsGroupingEnabled     = true;
            notificationList.GroupDisplayBinding   = new Binding("GroupName");
            notificationList.GroupShortNameBinding = new Binding("GroupShortName");;
            notificationList.IsRefreshing          = true;

            Phoenix.Application.NotificationManager.AllForPosition(CurrentPosition.Id, (results) => {
                if (results.Count > 0)
                {
                    UpdateNotifications(results);
                    EntityGroup.GroupEntities <Notification> (results, (groupedResults) => {
                        Device.BeginInvokeOnMainThread(() => {
                            notificationList.ItemsSource  = groupedResults;
                            notificationList.IsRefreshing = false;
                        });
                    });
                }
                else
                {
                    Device.BeginInvokeOnMainThread(() => {
                        notificationList.IsRefreshing = false;
                    });
                }
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// Entities the selected.
 /// </summary>
 /// <param name="manager">Manager.</param>
 /// <param name="item">Item.</param>
 protected virtual void EntitySelected(NexusManager <T> manager, T item)
 {
     if (EntityHasDetail)
     {
         EntityPageBuilderFactory.ShowEntityPage <T>(manager, item.Id);
     }
     listView.IsEnabled = true;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Shows the entity page.
        /// </summary>
        /// <param name="manager">Manager.</param>
        /// <param name="id">Identifier.</param>
        /// <param name="tabIndex">Tab index.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public static void ShowEntityPage <T>(NexusManager <T> manager, int id, int tabIndex = 0) where T :   EntityBase, new()
        {
            IEntityPageBuilder <T> builder = EntityPageBuilderFactory.CreateBuilder <T>(manager);

            manager.Get(id, (item) => {
                TabbedPage page = builder.BuildPage((T)item);
                if (tabIndex > 0)
                {
                    page.CurrentPage = page.Children[tabIndex];
                }
                Device.BeginInvokeOnMainThread(() => {
                    RootPage.Root.NextPage(page);
                });
            });
        }
Exemplo n.º 4
0
        private void AddPositions()
        {
            Phoenix.Application.PositionManager.GetPositionsInStarSystem(CurrentStarSystem, (results) => {
                if (results.GetEnumerator().MoveNext())
                {
                    Device.BeginInvokeOnMainThread(() => {
                        AddContentTab("Positions", "icon_positions.png");

                        currentTab.AddListViewWithSearchBar(typeof(TextCell), results, (sender, e) => {
                            Position p = (Position)e.Item;
                            EntityPageBuilderFactory.ShowEntityPage <Position> (Phoenix.Application.PositionManager, p.Id);
                        });
                    });
                }
            });
        }
Exemplo n.º 5
0
        private void AddJumpLinks()
        {
            if (CurrentStarSystem.JumpLinks.Count > 0)
            {
                AddContentTab("Jump Links", "icon_jumplink.png");

                currentTab.AddProperty("Periphery", CurrentStarSystem.PeripheryName);

                currentTab.AddListView(typeof(TextCell), CurrentStarSystem.JumpLinks, (sender, e) => {
                    StarSystem ss = ((JumpLink)e.Item).ToStarSysytem;
                    EntityPageBuilderFactory.ShowEntityPage <StarSystem> (Manager, ss.Id);
                });

                currentTab.AddHelpLabel("Tap a link to view system");
            }
        }
 /// <summary>
 /// Entities the selected.
 /// </summary>
 /// <param name="manager">Manager.</param>
 /// <param name="item">Item.</param>
 protected override void EntitySelected(NexusManager <Position> manager, Position item)
 {
     EntityPageBuilderFactory.ShowEntityPage <Position>(manager, item.Id, (int)PositionPageBuilder.PositionTab.TurnReport);
 }
Exemplo n.º 7
0
        private void AddOrdersTab()
        {
            AddContentTab("Orders", "icon_orders.png");
            ordersTab = currentTab;

            ListView ordersList = null;

            Button clearOrdersButton = new Button {
                Text              = "Clear Orders",
                TextColor         = Color.White,
                BackgroundColor   = Color.Red,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            clearOrdersButton.Clicked += async(sender, e) => {
                bool confirm = await currentTab.DisplayAlert("Clear Orders", "Are you sure?", "Yes", "No");

                if (confirm)
                {
                    Phoenix.Application.OrderManager.ClearOrders(CurrentPosition.Id, (results) => {
                        Orders = new ObservableCollection <Order> (results);
                        Device.BeginInvokeOnMainThread(() => {
                            ordersList.ItemsSource = Orders;
                        });
                        SwitchToOrdersTab();
                    });
                }
            };

            Button copyOrdersButton = new Button {
                Text              = "Copy Orders",
                TextColor         = Color.White,
                BackgroundColor   = Color.Blue,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            copyOrdersButton.Clicked += (sender, e) => {
                PositionSelectorPage page = new PositionSelectorPage((Position.PositionFlag)CurrentPosition.PositionType, (position) => {
                    Phoenix.Application.OrderManager.CopyOrders(CurrentPosition.Id, position.Id, (results) => {
                        EntityPageBuilderFactory.ShowEntityPage <Position>(Manager, position.Id, (int)PositionPageBuilder.PositionTab.Orders);
                    });
                });
                RootPage.Root.NextPageModal(page);
            };

            StackLayout buttonBar = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    clearOrdersButton,
                    copyOrdersButton
                }
            };

            currentTab.PageLayout.Children.Add(buttonBar);

            ordersList = currentTab.AddListView(typeof(OrderViewCell), null, (sender, e) => {
                currentTab.Spinner.IsRunning = true;
                Phoenix.Application.OrderManager.Get(((Order)e.Item).Id, (order) => {
                    OrderEditPage page = new OrderEditPage(order);
                    Device.BeginInvokeOnMainThread(() => {
                        RootPage.Root.NextPage(page);
                        currentTab.Spinner.IsRunning = false;
                    });
                });
            });

            Button addOrderButton = new Button {
                Text            = "Add Order",
                TextColor       = Color.White,
                BackgroundColor = Color.Blue
            };

            addOrderButton.Clicked += (sender, e) => {
                OrderSelectorPage page = new OrderSelectorPage(CurrentPosition);
                RootPage.Root.NextPageModal(page);
            };
            currentTab.PageLayout.Children.Add(addOrderButton);

            currentTab.AddHelpLabel("Tap an order to edit. Swipe left to delete an order.");

            ordersList.IsRefreshing = true;

            Phoenix.Application.OrderManager.AllForPosition(CurrentPosition.Id, (results) => {
                if (results.Count > 0)
                {
                    UpdateOrders(results);
                    Device.BeginInvokeOnMainThread(() => {
                        ordersList.IsRefreshing = false;
                        ordersList.ItemsSource  = Orders;
                    });
                }
                else
                {
                    Phoenix.Application.OrderManager.FetchForPosition(CurrentPosition.Id, (fetchResults, ex) => {
                        if (ex == null)
                        {
                            UpdateOrders(fetchResults);
                        }
                        else
                        {
                            Orders = new ObservableCollection <Order>();
                            ShowErrorAlert(ex);
                        }
                        Device.BeginInvokeOnMainThread(() => {
                            ordersList.IsRefreshing = false;
                            ordersList.ItemsSource  = Orders;
                        });
                    });
                }
            });
        }