vector image Shape

Jun 11, 2013 at 4:50 AM
Dear All


I modified Nshape source code especially Software Architecture Shape i try to add new vectorImage Shape I Copied image from the resource file and i rename file and i added image file to Resx file and add
 registrar.RegisterShapeType(new ShapeType("Piping", namespaceName, namespaceName,
               delegate(ShapeType shapeType, Template t)
               {
                   VectorImage result = VectorImage.CreateInstance(shapeType, t,
                       "Dataweb.NShape.SoftwareArchitectureShapes.Resources.Actor2.emf", Assembly.GetExecutingAssembly());
                   result.Text = "Piping";
                   return result;
               }, VectorImage.GetPropertyDefinitions));
after i add code i Build and test dll when i Load Library appears msg
like
Dataweb.NShape.SoftwareArchitectureShapes.Resources.Actor2.emf' is not a valid resource in 'Dataweb.NShape.SoftwareArchitectureShapes, Version=2.0.3.0, Culture=neutral, PublicKeyToken=1512080cd664963c'.\r\nParameter name: resourceBaseName 
What i must do For solve this problems? Thanks


Best Regards



Sonson
Coordinator
Jun 11, 2013 at 8:02 AM
Did you change the build action of the new image file to "Resource"?
Jun 11, 2013 at 4:21 PM
Edited Jun 12, 2013 at 5:55 AM
Dear Kurt

Thanks very much kurt problem Solve, One question if I want to create own Libary I Need include file CommonAssemblyInfo.cs and Dataweb.NShape.snk to My project ?


Best Regards

SonSon
Coordinator
Jun 12, 2013 at 8:46 AM
You do not need the CommonAssemblyInfo file. It defines the parameters of the assembly info that all our shipped assemblies have in common (company, copyright, version number).

The *.snk file is for signing your assembly. You need to sign your assembly if you create a library assembly.
You do not need to sign it if you implement your custom shapes as part of your application. In this case, you can add the library like this:
this.project1.AddLibrary(this.GetType().Assembly, false);
Jun 18, 2013 at 9:20 AM
Dear kurt


I want to ask you,I try to modified Nshape source code i try To Create a new Library i added new project in nshape source code. I named a project RiskwiseShapes I change namespace and Assembly name on project properties like "Dataweb.NShape.RiskwiseShapes" and Target framework ".Net Framework 2.0" and "any cpu" on platform target and i have to signing Nshape.Snk on Signing Tab. I create one class i named RiskwiseShapes.cs and i added one resource and i add one image and i change the build action I copied code from Software Architecture code Like below
public class VectorImage : CustomizableMetaFile
    {
        internal static VectorImage CreateInstance(ShapeType shapeType, Template template,
            string resourceBasename, Assembly resourceAssembly)
        {
            return new VectorImage(shapeType, template, resourceBasename, resourceAssembly);
        }


        /// <override></override>
        public override Shape Clone()
        {
            //Shape result = new VectorImage(Type, (Template)null, resourceName, resourceAssembly);
            Shape result = new VectorImage(Type, this.Template, resourceName, resourceAssembly);
            result.CopyFrom(this);
            return result;
        }


        protected internal VectorImage(ShapeType shapeType, IStyleSet styleSet, string resourceBaseName, Assembly resourceAssembly)
            : base(shapeType, styleSet, resourceBaseName, resourceAssembly)
        {
        }


        protected internal VectorImage(ShapeType shapeType, Template template, string resourceBaseName, Assembly resourceAssembly)
            : base(shapeType, template, resourceBaseName, resourceAssembly)
        {
        }
    }
public static class NShapeLibraryInitializer
    {

        public static void Initialize(IRegistrar registrar)
        {
            registrar.RegisterLibrary(namespaceName, preferredRepositoryVersion);
            

            registrar.RegisterShapeType(new ShapeType("Piping", namespaceName, namespaceName,
               delegate(ShapeType shapeType, Template t)
               {
                   VectorImage result = VectorImage.CreateInstance(shapeType, t,
                       "Dataweb.NShape.RiskwiseShapes.Resources.Vessel.emf", Assembly.GetExecutingAssembly());
                   result.Text = "Piping";
                   return result;
               }, VectorImage.GetPropertyDefinitions));
        }


        private const string namespaceName = "RiskwiseShape";
        private const int preferredRepositoryVersion = 1;
    }
And I Build a Solution and i checked on bin directory dll file generated after that i open Nshape designer and add new library and appeared msgbox invalid file type and 'C:\users\Public\Documents\Nshape\bin\debug\Dataweb.Nshape.Riskwise.Shapes.dll' is not a valid NshapeLibary.can you help me Kurt Thanks you very much.



Best Regards



Sonson
Coordinator
Jun 19, 2013 at 10:51 AM
Did you copy the assembly to the directory of the NShapeDesigner.exe?
Shape assemblies need to reside in the startup directory of the NShapeDesigner.
Jun 19, 2013 at 12:24 PM
Edited Jun 19, 2013 at 12:24 PM
Thank you Very much kurt