Exemplo n.º 1
0
        ///<summary>
        /// Deletes the given business object
        ///</summary>
        ///<param name="businessObject">The business object to delete</param>
        public void DeleteBusinessObject(IBusinessObject businessObject)
        {
            string message;

            if (CustomConfirmationMessageDelegate != null)
            {
                message = CustomConfirmationMessageDelegate(businessObject);
            }
            else
            {
                message = string.Format("Are you certain you want to delete the object '{0}'", businessObject);
            }
            Confirmer.Confirm(message, delegate(bool confirmed)
            {
                if (!confirmed)
                {
                    return;
                }
                var defaultBODeletor = new DefaultBODeletor();
                try
                {
                    defaultBODeletor.DeleteBusinessObject(businessObject);
                }
                catch (Exception ex)
                {
                    GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error Deleting");
                }
            });
        }
Exemplo n.º 2
0
 //when two player trains connected, require decouple at speed 0.
 public static bool TrainOK2Decouple(Confirmer confirmer, Train t)
 {
     if (t == null)
     {
         return(false);
     }
     if (Math.Abs(t.SpeedMpS) < 0.001)
     {
         return(true);
     }
     try
     {
         var count = 0;
         foreach (var p in OnlineTrains.Players.Keys)
         {
             string p1 = p + " ";
             foreach (var car in t.Cars)
             {
                 if (car.CarID.Contains(p1))
                 {
                     count++;
                 }
             }
         }
         if (count >= 2)
         {
             if (confirmer != null)
             {
                 confirmer.Information(MPManager.Catalog.GetPluralStringFmt("Cannot decouple: train has {0} player, need to completely stop.", "Cannot decouple: train has {0} players, need to completely stop.", count));
             }
             return(false);
         }
     }
     catch { return(false); }
     return(true);
 }