Example #1
0
        public override bool DoAction()
        {
            try
            {
                WaitStart();

                if (!base.DoAction())
                {
                    return(false);
                }

                var e = new ValidateEventArgs();
                OnValidating(e);
                if (e.Cancel)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                if (!ExceptionHandler(ex, ExceptionResources.ItemCantSave))
                {
                    throw;
                }
                return(false);
            }
            finally
            {
                WaitStop();
            }
        }
Example #2
0
 protected virtual void OnFilterValidate(ValidateEventArgs e)
 {
     if (FilterValidate != null)
     {
         FilterValidate(this, e);
     }
 }
Example #3
0
        private void OnValidating(ValidateEventArgs e)
        {
            var handler = Validating;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Example #4
0
        public void SAStudent_FullName_Validate(SAStudent entity, ValidateEventArgs <string> e)
        {
            var result = IsFullNameValid(e.NewValue);

            if (result >= 0)
            {
                entity.Message(e, (uint)result);
            }
        }
Example #5
0
 private void Pv3_ValidateEvent(object sender, ValidateEventArgs e)
 {
     // We didn't specify the flag that allows system properties to be updated, all value's should be different
     if (e.PropertyName.Equals("Value", StringComparison.InvariantCultureIgnoreCase))
     {
         if (!e.SourceValue.Equals(e.TargetValue))
         {
             e.IsEqual = true;
         }
     }
 }
        public void Update(object sender, ValidateEventArgs e)
        {
            Airspace.Trackables.RemoveAll(tracks => e.NotInAirspaceButUsedToBe.Exists(tr => tr.Tag == tracks.Tag));
            List <ITrack> tempTracks = Airspace.Trackables;

            _updater.Update(ref tempTracks, e.StillInAirspace);
            Airspace.Trackables = tempTracks;
            Airspace.Trackables.AddRange(e.NewInAirspace);
            _conditionDetector.DetectCondition(Airspace);
            _outputter.TrafficController.DisplayTracks(Airspace.Trackables);
            _outputter.TrafficController.DisplayConditions(Conditions);
        }
Example #7
0
        public bool Validate()
        {
            ValidateEventArgs args = new ValidateEventArgs();

            this.GetStorage();
            _storage.Validate(args);
            errorText = args.ErrorText;
            if (args.Valid && (_storage.Values == null || _storage.Values.Length == 0) && _storage.FilterType == ColumnFilterType.In)
            {
                args.Valid = false;
                errorText  = string.Format(Resources.SRequiredFieldMessage, _storage.Caption);
            }

            return(args.Valid);
        }
Example #8
0
 private void Pv2_ValidateEvent(object sender, ValidateEventArgs e)
 {
     // If "Overwrite" was set to false then we're not updating the property, hence we need to make an exception in our comparison logic
     if (e.PropertyName.Equals("Value", StringComparison.InvariantCultureIgnoreCase))
     {
         if ((e.SourceObject as PropertyBagEntry).Overwrite == false)
         {
             // if source and target value are the same then somehow this delta update overwrote which it shouldn't
             if (!e.SourceValue.Equals(e.TargetValue))
             {
                 e.IsEqual = true;
             }
         }
     }
 }
        public void TestSetUp()
        {
            _validationCompleteEventArgs = null;

            _trackListEvent = Substitute.For <ITrackListEvent>();

            // setup Airspace to work on
            _airspace = FakeAirspaceGenerator.GetAirspace(0, 0, 0);

            // set Validator to subscribe to Interpreter(done in constructor)
            _validateTransponderData = new ValidateTransponderData(ref _trackListEvent, _airspace);

            // setup listener
            _validateTransponderData.ValidationCompleteEventHandler += (sender, args) => { _validationCompleteEventArgs = args; };
        }
Example #10
0
        private static void CustomValidate(object sender, ValidateEventArgs e)
        {
            User user = (User)sender;

            if (BusinessDomain.LoggedUser.UserLevel != UserAccessLevel.Owner &&
                user.UserLevel >= BusinessDomain.LoggedUser.UserLevel)
            {
                e.Callback(string.Format(Translator.GetString("The user \"{0}\" has higher or equal access level than current\'s one and will not be imported!"), user.Name),
                           ErrorSeverity.Error, -1, e.State);
                e.IsValid = false;
            }
            else
            {
                e.IsValid = true;
            }
        }
Example #11
0
        public static void ImportData <T> (EventHandler <ValidateEventArgs> validateCallback = null, EventHandler <ImportEventArgs> commitCallback = null, bool usesLocation = false) where T : IStrongEntity, IPersistableEntity <T>
        {
            Dictionary <int, bool> responses = new Dictionary <int, bool> ();

            using (MessageProgress progress = new MessageProgress(Translator.GetString("Importing..."), "Icons.Import24.png", Translator.GetString("Importing in progress..."))) {
                bool cancelImport = false;
                progress.Response          += delegate { cancelImport = true; };
                progress.CustomProgressText = true;

                StateHolder state = new StateHolder();
                state ["responses"]       = responses;
                state ["messageProgress"] = progress;

                ImportData(delegate(T entity, long?locationId, int current, int total, out bool cancel)
                {
                    progress.Show();
                    progress.Progress     = ((double)current * 100) / (total - 1);
                    progress.ProgressText = string.Format(Translator.GetString("{0} of {1}"), current + 1, total);
                    PresentationDomain.ProcessUIEvents();
                    cancel = cancelImport;
                    if (validateCallback != null)
                    {
                        ValidateEventArgs args = new ValidateEventArgs(InteractiveValidationCallback, state);
                        validateCallback(entity, args);
                        if (!args.IsValid)
                        {
                            return;
                        }
                    }

                    if (!entity.Validate(InteractiveValidationCallback, state))
                    {
                        return;
                    }

                    entity.CommitChanges();

                    if (commitCallback != null)
                    {
                        commitCallback(entity, new ImportEventArgs(locationId));
                    }
                }, usesLocation);
            }
        }
Example #12
0
        public Boolean Validate()
        {
            var args = new ValidateEventArgs();

            ColumnFilterStorage.Validate(args);
            errorText = args.ErrorText;
            var eventArgs = new ValidateEventArgs();

            OnFilterValidate(eventArgs);
            if (string.IsNullOrEmpty(errorText))
            {
                errorText = eventArgs.ErrorText;
            }
            else
            {
                errorText += "\r\n" + eventArgs.ErrorText;
            }
            return(args.Valid && eventArgs.Valid);
        }
Example #13
0
        public void Update_ValidationEventRaise_UpdaterInvoked()
        {
            var fakeNewList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("newTrack", 0, 0, 0)
            };
            var fakeUpdateList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("updateTrack", 0, 0, 0)
            };
            var fakeRemoveList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("removeTrack", 0, 0, 0)
            };
            var fakeEventArgs = new ValidateEventArgs(fakeNewList, fakeRemoveList, fakeUpdateList);

            _fakeValidator.ValidationCompleteEventHandler += Raise.EventWith(_fakeValidator, fakeEventArgs);


            _fakeUpdater.Received().Update(ref Arg.Any <List <ITrack> >(),
                                           Arg.Is <List <ITrack> >(trackList => trackList.Exists(t => t.Tag == "updateTrack")));
        }
Example #14
0
        public void Update_NewTrackConditionCheck_ConditionDetectorInvoked()
        {
            var fakeNewList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("newTrack", 0, 0, 0)
            };
            var fakeUpdateList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("updateTrack", 0, 0, 0)
            };
            var fakeRemoveList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("removeTrack", 0, 0, 0)
            };
            var fakeEventArgs = new ValidateEventArgs(fakeNewList, fakeRemoveList, fakeUpdateList);

            _fakeValidator.ValidationCompleteEventHandler += Raise.EventWith(_fakeValidator, fakeEventArgs);


            _fakeConditionDetector.Received().DetectCondition(Arg.Is <ITrackable>(trackList =>
                                                                                  trackList.Trackables.Exists(t => t.Tag == "newTrack")));
        }
Example #15
0
        public void Update_ValidationEventRaise_CorrectTracksRemoved()
        {
            var fakeNewList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("newTrack", 0, 0, 0)
            };
            var fakeUpdateList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("updateTrack", 0, 0, 0)
            };
            var fakeRemoveList = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("removeTrack", 0, 0, 0)
            };

            _uutAirTrafficMonitor.Airspace.Trackables.Add(FakeTrackFactory.GetTrackWithTag("removeTrack", 120, 120, 120));
            var fakeEventArgs = new ValidateEventArgs(fakeNewList, fakeRemoveList, fakeUpdateList);

            _fakeValidator.ValidationCompleteEventHandler += Raise.EventWith(_fakeValidator, fakeEventArgs);


            Assert.That(_uutAirTrafficMonitor.Airspace.Trackables.Exists(t => t.Tag == "removeTrack"), Is.False);
        }
Example #16
0
 void DialogBox_Validated(WindowedWidget sender, ValidateEventArgs e)
 {
     CallOnDialogValidate();
 }
Example #17
0
 void OnBoundingBoxCreatorAddValidation(WindowedWidget sender, ValidateEventArgs e)
 {
     EBoundingBox BB = e.GetArg<EBoundingBox>("BoundingBox");
     BB.Holder = CurrentSelectedObject;
     CurrentSelectedObject.AddEventBoundingBox(BB, EventBoundingBoxType.External);
     AddBoundingBoxToCurrentSelectedObject(BB);
 }
Example #18
0
        void OnObjectCreatorValidated(WindowedWidget sender, ValidateEventArgs e)
        {
            WorldObject wObj = e.GetArg<WorldObject>("Object");
            wObj.ToScript();

            AddType(e.GetArg<WorldObjectBaseType>("BaseType"), wObj.Type);
        }
Example #19
0
        void CurrentWarpPointPointCreator_Validated(WindowedWidget sender, ValidateEventArgs e)
        {
            WarpPoint newWarpPoint = e.GetArg<WarpPoint>("WarpPoint");

            WarpPoints[CurrentWarpPointButton] = newWarpPoint;

            Maps[CurrentMap.Type].SetWarpPoint(CurrentWarpPoint.Name, newWarpPoint, e.GetArg<Boolean>("Default"));
            CurrentWarpPoint = newWarpPoint;
            CurrentWarpPointButton.Text = WarpPointCreator.Instance.WarpPointToString(CurrentWarpPoint);
        }
Example #20
0
        void OnActionCreatorEditValidated(WindowedWidget sender, ValidateEventArgs e)
        {
            BlazeraLib.Action action = e.GetArg<BlazeraLib.Action>("Action");

            CurrentEditedActionButton.Text = ActionCreator.Instance.ActionToString(action);
            Actions[CurrentEditedActionButton] = action;
        }
Example #21
0
 void OnTileManEditValidated(WindowedWidget sender, ValidateEventArgs e)
 {
     CurrentTileList.Remove(CurrentEditedTileContainer.CurrentTile);
     Tile tile = e.GetArg<Tile>("Tile");
     CurrentEditedTileContainer.SetContent(tile);
     CurrentTileList.Add(CurrentEditedTileContainer.CurrentTile);
 }
Example #22
0
        /// <summary>
        /// Validate method performs the validation process and allows overriding
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public virtual void Validate(object sender, ValidateEventArgs e)
        {
            //Initialise the error collection
            Errors.Clear();

            //Enable calling the OnValidate event before validation takes place
            if (this.OnValidate != null)
            {
                this.OnValidate(this, new ValidateEventArgs());
            }
            try
            {
                foreach (PropertyInfo info in this.GetType().GetProperties())
                {
                    /* Get property value assigned to property */
                    object data = info.GetValue(this, null);

                    /* Set Default value if value is empty */
                    foreach (object customAttribute in info.GetCustomAttributes(typeof(DefaultValueAttribute), true))
                    {
                        if (data == null)
                        {
                            info.SetValue(this, (customAttribute as DefaultValueAttribute).Default, null);
                            data = info.GetValue(this, null);
                        }
                    }

                    /* Check if property value is required */
                    foreach (object customAttribute in info.GetCustomAttributes(typeof(RequiredAttribute), true))
                    {
                        if (string.IsNullOrEmpty((string)data))
                        {
                            Errors.Add(new Error(this, info.Name, string.IsNullOrEmpty((customAttribute as RequiredAttribute).ErrorMessage) ? string.Format("{0} is required", info.Name) : (customAttribute as RequiredAttribute).ErrorMessage));
                        }
                    }

                    /* Evaluate whether the property value lies within range */
                    foreach (object customAttribute in info.GetCustomAttributes(typeof(InRangeAttribute), true))
                    {
                        if (!(((IComparable)data).CompareTo((customAttribute as InRangeAttribute).Min) > 0) ||
                            !(((IComparable)data).CompareTo((customAttribute as InRangeAttribute).Max) < 0))
                        {
                            Errors.Add(new Error(this, info.Name, string.IsNullOrEmpty((customAttribute as InRangeAttribute).ErrorMessage) ? string.Format("{0} is out of range", info.Name) : (customAttribute as InRangeAttribute).ErrorMessage));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //
                throw new Exception("Could not validate Object!", ex);
            }
            finally
            {
                //Enable calling the OnValidated event after validation has taken place
                if (this.OnValidated != null)
                {
                    this.OnValidated(this, new ValidateEventArgs());
                }
            }
        }
Example #23
0
 private void ValidateEvent(Validator <CustomerViewmodel> sender, CustomerViewmodel viewmodel, ValidateEventArgs <CustomerViewmodel> e)
 {
     if (e.IsProperty(vm => vm.CountryCode))
     {
         CountryCodeHelper.Validate(e, viewmodel.CountryCode);
     }
 }
Example #24
0
 void OnTextureManValidated(WindowedWidget sender, ValidateEventArgs e)
 {
     TextureButton.Text = e.GetArg<Texture>("Texture").Type;
 }
Example #25
0
 void OnTextureManValidated(WindowedWidget sender, ValidateEventArgs e)
 {
     CurrentTileSetTexture = e.GetArg<BlazeraLib.Texture>("Texture");
     TextureButton.Text = CurrentTileSetTexture.Type;
 }
Example #26
0
 void OnPointCreatorValidated(WindowedWidget sender, ValidateEventArgs e)
 {
     CurrentPoint = new Vector2f(e.GetArg<Int32>("X"), e.GetArg<Int32>("Y"));
     PointButton.Text = PointCreator.Instance.PointToString(CurrentPoint);
 }
Example #27
0
        void OnTileManAddValidated(WindowedWidget sender, ValidateEventArgs e)
        {
            Tile tile = e.GetArg<Tile>("Tile");

            AddTile(tile);

            TileSelector.AddTile(tile, OnTileClick);
        }
Example #28
0
 void OnTileSetManSelectValidated(WindowedWidget sender, ValidateEventArgs e)
 {
     TileSelector.SetTileSet(e.GetArg<TileSet>("TileSet"), tileContainer_Clicked);
 }
Example #29
0
 void OnActionCreatorAddValidated(WindowedWidget sender, ValidateEventArgs e)
 {
     AddAction(e.GetArg<BlazeraLib.Action>("Action"));
 }
Example #30
0
 void OnObjectManSelectPencilValidated(WindowedWidget sender, ValidateEventArgs e)
 {
     ObjectPencil.Instance.SetCurrentObject(e.GetArg<WorldObject>("Object"));
 }
Example #31
0
 void AddWarpPointCreator_Validated(WindowedWidget sender, ValidateEventArgs e)
 {
     AddWarpPoint(e.GetArg<WarpPoint>("WarpPoint"), true, e.GetArg<Boolean>("Default"));
 }
Example #32
0
        void OnBoundingBoxCreatorEditValidated(WindowedWidget sender, ValidateEventArgs e)
        {
            CurrentSelectedObject.RemoveEventBoundingBox(CurrentSelectedObjectExternalBoundingBoxes[CurrentEditedBBButton], EventBoundingBoxType.External);

            EBoundingBox BB = e.GetArg<EBoundingBox>("BoundingBox");
            BB.Holder = CurrentSelectedObject;

            CurrentSelectedObject.AddEventBoundingBox(BB, EventBoundingBoxType.External);

            CurrentEditedBBButton.Text = BoundingBoxCreator.Instance.BBToString(BB);
            CurrentSelectedObjectExternalBoundingBoxes[CurrentEditedBBButton] = BB;
        }
Example #33
0
        void MapCreator_Validated(WindowedWidget sender, ValidateEventArgs e)
        {
            Map map = e.GetArg<Map>("Map");

            map.ToScript();

            RefreshMaps();
        }
Example #34
0
 void PointCreator_Validated(WindowedWidget sender, ValidateEventArgs e)
 {
     Log.Cl("Point : (" + e.GetArg<Int32>("X") + ", " + e.GetArg<Int32>("Y") + ")");
 }
 public void Update(object sender, ValidateEventArgs e)
 {
     NewInAirspace      = e.NewInAirspace;
     StillInAirspace    = e.StillInAirspace;
     UsedToBeInAirspace = e.NotInAirspaceButUsedToBe;
 }
        private void ValidateEvent(Validator <OrderViewmodel> sender, OrderViewmodel viewmodel, ValidateEventArgs <OrderViewmodel> e)
        {
            if (e.IsProperty(vm => vm.CustomerID))
            {
                CustomerIdHelper.Validate(e, viewmodel.CustomerID);
            }
            else if (e.IsProperty(vm => vm.ShippedDate))
            {
                if (viewmodel.ShippedDate != null && viewmodel.ShippedDate.Value.Year < 2019)
                {
                    e.Remark = "The date is not correct.";
                    return;
                }

                e.IsValid = true;
            }
            else if (e.IsProperty(vm => vm.ShipCountryCode))
            {
                CountryCodeHelper.Validate(e, viewmodel.ShipCountryCode);
            }
        }