Inheritance: ResourceBase, IResource
        void OnResourceListBoxSelectedIndexChanged(object sender, EventArgs e)
        {
            resourceContentControl.ClearActivePanel( );

            IResource resource = resourceSelectionControl.SelectedResourceListBoxItem;

            if (resource == null)
            {
                return;
            }

            switch (resource.ResourceType)
            {
            case ResourceType.TypeImage:
                resourceContentControl.ActivateImagePanel( );

                ResourceImage resImage = resource as ResourceImage;
                resourceContentControl.ImagePanel.Image = resImage.Image;
                break;

            case ResourceType.TypeString:
                resourceContentControl.ActivateTextPanel( );

                ResourceString resString = resource as ResourceString;
                resourceContentControl.TextPanel.ResourceText = resString.Text;
                break;

            case ResourceType.TypeCursor:
                resourceContentControl.ActivateImagePanel( );

                ResourceCursor resCursor = resource as ResourceCursor;
                resourceContentControl.ImagePanel.Cursor = resCursor.Cursor;
                break;

            case ResourceType.TypeIcon:
                resourceContentControl.ActivateImagePanel( );

                ResourceIcon resIcon = resource as ResourceIcon;
                resourceContentControl.ImagePanel.Icon = resIcon.Icon;
                break;

            case ResourceType.TypeColor:
                resourceContentControl.ActivateColorPanel( );

                ResourceColor resColor = (ResourceColor)resource;
                resourceContentControl.ColorPanel.Color = resColor.Color;
                break;

            case ResourceType.TypeByteArray:
                resourceContentControl.ActivateByteArrayPanel( );

                ResourceByteArray resByteArray = (ResourceByteArray)resource;
                resourceContentControl.ByteArrayPanel.ByteArray = resByteArray.ByteArray;
                break;

            default:
                break;
            }
        }
Example #2
0
        public int AddResource(string resource_name, object resource)
        {
            if (ContainsName(resource_name))
            {
                return(0);
            }

            IResource iresource = null;

            if (resource is Bitmap)
            {
                iresource = new ResourceImage(resource_name, resource as Image);
            }
            else
            if (resource is String)
            {
                iresource = new ResourceString(resource_name, resource.ToString( ));
            }
            else
            if (resource is Icon)
            {
                iresource = new ResourceIcon(resource_name, resource as Icon);
            }
            else
            if (resource is Color)
            {
                iresource = new ResourceColor(resource_name, (Color)resource);
            }
            else
            if (resource is Cursor)
            {
                iresource = new ResourceCursor(resource_name, resource as Cursor);
            }

            items.Add(iresource);

            return(1);
        }
Example #3
0
        public int AddResource( string resource_name, object resource )
        {
            if ( ContainsName( resource_name ) )
                return 0;

            IResource iresource = null;

            if ( resource is Bitmap )
            {
                iresource = new ResourceImage( resource_name, resource as Image );
            }
            else
            if ( resource is String )
            {
                iresource = new ResourceString( resource_name, resource.ToString( ) );
            }
            else
            if ( resource is Icon )
            {
                iresource = new ResourceIcon( resource_name, resource as Icon );
            }
            else
            if ( resource is Color )
            {
                iresource = new ResourceColor( resource_name, (Color)resource );
            }
            else
            if ( resource is Cursor )
            {
                iresource = new ResourceCursor( resource_name, resource as Cursor );
            }

            items.Add( iresource );

            return 1;
        }
        void WriteResourceFile( )
        {
            ResXResourceWriter rxrw = new ResXResourceWriter(fullFileName);

            foreach (IResource res_abstract in resourceList.Items)
            {
                switch (res_abstract.ResourceType)
                {
                case ResourceType.TypeImage:
                    ResourceImage resImage = res_abstract as ResourceImage;

                    if (resImage.Image == null)
                    {
                        continue;
                    }

                    rxrw.AddResource(resImage.ResourceName, resImage.Image);
                    break;

                case ResourceType.TypeString:
                    ResourceString resStr = res_abstract as ResourceString;

                    if (resStr == null)
                    {
                        continue;
                    }

                    rxrw.AddResource(resStr.ResourceName, resStr.Text);
                    break;

                case ResourceType.TypeCursor:
                    ResourceCursor resCursor = res_abstract as ResourceCursor;

                    if (resCursor == null)
                    {
                        continue;
                    }

                    rxrw.AddResource(resCursor.ResourceName, resCursor.Cursor);
                    break;

                case ResourceType.TypeIcon:
                    ResourceIcon resIcon = res_abstract as ResourceIcon;

                    if (resIcon == null)
                    {
                        continue;
                    }

                    rxrw.AddResource(resIcon.ResourceName, resIcon.Icon);
                    break;

                case ResourceType.TypeColor:
                    ResourceColor resColor = res_abstract as ResourceColor;

                    if (resColor == null)
                    {
                        continue;
                    }

                    rxrw.AddResource(resColor.ResourceName, resColor.Color);
                    break;

                case ResourceType.TypeByteArray:
                    ResourceByteArray resByteArray = res_abstract as ResourceByteArray;

                    if (resByteArray == null)
                    {
                        continue;
                    }

                    rxrw.AddResource(resByteArray.ResourceName, resByteArray.ByteArray);
                    break;

                default:
                    break;
                }
            }

            rxrw.Close( );
        }