Esempio n. 1
0
 private async void ShellPage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable)
     {
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => InAppNotification.Show("No network access", 2000));
     }
 }
Esempio n. 2
0
 private async void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
 {
     if (!e.IsAvailable)
     {
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => InAppNotification.Show("No network access", 2000));
     }
 }
Esempio n. 3
0
        // DOWNLOAD
        public async Task Download(InAppNotification ExampleInAppNotification)
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            savePicker.FileTypeChoices.Add("Archive", new List <string>()
            {
                ".zip"
            });
            savePicker.SuggestedFileName = Name;
            StorageFile savefile = await savePicker.PickSaveFileAsync();

            if (savefile == null)
            {
                return;
            }

            string folder_name = "buffer_folder_" + DateTime.Now.ToString("yyyyMMddhhmmss");

            StorageFolder folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(folder_name);

            ObservableCollection <Page> pages = await PagesLoad();

            if (pages == null)
            {
                ExampleInAppNotification.Show("Can't loading :(", 4000);
                return;
            }

            int index = 1;

            foreach (Page page in pages)
            {
                await page.Download(folder);

                ExampleInAppNotification.Show(index + "/" + pages.Count(), 2000);
                index++;
            }

            await Helpers.ZipArchiveManager.ZipFolder(folder, savefile);

            //ZipFile.CreateFromDirectory(folder.Path, savefile.Path);

            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();

            ExampleInAppNotification.Show(resourceLoader.GetString("download_complit"), 4000);
        }
Esempio n. 4
0
 public void ShowNotification()
 {
     if (appbar != null)
     {
         appbar.IsOpen = true;
     }
     note?.Show();
 }
Esempio n. 5
0
        private void OnCopy(object sender, RoutedEventArgs e)
        {
            var dataPackage = new DataPackage();

            dataPackage.SetText(_colorText);
            Clipboard.SetContent(dataPackage);
            InAppNotification.Show(2000);
        }
Esempio n. 6
0
 public void NotifyMessage(string message)
 {
     if (LastNotifiedMessage != message)
     {
         LastNotifiedMessage = message;
         InAppNotification.Show(message);
     }
 }
Esempio n. 7
0
 private void Load()
 {
     SampleController.Current.RegisterNewCommand("Global Eyedropper", async(sender, args) =>
     {
         var eyedropper = new Eyedropper();
         var color      = await eyedropper.Open();
         InAppNotification.Show($"You get {color}.", 3000);
     });
 }
        private void InAppNotificationShow(InAppNotification inAppNotification, ListViewSelectionMode mode = ListViewSelectionMode.Multiple)//Notification:通知展示
        {
            inAppNotification.Show();

            AdaptiveGridViewControl.IsItemClickEnabled = false; //不可点击
            AdaptiveGridViewControl.SelectionMode      = mode;  //多选状态

            PhotoFileList.Remove(AddPhotoFile);                 //空白添加:移除
        }
    public void ShowNotification()
    {
        this.BottomAppBar.IsOpen = true;
        InAppNotification note = this.BottomAppBar.Content as InAppNotification;

        if (note != null)
        {
            note.Show();
        }
    }
Esempio n. 10
0
        public override Task <object> ShowToastAsync(ToastParameters toastParameters)
        {
            if (InAppNotification != null)
            {
                int hiddenMS = 0;
                if (toastParameters.MillisecondsUntilHidden.HasValue)
                {
                    hiddenMS = toastParameters.MillisecondsUntilHidden.Value;
                }

                InAppNotification.Show(toastParameters.Caption?.ToString(),
                                       hiddenMS > 0 ? hiddenMS : (int)ToastHideMS);

                return(Task.FromResult(new object()));
            }

            return(base.ShowToastAsync(toastParameters));
        }
Esempio n. 11
0
        private void TryAndSaveSnapshots()
        {
            // Only record after at least two movements
            // This prevents accidental triggering/overwriting
            if (Temporary_Snapshots.Count > 1)
            {
                CurrentSnapshot = 0;
                Snapshots.Clear();
                Temporary_Snapshots.ForEach((item) => { Snapshots.Add(item); });

                SnapshotButton.Fade((float)1, duration: 200).Then().Scale((float)1.2, (float)1.2, (float)(SnapshotButton.Width / 2), (float)(SnapshotButton.Height / 2), 100).Then().Scale(1, 1, (float)(SnapshotButton.Width / 2), (float)(SnapshotButton.Height / 2), 100).Start();
                SnapshotButton.Content = "\uEA3B";;

                ChaosNotifier.Show("\uE96A", 2000); // Tape icon
            }
            else
            {
                SnapshotButton.Fade((float)1).Start();
            }

            Temporary_Snapshots.Clear();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Shell.Current.RegisterNewCommand("Show notification with random text", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();

                var random = new Random();
                int result = random.Next(1, 4);

                if (result == 1)
                {
                    _exampleInAppNotification?.Show("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sollicitudin bibendum enim at tincidunt. Praesent egestas ipsum ligula, nec tincidunt lacus semper non.", NotificationDuration);
                }

                if (result == 2)
                {
                    _exampleInAppNotification?.Show("Pellentesque in risus eget leo rhoncus ultricies nec id ante.", NotificationDuration);
                }

                if (result == 3)
                {
                    _exampleInAppNotification?.Show("Sed quis nisi quis nunc condimentum varius id consectetur metus. Duis mauris sapien, commodo eget erat ac, efficitur iaculis magna. Morbi eu velit nec massa pharetra cursus. Fusce non quam egestas leo finibus interdum eu ac massa. Quisque nec justo leo. Aenean scelerisque placerat ultrices. Sed accumsan lorem at arcu commodo tristique.", NotificationDuration);
                }
            });

            Shell.Current.RegisterNewCommand("Show notification with buttons (without DataTemplate)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();

                var grid = new Grid();

                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });

                // Text part
                var textBlock = new TextBlock
                {
                    Text = "Do you like it?",
                    VerticalAlignment = VerticalAlignment.Center
                };
                grid.Children.Add(textBlock);

                // Buttons part
                var stackPanel = new StackPanel
                {
                    Orientation       = Orientation.Horizontal,
                    VerticalAlignment = VerticalAlignment.Center
                };

                var yesButton = new Button
                {
                    Content = "Yes",
                    Width   = 150,
                    Height  = 30
                };
                yesButton.Click += YesButton_Click;
                stackPanel.Children.Add(yesButton);

                var noButton = new Button
                {
                    Content = "No",
                    Width   = 150,
                    Height  = 30,
                    Margin  = new Thickness(10, 0, 0, 0)
                };
                noButton.Click += NoButton_Click;
                stackPanel.Children.Add(noButton);

                Grid.SetColumn(stackPanel, 1);
                grid.Children.Add(stackPanel);

                _exampleInAppNotification?.Show(grid, NotificationDuration);
            });

            Shell.Current.RegisterNewCommand("Show notification with buttons (with DataTemplate)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();

                object inAppNotificationWithButtonsTemplate = null;
                bool?isTemplatePresent = _resources?.TryGetValue("InAppNotificationWithButtonsTemplate", out inAppNotificationWithButtonsTemplate);

                if (isTemplatePresent == true && inAppNotificationWithButtonsTemplate is DataTemplate template)
                {
                    _exampleInAppNotification.Show(template, NotificationDuration);
                }
            });

            Shell.Current.RegisterNewCommand("Show notification with Drop Shadow (based on default template)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification.Dismiss();

                // Update control template
                object inAppNotificationDropShadowControlTemplate = null;
                bool?isTemplatePresent = _resources?.TryGetValue("InAppNotificationDropShadowControlTemplate", out inAppNotificationDropShadowControlTemplate);

                if (isTemplatePresent == true && inAppNotificationDropShadowControlTemplate is ControlTemplate template)
                {
                    _exampleInAppNotification.Template = template;
                }

                _exampleInAppNotification.Show(NotificationDuration);
            });

            Shell.Current.RegisterNewCommand("Show notification with Visual Studio Code template (info notification)", (sender, args) =>
            {
                _exampleInAppNotification.Dismiss();
                _exampleVSCodeInAppNotification.Show(NotificationDuration);
            });

            Shell.Current.RegisterNewCommand("Dismiss", (sender, args) =>
            {
                // Dismiss all notifications (should not be replicated in production)
                _exampleInAppNotification.Dismiss();
                _exampleVSCodeInAppNotification.Dismiss();
            });
        }
        private void Load()
        {
            SampleController.Current.RegisterNewCommand("Show notification with random text", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();
                _exampleInAppNotification?.Show(GetRandomText(), NotificationDuration);
            });

            SampleController.Current.RegisterNewCommand("Show notification with object", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();

                var random = new Random();
                _exampleInAppNotification?.Show(new KeyValuePair <int, string>(random.Next(1, 10), GetRandomText()), NotificationDuration);
            });

            SampleController.Current.RegisterNewCommand("Show notification with buttons (without DataTemplate)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetDefaultControlTemplate();

                var grid = new Grid()
                {
                    Margin = new Thickness(0, 0, -38, 0)
                };

                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });

                // Text part
                var textBlock = new TextBlock
                {
                    Text = "Do you like it?",
                    VerticalAlignment = VerticalAlignment.Center,
                    Margin            = new Thickness(0, 0, 24, 0),
                    FontSize          = 16
                };
                grid.Children.Add(textBlock);

                // Buttons part
                var stackPanel = new StackPanel
                {
                    Orientation       = Orientation.Horizontal,
                    VerticalAlignment = VerticalAlignment.Center
                };

                var yesButton = new Button
                {
                    Content  = "Yes",
                    Width    = 120,
                    Height   = 40,
                    FontSize = 16
                };
                yesButton.Click += YesButton_Click;
                stackPanel.Children.Add(yesButton);

                var noButton = new Button
                {
                    Content  = "No",
                    Width    = 120,
                    Height   = 40,
                    FontSize = 16,
                    Margin   = new Thickness(4, 0, 0, 0)
                };
                noButton.Click += NoButton_Click;
                stackPanel.Children.Add(noButton);

                Grid.SetColumn(stackPanel, 1);
                grid.Children.Add(stackPanel);

                _exampleInAppNotification?.Show(grid, NotificationDuration);
            });

            SampleController.Current.RegisterNewCommand("Show notification with buttons (with DataTemplate)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification?.Dismiss();
                SetCustomControlTemplate(); // Use the custom template without the Dismiss button. The DataTemplate will handle re-adding it.

                object inAppNotificationWithButtonsTemplate = null;
                bool?isTemplatePresent = _resources?.TryGetValue("InAppNotificationWithButtonsTemplate", out inAppNotificationWithButtonsTemplate);

                if (isTemplatePresent == true && inAppNotificationWithButtonsTemplate is DataTemplate template)
                {
                    _exampleInAppNotification.Show(template, NotificationDuration);
                }
            });

            SampleController.Current.RegisterNewCommand("Show notification with Drop Shadow (based on default template)", (sender, args) =>
            {
                _exampleVSCodeInAppNotification.Dismiss();
                SetDefaultControlTemplate();

                // Update control template
                object inAppNotificationDropShadowControlTemplate = null;
                bool?isTemplatePresent = _resources?.TryGetValue("InAppNotificationDropShadowControlTemplate", out inAppNotificationDropShadowControlTemplate);

                if (isTemplatePresent == true && inAppNotificationDropShadowControlTemplate is ControlTemplate template)
                {
                    _exampleInAppNotification.Template = template;
                }

                _exampleInAppNotification.Show(GetRandomText(), NotificationDuration);
            });

            SampleController.Current.RegisterNewCommand("Show notification with Visual Studio Code template (info notification)", (sender, args) =>
            {
                _exampleInAppNotification.Dismiss();
                _exampleVSCodeInAppNotification.Show(NotificationDuration);
            });

            SampleController.Current.RegisterNewCommand("Dismiss", (sender, args) =>
            {
                // Dismiss all notifications (should not be replicated in production)
                _exampleInAppNotification.Dismiss();
                _exampleVSCodeInAppNotification.Dismiss();
            });
        }
        public void Show()
        {
            RootGrid.Children.Add(InAppNotification);
            Grid.SetRow(InAppNotification, 1);

            /* Addition: set snackbar width based on screen width */
            var ViewWidth = ApplicationView.GetForCurrentView().VisibleBounds.Width;

            if (ViewWidth <= 640)
            {
                InAppNotification.MinWidth = ViewWidth;
            }
            else if (ViewWidth <= 1080)
            {
                InAppNotification.MinWidth = ViewWidth * (0.75);
            }
            else
            {
                InAppNotification.MinWidth = ViewWidth * (0.50);
            }

            if (!String.IsNullOrWhiteSpace(ButtonLabel) || ButtonAction != null)
            {
                var grid = new Grid();

                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });

                // Text part
                var textBlock = new TextBlock
                {
                    Text = Message,
                    VerticalAlignment = VerticalAlignment.Center,
                    Style             = (Application.Current.Resources["CaptionTextBlockStyle"] as Style),
                    TextWrapping      = TextWrapping.WrapWholeWords
                };
                grid.Children.Add(textBlock);

                // Buttons part
                var stackPanel = new StackPanel
                {
                    Orientation       = Orientation.Horizontal,
                    VerticalAlignment = VerticalAlignment.Center,
                    Padding           = new Thickness(4, 0, 4, 0)
                };

                var actionButton = new Button
                {
                    Content    = ButtonLabel.ToUpper(),
                    FontWeight = Windows.UI.Text.FontWeights.SemiBold,
                    Height     = 30,
                    Background = new SolidColorBrush(Colors.Transparent),
                    Foreground = InAppNotification.BorderBrush,
                    Style      = (Application.Current.Resources["TextButtonStyle"] as Style),
                };
                actionButton.Click += (s, e) => ButtonAction?.Invoke();
                stackPanel.Children.Add(actionButton);

                Grid.SetColumn(stackPanel, 1);
                grid.Children.Add(stackPanel);

                InAppNotification?.Show(grid, Duration);
            }
            else
            {
                InAppNotification?.Show(Message, Duration);
            }
        }
Esempio n. 15
0
 public void Show(string message, TimeSpan timeSpan)
 {
     notification.Show(message, (int)timeSpan.TotalMilliseconds);
 }
 public static void ShowMessage(string message, int duration = 0)
 {
     _inAppNotification.Show(message, duration);
 }