private bool swapDesktopWallpaper() { // StringBuilder sb = new StringBuilder(); // textToImage oTextToImage = new textToImage(); try { // Attempt to connect to WSH InfaWSHMetaDataInfo oGo = null; try { oGo = new InfaWSHMetaDataInfo(tbxWSHServerName.Text, (int)tbxWSHServerPort.Value , "", tbxDomainName.Text, tbxRepName.Text, tbxRepUserName.Text, tbxRepPassword.Text , tbxDomainName.Text, ""); } catch (Exception ex) { isInfaWSHServerHavingIssue = true; MessageBox.Show("InfaBGInfo Process Failure or Server Connectivity Issue:\n" + ex.Message.ToString() + "\n\n" + "Please correct the issue with the Informatica Server." + "\n\n" + "You may need to close and re-open the application in order to attempt to re-connect." ); return(false); } // provide options as a struct and passed to wallpaper settings ShowOutputInfoOptions oBkgOptions = new ShowOutputInfoOptions(); oBkgOptions.showWSHRepositoriesAvailable = cbxShowAvailableWSHReps.Checked; oBkgOptions.showAllRepositoryFolders = cbxShowAllRepFolders.Checked; oBkgOptions.showGlobalRepositoryWorkflowInfo = cbxShowGlobalRepWorkflows.Checked; oBkgOptions.showRepositoryAssociatedIntSvc = cbxShowAssociatedIntSvc.Checked; oBkgOptions.showOSInformation = cbxShowSystemInfoBlock.Checked; //...testing... //sb.AppendLine("Last Refresh: " + DateTime.Now.ToLongTimeString()); // Add compiles values to the output sb.Append(oGo.GatherStringDataValues(oBkgOptions).ToString()); if (oBkgOptions.showOSInformation) { WindowsSystemInfo oWSI = new WindowsSystemInfo(); sb.Append(oWSI.GetSystemInfoString()); } string tmpOutput = sb.ToString(); // Build Image with Critical Text Values oTextToImage.SaveImageToFile(tmpOutput , colorDialogBackground.Color, colorDialogForeground.Color , int.Parse(ddFontSize.SelectedItem.ToString()) , FontStyle.Regular , outputFullFilePathForFinalImage , WallpaperManager.GetDesktopDimensions() , tbxOutputExistingImage.Text); oTextToImage = null; tmpOutput = ""; sb.Length = 0; //Main Task to Swap wallpaper WallpaperManager.SetWallpaper(outputFullFilePathForFinalImage , (Wallpaper.Style)ddWallpaperPosition.SelectedIndex); return(true); } catch (Exception ex) { MessageBox.Show("Process Failure:\n" + ex.Message.ToString()); return(false); } }
private bool RefreshWallpaperOnTimer() { if (File.Exists(outputFullFilePathForConfigXML) && isAutoRefreshEnabled) { XmlDocument ConfigXMLDoc = new XmlDocument(); ConfigXMLDoc.Load(outputFullFilePathForConfigXML); InfaBGInfo.Config.ConfigXML oConfig = new InfaBGInfo.Config.ConfigXML(ConfigXMLDoc); // StringBuilder sb = new StringBuilder(); // textToImage oTextToImage = new textToImage(); try { InfaWSHMetaDataInfo oGo = null; try { // Attempt to connect to WSH if (!isInfaWSHServerHavingIssue) { oGo = new InfaWSHMetaDataInfo(oConfig.WSHServerName, (int)oConfig.WSHServerPort , "", oConfig.DomainName, oConfig.RepositoryName, oConfig.RepositoryUsername, oConfig.RepositoryPassword , oConfig.DomainName, ""); } } catch (Exception ex) { isInfaWSHServerHavingIssue = true; MessageBox.Show("InfaBGInfo Process Failure or Server Connectivity Issue:\n" + ex.Message.ToString() + "\n\n" + "Please correct the issue with the Informatica Server." + "\n\n" + "You must close and re-open the application in order to attempt to re-connect." + "\n\n" + "Timer Enabled: True" ); return(false); } // provide options as a struct and passed to wallpaper settings ShowOutputInfoOptions oBkgOptions = new ShowOutputInfoOptions(); oBkgOptions.showWSHRepositoriesAvailable = oConfig.ShowAvailableWSHRepositories; oBkgOptions.showAllRepositoryFolders = oConfig.ShowAllRepositoryFolders; oBkgOptions.showGlobalRepositoryWorkflowInfo = oConfig.ShowGlobalRepositoryWorkflows; oBkgOptions.showRepositoryAssociatedIntSvc = oConfig.ShowAssociatedIntegrationServices; oBkgOptions.showOSInformation = oConfig.ShowSystemInformationBlock; //...testing.. sb.AppendLine("Last Refresh: " + DateTime.Now.ToLongTimeString()); // Add compiles values to the output sb.Append(oGo.GatherStringDataValues(oBkgOptions).ToString()); if (oBkgOptions.showOSInformation) { WindowsSystemInfo oWSI = new WindowsSystemInfo(); sb.Append(oWSI.GetSystemInfoString()); } string tmpOutput = sb.ToString(); // Build Image with Critical Text Values oTextToImage.SaveImageToFile(tmpOutput , oConfig.BkgColor, oConfig.ForegroundColor , oConfig.FontSize , FontStyle.Regular , outputFullFilePathForFinalImage , WallpaperManager.GetDesktopDimensions() , oConfig.LayerOnImage); oTextToImage = null; tmpOutput = ""; sb.Length = 0; //Main Task to Swap wallpaper WallpaperManager.SetWallpaper(outputFullFilePathForFinalImage , (Wallpaper.Style)oConfig.BkgPosition); } catch (Exception ex) { MessageBox.Show("Process Failure (Refresh Enabled):\n" + ex.Message.ToString()); } } else { return(false); } return(true); }