Пример #1
0
        static Decorator()
        {
            // Load the default deco from the data assembly
            var stream     = Pandora.DataAssembly.GetManifestResourceStream("Data.Deco.xml");
            var serializer = new XmlSerializer(typeof(BoxDecoList));

            m_Default = serializer.Deserialize(stream) as BoxDecoList;
            stream.Close();

            /*Support s = new Support();
             * s.StructureS = new List<GenericNode>();
             * for(int i = 0; i < m_Default.Structure.Count; i++)
             * {
             *      GenericNode n = m_Default.Structure[i] as GenericNode;
             *      s.StructureS.Add(n);
             * }
             * TextWriter w = new StreamWriter(@"c:\deco.xml");
             * try
             * {
             * XmlSerializer ser = new XmlSerializer(typeof(Support));
             *
             *      ser.Serialize(w, s);
             * }
             * catch (System.Exception e)
             * {
             *      MessageBox.Show(e.ToString());
             * }
             *
             * w.Close();*/

            var custom = Path.Combine(Pandora.Profile.BaseFolder, "CustomDeco.xml");

            if (File.Exists(custom))
            {
                try
                {
                    var cStream = new FileStream(custom, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    m_Custom = serializer.Deserialize(cStream) as BoxDecoList;
                    cStream.Close();
                }
                catch (Exception err)
                {
                    Pandora.Log.WriteError(err, "Couldn't load custom deco for profile {0}", Pandora.Profile.Name);
                    m_Custom = new BoxDecoList();
                }
            }
            else
            {
                m_Custom = new BoxDecoList();
            }

            // Create the default nodes
            m_DefaultNodes = GetNodes(m_Default.Structure);
        }
Пример #2
0
        /// <summary>
        ///     Loads a BoxDecoList from file
        /// </summary>
        /// <param name="filename">The file to read from</param>
        /// <returns>The BoxDecoList read from the specified file</returns>
        public static BoxDecoList FromFile(string filename)
        {
            BoxDecoList list = null;

            try
            {
                var stream     = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                var serializer = new XmlSerializer(typeof(BoxDecoList));
                list = serializer.Deserialize(stream) as BoxDecoList;
                stream.Close();
                return(list);
            }
            catch
            {
                return(null);
            }
        }
Пример #3
0
		static Decorator()
		{
			// Load the default deco from the data assembly
			Stream stream = Pandora.DataAssembly.GetManifestResourceStream( "Data.Deco.xml" );
			XmlSerializer serializer = new XmlSerializer( typeof( BoxDecoList ) );
			m_Default = serializer.Deserialize( stream ) as BoxDecoList;
			stream.Close();

			/*Support s = new Support();
			s.StructureS = new List<GenericNode>();
			for(int i = 0; i < m_Default.Structure.Count; i++)
			{
				GenericNode n = m_Default.Structure[i] as GenericNode;
				s.StructureS.Add(n);
			}
			TextWriter w = new StreamWriter(@"c:\deco.xml");
			try
			{
			XmlSerializer ser = new XmlSerializer(typeof(Support));
			
				ser.Serialize(w, s);
			}
			catch (System.Exception e)
			{
				MessageBox.Show(e.ToString());
			}
			
			w.Close();*/

			string custom = Path.Combine( Pandora.Profile.BaseFolder, "CustomDeco.xml" );

			if ( File.Exists( custom ) )
			{
				try
				{
					FileStream cStream = new FileStream( custom, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
					m_Custom = serializer.Deserialize( cStream ) as BoxDecoList;
					cStream.Close();
				}
				catch ( Exception err )
				{
					Pandora.Log.WriteError( err, "Couldn't load custom deco for profile {0}", Pandora.Profile.Name );
					m_Custom = new BoxDecoList();
				}
			}
			else
			{
				m_Custom = new BoxDecoList();
			}

			// Create the default nodes
			m_DefaultNodes = GetNodes( m_Default.Structure );
		}
Пример #4
0
		private void button1_Click(object sender, System.EventArgs e)
		{
			// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
			m_IDs = new List<int>();
			// Issue 10 - End
			m_Deco = BoxDecoList.FromFile( m_File );

			foreach ( GenericNode g in m_Deco.Structure )
			{
				foreach ( GenericNode g2 in g.Elements )
				{
					foreach ( BoxDeco deco in g2.Elements )
					{
						m_IDs.Add( deco.ID );
					}
				}
			}
		}