当前位置: 首页>>代码示例>>C#>>正文


C# PictureBox.Load方法代码示例

本文整理汇总了C#中System.Windows.Forms.PictureBox.Load方法的典型用法代码示例。如果您正苦于以下问题:C# PictureBox.Load方法的具体用法?C# PictureBox.Load怎么用?C# PictureBox.Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.PictureBox的用法示例。


在下文中一共展示了PictureBox.Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SingleImageToShow

 public void SingleImageToShow(string i_ImageURL)
 {
     PictureBox singleImageBox = new PictureBox();
     singleImageBox.Load(i_ImageURL);
     singleImageBox.SizeMode = PictureBoxSizeMode.AutoSize;
     imagesFlowLayoutPanel.Controls.Add(singleImageBox);
 }
开发者ID:OrSi333,项目名称:FacebookApp,代码行数:7,代码来源:ImagesForm.Designer.cs

示例2: executeEasterEgg

 public void executeEasterEgg()
 {
     try
     {
         f = new Form();
         Random numGenerator = new Random();
         int randomPicker = numGenerator.Next(0, secretEasterEggs.Length);
         String url = secretEasterEggs[randomPicker];
         f.Width = 245;
         f.Location = this.Location;
         f.Height = 245;
         PictureBox picture = new PictureBox();
         picture.Width = 245;
         picture.Height = 245;
         picture.Load(url);
         f.Controls.Add(picture);
         f.Visible = true;
         f.Show();
         f.Text = "Sending in Progress....";
     }
     catch (Exception ex)
     {
         Console.Write("W11.001.01 Failed loading Easteregg, Exception[" + ex + "]");
     }
 }
开发者ID:fierc3,项目名称:SysLogViewer,代码行数:25,代码来源:MailForm.cs

示例3: ChangeColor

        /// <summary>
        /// Changes the color of an LED PictureBox.
        /// </summary>
        /// <param name="ledPictureBox">WinFom LED PictureBox to change.</param>
        /// <param name="ledColor">Color to set LED to.</param>
        internal static void ChangeColor(PictureBox ledPictureBox, LEDColors ledColor)
        {
            string resourceUrl = string.Empty;

            //Parameter Validations.
            if (ledPictureBox == null)
                throw new ArgumentNullException("PictureBox ledPictureBox");

            //Switch on the color and update the image.
            switch(ledColor)
            {
                case LEDColors.Green: resourceUrl = @"..\..\Resources\GreenLED_25x25.png"; break;
                case LEDColors.Yellow: resourceUrl = @"..\..\Resources\YellowLED_25x25.png"; break;
                case LEDColors.Red: resourceUrl = @"..\..\Resources\RedLED_25x25.png"; break;

                default:
                    throw new ArgumentOutOfRangeException("LEDColors ledColor",
                                                          string.Format("Unsupported Color. Color: {0}",
                                                                        ledColor.ToString()));
            }

            //Attempt to load it.
            Debug.Assert(string.IsNullOrEmpty(resourceUrl) == false);

            ledPictureBox.Load(resourceUrl);
        }
开发者ID:ChristopherJCavage,项目名称:MooseBox,代码行数:31,代码来源:LEDHelper.cs

示例4: AddTiles

        public void AddTiles(string folderName)
        {   // add tiles to tile library
            ArrayList tilesArrayList = new ArrayList();

            Cursor.Current = Cursors.WaitCursor;

            if (!Directory.Exists(folderName))
                throw new DirectoryNotFoundException();

            foreach (string f in Directory.GetFiles(folderName))
            {   // load tiles
                if (Path.GetExtension(f) == ".bmp" ||
                    Path.GetExtension(f) == ".png" ||
                    Path.GetExtension(f) == ".jpg" ||
                    Path.GetExtension(f) == ".jpeg")
                    tilesArrayList.Add(f.ToString());
            }

            // delete all controls
            pnlTileLibrary.Controls.Clear();
            pnlTileLibrary.Refresh();

            int t = 0;

            // resize _tile_library
            if (tile_library != null && tile_library.Length > 0)
            {   // add to the library
                t = tile_library.Length;
                Array.Resize(ref tile_library, tilesArrayList.Count + tile_library.Length);
            }
            else
            {   // load new library
                Array.Resize(ref tile_library, tilesArrayList.Count);
            }

            foreach (string i in tilesArrayList)
            {   // update tiles library
                Model.Tile newTile = new Model.Tile();
                PictureBox pB = new PictureBox();
                pB.Left = 20;
                pB.Top = (t * (tile_height + 5)) + 20;
                pB.Width = tile_width;
                pB.Height = tile_height;
                pB.Name = t.ToString();
                pB.Load(i);
                newTile.TileID = t;
                newTile.TileName = t.ToString();
                newTile.TilePictureBox = pB;
                tile_library[t] = newTile;
                pB.MouseClick += new MouseEventHandler(tilePicBox_MouseClick);

                t++;
            }

            RenderTiles();

            Cursor.Current = Cursors.Default;
        }
开发者ID:amrufathy,项目名称:EscapeRunner,代码行数:58,代码来源:TilesController.cs

示例5: SongAlert

        public SongAlert(string song, string artist, string album, string url)
        {
            BackColor = Color.FromArgb(240, 240, 240);
            FormBorderStyle = FormBorderStyle.None;
            Size = new Size(390, 70);
            Opacity = 0;
            ShowInTaskbar = false;
            Load += new EventHandler(Alert_Loaded);

            PictureBox albumArt = new PictureBox();
            albumArt.Load(url);
            albumArt.Size = new Size(70, 70);
            albumArt.SizeMode = PictureBoxSizeMode.StretchImage;
            Controls.Add(albumArt);

            int n = 15;
            Font titleFont = new Font("Calibri", n, FontStyle.Regular);
            while (TextRenderer.MeasureText(song, titleFont).Width > 312)
            {
                if (n < 6)
                {
                    break;
                }
                titleFont = new Font("Calibri", n--, FontStyle.Regular);
            }

            Label songTitle = makeLabel(song);
            songTitle.Location = new Point(78, 8);
            songTitle.Font = titleFont;
            Controls.Add(songTitle);

            if (n > 12)
            {
                n = 12;
            }
            Font infoFont = new Font("Calibri", n, FontStyle.Regular);
            while (TextRenderer.MeasureText(artist + " - " + album, infoFont).Width > 312 * 2)
            {
                if (n < 6)
                {
                    break;
                }
                infoFont = new Font("Calibri", n--, FontStyle.Regular);
            }

            Label songInfo = makeLabel(artist + " - " + album);
            songInfo.Location = new Point(78, 32);
            if (TextRenderer.MeasureText(artist + " - " + album, infoFont).Width <= 312)
            {
                songInfo.Location = new Point(78, 38);
            }
            songInfo.AutoSize = false;
            songInfo.Size = new Size(312, 40);
            songInfo.Font = infoFont;
            Controls.Add(songInfo);
        }
开发者ID:hexlator,项目名称:Google-Play-Music-Desktop-Player-UNOFFICIAL-,代码行数:56,代码来源:SongAlert.cs

示例6: ImageBox

 private void ImageBox(string img, PictureBox pic)
 {
     try
     {
         pic.Load(img);
     }
     catch (Exception ex)
     {
           MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
开发者ID:xuzhisme,项目名称:test,代码行数:11,代码来源:FormMain.cs

示例7: LoadPicture

 private void LoadPicture(PictureBox pictureBox, string fileName)
 {
     try
     {
         pictureBox.Load(fileName);
     }
     catch (ArgumentException)
     {
         pictureBox.Image = null;
     }
 }
开发者ID:Wholing,项目名称:PictureScanner,代码行数:11,代码来源:Form1.cs

示例8: Show

 public static void Show(PictureBox pictureBox1, Label label2, Label label3, Label numberLabel,Label label5)
 {
     if(CurrentWord == null)
     {
         throw new Exception("未设置CurrentWord");
     }
     else
     {
         pictureBox1.Load(CurrentWord.MySub[CurrentSub].SubImg);
         label2.Text = CurrentWord.MySub[CurrentSub].SubEN;
         label3.Text = CurrentWord.MySub[CurrentSub].SubCN;
         label5.Text = "——" + currentWord.MySub[CurrentSub].FilmName;
         numberLabel.Text = (CurrentSub + 1) + "/" + TotalSub;
     }
 }
开发者ID:Flylively,项目名称:rrcd2anki,代码行数:15,代码来源:SubShow.cs

示例9: Form3_Load

        private void Form3_Load(object sender, EventArgs e)
        {
            Salis airija = new Salis();
            airija.pavadinimas = "Airija";
            airija.paveiksliukas = "EuroposVeliavos/Airija.png";
            salys.Add(airija);

            Salis albanija = new Salis();
            albanija.pavadinimas = "Albanija";
            albanija.paveiksliukas = "EuroposVeliavos/Albanija.png";
            salys.Add(albanija);

            Salis andora = new Salis();
            andora.pavadinimas = "Andora";
            andora.paveiksliukas = "EuroposVeliavos/Andora.png";
            salys.Add(andora);

            Salis austrija = new Salis();
            austrija.pavadinimas = "Austrija";
            austrija.paveiksliukas = "EuroposVeliavos/Austrija.png";
            salys.Add(austrija);

            Salis baltarusija = new Salis();
            baltarusija.pavadinimas = "Baltarusija";
            baltarusija.paveiksliukas = "EuroposVeliavos/Baltarusija.png";
            salys.Add(baltarusija);


            for (int i = 0;  i < salys.Count(); i++)
            {
                PictureBox pic = new PictureBox();
              
                pic.Top = 10;
                pic.Left = 10 + 110 * i;
                this.Controls.Add(pic);
                pic.Load(salys[i].paveiksliukas);
                pic.SizeMode = PictureBoxSizeMode.StretchImage;
                if (pic.Left > 400)
                {
                    pic.Left = 0;
                    pic.Left = pic.Left + 10;
                    pic.Top = pic.Top + 60;
                }
              
            }

            
        }
开发者ID:Pkulyte,项目名称:veliavos,代码行数:48,代码来源:Form3.cs

示例10: LoadImage

 public System.Drawing.Image LoadImage(PictureBox pictureBox, System.Drawing.Bitmap map)
 {
     OpenFileDialog op = new OpenFileDialog();
     DialogResult dr = op.ShowDialog();
     if (dr == DialogResult.OK)
     {
         string path = op.FileName;
         pictureBox.Load(path);
         Bitmap temp = new Bitmap(pictureBox.Image);
         pictureBox.Image = temp;
         pictureBox.Size = pictureBox.Image.Size;
         map = new Bitmap(pictureBox.Image);
         return pictureBox.Image;
     }
     return null;
 }
开发者ID:StefanEggenschwiler,项目名称:625-1_TDD_Project,代码行数:16,代码来源:FileAccessHandler.cs

示例11: AsyncCoverLoad

        public static void AsyncCoverLoad(string ArtistName, CaptainHook WebHook, DrunkenXMLSailor XMLSailor, PictureBox PBOX_Cover)
        {
            /*LASTFM API*/
            string GETReq = @"http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&artist=$artist&api_key=d1146fc51bcc3bec1d3fb356398d7362";

            GETReq = GETReq.Replace("$artist", WebUtility.UrlEncode(ArtistName));
            WebHook.HookRequest(GETReq, "GET");
            XMLSailor = new DrunkenXMLSailor(WebHook.HookResponse());

            /*Load cover image*/
            try
            {
                if (XMLSailor.CanNavigate())
                {
                    string imgUrl = XMLSailor.SailorNavigate_GetArtistImageBig();
                    if (!String.IsNullOrEmpty(imgUrl) && imgUrl != String.Empty)
                    {
                        try
                        {
                            PBOX_Cover.BackgroundImage = null;
                            PBOX_Cover.InitialImage = null;
                            PBOX_Cover.Image = null;
                            
                            PBOX_Cover.Load(imgUrl);
                        }
                        catch (ExternalException e)
                        {
                            return;
                        }

                    }

                    else
                    {
                        PBOX_Cover.Image = Image.FromFile("assets/pelvisLogo110.png");
                    }
                }

            }
            catch (ExternalException e)
            {
                return;
            }

        }
开发者ID:Civile,项目名称:PelvisRecorder,代码行数:45,代码来源:LASTFMService.cs

示例12: DrawImageList

        private void DrawImageList(IEnumerable<SpotlightImage> spotlightImages)
        {
            var imageNumber = 0;

            foreach (var spotlightImage in spotlightImages)
            {
                var imageBox = new PictureBox();
                imageBox.Width = MaximumImageWidth;
                imageBox.Height = MaximumImageHeight;
                imageBox.Load(spotlightImage.FullPath);
                imageBox.SizeMode = PictureBoxSizeMode.StretchImage;
                imageBox.Parent = pnImageContainer;
                imageBox.Top = 8;
                imageBox.Left = 8 + ((MaximumImageWidth + ImageSpacing)  * imageNumber);
                imageBox.DoubleClick += ImageBox_DoubleClick;
                imageBox.MouseDown += ImageBox_MouseDown;
                imageBox.ContextMenu = null;

                imageNumber++;
            }
        }
开发者ID:GeekInTheNorth,项目名称:SpotlightLockScreenSaver,代码行数:21,代码来源:ImageList.cs

示例13: ImageDetailForm

        //Overloaded Constructor taking the full image URL as input
        public ImageDetailForm(string fullImageURL)
        {
            InitializeComponent();

            try {
                //Create a new PictureBox
                PictureBox pb = new PictureBox();

                //Load the image
                pb.Load(fullImageURL);

                //Set several other attributes
                pb.Left = 30;
                pb.Top = 30;
                pb.Width = this.Width - 75;
                pb.Height = this.Height - 95;
                pb.Visible = true;
                pb.BorderStyle = BorderStyle.FixedSingle;
                pb.SizeMode = PictureBoxSizeMode.StretchImage;

                //Add the PictureBox to the Form's controls
                this.Controls.Add(pb);
            }

            catch(ArgumentException)
            {
                //Close the window and release the associated resources
                this.Close();
                this.Dispose();
            }

            catch (WebException)
            {
                //Close the window and release the associated resources
                this.Close();
                this.Dispose();
            }
        }
开发者ID:matt90github,项目名称:AutoImageAnnotation,代码行数:39,代码来源:ImageDetailForm.cs

示例14: GenerateSummary

        private void GenerateSummary(DataTable csvData, bool LoadFromURL)
        {
            int[] lst = { 250, 251, 252,253, 255, 254 };
            DataTable dt = new DataTable();
            dt.Clear();
            dt.Columns.Add("Image Name");
            dt.Columns.Add("Image Width");
            dt.Columns.Add("Image Height");
            dt.Columns.Add("Image Size");
            dt.Columns.Add("Image White Pix");
            dt.Columns.Add("Image NonWhite Pix");
            dt.Columns.Add("Product Coverage %");
            dt.Columns.Add("Status");

            for (int iCounter = 0; iCounter < csvData.Rows.Count; iCounter++)
            {
                _WhitePix = 0;
                _NonWhitePix = 0;
                string remoteFileName = csvData.Rows[iCounter][0].ToString();
                string[] parts = remoteFileName.Split('/');
                string localFileName = parts.Length > 0 ? parts[parts.Length - 1] : remoteFileName;
                lblFileUploadStatus.Text = "Processing File: " + (LoadFromURL ? localFileName : _imageName) + "(Started)";

                PictureBox pictureBox = new PictureBox();
                pictureBox.Load(LoadFromURL ? remoteFileName : _imagePath);

                WebClient webClient = new WebClient();
                string localImagePath = LoadFromURL ? Environment.CurrentDirectory + @"\" + localFileName : _imagePath;
                if (LoadFromURL)
                {
                    webClient.DownloadFile(remoteFileName, localFileName);
                }

                Bitmap img = new Bitmap(localFileName);
                Refresh();
                FileInfo file = new System.IO.FileInfo(localImagePath);

                for (int j = 0; j < img.Width; j++)
                {
                    for (int i = 0; i < img.Height; i++)
                    {
                        //if ((255 == img.GetPixel(j, i).R) && (255 == img.GetPixel(j, i).G) && (255 == img.GetPixel(j, i).B))
                        if ((lst.Contains(img.GetPixel(j, i).R)) && (lst.Contains(img.GetPixel(j, i).G)) && (lst.Contains(img.GetPixel(j, i).B)))
                        {
                            _WhitePix++;
                        }
                        else
                        {
                            _NonWhitePix++;
                        }
                    }
                    lblFileUploadStatus.Refresh();
                    lblFileUploadStatus.Text = "Processing File: " + (iCounter + 1) + @"/" + csvData.Rows.Count + " " + localFileName
                        + " " + Math.Round(((j) / (double)(img.Width) * 100), 2) + "%";
                }

                lblFileUploadStatus.Text = "Processing File: " + localFileName + "(Done)";
                _imageName = localFileName;
                _imageHeight = img.Height;
                _imageWidth = img.Width;
                _imageSize = Math.Round(file.Length / 1024.0 / 1024.0, 2) + "MB";
                img.Dispose();

                decimal productCoveragePercent = (Math.Round((decimal)_NonWhitePix / (_WhitePix + _NonWhitePix) * 100, 2));

                object[] o = { localFileName, _imageWidth, _imageHeight, _imageSize, _WhitePix, _NonWhitePix, productCoveragePercent + "%", Convert.ToInt32(productCoveragePercent) > 60 ? "Success" : "Failed" };
                dt.Rows.Add(o);
                Update_GridView(dt);
                if(LoadFromURL)
                File.Delete(file.FullName);
            }
        }
开发者ID:virendra-velingkar,项目名称:imagevalidation,代码行数:72,代码来源:frmImageProcessing.cs

示例15: ImageLocation_Async

		public void ImageLocation_Async ()
		{
			Form f = new Form ();
			PictureBox pb = new PictureBox ();
			f.Controls.Add (pb);
			f.Show ();

			Assert.IsNull (pb.ImageLocation, "#A");

			pb.ImageLocation = "M.gif";
			Application.DoEvents ();

			Assert.AreEqual ("M.gif", pb.ImageLocation, "#B1");
			Assert.AreSame (pb.InitialImage, pb.Image, "#B2");

			using (Stream s = this.GetType ().Assembly.GetManifestResourceStream ("32x32.ico")) {
				pb.Image = Image.FromStream (s);
			}
			Application.DoEvents ();

			Assert.AreEqual ("M.gif", pb.ImageLocation, "#C1");
			Assert.IsNotNull (pb.Image, "#C2");
			Assert.AreEqual (60, pb.Image.Height, "#C3");
			Assert.AreEqual (150, pb.Image.Width, "#C4");

			pb.ImageLocation = null;
			Application.DoEvents ();

			Assert.IsNull (pb.ImageLocation, "#D1");
			Assert.IsNull (pb.Image, "#D2");

			pb.ImageLocation = "M.gif";
			Application.DoEvents ();

			Assert.AreEqual ("M.gif", pb.ImageLocation, "#E1");
			Assert.IsNull (pb.Image, "#E2");

			pb.Load ();
			Application.DoEvents ();

			Assert.AreEqual ("M.gif", pb.ImageLocation, "#F1");
			Assert.IsNotNull (pb.Image, "#F2");
			Assert.AreEqual (60, pb.Image.Height, "#F3");
			Assert.AreEqual (150, pb.Image.Width, "#F4");

			pb.ImageLocation = null;
			Application.DoEvents ();

			Assert.IsNull (pb.ImageLocation, "#G1");
			Assert.IsNull (pb.Image, "#G2");

			pb.ImageLocation = "M.gif";
			pb.Load ();
			pb.ImageLocation = "XYZ.gif";
			Application.DoEvents ();

			Assert.AreEqual ("XYZ.gif", pb.ImageLocation, "#H1");
			Assert.IsNotNull (pb.Image, "#H2");
			Assert.AreEqual (60, pb.Image.Height, "#H3");
			Assert.AreEqual (150, pb.Image.Width, "#H4");

			pb.ImageLocation = string.Empty;
			Application.DoEvents ();

			Assert.AreEqual (string.Empty, pb.ImageLocation, "#I1");
			Assert.IsNull (pb.Image, "#I2");

			using (Stream s = this.GetType ().Assembly.GetManifestResourceStream ("32x32.ico")) {
				pb.Image = Image.FromStream (s);
			}
			Application.DoEvents ();

			Assert.AreEqual (string.Empty, pb.ImageLocation, "#J1");
			Assert.IsNotNull (pb.Image, "#J2");
			Assert.AreEqual (96, pb.Image.Height, "#J3");
			Assert.AreEqual (96, pb.Image.Width, "#J4");

			pb.Load ("M.gif");
			Application.DoEvents ();

			Assert.AreEqual ("M.gif", pb.ImageLocation, "#K1");
			Assert.IsNotNull (pb.Image, "#K2");
			Assert.AreEqual (60, pb.Image.Height, "#K3");
			Assert.AreEqual (150, pb.Image.Width, "#K4");

			pb.ImageLocation = null;
			Application.DoEvents ();

			Assert.IsNull (pb.ImageLocation, "#L1");
			Assert.IsNull (pb.Image, "#L2");

			f.Dispose ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:93,代码来源:PictureBoxTest.cs


注:本文中的System.Windows.Forms.PictureBox.Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。