AddImage() public méthode

public AddImage ( string fullName, Image image ) : void
fullName string
image Image
Résultat void
        private void ImportFolder(ImagesFolder folder, string folderPath)
        {
            var files = new Dictionary <string, List <string> >();

            LoadImages(folderPath, false, string.Empty, files);

            foreach (var kvp in files)
            {
                var prefix = string.IsNullOrEmpty(kvp.Key) ? string.Empty : kvp.Key + ImagesFolder.NameSeparator;
                foreach (var file in kvp.Value)
                {
                    var shortName = Path.GetFileNameWithoutExtension(file);
                    folder.AddImage(folder.GetFullName(prefix + shortName), _loadedImages[file]);
                }
            }
        }
        private void AddImage(string imageFileName)
        {
            try
            {
                Image img;
                if (!_loadedImages.TryGetValue(imageFileName, out img))
                {
                    img = Image.FromFile(imageFileName);
                    _loadedImages.Add(imageFileName, img);
                }

                using (var inf = new ImageNameForm())
                {
                    if (_activeFolder != null)
                    {
                        inf.ImageNameChanged += ImageNameForm_ImageNameChanged;
                        inf.ImageName         = _activeFolder.GetFullName(
                            Path.GetFileNameWithoutExtension(imageFileName));
                    }

                    if (inf.ShowDialog() == DialogResult.OK)
                    {
                        if (_rootFolder == null)
                        {
                            _rootFolder = new ImagesFolder();
                            _rootFolder.ImageAddConflict += RootFolderImageAddConflict;
                            _rootFolder.AddImage(inf.ImageName, img);

                            AssignRootFolder();
                        }
                        else
                        {
                            using (new TreeGridUpdater(_foldersTree))
                                _rootFolder.AddImage(inf.ImageName, img);
                        }
                    }
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
		private void AddImage(string imageFileName)
		{
			try
			{
				Image img;
				if (!_loadedImages.TryGetValue(imageFileName, out img))
				{
					img = Image.FromFile(imageFileName);
					_loadedImages.Add(imageFileName, img);
				}

				using (var inf = new ImageNameForm())
				{
					if (_activeFolder != null)
					{
						inf.ImageNameChanged += ImageNameForm_ImageNameChanged;
						inf.ImageName = _activeFolder.GetFullName(
							Path.GetFileNameWithoutExtension(imageFileName));
					}

					if (inf.ShowDialog() == DialogResult.OK)
					{
						if (_rootFolder == null)
						{
							_rootFolder = new ImagesFolder();
							_rootFolder.ImageAddConflict += RootFolderImageAddConflict;
							_rootFolder.AddImage(inf.ImageName, img);

							AssignRootFolder();
						}
						else
						{
							using (new TreeGridUpdater(_foldersTree))
								_rootFolder.AddImage(inf.ImageName, img);
						}
					}
				}
			}
			catch (ArgumentException ex)
			{
				MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
		}
Exemple #4
0
		private void ImportFolder(ImagesFolder folder, string folderPath)
		{
			var files = new Dictionary<string, List<string>>();

			LoadImages(folderPath, false, string.Empty, files);

			foreach (var kvp in files)
			{
				var prefix = string.IsNullOrEmpty(kvp.Key) ? string.Empty : kvp.Key + ImagesFolder.NameSeparator;
				foreach (var file in kvp.Value)
				{
					var shortName = Path.GetFileNameWithoutExtension(file);
					folder.AddImage(folder.GetFullName(prefix + shortName), _loadedImages[file]);
				}
			}
		}