Esempio n. 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);
        }
Esempio n. 2
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;
            }
        }