Esempio n. 1
0
		private void miImport_Click(object sender, System.EventArgs e)
		{
			CheckModified();

			if ( OpenFile.ShowDialog() == DialogResult.OK )
			{
				Facet f = Box.Misc.PB1Import.Convert( OpenFile.FileName );

				if ( f != null )
				{
					if ( m_FacetNode.Nodes.Count > 0 )
					{
						// Merge?
						if ( MessageBox.Show( this,
							"You can add the new locations to the current project, or delete all exisitng entires and add the imported file to a blank project.\n\nYes: Merge the new locations with the existing project\nNo: Create a new blank project and add the imported locations",
							"Import Succesful",
							MessageBoxButtons.YesNo,
							MessageBoxIcon.Question ) == DialogResult.Yes )
						{
							// Merge
							Merge( f );
							m_Changed = true;
						}
						else
						{
							CurrentFacet = f;
							m_Changed = true;
						}
					}
					else
					{
						CurrentFacet = f;
						m_Changed = true;
					}
				}
				else
				{
					MessageBox.Show( "Import failed" );
				}
			}
		}
Esempio n. 2
0
		private void miOpen_Click(object sender, System.EventArgs e)
		{
			CheckModified();

			if ( OpenFile.ShowDialog() == DialogResult.OK )
			{
				Facet f = Utility.LoadXml( typeof( Facet ), OpenFile.FileName ) as Facet;

				if ( f != null )
				{
					CurrentFacet = f;
					m_Changed = false;
					m_Map.Map = (Maps) f.MapValue;
				}
				else
				{
					MessageBox.Show( "Couldn't load the selected file" );
				}
			}
		}
Esempio n. 3
0
		private void Merge( Facet f )
		{
			tCat.BeginUpdate();

			foreach( GenericNode cat in f.Nodes )
			{
				TreeNode catNode = null;

				foreach( TreeNode n in m_FacetNode.Nodes )
				{
					if ( cat.Name.ToLower() == n.Text.ToLower() )
					{
						catNode = n;
						break;
					}
				}

				if ( catNode == null )
				{
					catNode = new TreeNode( cat.Name );
					m_FacetNode.Nodes.Add( catNode );
				}

				foreach( GenericNode sub in cat.Elements )
				{
					TreeNode subNode = null;

					foreach( TreeNode n in catNode.Nodes )
					{
						if ( sub.Name.ToLower() == n.Text.ToLower() )
						{
							subNode = n;
							break;
						}
					}

					if ( subNode == null )
					{
						subNode = new TreeNode( sub.Name );
						// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
						subNode.Tag = new List<object>();
						// Issue 10 - End
					}

					catNode.Nodes.Add( subNode );

					// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
					( subNode.Tag as List<object> ).AddRange( sub.Elements );
					// Issue 10 - End
				}
			}

			CurrentLocation = null;
			tLoc.Nodes.Clear();

			tCat.EndUpdate();
		}
Esempio n. 4
0
		private void SaveAs( string FileName )
		{
			m_Facet = Facet.FromTreeNodes( m_FacetNode.Nodes, (byte) Map.Map );

			try
			{
				XmlSerializer serializer = new XmlSerializer( typeof( Facet ) );
				System.IO.FileStream stream = new System.IO.FileStream( FileName, System.IO.FileMode.Create );
				serializer.Serialize( stream, m_Facet );
				stream.Close();
			}
			catch ( Exception err )
			{
				MessageBox.Show( err.ToString() );
			}
		}
Esempio n. 5
0
		private void LoadFile( string FileName )
		{
			XmlSerializer serializer = new XmlSerializer( typeof( Facet ) );
			System.IO.FileStream stream = new System.IO.FileStream( FileName, System.IO.FileMode.Open );
			m_Facet = (Facet) serializer.Deserialize( stream );
			stream.Close();

			tCat.BeginUpdate();
			tCat.Nodes.Clear();

			m_FacetNode = m_Facet.GetTreeNode( "Facet" );

			tCat.Nodes.Add( m_FacetNode );
			tCat.SelectedNode = m_FacetNode;

			tCat.EndUpdate();			
		}
Esempio n. 6
0
		private void NewDocument()
		{
			tCat.Nodes.Clear();
			tLoc.Nodes.Clear();
			Map.Map = Maps.Felucca;

			m_Facet = new Facet();
			m_Facet.MapValue = 0;

			m_FacetNode = new TreeNode( "Facet" );
			tCat.Nodes.Add( m_FacetNode );

			LocationControls( false );
		}
Esempio n. 7
0
		/// <summary>
		/// Creates a Facet object from a collection of tree nodes
		/// </summary>
		/// <param name="nodes">The TreeNodeCollection used as source for this Facet object</param>
		/// <param name="name">The map file index corresponding to this facet</param>
		/// <returns>A Facet object representing the nodes collection</returns>
		public static Facet FromTreeNodes( TreeNodeCollection nodes, byte name )
		{
			Facet facet = new Facet();

			facet.MapValue = name;

			foreach ( TreeNode CatNode in nodes )
			{
				GenericNode Category = new GenericNode( CatNode.Text );

				foreach ( TreeNode SubNode in CatNode.Nodes )
				{
					GenericNode Subsection = new GenericNode( SubNode.Text );
					// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
					Subsection.Elements = (List<object>)SubNode.Tag;
					// Issue 10 - End

					Category.Elements.Add( Subsection );
				}

				facet.m_Nodes.Add( Category );
			}

			return facet;
		}
Esempio n. 8
0
		private void Load()
		{
			Utility.EnsureDirectory( m_BaseFolder );

			XmlSerializer serializer = new XmlSerializer( typeof( Facet ) );

			for ( int i = 0; i < Pandora.Profile.Travel.MapCount; i++ )
			{
				if ( !Pandora.Profile.Travel.EnabledMaps[ i ] )
					continue;

				Pandora.Log.WriteEntry( string.Format( "Reading locations file {0}: {1}", i, GetFile( i ) ) );

				FileStream stream = null;

				try
				{
					stream = new FileStream( GetFile( i ), FileMode.Open );
				}
				catch ( System.IO.FileNotFoundException )
				{
					Pandora.Log.WriteEntry( "Creating new data files for map {0}", i.ToString() );

					m_Facets[ i ] = new Facet();
					m_Facets[ i ].MapValue = (byte) i;

					continue;
				}
				catch ( Exception err )
				{
					Pandora.Log.WriteError( err, null );
					continue;
				}

				try
				{
					m_Facets[i] = (Facet)serializer.Deserialize(stream);
				}
				
				catch ( Exception err )
				{
					Pandora.Log.WriteError( err, null );
					continue;
				}

				m_Facets[ i ].MapValue = (byte) i;
				stream.Close();
			}
		}
Esempio n. 9
0
		/// <summary>
		/// Updates an existing facet overwriting the current one
		/// </summary>
		/// <param name="newFacet">The new facet</param>
		/// <param name="map">The map corresponding to the facet</param>
		public void UpdateFacet( Facet newFacet, int map )
		{
			m_Facets[ map ] = newFacet;
			SaveFile( map );
		}
Esempio n. 10
0
		/// <summary>
		/// Gets a TreeNode array for the full version of the tree
		/// </summary>
		/// <returns>A TreeNode arraylist. Each node is a facet node</returns>
		public TreeNode[] GetFullTree()
		{
			int count = 0;

			for ( int i = 0; i < Pandora.Profile.Travel.MapCount; i++ )
			{
				if ( Pandora.Profile.Travel.EnabledMaps[ i ] )
					count++;
			}

			TreeNode[] nodes = new TreeNode[ count ];

			int index = 0;

			for ( int i = 0; i < Pandora.Profile.Travel.MapCount; i++ )
			{
				if ( Pandora.Profile.Travel.EnabledMaps[ i ] )
				{
					if ( m_Facets[ i ] == null )
					{
						m_Facets[ i ] = new Facet();
						m_Facets[ i ].MapValue = (byte) i;
						m_FacetNames[ i ] = Pandora.Profile.Travel.MapNames[ i ];
					}

					nodes[ index ] = m_Facets[ i ].GetTreeNode( m_FacetNames[ i ] );
					nodes[ index ].Tag = (int) m_Facets[ i ].MapValue;

					index++;
				}
			}

			return nodes;
		}