当前位置: 首页>>代码示例>>C#>>正文


C# Form1.getElementTreeView方法代码示例

本文整理汇总了C#中System.Form1.getElementTreeView方法的典型用法代码示例。如果您正苦于以下问题:C# Form1.getElementTreeView方法的具体用法?C# Form1.getElementTreeView怎么用?C# Form1.getElementTreeView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Form1的用法示例。


在下文中一共展示了Form1.getElementTreeView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: importObject

        //---------------------------------------------------------------------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------- OBJECT ----------------------------------------------------------------------------
        //---------------------------------------------------------------------------------------------------------------------------------------------------------
        public static void importObject(Form1 mainForm, string filename, BackgroundWorker worker)
        {
            CoronaLayer layerParent = mainForm.getElementTreeView().LayerSelected;
            if (layerParent != null)
            {
                string projectPath = layerParent.SceneParent.projectParent.ProjectPath;
                worker.ReportProgress(10);
                FileStream fs = File.OpenRead(filename);
                if (fs.Length > 0)
                {
                    MemoryStream ms = new MemoryStream();
                    ms.SetLength(fs.Length);

                    fs.Read(ms.GetBuffer(), 0, (int)ms.Length);
                    worker.ReportProgress(30);
                    CoronaObject obj = (CoronaObject)SerializerHelper.DeSerializeBinary(ms);
                    fs.Close();
                    ms.Close();
                    worker.ReportProgress(50);
                    if (obj != null)
                    {
                        obj.LayerParent = layerParent;
                        obj.DisplayObject.Name = layerParent.SceneParent.projectParent.IncrementObjectName(obj.DisplayObject.Name);
                        //Ajouter l'entité ay layer
                        layerParent.CoronaObjects.Add(obj);

                        string currentDir = Path.GetDirectoryName(filename);
                        if (Directory.Exists(currentDir + "\\Images"))
                        {
                            string[] files = Directory.GetFiles(currentDir + "\\Images");
                            for (int i = 0; i < files.Length; i++)
                            {
                                string fileNameOnly = Path.GetFileName(files[i]);
                                File.Copy(files[i],
                                     projectPath + "\\Resources\\Images\\" + fileNameOnly, true);
                            }
                        }

                        if (Directory.Exists(currentDir + "\\SpriteSheets"))
                        {
                            string[] sheetDirectories = Directory.GetDirectories(currentDir + "\\SpriteSheets");
                            for (int i = 0; i < sheetDirectories.Length; i++)
                            {
                                string finalDirectoryDestNameOnly = Path.GetFileName(sheetDirectories[i]);
                                if (!Directory.Exists(projectPath + "\\Resources\\SpriteSheets\\" + finalDirectoryDestNameOnly))
                                {
                                    Directory.CreateDirectory(projectPath + "\\Resources\\SpriteSheets\\" + finalDirectoryDestNameOnly);
                                }

                                string[] files = Directory.GetFiles(sheetDirectories[i]);
                                for (int j = 0; j < files.Length; j++)
                                {
                                    string fileNameOnly = Path.GetFileName(files[j]);
                                    File.Copy(files[j],
                                         projectPath + "\\Resources\\SpriteSheets\\" + finalDirectoryDestNameOnly + "\\" + fileNameOnly, true);
                                }

                            }
                        }

                        mainForm.sceneEditorView1.GraphicsContentManager.UpdateSpriteContent(obj, 1, System.Drawing.Point.Empty);
                        worker.ReportProgress(90);
                        mainForm.sceneEditorView1.GraphicsContentManager.CleanProjectBitmaps();

                        obj.objectAttachedToGenerator = null;

                    }
                    else
                    {
                        MessageBox.Show("Error during object importation!\n The file seems to be corrupted!", "Object Importation Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        mainForm.currentWorkerAction = "NONE";
                    }

                }
            }
        }
开发者ID:nadar71,项目名称:Krea,代码行数:79,代码来源:ProjectSerializer.cs

示例2: importLayer

        //---------------------------------------------------------------------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------- LAYER ----------------------------------------------------------------------------
        //---------------------------------------------------------------------------------------------------------------------------------------------------------
        public static void importLayer(Form1 mainForm, string filename, BackgroundWorker worker)
        {
            Scene sceneParent = mainForm.getElementTreeView().SceneSelected;
            if (sceneParent != null)
            {
                string directoryName = Path.GetDirectoryName(filename);

                worker.ReportProgress(10);
                FileStream fs = File.OpenRead(filename);
                if (fs.Length > 0)
                {
                    MemoryStream ms = new MemoryStream();
                    ms.SetLength(fs.Length);

                    fs.Read(ms.GetBuffer(), 0, (int)ms.Length);
                    worker.ReportProgress(30);
                    CoronaLayer layer = (CoronaLayer)SerializerHelper.DeSerializeBinary(ms);
                    fs.Close();
                    ms.Close();
                    worker.ReportProgress(50);
                    if (layer != null)
                    {
                        layer.SceneParent = sceneParent;
                        //Ajouter la scene au projet
                        sceneParent.Layers.Add(layer);

                        layer.Name = sceneParent.projectParent.IncrementObjectName(layer.Name);

                        string oldMapName = "";
                        if (layer.TilesMap != null)
                        {
                            oldMapName = layer.TilesMap.TilesMapName;
                            layer.TilesMap.TilesMapName = sceneParent.projectParent.IncrementObjectName(layer.TilesMap.TilesMapName);
                        }

                        for (int i = 0; i < layer.CoronaObjects.Count; i++)
                        {
                            CoronaObject obj = layer.CoronaObjects[i];
                            if (obj.isEntity == false)
                            {
                                obj.DisplayObject.Name = sceneParent.projectParent.IncrementObjectName(obj.DisplayObject.Name);
                            }
                            else
                            {
                                obj.Entity.Name = sceneParent.projectParent.IncrementObjectName(obj.Entity.Name);
                                for (int j = 0; j < obj.Entity.CoronaObjects.Count; j++)
                                {
                                    obj.Entity.CoronaObjects[j].DisplayObject.Name = sceneParent.projectParent.IncrementObjectName(obj.Entity.CoronaObjects[j].DisplayObject.Name);
                                }
                            }
                        }

                        //Traiter les fichiers necessaires aux tilesmap
                        worker.ReportProgress(60);
                        int prog = 60;

                        if (Directory.Exists(directoryName + "\\Images"))
                        {
                            if (!Directory.Exists(sceneParent.projectParent.ProjectPath + "\\Resources\\Images"))
                                Directory.CreateDirectory(sceneParent.projectParent.ProjectPath + "\\Resources\\Images");

                            string[] files = Directory.GetFiles(directoryName + "\\Images");
                            for (int i = 0; i < files.Length; i++)
                            {
                                string fileNameOnly = Path.GetFileName(files[i]);
                                File.Copy(files[i], sceneParent.projectParent.ProjectPath + "\\Resources\\Images\\" + fileNameOnly, true);
                            }
                        }

                        if (Directory.Exists(directoryName + "\\SpriteSheets"))
                        {
                            if (!Directory.Exists(sceneParent.projectParent.ProjectPath + "\\Resources\\SpriteSheets"))
                                Directory.CreateDirectory(sceneParent.projectParent.ProjectPath + "\\Resources\\SpriteSheets");

                            string[] directories = Directory.GetDirectories(directoryName + "\\SpriteSheets");
                            for (int i = 0; i < directories.Length; i++)
                            {
                                string directoryNameOnly = Path.GetFileName(directories[i]);

                                if (!Directory.Exists(sceneParent.projectParent.ProjectPath + "\\Resources\\SpriteSheets\\" + directoryNameOnly))
                                    Directory.CreateDirectory(sceneParent.projectParent.ProjectPath + "\\Resources\\SpriteSheets\\" + directoryNameOnly);

                                string[] files = Directory.GetFiles(directories[i]);
                                for (int j = 0; j < files.Length; j++)
                                {
                                    string fileNameOnly = Path.GetFileName(files[j]);
                                    File.Copy(files[j], sceneParent.projectParent.ProjectPath + "\\Resources\\SpriteSheets\\" +
                                        directoryNameOnly + "\\" + fileNameOnly, true);
                                }
                            }

                        }

                        if (Directory.Exists(directoryName + "\\TileMaps") && layer.TilesMap!=null)
                        {
                            if (!Directory.Exists(sceneParent.projectParent.ProjectPath + "\\Resources\\TileMaps\\"+layer.TilesMap.TilesMapName))
                                Directory.CreateDirectory(sceneParent.projectParent.ProjectPath + "\\Resources\\TileMaps\\"+layer.TilesMap.TilesMapName);
//.........这里部分代码省略.........
开发者ID:nadar71,项目名称:Krea,代码行数:101,代码来源:ProjectSerializer.cs


注:本文中的System.Form1.getElementTreeView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。