public ChainModel VisualizerFor(Guid uniqueId) { var chain = _graph .Behaviors .SingleOrDefault(c => c.UniqueId == uniqueId); if (chain == null) { return(null); } return(new ChainModel { Chain = chain, Constraints = _constraintResolver.Resolve(chain), Behaviors = chain.Select(x => { var behavior = new BehaviorModel { Id = x.UniqueId, DisplayType = x.GetType().PrettyPrint(), BehaviorType = x.ToString(), BehaviorLabel = BuildLabel(x) }; var call = x as ActionCall; if (call != null) { behavior.Logs = _graph.Observer.GetLog(call); } return behavior; }) }); }
public ChainModel Execute(ChainRequest request) { var chain = _graph.Behaviors.SingleOrDefault(c => c.UniqueId == request.Id); if(chain == null) { throw new ArgumentException("{0} does not exist".ToFormat(request.Id)); } return new ChainModel { Chain = chain, Constraints = _constraintResolver.Resolve(chain), Behaviors = chain.Select(x => { var behavior = new BehaviorModel {BehaviorType = x.ToString()}; var call = x as ActionCall; if(call != null) { behavior.Logs = _graph.Observer.GetLog(call); } return behavior; }) }; }
public ChainModel Get(ChainRequest request) { var chain = _graph.Behaviors.SingleOrDefault(c => c.UniqueId == request.Id); if (chain == null) { throw new UnknownObjectException(request.Id); } return(new ChainModel { Chain = chain, Constraints = _constraintResolver.Resolve(chain), Behaviors = chain.Select(x => { var behavior = new BehaviorModel { BehaviorType = x.ToString() }; var call = x as ActionCall; if (call != null) { behavior.Logs = _graph.Observer.GetLog(call); } return behavior; }) }); }
public void Merge(BehaviorModel behavior) { if (lookAtPlayer.HasValue) { behavior.LookAtPlayer = lookAtPlayer.Value; } }
public static ActorModel Load(FigureDefinition definition, string initialAnimationName) { AnimationModel animationModel = AnimationModel.Load(definition, initialAnimationName); BehaviorModel behaviorModel = new BehaviorModel(); return(new ActorModel(definition, animationModel, behaviorModel)); }
async Task SaveBehaviorAsync() { BehaviorModel Behavior_To_Add = new BehaviorModel { Id = Guid.NewGuid().ToString(), Name = Name, Active = true, Description = Description, Task = Type }; // adds patient to our patient collection PatientViewModel.StaticBehavior.Add(Behavior_To_Add); // gets our teacher id string patient_id = PatientViewModel.StaticPatient.Id; // creates new data base object to save our patient DatabaseCommunication DatabaseComm = new DatabaseCommunication(); await DatabaseComm.saveGenericModelUpdateRelationFinalTable <BehaviorModel, PatientBehaviorModel>(Behavior_To_Add, patient_id); // Clears the input so that user doesn't have to delete characters to add // another patient Name = ""; Description = ""; }
public PaymentConfiguration Load(ISqlConnectionInfo connection, BehaviorModel behaviorModel) { SqlQueryParameters parameters = new SqlQueryParameters(); parameters.Where = "[pc].BehaviorModelID = @BehaviorModelID"; parameters.Arguments.Add("BehaviorModelID", behaviorModel.ID); return(this.Load(connection, parameters)); }
public PaymentConfiguration CreateInstance(PaymentProvider paymentProvider, BehaviorModel behaviorModel) { if (!this.HasData) { return(null); } return(new PaymentConfiguration(this.PaymentConfigurationID, new PaymentCredentials(this.PaymentCredentialsID), new PaymentInterface(this.PaymentInterfaceID), paymentProvider ?? new PaymentProvider(this.PaymentProviderID), behaviorModel ?? new BehaviorModel(this.BehaviorModelID), this.Name, this.Updated, this.Created)); }
/// <summary> /// Initializes a new instance of the <see cref="HeaderCell"/> class. /// </summary> /// <param name="value">The value.</param> /// <param name="p_VisualModel">The visual model.</param> /// <param name="p_HeaderBehavior">The header behavior.</param> public HeaderCell(object value, VisualModels.IVisualModel p_VisualModel, BehaviorModel.IBehaviorModel p_HeaderBehavior) : base(value) { VisualModel = p_VisualModel; if (p_HeaderBehavior != null) { BehaviorModels.Add(p_HeaderBehavior); } }
public PaymentConfiguration Load(IConnectionInfo connection, BehaviorModel behaviorModel) { ISqlConnectionInfo sqlConnection = connection as ISqlConnectionInfo; if (sqlConnection != null) { return(this.Load(sqlConnection, behaviorModel)); } using (sqlConnection = new SqlConnectionInfo(connection, this.Type)) return(this.Load(sqlConnection, behaviorModel)); }
public long Add(BehaviorModel model) { var result = Execute <long>(() => { model.KeyId = Guid.NewGuid(); model.CreatedAt = model.UpdatedAt = DateTime.Now; return(_repository.Add(model)); }); return(result.Data); }
public ActorModel(FigureDefinition mainDefinition, AnimationModel animation, BehaviorModel behavior) { this.mainDefinition = mainDefinition; this.animation = animation; this.behavior = behavior; inputs = mainDefinition.ChannelSystem.MakeZeroChannelInputs(); //hack to turn on eCTRLConfident at start mainDefinition.ChannelSystem.ChannelsByName["eCTRLConfident?value"].SetValue(inputs, 1); }
public StandardProceduralAnimator(FigureDefinition definition, BehaviorModel behaviorModel) { var channelSystem = definition.ChannelSystem; var boneSystem = definition.BoneSystem; animators = new IProceduralAnimator[] { //new HeadLookAtAnimator(channelSystem, boneSystem), new EyeLookAtAnimator(channelSystem, boneSystem, behaviorModel), new BreastGravityAnimator(channelSystem, boneSystem), new BlinkAnimator(channelSystem), //new ExpressionAnimator(channelSystem), //new SpeechAnimator(channelSystem, boneSystem) }; }
public EyeLookAtAnimator(ChannelSystem channelSystem, BoneSystem boneSystem, BehaviorModel behaviorModel) { this.channelSystem = channelSystem; this.boneSystem = boneSystem; this.behaviorModel = behaviorModel; leftEyeBone = boneSystem.BonesByName["lEye"]; rightEyeBone = boneSystem.BonesByName["rEye"]; eyeParentBone = leftEyeBone.Parent; if (eyeParentBone != rightEyeBone.Parent) { throw new Exception("expected eyes to have same parent"); } }
protected void FireEvent(BehaviorModel behaviorModel, string eventName) { ActionModel actionModel = behaviorModel.Actions[eventName]; try { KeyAction keyAction = TempApplication.Container.ResolveNamed <KeyAction>(actionModel.Type, new NamedParameter("parameters", actionModel.Parameters)); keyAction.StartAction(); } catch (Exception e) { throw; throw new ActionNotFoundException(actionModel.Type); } }
public void InitStates() { Behavior = Manager.Behaviors.Resolve(Type); if (Behavior != null) { #if DEBUG Program.Print(PrintType.Debug, $"Behavior resolved for <{Type}> <{Desc.DisplayId}>"); #endif StateCooldown = new Dictionary <int, int>(); StateObject = new Dictionary <int, object>(); CurrentStates = new List <State>(); Dictionary <int, State> states = Behavior.States; while (states != null) { if (states.Count > 0) { CurrentStates.Add(states.Values.First()); states = CurrentStates.Last().States; } else { states = null; } } foreach (State s in CurrentStates) { foreach (Behavior b in s.Behaviors) { b.Enter(this); } foreach (Transition t in s.Transitions) { t.Enter(this); } } foreach (Behavior b in Behavior.Behaviors) { b.Enter(this); } } }
public static List <BehaviorModel> GetBehavior(string dbName, string userId, string time) { StringBuilder sb = new StringBuilder(); sb.Append("select"); sb.Append(" "); sb.Append("a.u_f_log_id,a.access_time,a.fun_id,b.user_code"); sb.Append(" "); sb.Append("from"); sb.Append(" "); sb.Append("tl_user_function_log a"); sb.Append(" "); sb.Append("left join sys_user b on a.user_id = b.user_id"); sb.Append(" "); sb.Append("where"); sb.Append(" "); sb.Append(string.Format("a.user_id = '{0}' and a.access_time>{1}", userId, time)); List <BehaviorModel> lists = new List <BehaviorModel>(); //当前在线用户 DataTable dt = DataHelper.GetDataTable(dbName, sb.ToString()); if (dt != null) { foreach (DataRow dr in dt.Rows) { BehaviorModel bm = new BehaviorModel(); bm.uOperId = dr["u_f_log_id"].ToString(); bm.comName = GlobalStaticObj_Server.Instance.ComName; bm.comCode = GlobalStaticObj_Server.Instance.ComID; bm.setbookName = dbName; bm.watchTime = dr["access_time"].ToString(); bm.userCode = dr["user_code"].ToString(); bm.onlineType = dr["fun_id"].ToString(); bm.tbUserOnlineId = dr["fun_id"].ToString(); lists.Add(bm); } } return(lists); }
async void BehaviorTappedAsync(object sender, ItemTappedEventArgs args) { BehaviorModel Behavior = (BehaviorModel)args.Item; BehaviorViewModel.StaticBehavior = Behavior; if (Behavior.Task.Equals("Duration")) { await Navigation.PushAsync(new DurationTaskView()); } if (Behavior.Task.Equals("Frequency")) { await Navigation.PushAsync(new FrequencyTaskView()); } if (Behavior.Task.Equals("PassFail")) { await Navigation.PushAsync(new PassFailTaskView()); } //await Navigation.PushAsync(new BehaviorView()); OnPropertyChanged(); }
/// <summary> /// 删除 /// </summary> /// <param name="model"></param> /// <returns></returns> public int?Delete(BehaviorModel model) { return(model.Delete()); }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public string Add(BehaviorModel model) { return(model.Insert()); }
public override void OnKeyUp(DeviceModel device, int key, BehaviorModel behavior, KeyHistoryModel keyHistory) { FireEvent(behavior, keyHistory.LastDown.AddMilliseconds(_holdDelay) < DateTime.Now ? "hold" : "press"); }
public override void OnKeyDown(DeviceModel device, int key, BehaviorModel behavior, KeyHistoryModel keyHistory) { }
public LookAtPlayerMenuItem(BehaviorModel model) { this.model = model; }
public BehaviorMenuLevel(BehaviorModel model) { this.model = model; }
/// <summary> /// Initializes a new instance of the <see cref="HeaderCell"/> class. /// </summary> /// <param name="p_VisualModel">The visual model.</param> /// <param name="p_HeaderBehavior">The header behavior.</param> protected HeaderCell(VisualModels.IVisualModel p_VisualModel, BehaviorModel.IBehaviorModel p_HeaderBehavior) { VisualModel = p_VisualModel; if (p_HeaderBehavior != null) { BehaviorModels.Add(p_HeaderBehavior); } }
protected override PaymentConfiguration LoadInternal(ISqlConnectionInfo connection, int id) { IDatabase database = connection.Database; if (database == null) { throw new ArgumentNullException("database", "Error initializing database connection."); } string sqlCmdText = string.Empty; try { sqlCmdText = "SELECT " + PaymentConfigurationTable.GetColumnNames("[pc]") + (this.Depth > 0 ? "," + PaymentCredentialsTable.GetColumnNames("[pc_pc]") : string.Empty) + (this.Depth > 0 ? "," + PaymentInterfaceTable.GetColumnNames("[pc_pi]") : string.Empty) + (this.Depth > 0 ? "," + PaymentProviderTable.GetColumnNames("[pc_pp]") : string.Empty) + (this.Depth > 0 ? "," + BehaviorModelTable.GetColumnNames("[pc_bm]") : string.Empty) + " FROM [core].[PaymentConfiguration] AS [pc] "; if (this.Depth > 0) { sqlCmdText += "INNER JOIN [core].[PaymentCredentials] AS [pc_pc] ON [pc].[PaymentCredentialsID] = [pc_pc].[PaymentCredentialsID] "; } if (this.Depth > 0) { sqlCmdText += "INNER JOIN [core].[PaymentInterface] AS [pc_pi] ON [pc].[PaymentInterfaceID] = [pc_pi].[PaymentInterfaceID] "; } if (this.Depth > 0) { sqlCmdText += "INNER JOIN [core].[PaymentProvider] AS [pc_pp] ON [pc].[PaymentProviderID] = [pc_pp].[PaymentProviderID] "; } if (this.Depth > 0) { sqlCmdText += "INNER JOIN [core].[BehaviorModel] AS [pc_bm] ON [pc].[BehaviorModelID] = [pc_bm].[BehaviorModelID] "; } sqlCmdText += "WHERE [pc].[PaymentConfigurationID] = @PaymentConfigurationID;"; SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand; sqlCmd.Parameters.AddWithValue("@PaymentConfigurationID", id); SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader; if (!sqlReader.HasRows || !sqlReader.Read()) { IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "loadinternal", "notfound"), "PaymentConfiguration could not be loaded by id as it was not found.", sqlCmdText, this, connection, id); if (this.Logger.IsWarnEnabled) { this.Logger.Warn(builder.ToString()); } sqlReader.Close(); return(null); } SqlQuery query = new SqlQuery(sqlReader); PaymentConfigurationTable pcTable = new PaymentConfigurationTable(query); PaymentCredentialsTable pc_pcTable = (this.Depth > 0) ? new PaymentCredentialsTable(query) : null; PaymentInterfaceTable pc_piTable = (this.Depth > 0) ? new PaymentInterfaceTable(query) : null; PaymentProviderTable pc_ppTable = (this.Depth > 0) ? new PaymentProviderTable(query) : null; BehaviorModelTable pc_bmTable = (this.Depth > 0) ? new BehaviorModelTable(query) : null; PaymentCredentials pc_pcObject = (this.Depth > 0) ? pc_pcTable.CreateInstance() : null; PaymentInterface pc_piObject = (this.Depth > 0) ? pc_piTable.CreateInstance() : null; PaymentProvider pc_ppObject = (this.Depth > 0) ? pc_ppTable.CreateInstance() : null; BehaviorModel pc_bmObject = (this.Depth > 0) ? pc_bmTable.CreateInstance() : null; PaymentConfiguration pcObject = pcTable.CreateInstance(pc_pcObject, pc_piObject, pc_ppObject, pc_bmObject); sqlReader.Close(); return(pcObject); } catch (Exception ex) { database.HandleException(ex); IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "loadinternal", "exception"), "PaymentConfiguration could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id); if (this.Logger.IsErrorEnabled) { this.Logger.Error(builder.ToString(), ex); } throw new DataOperationException(DataOperation.Load, "PaymentConfiguration", "Exception while loading PaymentConfiguration object from database. See inner exception for details.", ex); } }
public PaymentConfiguration Load(BehaviorModel behaviorModel) { using (SqlConnectionInfo connection = new SqlConnectionInfo(this.Type)) return(this.Load(connection, behaviorModel)); }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public int?Update(BehaviorModel model) { model.LastUpdatedDate = DateTime.Now; return(model.Update()); }
public List <PaymentConfiguration> LoadMany(ISqlConnectionInfo connection, SqlQueryParameters parameters) { IDatabase database = connection.Database; if (database == null) { throw new ArgumentNullException("database", "Error initializing database connection."); } if (parameters == null) { throw new ArgumentNullException("parameters"); } string sqlCmdText = string.Empty; try { sqlCmdText = "SELECT {0} " + PaymentConfigurationTable.GetColumnNames("[pc]") + (this.Depth > 0 ? "," + PaymentCredentialsTable.GetColumnNames("[pc_pc]") : string.Empty) + (this.Depth > 0 ? "," + PaymentInterfaceTable.GetColumnNames("[pc_pi]") : string.Empty) + (this.Depth > 0 ? "," + PaymentProviderTable.GetColumnNames("[pc_pp]") : string.Empty) + (this.Depth > 0 ? "," + BehaviorModelTable.GetColumnNames("[pc_bm]") : string.Empty) + " FROM [core].[PaymentConfiguration] AS [pc] "; if (this.Depth > 0) { sqlCmdText += "INNER JOIN [core].[PaymentCredentials] AS [pc_pc] ON [pc].[PaymentCredentialsID] = [pc_pc].[PaymentCredentialsID] "; } if (this.Depth > 0) { sqlCmdText += "INNER JOIN [core].[PaymentInterface] AS [pc_pi] ON [pc].[PaymentInterfaceID] = [pc_pi].[PaymentInterfaceID] "; } if (this.Depth > 0) { sqlCmdText += "INNER JOIN [core].[PaymentProvider] AS [pc_pp] ON [pc].[PaymentProviderID] = [pc_pp].[PaymentProviderID] "; } if (this.Depth > 0) { sqlCmdText += "INNER JOIN [core].[BehaviorModel] AS [pc_bm] ON [pc].[BehaviorModelID] = [pc_bm].[BehaviorModelID] "; } sqlCmdText = parameters.BuildQuery(sqlCmdText); SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand; foreach (KeyValuePair <string, object> argument in parameters.Arguments) { sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value); } SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader; if (!sqlReader.HasRows || !sqlReader.Read()) { IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "customloadmany", "notfound"), "PaymentConfiguration list could not be loaded using custom logic as no items were found.", sqlCmdText, this, connection, parameters); if (this.Logger.IsDebugEnabled) { this.Logger.Debug(builder.ToString()); } sqlReader.Close(); return(new List <PaymentConfiguration>()); } SqlQuery query = new SqlQuery(sqlReader); PaymentConfigurationTable pcTable = new PaymentConfigurationTable(query); PaymentCredentialsTable pc_pcTable = (this.Depth > 0) ? new PaymentCredentialsTable(query) : null; PaymentInterfaceTable pc_piTable = (this.Depth > 0) ? new PaymentInterfaceTable(query) : null; PaymentProviderTable pc_ppTable = (this.Depth > 0) ? new PaymentProviderTable(query) : null; BehaviorModelTable pc_bmTable = (this.Depth > 0) ? new BehaviorModelTable(query) : null; List <PaymentConfiguration> result = new List <PaymentConfiguration>(); do { PaymentCredentials pc_pcObject = (this.Depth > 0) ? pc_pcTable.CreateInstance() : null; PaymentInterface pc_piObject = (this.Depth > 0) ? pc_piTable.CreateInstance() : null; PaymentProvider pc_ppObject = (this.Depth > 0) ? pc_ppTable.CreateInstance() : null; BehaviorModel pc_bmObject = (this.Depth > 0) ? pc_bmTable.CreateInstance() : null; PaymentConfiguration pcObject = (this.Depth > -1) ? pcTable.CreateInstance(pc_pcObject, pc_piObject, pc_ppObject, pc_bmObject) : null; result.Add(pcObject); } while (sqlReader.Read()); sqlReader.Close(); return(result); } catch (Exception ex) { database.HandleException(ex); IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "customloadmany", "exception"), "PaymentConfiguration list could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters); if (this.Logger.IsErrorEnabled) { this.Logger.Error(builder.ToString(), ex); } throw new DataOperationException(DataOperation.Load, "PaymentConfiguration", "Exception while loading (custom/many) PaymentConfiguration object from database. See inner exception for details.", ex); } }
public abstract void OnKeyUp(DeviceModel device, int key, BehaviorModel behavior, KeyHistoryModel keyHistory);
public override void OnKeyDown(DeviceModel device, int key, BehaviorModel behavior, KeyHistoryModel keyHistory) { KeyTimer.RegisterRepeatable(device.DeviceId, key, 250, () => FireEvent(behavior, "press")); }
/// <summary> /// Initializes a new instance of the <see cref="ColumnHeader"/> class. /// </summary> /// <param name="visualModel">The visual model.</param> /// <param name="behaviorModel">The behavior model.</param> protected ColumnHeader(VisualModels.Header visualModel, BehaviorModel.ColumnHeaderBehaviorModel behaviorModel) : base(visualModel, behaviorModel) { // Do nothing. }
public ChainModel VisualizerFor(Guid uniqueId) { var chain = _graph .Behaviors .SingleOrDefault(c => c.UniqueId == uniqueId); if(chain == null) { return null; } return new ChainModel { Chain = chain, Constraints = _constraintResolver.Resolve(chain), Behaviors = chain.Select(x => { var behavior = new BehaviorModel { Id = x.UniqueId, DisplayType = x.GetType().PrettyPrint(), BehaviorType = x.ToString(), BehaviorLabel = BuildLabel(x) }; var call = x as ActionCall; if (call != null) { behavior.Logs = _graph.Observer.GetLog(call); } return behavior; }) }; }
public override void OnKeyUp(DeviceModel device, int key, BehaviorModel behavior, KeyHistoryModel keyHistory) { KeyTimer.UnregisterRepeatable(device.DeviceId, key); }