Beispiel #1
0
        private void AddTextureItem(string category, string itemName, string variableName, string fileName)
        {
            Image original = DevILMethods.ImageFromFile(fileName);

            if (original != null)
            {
                original = DevILMethods.FixedSize(original, 20, 20);
            }
            Inspector.ImageItem imageItem = new Inspector.ImageItem(category, itemName, variableName, fileName, original);
            imageItem.ValueChanging += ImageItem_ValueChanging;
            inspectorComponent.ItemAdd(imageItem);
        }
Beispiel #2
0
        private void ImageItem_ValueChanging(object sender, string value)
        {
            TexturesDialog dialog = new TexturesDialog();

            dialog.FileName         = value;
            dialog.TextureDirectory = m_ProjectLocation + @"\Textures";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Inspector.ImageItem imageItem = sender as Inspector.ImageItem;
                m_ModifyDelegate?.Invoke(imageItem.VariableName, Path.GetFileName(dialog.FileName));
                imageItem.FileName = dialog.FileName;
                Image original = DevILMethods.ImageFromFile(dialog.FileName);
                if (original != null)
                {
                    original = DevILMethods.FixedSize(original, 20, 20);
                }
                imageItem.Value = original;
            }
        }
Beispiel #3
0
        private void AddNewImage(string filePath)
        {
            ListViewItem item = new ListViewItem();

            item.Text        = Path.GetFileName(filePath);
            item.ToolTipText = filePath;
            listViewTextures.Items.Add(item);

            bool success = false;

            try
            {
                Image original = Image.FromFile(filePath);
                if (original != null)
                {
                    imageListLarge.Images.Add(DevILMethods.FixedSize(original, imageListLarge.ImageSize.Width, imageListLarge.ImageSize.Height));
                    item.ImageIndex = imageListLarge.Images.Count - 1;
                    success         = true;
                }
            }
            catch (OutOfMemoryException)
            {
            }

            if (!success)
            {
                Image original = DevILMethods.ImageFromFile(filePath);
                if (original != null)
                {
                    imageListLarge.Images.Add(DevILMethods.FixedSize(original, imageListLarge.ImageSize.Width, imageListLarge.ImageSize.Height));
                    item.ImageIndex = imageListLarge.Images.Count - 1;
                }
                else
                {
                    item.ImageIndex = 0;
                }
            }
        }