private void Form1_Load(object sender, EventArgs e) { // Set default colors btnForegroundColor.BackColor = Color.Black; btnBackgroundColor.BackColor = Color.White; colorDialogBackground.Color = Color.White; colorDialogForeground.Color = Color.Black; // Set URL links LinkLabel.Link link1 = new LinkLabel.Link(); link1.LinkData = "www.fyghtsoft.com"; llblFyghtSoft1.Text = "FyghtSoft Website"; llblFyghtSoft1.Links.Add(link1); LinkLabel.Link link2 = new LinkLabel.Link(); link2.LinkData = "www.fyghtsoft.com/index.php/resources"; llblSupportA.Text = "Resources and Training"; llblSupportA.Links.Add(link2); LinkLabel.Link link3 = new LinkLabel.Link(); link3.LinkData = "www.fyghtsoft.com/forums/"; llblSupportB.Text = "Community Support Forums"; llblSupportB.Links.Add(link3); // Set default image paths tbxImageOutputPath.Text = outputPathForFinalImage; lblOutputImagePath.Text = outputPathForFinalImage; // Set Dimension Layout Info CurrentDesktopDimensions oCDD = WallpaperManager.GetDesktopDimensions(); lblDesktopDimensions.Text = oCDD.DesktopWidth.ToString() + " x " + oCDD.DesktopHeight.ToString() + " (pixels)"; // Default URLs lblDefaultWSHDataIntegrationURL.Text = oInfaWSHMetaData.strDefaultURL_DataIntegration; lblDefaultWSHMetaDataURL.Text = oInfaWSHMetaData.strDefaultURL_MetaData; // set dropdown defaults ddWallpaperPosition.SelectedIndex = 0; ddFontSize.SelectedIndex = 6; if (File.Exists(outputFullFilePathForConfigXML)) { //MessageBox.Show("Configuration File Exists!"); XmlDocument ConfigXMLDoc = new XmlDocument(); ConfigXMLDoc.Load(outputFullFilePathForConfigXML); InfaBGInfo.Config.ConfigXML oConfig = new InfaBGInfo.Config.ConfigXML(ConfigXMLDoc); PopulateFormWithConfigXMLValues(oConfig); } //else //MessageBox.Show("Configuration File Does Not Exist"); }
public static CurrentDesktopDimensions GetDesktopDimensions() { const int SM_CXSCREEN = 0; const int SM_CYSCREEN = 1; CurrentDesktopDimensions oCDD = new CurrentDesktopDimensions(); oCDD.DesktopHeight = GetSystemMetrics(SM_CYSCREEN); oCDD.DesktopWidth = GetSystemMetrics(SM_CXSCREEN); return(oCDD); }
public void SaveImageToFile(string sImageText, Color backgroundColor , Color foregroundColor, int fontSize, FontStyle fontStyle, string sOutputFile , CurrentDesktopDimensions oCDD, string sLayerOnImageFullFilePath ) { // set some properties Bitmap objBmpImage = null; System.Drawing.Image original = null; if (String.IsNullOrEmpty(sLayerOnImageFullFilePath)) { // Create a background image of size and color basic bkg objBmpImage = new Bitmap(oCDD.DesktopWidth, oCDD.DesktopHeight); // Create a graphics object to measure the text's width and height. Graphics objGraphics = Graphics.FromImage(objBmpImage); // Set Background color objGraphics.Clear(backgroundColor); objGraphics.Flush(); original = objBmpImage; } else { //objBmpImage = new Bitmap(sLayerOnImageFullFilePath); objBmpImage = new Bitmap(Image.FromFile(sLayerOnImageFullFilePath) , oCDD.DesktopWidth , oCDD.DesktopHeight); original = objBmpImage; } // Construct a bitmap from the button image resource // to create the main textToString image Bitmap bmp1 = CreateBitmapImage(sImageText, fontSize , fontStyle, foregroundColor); Graphics gra = null; try { gra = Graphics.FromImage(original); } catch (Exception) { /* * On 2010/07/30 I couldn't figure out how to prevent a bad .GIF file from causing an Exception. * The goal here was to some how convert the image to a renderable format that the text could be * superimposed on. I did not get this working. instead I am posting basic code for a blank * solid background image. */ ////////Bitmap org = (Bitmap)Image.FromFile(sLayerOnImageFullFilePath); ////////Bitmap bm = new Bitmap(org.Width, org.Height); // Can specify optional pixel format but defaults to 32bppArgb ////////gra=Graphics.FromImage(bm); //////////bm.Save(sOutputFile, System.Drawing.Imaging.ImageFormat.Bmp); //////////gra.DrawImage(org,0,0); ////////original = bm; // Create a background image of size and color basic bkg objBmpImage = new Bitmap(oCDD.DesktopWidth, oCDD.DesktopHeight); // Create a graphics object to measure the text's width and height. Graphics objGraphics = Graphics.FromImage(objBmpImage); // Set Background color objGraphics.Clear(backgroundColor); objGraphics.Flush(); // These two objects must availble before proceeding. original = objBmpImage; gra = Graphics.FromImage(original); } Bitmap logo = new Bitmap(bmp1); gra.DrawImage(logo, new Point(5, 5)); original.Save(sOutputFile, System.Drawing.Imaging.ImageFormat.Bmp); // Dispose of the image file. bmp1.Dispose(); gra.Dispose(); }