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 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"; } }
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 static void onLaunchMainInstace(LaunchOptions options) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); cleanUpOldFiles(); bool runningAsUwp = new DesktopBridge.Helpers().IsRunningAsUwp(); Trace.TraceInformation(String.Format("[MainForm] Running as UWP = {0}", runningAsUwp ? "Yes" : "No")); if (runningAsUwp) { revertOldInstallations(); } string path = runningAsUwp ? Constants.UWP_Launcher_Name : Process.GetCurrentProcess().MainModule.FileName; if (!prepareGitEnvironment() || !integrateInDiffTool(path)) { return; } integrateInGitUI(); Version currentVersion = Environment.OSVersion.Version; Trace.TraceInformation(String.Format("OS Version is {0}", currentVersion.ToString())); LaunchOptions.NormalModeOptions normalOptions = options.SpecialOptions as LaunchOptions.NormalModeOptions; Application.Run(new MainForm(normalOptions.StartMinimized, runningAsUwp, normalOptions.StartUrl)); }
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; }
public UFS() { paths = new string[3]; paths[0] = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); paths[1] = Directory.GetCurrentDirectory(); paths[2] = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "/../DoomBFA"; helpers = new DesktopBridge.Helpers(); }
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; }
static Stream GetTermsAndConditions() { string @namespace = typeof(LicenseTermsAcceptance).Namespace !; string resourceName = new DesktopBridge.Helpers().IsRunningAsUwp() ? "StoreTerms" : "Terms"; resourceName = $"{@namespace}.{resourceName}.html"; return(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName) !); }
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(); }
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 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"; } }
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(); } }
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; } }
static Utilities() { var tempFolderPath = Environment.GetEnvironmentVariable("temp"); if (tempFolderPath != null) { DirectoryInfo tempFolderInfo = new DirectoryInfo(tempFolderPath); DirectoryInfo currentDirectoryInfo = new DirectoryInfo(Directory.GetCurrentDirectory()); IsPortable = currentDirectoryInfo.FullName.StartsWith(tempFolderInfo.FullName, StringComparison.OrdinalIgnoreCase); } IsRunningAsAppx = new DesktopBridge.Helpers().IsRunningAsUwp(); string settingsDirectorySetting = ConfigurationManager.AppSettings["SettingsDirectory"]; if (settingsDirectorySetting != null) { settingsDirectory = Path.GetFullPath(settingsDirectorySetting); } }
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(); }
private static void onLaunchMainInstance(LaunchOptions options) { cleanUpOldFiles(); if (ApplicationUpdateHelper.ShowCheckForUpdatesDialog()) { Trace.TraceInformation("Application is exiting to install a new version"); return; } bool runningAsUwp = new DesktopBridge.Helpers().IsRunningAsUwp(); Trace.TraceInformation(String.Format("Running as UWP = {0}", runningAsUwp ? "Yes" : "No")); if (runningAsUwp) { revertOldInstallations(); } string path = runningAsUwp ? Constants.UWP_Launcher_Name : Process.GetCurrentProcess().MainModule.FileName; if (!prepareGitEnvironment() || !integrateInDiffTool(path)) { return; } bool integratedInGitExtensions = integrateInGitExtensions(); bool integratedInSourceTree = integrateInSourceTree(); Version osVersion = Environment.OSVersion.Version; Trace.TraceInformation(String.Format("OS version is {0}", osVersion.ToString())); Version clrVersion = Environment.Version; Trace.TraceInformation(String.Format("CLR version is {0}", clrVersion.ToString())); Trace.TraceInformation(String.Format(".NET Framework version is {0}", typeof(string).Assembly.ImageRuntimeVersion)); LaunchOptions.NormalModeOptions normalOptions = options.SpecialOptions as LaunchOptions.NormalModeOptions; Application.Run(new MainForm(normalOptions.StartMinimized, runningAsUwp, normalOptions.StartUrl, integratedInGitExtensions, integratedInSourceTree)); }
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 IsRunningInCentennial() { DesktopBridge.Helpers checker = new DesktopBridge.Helpers(); return(checker.IsRunningAsUwp()); }
public bool IsRunningAsUwp() { DesktopBridge.Helpers helpers = new DesktopBridge.Helpers(); return(helpers.IsRunningAsUwp()); }
public static bool IsUwpApp() { var helpers = new DesktopBridge.Helpers(); return(helpers.IsRunningAsUwp()); }
/// <summary> /// Creates device-based resources to store a constant buffer, cube /// geometry, and vertex and pixel shaders. In some cases this will also /// store a geometry shader. /// </summary> public async void CreateDeviceDependentResourcesAsync() { ReleaseDeviceDependentResources(); usingVprtShaders = deviceResources.D3DDeviceSupportsVprt; var folder = new DesktopBridge.Helpers().IsRunningAsUwp() ? Windows.ApplicationModel.Package.Current.InstalledLocation : await StorageFolder.GetFolderFromPathAsync(Environment.CurrentDirectory); // On devices that do support the D3D11_FEATURE_D3D11_OPTIONS3:: // VPAndRTArrayIndexFromAnyShaderFeedingRasterizer optional feature // we can avoid using a pass-through geometry shader to set the render // target array index, thus avoiding any overhead that would be // incurred by setting the geometry shader stage. var vertexShaderFileName = usingVprtShaders ? "Content\\Shaders\\VPRTVertexShader.cso" : "Content\\Shaders\\VertexShader.cso"; // Load the compiled vertex shader. var vertexShaderByteCode = await DirectXHelper.ReadDataAsync(await folder.GetFileAsync(vertexShaderFileName)); // After the vertex shader file is loaded, create the shader and input layout. vertexShader = this.ToDispose(new SharpDX.Direct3D11.VertexShader( deviceResources.D3DDevice, vertexShaderByteCode)); SharpDX.Direct3D11.InputElement[] vertexDesc = { new SharpDX.Direct3D11.InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32_Float, 0, 0, SharpDX.Direct3D11.InputClassification.PerVertexData, 0), new SharpDX.Direct3D11.InputElement("COLOR", 0, SharpDX.DXGI.Format.R32G32B32_Float, 12, 0, SharpDX.Direct3D11.InputClassification.PerVertexData, 0), }; inputLayout = this.ToDispose(new SharpDX.Direct3D11.InputLayout( deviceResources.D3DDevice, vertexShaderByteCode, vertexDesc)); if (!usingVprtShaders) { // Load the compiled pass-through geometry shader. var geometryShaderByteCode = await DirectXHelper.ReadDataAsync(await folder.GetFileAsync("Content\\Shaders\\GeometryShader.cso")); // After the pass-through geometry shader file is loaded, create the shader. geometryShader = this.ToDispose(new SharpDX.Direct3D11.GeometryShader( deviceResources.D3DDevice, geometryShaderByteCode)); } // Load the compiled pixel shader. var pixelShaderByteCode = await DirectXHelper.ReadDataAsync(await folder.GetFileAsync("Content\\Shaders\\PixelShader.cso")); // After the pixel shader file is loaded, create the shader. pixelShader = this.ToDispose(new SharpDX.Direct3D11.PixelShader( deviceResources.D3DDevice, pixelShaderByteCode)); // Load mesh vertices. Each vertex has a position and a color. // Note that the cube size has changed from the default DirectX app // template. Windows Holographic is scaled in meters, so to draw the // cube at a comfortable size we made the cube width 0.2 m (20 cm). VertexPositionColor[] cubeVertices = { new VertexPositionColor(new Vector3(-0.1f, -0.1f, -0.1f), new Vector3(0.0f, 0.0f, 0.0f)), new VertexPositionColor(new Vector3(-0.1f, -0.1f, 0.1f), new Vector3(0.0f, 0.0f, 1.0f)), new VertexPositionColor(new Vector3(-0.1f, 0.1f, -0.1f), new Vector3(0.0f, 1.0f, 0.0f)), new VertexPositionColor(new Vector3(-0.1f, 0.1f, 0.1f), new Vector3(0.0f, 1.0f, 1.0f)), new VertexPositionColor(new Vector3(0.1f, -0.1f, -0.1f), new Vector3(1.0f, 0.0f, 0.0f)), new VertexPositionColor(new Vector3(0.1f, -0.1f, 0.1f), new Vector3(1.0f, 0.0f, 1.0f)), new VertexPositionColor(new Vector3(0.1f, 0.1f, -0.1f), new Vector3(1.0f, 1.0f, 0.0f)), new VertexPositionColor(new Vector3(0.1f, 0.1f, 0.1f), new Vector3(1.0f, 1.0f, 1.0f)), }; vertexBuffer = this.ToDispose(SharpDX.Direct3D11.Buffer.Create( deviceResources.D3DDevice, SharpDX.Direct3D11.BindFlags.VertexBuffer, cubeVertices)); // Load mesh indices. Each trio of indices represents // a triangle to be rendered on the screen. // For example: 0,2,1 means that the vertices with indexes // 0, 2 and 1 from the vertex buffer compose the // first triangle of this mesh. ushort[] cubeIndices = { 2, 1, 0, // -x 2, 3, 1, 6, 4, 5, // +x 6, 5, 7, 0, 1, 5, // -y 0, 5, 4, 2, 6, 7, // +y 2, 7, 3, 0, 4, 6, // -z 0, 6, 2, 1, 3, 7, // +z 1, 7, 5, }; indexCount = cubeIndices.Length; indexBuffer = this.ToDispose(SharpDX.Direct3D11.Buffer.Create( deviceResources.D3DDevice, SharpDX.Direct3D11.BindFlags.IndexBuffer, cubeIndices)); // Create a constant buffer to store the model matrix. modelConstantBuffer = this.ToDispose(SharpDX.Direct3D11.Buffer.Create( deviceResources.D3DDevice, SharpDX.Direct3D11.BindFlags.ConstantBuffer, ref modelConstantBufferData)); // Once the cube is loaded, the object is ready to be rendered. loadingComplete = true; }
public CreateExpenseReportDialogBox() { InitializeComponent(); dbService = new DatabaseService(); bridgeHelpers = new DesktopBridge.Helpers(); }