private void Watcher_Changed(object sender, FileSystemEventArgs e)
 {
     if (ExecutionMode.IsRunningAsUwp())
     {
         if (File.Exists(e.FullPath))
         {
             var xml = "<toast><visual><binding template='ToastGeneric'><image src='" + e.FullPath + "'/><text hint-maxLines='1'>Microsoft.Knowzy.WPF received a new image</text></binding></visual></toast>";
             Toast.CreateToast(xml);
         }
     }
 }
 public async void Handle(OpenLoginMessage message)
 {
     if (ExecutionMode.IsRunningAsUwp())
     {
         await WindowsHello.Login();
     }
     else
     {
         _windowManager.ShowDialog(_loginViewModel);
     }
 }
        public Product[] GetData()
        {
            String jsonFilePath;

            if (ExecutionMode.IsRunningAsUwp())
            {
                jsonFilePath = Path.Combine(AppFolders.Current, "desktop", _configuration.Configuration.JsonFilePath);
            }
            else
            {
                jsonFilePath = _configuration.Configuration.JsonFilePath;
            }

            return(_jsonHelper.Deserialize <Product[]>(_fileHelper.ReadTextFile(jsonFilePath)));
        }
示例#4
0
        private async void Menu_Click(object sender, EventArgs e)
        {
            if (ExecutionMode.IsRunningAsUwp())
            {
                if (_appService == null)
                {
                    // start the app service
                    _appService = new AppService();
                    var result = await _appService.StartAppServiceConnection("com.microsoft.knowzy.appservice.test");
                }

                // start the XAML UI that will communicate with the App Service
                Uri uri = new Uri("com.microsoft.knowzy.protocol.test://" + "message?appserviceid=" + "com.microsoft.knowzy.appservice.test");
                await UriProtocol.SendUri(uri);
            }
        }
 public MainView()
 {
     InitializeComponent();
     if (ExecutionMode.IsRunningAsUwp())
     {
         try
         {
             // get the path to the App folder (WPF or UWP).
             var path = AppFolders.Local;
             FileSystemWatcher watcher = new FileSystemWatcher(path);
             watcher.EnableRaisingEvents = true;
             watcher.Changed            += Watcher_Changed;
         }
         catch (Exception ex)
         {
             Debug.WriteLine("FileSystemWatcher Error:" + ex.Message);
         }
     }
 }