Ejemplo n.º 1
0
        private void BuildPinList()
        {
            if (pinListView == null)
            {
                return;
            }

            pinListView.Items.Clear();

            // Set a global 'Centre' pin
            pinListView.Items.Add(new ListViewItem("Page Centre")
            {
                Tag = InfoPin.Centre()
            });

            // Read current pins and fill in the list box
            var pins = _canvas.AllPins().OrderBy(p => p?.Description);

            foreach (var pin in pins)
            {
                if (pin?.Description == null)
                {
                    continue;
                }
                pinListView.Items.Add(new ListViewItem(pin.Description)
                {
                    Tag = pin
                });
            }
        }
Ejemplo n.º 2
0
        public PinsOverlay()
        {
            InitializeComponent();
            if (existingPinList?.Items == null)
            {
                return;
            }

            existingPinList.Items.Add(new ListViewItem
            {
                Tag     = InfoPin.Centre(),
                Content = "Page Centre"
            });


            // This crazyness is required to allow us to deselect items in the list.
            existingPinList.SelectionMode     = ListViewSelectionMode.Extended;
            existingPinList.DoubleTapped     += ExistingPinList_DoubleTapped;
            existingPinList.SelectionChanged += ExistingPinList_SelectionChanged;
        }
Ejemplo n.º 3
0
        private void ReloadPins()
        {
            if (existingPinList?.Items == null || _storage == null)
            {
                return;
            }

            Result <InfoPin[]> pinResult;

            try
            {
                pinResult = _storage.ReadAllPins();
            }
            catch (Exception ex)
            {
                existingPinList.Dispatcher?.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    existingPinList.Items.Clear();
                    existingPinList.Items.Add(new ListViewItem
                    {
                        Tag     = null,
                        Content = "Loading pins from DB failed: " + ex.Message
                    });
                });
                return;
            }

            if (pinResult.IsFailure)
            {
                return;
            }
            var pins = pinResult.ResultData?.OrderBy(p => p?.Description);

            if (pins == null)
            {
                return;
            }

            existingPinList.Dispatcher?.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                existingPinList.Items.Clear();
                existingPinList.Items.Add(new ListViewItem
                {
                    Tag     = InfoPin.Centre(),
                    Content = "Page Centre"
                });

                foreach (var pin in pins)
                {
                    if (pin == null)
                    {
                        continue;
                    }
                    existingPinList.Items.Add(new ListViewItem
                    {
                        Tag     = pin,
                        Content = pin.Description
                    });
                }
            });
        }