コード例 #1
0
        public MImgsManager Clone(Form_Main form_MainT)
        {
            MImgsManager newInstance = new MImgsManager(form_MainT);

            for (int i = 0; i < Count(); i++)
            {
                newInstance.Add(this[i].Clone(newInstance), false);
            }
            newInstance.ui = ui;
            return(newInstance);
        }
コード例 #2
0
 public void loadImage()
 {
     try
     {
         MImgsManager imgsManager = ((MImgsManager)parent);
         image = GraphicsUtil.createAlphaPmtImage(imgsManager.form_Main.path_folder, name, strAlphaImage, strPmt, alpha);
         rebindTexture();
     }
     catch (Exception e)
     {
         Console.WriteLine("load Image Error:" + e.Message);
     }
 }
コード例 #3
0
        public MImgElement Clone(MImgsManager parentT)
        {
            MImgElement newElement = new MImgElement(parentT);

            newElement.name           = name + "";
            newElement.image          = image;
            newElement.imageTextured  = imageTextured;
            newElement.forbidOptimize = forbidOptimize;
            newElement.strAlphaImage  = strAlphaImage;
            newElement.strPmt         = strPmt;
            newElement.alpha          = alpha;
            newElement.linkID         = linkID;
            return(newElement);
        }
コード例 #4
0
        public bool renameImage(String newName)
        {
            if (this.name == null)
            {
                return(false);
            }
            //改变文件名称
            String path    = Consts.PATH_PROJECT_FOLDER + Consts.SUBPARH_IMG + name;
            String newPath = Consts.PATH_PROJECT_FOLDER + Consts.SUBPARH_IMG + newName;

            if (File.Exists(newPath))
            {
                MessageBox.Show("已经存在同名文件");
                return(false);
            }
            if (File.Exists(path))
            {
                File.Copy(path, newPath);
                File.Delete(path);
            }
            //检查动画图片中的同类名字
            MImgsManager imsManager = ((MImgsManager)parent).form_Main.form_MAnimation.form_MImgsList.mImgsManager;

            for (int i = 0; i < imsManager.Count(); i++)
            {
                MImgElement imgElement = imsManager[i];
                if (!imgElement.Equals(this) && imgElement.name.Equals(name))
                {
                    imgElement.name = newName;
                }
            }
            //检查地图图片中的同类名字
            imsManager = ((MImgsManager)parent).form_Main.mapImagesManager;
            for (int i = 0; i < imsManager.Count(); i++)
            {
                MImgElement imgElement = imsManager[i];
                if (!imgElement.Equals(this) && imgElement.name.Equals(name))
                {
                    imgElement.name = newName;
                }
            }
            this.name = newName;
            return(true);
        }
コード例 #5
0
        public MParentNode GetTopParent()
        {
            MParentNode parent = GetParent();

            if (parent != null)
            {
                if (!(parent is MSonNode))
                {
                    Console.WriteLine("error");
                }
                while (((MSonNode)parent).GetParent() != null)
                {
                    parent = ((MSonNode)parent).GetParent();
                    if (!(parent is MSonNode))
                    {
                        Console.WriteLine("error");
                    }
                }
            }
            return(parent);
        }
コード例 #6
0
 public void setParent(MImgsManager parentT)
 {
     parent = parentT;
 }
コード例 #7
0
 public MImgElement(MImgsManager parentT)
 {
     this.parent = parentT;
 }
コード例 #8
0
 public MImgElement(String nameT, MImgsManager parentT)
 {
     this.parent = parentT;
     name        = nameT;
     loadImage();
 }
コード例 #9
0
 public void SetParent(MParentNode parentT)
 {
     parent = (MImgsManager)parentT;
 }
コード例 #10
0
        //合并图片资源
        public void combine(MImgsManager src_ImgsManager)
        {
            //检查子文件夹
            if (!Directory.Exists(Consts.PATH_PROJECT_FOLDER + Consts.SUBPARH_IMG))
            {
                Directory.CreateDirectory(Consts.PATH_PROJECT_FOLDER + Consts.SUBPARH_IMG);
            }
            int res = 0;

            //合并
            for (int i = 0; i < src_ImgsManager.Count(); i++)
            {
                MImgElement srcElement   = src_ImgsManager[i];
                String      nameSrc      = srcElement.name;
                MImgElement newElement   = null;
                bool        findSameName = false;
                MImgElement localElement = null;
                //同名检查
                for (int j = 0; j < this.Count(); j++)
                {
                    localElement = this[j];
                    if (localElement.equalsOnName(srcElement))//发现相同的文件名
                    {
                        findSameName = true;
                        break;
                    }
                }
                //同名处理
                if (findSameName)
                {
                    if (res < 2)
                    {
                        res = SmallDialog_MessageBox.getResult("覆盖", "忽略", "全部覆盖", "全部忽略", "发现相同的图片资源“" + localElement.name + "”");
                    }
                    if (res == 0 || res == 2)//覆盖
                    {
                        if (!srcElement.getFullName().Equals(localElement.getFullName()))
                        {
                            IOUtil.Copy(srcElement.getFullName(), localElement.getFullName(), true);
                            if (!srcElement.strAlphaImage.Equals(""))
                            {
                                IOUtil.Copy(srcElement.getFullAlphaName(), localElement.getFullAlphaName(srcElement.strAlphaImage), true);
                            }
                            if (!srcElement.strPmt.Equals(""))
                            {
                                IOUtil.Copy(srcElement.getFullPmtName(), localElement.getFullPmtName(srcElement.strPmt), true);
                            }
                        }
                        localElement.loadImage();
                        newElement = localElement;
                    }
                    else if (res == 1 || res == 3)//忽略新资源
                    {
                        newElement = localElement;
                    }
                }
                else
                {
                    newElement = srcElement;//.Clone(this);
                    this.Add(newElement);
                    IOUtil.Copy(srcElement.getFullName(), newElement.getFullName(srcElement.name), true);
                    if (!srcElement.strAlphaImage.Equals(""))
                    {
                        IOUtil.Copy(srcElement.getFullAlphaName(), localElement.getFullAlphaName(srcElement.strAlphaImage), true);
                    }
                    if (!srcElement.strPmt.Equals(""))
                    {
                        IOUtil.Copy(srcElement.getFullPmtName(), localElement.getFullPmtName(srcElement.strPmt), true);
                    }

                    newElement.loadImage();
                }
                if (this.Equals(form_Main.mapImagesManager))//地图图片
                {
                    TileGfxManager tileGfxManager = form_Main.mapsManager.tileGfxManager;
                    for (int iCM = 0; iCM < tileGfxManager.Count(); iCM++)
                    {
                        MClipsManager clipsManagerElement = tileGfxManager[iCM];
                        for (int k = 0; k < clipsManagerElement.Count(); k++)
                        {
                            MClipElement element = clipsManagerElement[k];
                            if (element.imageElement != null && element.imageElement.Equals(srcElement))
                            {
                                element.imageElement = newElement;
                            }
                        }
                    }
                }
                else if (this.Equals(form_Main.form_MAnimation.form_MImgsList.mImgsManager))//动画图片
                {
                    MClipsManager mClipsManager       = form_Main.form_MAnimation.form_MImgsList.MClipsManager;
                    MClipsManager clipsManagerElement = mClipsManager;
                    for (int k = 0; k < clipsManagerElement.Count(); k++)
                    {
                        MClipElement element = clipsManagerElement[k];
                        if (element.imageElement != null && element.imageElement.Equals(srcElement))
                        {
                            element.imageElement = newElement;
                        }
                    }
                }
            }
        }