コード例 #1
0
 public ReadOnlyDecorator(GenericDecorator decorator, 
     IntPtr parentHwnd, MgaFCO fco, MgaMetaFCO metafco, MgaProject project, Type formType, IBackroundDraw bgdraw)
     : base(decorator, parentHwnd, fco, metafco, project, bgdraw, formType)
 {
 }
コード例 #2
0
        public DefaultBitmapDecorator(GenericDecorator decorator,
            IntPtr parentHwnd, MgaFCO fco, MgaMetaFCO metafco, MgaProject project, IBackroundDraw backgrounddraw, Type formType = null)
            : base(parentHwnd, fco, project, formType != null)
        {
            string iconName;
            decorator.GetPreference(out iconName, "icon");
            string defaultIconName = iconName;

            if (fco != null)
            {
                string kind = fco.Meta.Name;
                if (kind == "ParkingSign")
                {
                    iconName = GetParkingSignIcon(fco);
                }
                else if (kind == "FloodSign")
                {
                    iconName = GetFloodSignIcon(fco);
                }
                else if (kind == "StreetSign")
                {
                    iconName = GetStreetSignIcon(fco);
                }
                // else fall through to the default icon
            }

            this.backgrounddraw = backgrounddraw;

            this.formType = formType;

            string projectDir = Path.GetDirectoryName(project.ProjectConnStr.Substring(4));
            string paradigmDir = Path.GetDirectoryName(project.ParadigmConnStr.Substring(4));

            MgaRegistrar registrar = new MgaRegistrar();
            StringBuilder iconPath = new StringBuilder(registrar.IconPath[regaccessmode_enum.REGACCESS_BOTH]);

            iconPath.Replace("$PROJECTDIR", projectDir);
            iconPath.Replace("$PARADIGMDIR", paradigmDir);

            search_paths = iconPath.ToString().Split(';');

            foreach (string path in search_paths)
            {
                string fileName = Path.Combine(path, iconName);
                if (File.Exists(fileName))
                {
                    image = Image.FromFile(fileName);
                    break;
                }
            }

            if (image == null) // look at the default
            {
                foreach (string path in search_paths)
                {
                    string fileName = Path.Combine(path, defaultIconName);
                    if (File.Exists(fileName))
                    {
                        image = Image.FromFile(fileName);
                        break;
                    }
                }
            }

            if (image == null)
            {
                image = LoadImage(defaultIconStr);
                default_image = image;
            }

            if (fco != null)
            {
                fcoName = fco.Name;
                //fcoName = String.IsNullOrEmpty(metafco.DisplayedName) ? metafco.Name : metafco.DisplayedName;

                if (fco.ObjType == objtype_enum.OBJTYPE_REFERENCE)
                {

                    MgaReference reference = fco as MgaReference;
                    if (reference.Referred == null)
                    {
                        Embellish = EmbellishType.NullReference;
                    }
                    else
                    {
                        Embellish = EmbellishType.Reference;
                    }

                } else  if (fco.IsInstance)
                {
                    // instance

                    Embellish = EmbellishType.Instance;
                }
                else if (fco.DerivedFrom != null)
                {
                    // Subtype
                    Embellish = EmbellishType.SubType;
                }
                else if (fco.DerivedObjects.Count != 0)
                {
                    Embellish = EmbellishType.Type;
                }
                else
                {
                    Embellish = EmbellishType.None;
                }
            }
            else
            {
                fcoName = String.IsNullOrEmpty(metafco.DisplayedName) ? metafco.Name : metafco.DisplayedName;
            }
        }