public string createFullPath(string filename) { string fullPath; if (isUnixFS() || helpers.IsRunningAsUwp()) { fullPath = paths[0] + "/" + filename; } else { fullPath = filename; } return(fullPath); }
private async void exportButton_Click(object sender, EventArgs e) { operationStatusLabel.Text = "Exporting file..."; progressBar.Visible = true; // Simulate a high load process await Task.Delay(5 * 1000); string userPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); string fileName = $"{userPath}\\BoardingPass.txt"; var builder = new StringBuilder(); builder.AppendLine("Boarding pass generated by FlightTracker"); builder.AppendLine("-----------------------------------------"); builder.AppendLine($"Flight code: {codeTextbox.Text}"); builder.AppendLine($"Flight date: {dateTextbox.Text}"); builder.AppendLine($"Departure city: {departureTextbox.Text}"); builder.AppendLine($"Arrival city: {arrivalTextbox.Text}"); builder.AppendLine("-----------------------------------------"); builder.AppendLine("Thank you for using FlightTracker"); File.WriteAllText(fileName, builder.ToString()); progressBar.Visible = false; operationStatusLabel.Visible = false; DesktopBridge.Helpers bridgeHelpers = new DesktopBridge.Helpers(); if (bridgeHelpers.IsRunningAsUwp()) { ShowNotification(); } else { operationStatusLabel.Text = "Export completed"; } }
static void Main(string[] args) { Application.ThreadException += (sender, e) => HandleUnhandledException(e.Exception); try { Trace.Listeners.Add(new CustomTraceListener(Path.Combine(getApplicationDataPath(), logfilename), String.Format("Merge Request Helper Revert MSI Tool {0} started. PID {1}", Application.ProductVersion, Process.GetCurrentProcess().Id))); } catch (ArgumentException) { return; } DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); if (!helpers.IsRunningAsUwp()) { return; } try { revert(); } catch (Exception ex) { HandleUnhandledException(ex); } }
private void MainWindow_Initialized(object sender, EventArgs e) { DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); if (helpers.IsRunningAsUwp()) { this.Title = "ExpenseIt - Desktop Bridge"; } RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\AppConsult\ExpenseIt", true); if (key == null) { key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\AppConsult\ExpenseIt", RegistryKeyPermissionCheck.ReadWriteSubTree); } var count = key.GetValue("LaunchesCount"); if (count != null) { int total = (int)count; key.SetValue("LaunchesCount", total + 1); } else { key.SetValue("LaunchesCount", 1); } // Select the first employee type radio button employeeTypeRadioButtons.SelectedIndex = 0; RefreshEmployeeList(); }
private async void Form1_Load(object sender, EventArgs e) { DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); bool isUwp = helpers.IsRunningAsUwp(); isUwpLabel.Text = isUwp ? "The app is running inside the UWP container" : "The app is running as desktop app"; string triggerName = "TimeZoneTriggerTest"; // Check if the task is already registered foreach (var cur in BackgroundTaskRegistration.AllTasks) { if (cur.Value.Name == triggerName) { // The task is already registered. return; } } BackgroundTaskBuilder builder = new BackgroundTaskBuilder(); builder.Name = triggerName; builder.SetTrigger(new SystemTrigger(SystemTriggerType.TimeZoneChange, false)); builder.TaskEntryPoint = "TileBackgroundTask.TileTask"; builder.Register(); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); bool isUwp = helpers.IsRunningAsUwp(); string text = isUwp ? "The app is running as a Universal Windows Package" : "The app is running as a native Win32 app"; Status.Text = text; }
private void Form1_Load(object sender, EventArgs e) { DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); bool isUwp = helpers.IsRunningAsUwp(); string text = isUwp ? "The app is running inside the UWP container" : "The app is running as a native Win32 app"; txtStatus.Text = text; }
static void Main(string[] args) { DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); bool isUwp = helpers.IsRunningAsUwp(); string text = isUwp ? "The app is running as a Universal Windows Package" : "The app is running as a native Win32 app"; Console.WriteLine(text); Console.ReadLine(); }
static void Main(string[] args) { DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); bool isUwp = helpers.IsRunningAsUwp(); string text = isUwp ? "The app is running inside the UWP container" : "The app is running as a native Win32 app"; Console.WriteLine(text); Console.ReadLine(); }
public ExpenseDetail() { InitializeComponent(); Signature.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen; DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); if (helpers.IsRunningAsUwp()) { MapService.ServiceToken = "IFFAI5SFOtHV9VBKF8Ea~3FS1XamCV2NM0IqlfoQo6A~AguqcUboJvnqWU1H9E-6MVThouJoCrM4wpv_1R_KX_oQLV_e59vyoK42470JvLsU"; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); if (helpers.IsRunningAsUwp()) { string version = $"{Package.Current.Id.Version.Major}.{Package.Current.Id.Version.Minor}.{Package.Current.Id.Version.Build}.{Package.Current.Id.Version.Revision}"; this.Title = $"Real Estate - Version {version}"; } LoadData(); }
public static async Task Initialize(int hostPort) { //MyDocuments这个路径不会虚拟化,方便从Dart端读取 _runningDataFilePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\\{AppName}\\runningData.json"; _userSettingFilePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\{AppName}\\Config\\userSetting.json"; try { //应用程序数据 RunningData = await JsonHelper.JsonDeserializeFromFileAsync <RunningData>(_runningDataFilePath); if (RunningData == null) { //生成默认运行数据 RunningData = new RunningData(); } //更新端口号 RunningData.HostPort = hostPort; await JsonHelper.JsonSerializeAsync(RunningData, _runningDataFilePath); await LoadUserSetting(); //开机启动 DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); if (helpers.IsRunningAsUwp()) { _startupManager = new DesktopBridgeStartupManager(AppName); } else { string path = Assembly.GetEntryAssembly().Location.Replace(".dll", ".exe"); _startupManager = new DesktopStartupHelper(AppName, path); } await ApplySetting(UserSetting); if (RunningData.CurrentWalpapers != null) { foreach (var item in RunningData.CurrentWalpapers) { await WallpaperApi.ShowWallpaper(item.Value, item.Key); } } } catch (Exception ex) { logger.Error($"WallpaperStore constructor Ex:{ex}"); } finally { Initialized = true; } }
public MainWindow() { InitializeComponent(); var helpers = new DesktopBridge.Helpers(); if (helpers.IsRunningAsUwp()) { PackageNameText.Text = Windows.ApplicationModel.Package.Current.DisplayName; } else { PackageNameText.Text = "Not running as UWP package"; } }
public static async void InitlizeSetting() { if (SettingInitialized) { return; } //开机启动 DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); if (helpers.IsRunningAsUwp()) { _startupManager = new DesktopBridgeStartupManager("LiveWallpaper"); } else { //string path = Assembly.GetEntryAssembly().Location.Replace(".dll", ".exe"); _startupManager = new DesktopStartupHelper("LiveWallpaper"); } //配置相关 SettingDefaultFile = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Res\\setting.default.json"); SettingDescFile = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Res\\setting.desc.json"); var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); AppDataDir = $"{appData}\\LiveWallpaper"; SettingPath = $"{AppDataDir}\\Config\\setting.json"; AppDataPath = $"{AppDataDir}\\appData.json"; PurchaseDataPath = $"{AppDataDir}\\purchaseData.json"; await CheckDefaultSetting(); //应用程序数据 AppData = await JsonHelper.JsonDeserializeFromFileAsync <AppData>(AppDataPath); if (AppData == null) { AppData = new AppData(); await ApplyAppDataAsync(); } Setting = await JsonHelper.JsonDeserializeFromFileAsync <SettingObject>(SettingPath); LocalWallpaperDir = Setting.General.WallpaperSaveDir; SettingInitialized = true; }
private void Form1_Load(object sender, EventArgs e) { if (ApplicationData.Current.LocalSettings.Values.ContainsKey("Code")) { codeTextbox.Text = ApplicationData.Current.LocalSettings.Values["Code"].ToString(); } if (ApplicationData.Current.LocalSettings.Values.ContainsKey("Date")) { dateTextbox.Text = ApplicationData.Current.LocalSettings.Values["Date"].ToString(); } if (ApplicationData.Current.LocalSettings.Values.ContainsKey("Departure")) { departureTextbox.Text = ApplicationData.Current.LocalSettings.Values["Departure"].ToString(); } if (ApplicationData.Current.LocalSettings.Values.ContainsKey("Arrival")) { arrivalTextbox.Text = ApplicationData.Current.LocalSettings.Values["Arrival"].ToString(); } DesktopBridge.Helpers bridgeHelpers = new DesktopBridge.Helpers(); if (bridgeHelpers.IsRunningAsUwp()) { updateStripMenuItem.Visible = false; string triggerName = "FlightTimeZoneTrigger"; // Check if the task is already registered foreach (var cur in BackgroundTaskRegistration.AllTasks) { if (cur.Value.Name == triggerName) { // The task is already registered. return; } } BackgroundTaskBuilder builder = new BackgroundTaskBuilder(); builder.Name = triggerName; builder.SetTrigger(new SystemTrigger(SystemTriggerType.TimeZoneChange, false)); builder.TaskEntryPoint = "DesktopBridge.FlightTracker.Notification.ToastTask"; builder.Register(); } }
private void okButton_Click(object sender, RoutedEventArgs e) { if (bridgeHelpers.IsRunningAsUwp()) { string fullName = $"{CurrentEmployee.FirstName} {CurrentEmployee.LastName}"; ShowToastNotification(fullName); UpdateTile(fullName, Report.TotalExpenses); } else { MessageBox.Show( "Expense Report Created!", "ExpenseIt Standalone", MessageBoxButton.OK, MessageBoxImage.Information); DialogResult = true; } }
public void ExploreWallpaper(Wallpaper s) { try { string path = s.AbsolutePath; DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); if (helpers.IsRunningAsUwp()) { //https://stackoverflow.com/questions/48849076/uwp-app-does-not-copy-file-to-appdata-folder path = path.Replace(AppManager.AppDataDir, AppManager.UWPRealAppDataDir); } Process.Start("Explorer.exe", $" /select, {path}"); } catch (Exception ex) { _logger.Error(ex); MessageBox.Show(ex.Message); } }
private void Form1_Load(object sender, EventArgs e) { _regKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\DesktopBridgeWorkshop\Demo", true); if (_regKey == null) { _regKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\DesktopBridgeWorkshop\Demo", RegistryKeyPermissionCheck.ReadWriteSubTree); } codeTextbox.Text = (string)_regKey.GetValue("Code"); dateTextbox.Text = (string)_regKey.GetValue("Date"); departureTextbox.Text = (string)_regKey.GetValue("Departure"); arrivalTextbox.Text = (string)_regKey.GetValue("Arrival"); DesktopBridge.Helpers bridgeHelpers = new DesktopBridge.Helpers(); if (bridgeHelpers.IsRunningAsUwp()) { updateStripMenuItem.Visible = false; } }
public ContextMenuViewModel(EyeNurseService servcies, IWindowManager windowManager, IEventAggregator eventAggregator) { eventAggregator.Subscribe(this); _eventAggregator = eventAggregator; _windowManager = windowManager; Services = servcies; IsVIP = Services.AppData.Purchased; //开机启动 DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); if (helpers.IsRunningAsUwp()) { _startupManager = new DesktopBridgeStartupManager("EyeNurse"); } else { _startupManager = new DesktopStartupHelper("EyeNurse"); } Init(); }
public void OpenConfigFolder() { try { string path = null; DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); if (helpers.IsRunningAsUwp()) { //https://stackoverflow.com/questions/48849076/uwp-app-does-not-copy-file-to-appdata-folder path = Path.Combine(ApplicationData.Current.LocalCacheFolder.Path, "Roaming\\LiveWallpaper"); } else { path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); path = Path.Combine(path, "LiveWallpaper"); } Process.Start(path); } catch (Exception ex) { logger.Warn("OpenConfigFolder:" + ex); } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { txtType.Text = SelectedExpense.Type; txtDescription.Text = SelectedExpense.Description; txtLocation.Text = SelectedExpense.Address; txtAmount.Text = SelectedExpense.Cost.ToString(); Chart.Height = (SelectedExpense.Cost * 400) / 1000; DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); if (helpers.IsRunningAsUwp()) { var result = await MapLocationFinder.FindLocationsAsync(SelectedExpense.Address, null); var location = result.Locations.FirstOrDefault(); if (location != null) { await ExpenseMap.TrySetViewAsync(location.Point, 13); } } else { ExpenseMap.Visibility = System.Windows.Visibility.Collapsed; } }
public static bool IsUwpApp() { var helpers = new DesktopBridge.Helpers(); return(helpers.IsRunningAsUwp()); }
public bool IsRunningAsUwp() { DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); return(helpers.IsRunningAsUwp()); }
public static bool IsRunningInCentennial() { DesktopBridge.Helpers checker = new DesktopBridge.Helpers(); return(checker.IsRunningAsUwp()); }