Server.Gumps.SetTimeSpanGump.OnResponse C# (CSharp) Méthode

OnResponse() public méthode

public OnResponse ( Server.Network.NetState sender, RelayInfo info ) : void
sender Server.Network.NetState
info RelayInfo
Résultat void
		public override void OnResponse( NetState sender, RelayInfo info )
		{
			TimeSpan toSet;
			bool shouldSet, shouldSend;

			TextRelay h = info.GetTextEntry( 0 );
			TextRelay m = info.GetTextEntry( 1 );
			TextRelay s = info.GetTextEntry( 2 );

			switch ( info.ButtonID )
			{
				case 1: // Zero
				{
					toSet = TimeSpan.Zero;
					shouldSet = true;
					shouldSend = true;

					break;
				}
				case 2: // From H:M:S
				{
					bool successfulParse = false;
					if( h != null && m != null && s != null )
					{
						successfulParse = TimeSpan.TryParse( h.Text + ":" + m.Text + ":" + s.Text, out toSet );
					}
					else
					{
						toSet = TimeSpan.Zero;
					}

					shouldSet = shouldSend = successfulParse;

					break;
				}
				case 3: // From H
				{
					if ( h != null )
					{
						try
						{
							toSet = TimeSpan.FromHours( Utility.ToDouble( h.Text ) );
							shouldSet = true;
							shouldSend = true;

							break;
						}
						catch
						{
						}
					}

					toSet = TimeSpan.Zero;
					shouldSet = false;
					shouldSend = false;

					break;
				}
				case 4: // From M
				{
					if ( m != null )
					{
						try
						{
							toSet = TimeSpan.FromMinutes( Utility.ToDouble( m.Text ) );
							shouldSet = true;
							shouldSend = true;

							break;
						}
						catch
						{
						}
					}

					toSet = TimeSpan.Zero;
					shouldSet = false;
					shouldSend = false;

					break;
				}
				case 5: // From S
				{
					if ( s != null )
					{
						try
						{
							toSet = TimeSpan.FromSeconds( Utility.ToDouble( s.Text ) );
							shouldSet = true;
							shouldSend = true;

							break;
						}
						catch
						{
						}
					}

					toSet = TimeSpan.Zero;
					shouldSet = false;
					shouldSend = false;

					break;
				}
				default:
				{
					toSet = TimeSpan.Zero;
					shouldSet = false;
					shouldSend = true;

					break;
				}
			}

			if ( shouldSet )
			{
				try
				{
					CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet.ToString() );
					m_Property.SetValue( m_Object, toSet, null );
					PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
				}
				catch
				{
					m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
				}
			}

			if ( shouldSend )
				m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
		}
	}