Exemple #1
0
		public QuickLocation()
		{
			InitializeComponent();

			Pandora.Localization.LocalizeControl( this );

			txName.Text = "";
			m_CurrentLocation = new Location();
		}
Exemple #2
0
        private static TheBox.Data.Location Convert(Location loc)
        {
            var newLoc = new TheBox.Data.Location();

            newLoc.Name = loc.Name;
            newLoc.Map  = loc.Map;
            newLoc.X    = loc.x;
            newLoc.Y    = loc.y;
            newLoc.Z    = (sbyte)loc.z;

            return(newLoc);
        }
Exemple #3
0
        private void bAddLoc_Click(object sender, EventArgs e)
        {
            var parent = tCat.SelectedNode;

            if (parent.Tag == null)
            {
                return;
            }

            var x   = 0;
            var y   = 0;
            var z   = 0;
            var map = 0;

            var loc = new Location();

            loc.Name = txLoc.Text;

            if (rClient.Checked)
            {
                Client.Calibrate();
                Client.FindLocation(ref x, ref y, ref z, ref map);
            }
            else if (rMap.Checked)
            {
                map = (int)m_Map.Map;
                x   = m_Map.Center.X;
                y   = m_Map.Center.Y;
                z   = m_Map.GetMapHeight();
            }

            loc.X   = (short)x;
            loc.Y   = (short)y;
            loc.Z   = (sbyte)z;
            loc.Map = map;

            var node = new TreeNode(loc.Name);

            node.Tag = loc;
            tLoc.Nodes.Add(node);
            tLoc.SelectedNode = node;

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

            txLoc.Clear();
            txLoc.Focus();

            m_Changed = true;
            EnableButtons();
        }
Exemple #4
0
		/// <summary>
		/// LOC TREE: After select
		/// </summary>
		private void tLoc_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			if ( tLoc.SelectedNode == null )
			{
				return;
			}

//			// Verify the currently loaded list corresponds to the node selected on the category
//			if ( tCat.SelectedNode == null || tCat.SelectedNode.Tag == null || ! ( tCat.SelectedNode.Tag is ArrayList ) )
//			{
//				return;
//			}
//			else
//			{
//				int index = tLoc.Nodes.IndexOf( tLoc.SelectedNode );
//
//				if ( ( ( ( tCat.SelectedNode.Tag as ArrayList )[ index ] ) as Location ) != ( tLoc.SelectedNode.Tag as Location ) )
//				{
//					return;
//				}
//			}

			if ( !Pandora.Profile.Travel.SelectedMapLocations )
			{
				TreeNode node = tCat.SelectedNode;

				while ( node.Tag == null || node.Tag.GetType() != typeof( int ) )
				{
					node = node.Parent;
				}

				Pandora.Map.Map = (MapViewer.Maps) m_Maps[ tCat.Nodes.IndexOf( node ) ];
			}

			SelectedLocation = tLoc.SelectedNode.Tag as Location;
			chkSynch.Checked = false;
		}
Exemple #5
0
		/// <summary>
		/// Create a new location. It's assumed a cat/subsection is already selected
		/// </summary>
		private void mLocNew_Click(object sender, System.EventArgs e)
		{
			TheBox.Data.Location location = new Location();
			location.X = (short) m_X;
			location.Y = (short) m_Y;
			location.Z = (sbyte) m_Z;

			TheBox.Forms.Editors.QuickLocation quickLoc = new TheBox.Forms.Editors.QuickLocation();

			EnsureMap();

			quickLoc.MapFile = m_Map;
			quickLoc.CurrentLocation = location;

			if ( quickLoc.ShowDialog() == DialogResult.OK )
			{
				// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
				List<object> list = tCat.SelectedNode.Tag as List<object>;
				// Issue 10 - End

				if ( list != null )
				{
					list.Add( quickLoc.CurrentLocation );
					list.Sort();

					int index = list.IndexOf( quickLoc.CurrentLocation );

					TreeNode node = tCat.SelectedNode;
					tCat.SelectedNode = null;
					tCat.SelectedNode = node;

					tLoc.SelectedNode = tLoc.Nodes[ index ];

					UpdateMap();
				}
				else
				{
					Pandora.Log.WriteError( null, string.Format( "Couldn't add location because the tCat node wasn't a subsection node" ) );
					MessageBox.Show( Pandora.Localization.TextProvider[ "Messages.NewLocErr" ] );
				}
			}
		}
		private void bAddLoc_Click(object sender, System.EventArgs e)
		{
			TreeNode parent = tCat.SelectedNode;

			if ( parent.Tag == null )
				return;

			int x = 0;
			int y = 0;
			int z = 0;
			int map = 0;

			Location loc = new Location();
			loc.Name = txLoc.Text;

			if ( rClient.Checked )
			{
				Ultima.Client.Calibrate();
				Ultima.Client.FindLocation( ref x, ref y, ref z, ref map );
			}
			else if ( rMap.Checked )
			{
				map = (int) m_Map.Map;
				x = m_Map.Center.X;
				y = m_Map.Center.Y;
				z = m_Map.GetMapHeight();
			}

			loc.X = (short) x;
			loc.Y = (short) y;
			loc.Z = ( sbyte) z;
			loc.Map = map;

			TreeNode node = new TreeNode( loc.Name );
			node.Tag = loc;
			tLoc.Nodes.Add( node );
			tLoc.SelectedNode = node;

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

			txLoc.Clear();
			txLoc.Focus();

			m_Changed = true;
			EnableButtons();
		}
Exemple #7
0
		private void tLoc_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			tLoc.SelectedNode.BackColor = SystemColors.Highlight;
			tLoc.SelectedNode.ForeColor = SystemColors.HighlightText;

			CurrentLocation = tLoc.SelectedNode.Tag as Location;
		}
Exemple #8
0
		private void bAddLoc_Click(object sender, System.EventArgs e)
		{
			string name = txNewLoc.Text;

			if ( name.Length == 0 )
			{
				MessageBox.Show( "Please enter a name for the new location" );
				return;
			}

			if ( CheckForDuplicates( tLoc.Nodes, name ) )
			{
				MessageBox.Show( string.Format( "A location called {0} already exists", name ) );
				return;
			}

			Location loc = new Location();
			loc.Name = name;

			TreeNode tNode = new TreeNode( name );
			tNode.Tag = loc;

			// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
			( (List<object>) tCat.SelectedNode.Tag ).Add( loc );
			// Issue 10 - End

			tLoc.Nodes.Add( tNode );

			tLoc.SelectedNode = tNode;

			txNewLoc.Text = "";
			txNewLoc.Focus();

			m_Updated = true;
		}
Exemple #9
0
		private void tCat_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			tCat.SelectedNode.BackColor = SystemColors.Highlight;
			tCat.SelectedNode.ForeColor = SystemColors.HighlightText;

			if ( tCat.SelectedNode.Parent != null && tCat.SelectedNode.Parent != m_FacetNode )
			{
				NewLocationControls( true );

				tLoc.BeginUpdate();
				tLoc.Nodes.Clear();
				// Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert
				tLoc.Nodes.AddRange( TheBox.Data.Location.ArrayToNodes( (List<object>) tCat.SelectedNode.Tag ) );
				// Issue 10 - End
				tLoc.EndUpdate();

				if ( tLoc.Nodes.Count > 0 )
				{
					tLoc.SelectedNode = tLoc.Nodes[ 0 ];
					CurrentLocation = tLoc.SelectedNode.Tag as Location;
					LocationControls( true );
				}
				else
				{
					LocationControls( false );
				}
			}
			else
			{
				tLoc.Nodes.Clear();

				NewLocationControls( false );

				LocationControls( false );
			}
		}
Exemple #10
0
		/// <summary>
		/// Removes a location from the list
		/// </summary>
		/// <param name="loc">The location object that should be deleted</param>
		/// <param name="category">The category it belongs to</param>
		/// <param name="subsection">The subsection parent of the location</param>
		public void DeleteLocation( Location loc, string category, string subsection )
		{
			foreach ( GenericNode cat in m_Nodes )
			{
				if ( cat.Name.ToLower() == category.ToLower() )
				{
					foreach ( GenericNode sub in ( cat.Elements ) )
					{
						if ( sub.Name.ToLower() == subsection.ToLower() )
						{
							foreach ( Location l in sub.Elements )
							{
								if ( l == loc )
								{
									sub.Elements.Remove( loc );
									return;
								}
							}
						}
					}
				}
			}
		}
Exemple #11
0
		/// <summary>
		/// Adds a new location to this facet
		/// </summary>
		/// <param name="loc">The location that should be added</param>
		/// <param name="category">The category name for the new location</param>
		/// <param name="subsection">The subsection name for the new location</param>
		public void AddLocation( Location loc, string category, string subsection )
		{
			GenericNode catNode = null;

			foreach ( GenericNode cat in m_Nodes )
			{
				if ( cat.Name.ToLower() == category.ToLower() )
				{
					catNode = cat;
					break;
				}
			}

			if ( catNode == null )
			{
				catNode = new GenericNode( category );
				m_Nodes.Add( catNode );
			}

			GenericNode subNode = null;

			foreach( GenericNode sub in catNode.Elements )
			{
				if ( sub.Name.ToLower() == subsection.ToLower() )
				{
					subNode = sub;
					break;
				}
			}

			if ( subNode == null )
			{
				subNode = new GenericNode( subsection );
				catNode.Elements.Add( subNode );
			}

			subNode.Elements.Add( loc );
		}