예제 #1
0
        public static void showScene(MyContainer myContainer, string path)
        {
            myContainer.Children.Clear();
            XmlDocument doc = HandleSources.readXMLDoc(path);

            if (doc == null)
            {
                return;
            }
            XmlNode    scenePage  = doc.GetElementsByTagName("scenePage")[0];
            XmlNode    canvas     = scenePage.ChildNodes[0];
            LayoutData layoutData = new LayoutData();

            layoutData.backgroundColor = Convert.ToInt32(canvas.Attributes[11].Value);
            layoutData.sceneTime       = Convert.ToInt32(canvas.Attributes[10].Value);
            layoutData.stretchModel    = Convert.ToInt32(canvas.Attributes[9].Value);
            layoutData.imageSwitch     = Convert.ToInt32(canvas.Attributes[8].Value);
            layoutData.canvasTop       = double.Parse(canvas.Attributes[7].Value);
            layoutData.canvasLeft      = double.Parse(canvas.Attributes[6].Value);
            layoutData.text            = canvas.Attributes[5].Value;
            layoutData.angle           = double.Parse(canvas.Attributes[4].Value);
            layoutData.sourcePath      = canvas.Attributes[3].Value;
            layoutData.width           = double.Parse(canvas.Attributes[2].Value);
            layoutData.height          = double.Parse(canvas.Attributes[1].Value);
            layoutData.tag             = canvas.Attributes[0].Value;

            myContainer.initLayout(layoutData);
            createChild(canvas, myContainer);
        }
예제 #2
0
        private static void saveSceneTo(MainWindow window)
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            dlg.InitialDirectory = appPath + "\\scene";
            dlg.DefaultExt       = ".Sce";
            dlg.Filter           = "场景文件(*.Sce)|*.Sce";
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                HandleSources.saveScene(window.myContainer, filename);
                MyListBoxItem lbi = new MyListBoxItem();
                lbi.DataContext = dlg.FileName;

                lbi.resolution = window.myContainer.Width + "," + window.myContainer.Height;
                lbi.Content    = dlg.SafeFileName.Substring(0, dlg.SafeFileName.Length - 4) + "{" + lbi.resolution + "}";
                window.scenes.Items.Add(lbi);
                //window.scenesArray.Add(dlg.FileName);
                window.scenes.SelectedIndex = window.scenes.Items.Count - 1;
            }
        }
예제 #3
0
        public static void readScene(MainWindow window)
        {
            string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.InitialDirectory = appPath + "\\scene";
            dlg.DefaultExt       = ".Sce";
            dlg.Filter           = "场景文件(*.Sce)|*.Sce";
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                //HandleSources.saveScene(window.myContainer, filename);
                int           count = window.scenes.Items.Count;
                MyListBoxItem lbi   = new MyListBoxItem();
                XmlDocument   doc   = HandleSources.readXMLDoc(dlg.FileName);
                if (doc == null)
                {
                    return;
                }
                XmlNode resolution = doc.GetElementsByTagName("resolution")[0];
                lbi.resolution  = resolution.InnerText;
                lbi.Content     = dlg.SafeFileName.Substring(0, dlg.SafeFileName.Length - 4) + "{" + lbi.resolution + "}";
                lbi.DataContext = dlg.FileName;

                window.scenes.Items.Add(lbi);
                //window.scenesArray.Add(dlg.FileName);
                window.scenes.SelectedIndex = window.scenes.Items.Count - 1;
            }
        }
예제 #4
0
 private static void saveScene(MainWindow window)
 {
     if (window.scenes.SelectedIndex == -1)
     {
         saveSceneTo(window);
     }
     else
     {
         string filename = (window.scenes.SelectedItem as MyListBoxItem).DataContext as string;
         (window.scenes.SelectedItem as MyListBoxItem).resolution = window.myContainer.Width + "," + window.myContainer.Height;
         HandleSources.saveScene(window.myContainer, filename);
     }
 }
예제 #5
0
        private static void savePrograme(List <string> scenesArray, string filename)
        {
            string zipFolder    = filename.Substring(0, filename.Length - 4) + "~";
            string sourceFolder = zipFolder + "\\source";

            bool zipFolderExists = System.IO.Directory.Exists(zipFolder);

            if (!zipFolderExists)
            {
                System.IO.Directory.CreateDirectory(zipFolder);
            }
            bool sourceFolderIsExists = System.IO.Directory.Exists(sourceFolder);

            if (!sourceFolderIsExists)
            {
                System.IO.Directory.CreateDirectory(sourceFolder);
            }

            XmlDocument doc     = new XmlDocument();
            XmlNode     docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

            doc.AppendChild(docNode);
            XmlNode programeElement = doc.CreateElement("programeElement");

            for (int i = 0; i < scenesArray.Count; i++)
            {
                XmlNode element = doc.CreateElement("scene" + i);

                if (!HandleSources.copyFileToZipFolder(scenesArray[i], zipFolder))
                {
                    continue;
                }
                string[] filenames = scenesArray[i].Split(new Char[] { '\\' });
                string   name      = filenames[filenames.Length - 1];
                element.InnerText = name;
                programeElement.AppendChild(element);
            }

            doc.AppendChild(programeElement);
            doc.Save(zipFolder + "\\scenes.xml");
            FileInfo file = new FileInfo(filename);

            file.Delete();
            ZipFile.CreateFromDirectory(zipFolder, filename);
            DirectoryInfo dir = new DirectoryInfo(zipFolder);

            dir.Delete(true);
            //System.IO.Directory.Delete(zipFolder);
        }