Example #1
0
        protected override void OnCreated()
        {
            m_TextEditor     = GetControl <TextEditor>("TextEditor");
            m_Viewer         = GetControl <Viewer>("Viewer");
            m_StatusBar      = GetControl <StatusBar>("StatusBar");
            m_XmlFiles       = GetControl <XmlFiles>("XmlFiles");
            m_ElementBrowser = GetControl <ElementBrowser>("ElementBrowser");
            m_SaveAsXmlFile  = GetControl <MenuItem>("SaveAsXmlFile");
            m_RemoveXmlFile  = GetControl <MenuItem>("RemoveXmlFile");
            m_DebugOutlines  = GetControl <LabeledCheckBox>("DebugOutlines");
            m_Skins          = GetControl <ComboBox>("Skins");

            SetCurrentXmlFile(null);

            Exception ex;

            m_FileList = XmlFileList.Open(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "GwenXmlDesigner", "XmlFiles.xml"), out ex);
            UpdateFileList();

            m_DebugOutlines.IsChecked = Settings.DebugOutlines;

            foreach (string path in Settings.GetAvailableSkins())
            {
                m_Skins.AddItem(Path.GetFileNameWithoutExtension(path), path, path);
            }

            m_Skins.SelectByUserData(Settings.Skin);
        }
Example #2
0
        public void SetFileList(XmlFileList fileList)
        {
            m_XmlFiles.RemoveAllNodes();

            foreach (XmlFile xmlFile in fileList.XmlFiles)
            {
                m_XmlFiles.AddNode(xmlFile.Name, xmlFile.FileName, xmlFile);
            }
        }
Example #3
0
        public void SetFileList(XmlFileList fileList, XmlFile current)
        {
            m_Items.Clear();

            foreach (XmlFile xmlFile in fileList.XmlFiles)
            {
                m_Items.AddRow(xmlFile.Name, xmlFile.FileName, xmlFile);
            }

            if (current == null && m_Items.RowCount > 0)
            {
                m_Items.SelectedRowIndex = 0;
            }
            else
            {
                m_Items.SelectByUserData(current);
            }
        }
Example #4
0
        public static XmlFileList Open(string fileName, out Exception exception)
        {
            XmlFileList xmlFileList;

            exception = null;
            if (File.Exists(fileName))
            {
                try
                {
                    using (StreamReader reader = new StreamReader(fileName))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(XmlFileList));
                        xmlFileList = serializer.Deserialize(reader) as XmlFileList;
                    }
                }
                catch (Exception ex)
                {
                    exception = ex;

                    xmlFileList = new XmlFileList();
                }
            }
            else
            {
                xmlFileList = new XmlFileList();
            }

            xmlFileList.m_FileName = fileName;

            foreach (XmlFile xmlfile in xmlFileList.m_XmlFiles)
            {
                if (!xmlfile.OpenXml(out exception))
                {
                    xmlfile.Xml = "<?xml version='1.0' encoding='UTF-8'?>\n";
                }
            }

            return(xmlFileList);
        }