Beispiel #1
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
                    });
                }
            });
        }