public override void NotifyOfPropertyChange(string propertyName = "") { base.NotifyOfPropertyChange(propertyName); switch (propertyName) { case "SliderValue": int curIdx = findViewMode(ViewModes, SliderValue); string viewMode; int step; int itemHeight; parseViewMode(ViewModes[curIdx], out viewMode, out step, out itemHeight); ViewModeStepCommandModel commandModel = SubCommands .Where(c => c is ViewModeStepCommandModel) .First(c => (c as ViewModeStepCommandModel).SliderStep == step) as ViewModeStepCommandModel; if (commandModel != null) { this.HeaderIconExtractor = commandModel.HeaderIconExtractor; } if (_flvm.Parameters.ItemSize != SliderValue) { updateViewMode(_flvm, commandModel.Header, SliderValue); //Debug.WriteLine(commandModel.Header + SliderValue.ToString()); } break; } }
public override void Execute(params object[] executeArgs) { //Check the condition, if success, the execute `if` block //If failed, then search the SubCommands, find the `elseif` block and check one by one //If no matched the `elseif` block, the find the `else` block and execute if (CheckCondition()) { var commands = SubCommands.Where(o => !(o is ElseIfScriptCommand) && !(o is ElseScriptCommand)); foreach (var command in commands) { command.Execute(executeArgs); } } else { var elseIfCommands = SubCommands.Where(o => o is ElseIfScriptCommand); foreach (var command in elseIfCommands) { if ((command as ConditionalScriptCommand).CheckCondition()) { command.Execute(executeArgs); return; } } var elseCommand = SubCommands.Where(o => o is ElseScriptCommand).FirstOrDefault(); if (elseCommand != null) { elseCommand.Execute(executeArgs); } } }