public IAction CreateAction(IActionConfig config, IActionType type) { if (config == null || !config.Enabled) { return(null); } lock (mActions.SyncRoot) { CAction action = mActions[config.Name] as CAction; if (action == null) { if (type == null) { type = mSystemContext.ActionTypeManager.GetConfig(config.Type); } if (type != null && type.Enabled && !type.ActionClass.Equals("")) { if (!type.FileName.Equals("")) { action = CommonUtil.CreateInstance(SystemContext, type.FileName, type.ActionClass) as CAction; } else { action = CommonUtil.CreateInstance(type.ActionClass) as CAction; } } if (action != null) { if (action.Init(this, config, type)) { action.OnActionStateChanged += new ActionStateChanged(DoActionStateChanged); action.OnBeforeAction += new ActionEvent(DoBeforeAction); action.OnAfterAction += new ActionEvent(DoAfterAction); mActions.Add(action.Name, action); action.RefreshState(); } else { return(null); } } } else { action.Config = config; } return(action); } }
public bool ConfigAction(string name, IActionConfig config) { IAction action = GetAction(name); if (action != null) { action.Config = config; return(true); } return(false); }
public IAction CreateAction(IActionConfig config) { if (config != null) { IActionType type = mSystemContext.ActionTypeManager.GetConfig(config.Type); return(CreateAction(config, type)); } else { return(null); } }
public void ShowAddDialog(IActionType type) { Text = "新增动作模块"; mIsOk = false; mManager = type.SystemContext.ActionConfigManager; mType = type; mConfig = null; InitTypeList(mManager.SystemContext); if (InitDialog()) { ShowDialog(); } }
public IAction CreateAction(string name) { IActionConfig config = mSystemContext.ActionConfigManager.GetConfig(name) as IActionConfig; if (config != null) { return(CreateAction(config)); } else { return(null); } }
public bool Init(IActionManager manager, IActionConfig config, IActionType type) { mConfig = config; mManager = manager; mType = type; if (!IsInit && Verify(ACOpts.Exec_Init)) { if (mManager.SystemContext.MonitorSystem.IsLocal) { if (InitAction()) { State = ActionState.Init; Config = mConfig; if (!IsActive && mConfig.AutoRun) { this.Start(); } return(true); } } else if (mManager.SystemContext.RemoteManageClient != null) { SystemContext.RemoteManageClient.OnConnected -= new ClientConnectEvent(DoConnected); SystemContext.RemoteManageClient.OnDisconnected -= new ClientConnectEvent(DoDisconnected); SystemContext.RemoteManageClient.OnReceiveData -= new ClientReceiveEvent(DoReceiveData); SystemContext.RemoteManageClient.OnConnected += new ClientConnectEvent(DoConnected); SystemContext.RemoteManageClient.OnDisconnected += new ClientConnectEvent(DoDisconnected); SystemContext.RemoteManageClient.OnReceiveData += new ClientReceiveEvent(DoReceiveData); IRemoteSystem rs = mManager.SystemContext.MonitorSystem as IRemoteSystem; if (rs != null) { StringBuilder sb = new StringBuilder(mManager.SystemContext.RequestHeadInfo); sb.Append(string.Format("{0}<Action>", Name)); sb.Append("Init<Command>"); sb.Append(string.Format("{0}<Type>", mType.ToXml())); sb.Append(string.Format("{0}<Config>", mConfig.ToXml())); return(mManager.SystemContext.RemoteManageClient.WaitReliableSend(rs.Config.IP, rs.Config.Port, sb.ToString())); } } } return(false); }
private void listBox_action_total_DoubleClick(object sender, EventArgs e) { if (listBox_action_total.SelectedIndex >= 0) { IActionConfig config = listBox_action_total.Items[listBox_action_total.SelectedIndex] as IActionConfig; if (config != null) { IActionParam paramConfig = new CActionParam(config.Name); paramConfig.Desc = config.Desc; paramConfig.Enabled = false; checkedListBox_action.Items.Add(paramConfig, paramConfig.Enabled); } } }
public override void ShowEditDialog(IConfig config) { Text = "编辑动作模块 - [" + config.Name + "]"; mIsOk = false; mManager = null; mType = null; mConfig = config as IActionConfig; if (config.Verify(ACOpts.Manager_Modify, false)) { InitTypeList(config.SystemContext); if (InitDialog()) { ShowDialog(); } } }
protected bool SetConfig() { if (mConfig == null && mManager != null) { mConfig = mManager.CreateConfigInstance(); } if (mConfig != null) { (mConfig as CConfig).Name = textBox_name.Text; mConfig.SetValue("Name", textBox_name.Text); mConfig.Desc = textBox_desc.Text; mConfig.Type = CtrlUtil.GetComboBoxText(comboBox_type); mConfig.SetValue("Params", textBox_params.Text); mConfig.AutoRun = checkBox_autorun.Checked; mConfig.Enabled = checkBox_enabled.Checked; return(true); } return(false); }
public static void AddComponent(Entity entity, IActionConfig data, ActionConfig action) { var stats = entity.Get <StatsContainer>(); stats.Add(new BaseStat(entity, Stats.CriticalMulti, data.CritMulti)); stats.Add(new RangeStat(entity, Stats.Power, Stats.Power, data.Power.Min, data.Power.Max)); var targeting = data.Targeting; if (targeting == TargetType.Self || targeting == TargetType.Friendly) { action.AddEvent(AnimationEvents.Default, new EventGenerateCollisionEvent()); } var radius = data.Radius; if (radius != ImpactRadiusTypes.Single) { entity.Add(new ImpactRadius(radius, true)); } action.Range = (int)data.Range; if (data.ActionFx != null) { entity.Add(new ActionFxComponent(data.ActionFx)); } for (int i = 0; i < data.ScriptedEvents.Length; i++) { var scriptingData = data.ScriptedEvents[i]; var eventType = scriptingData.Event; var scripting = scriptingData.Script; if (!string.IsNullOrEmpty(eventType) && !string.IsNullOrEmpty(scripting)) { var customScript = ScriptingSystem.ParseMessage(scripting.SplitIntoWords()); if (customScript != null) { action.AddEvent(eventType, customScript); } } } }
private void listBox_action_total_DoubleClick(object sender, EventArgs e) { if (listBox_action_total.SelectedIndex >= 0) { IActionConfig config = listBox_action_total.Items[listBox_action_total.SelectedIndex] as IActionConfig; if (config != null) { IActionParam paramConfig = new CActionParam(config.Name); paramConfig.Desc = config.Desc; paramConfig.Enabled = false; if (tabControl_action.SelectedTab == tabPage_alarm_action) { checkedListBox_alarm_action.Items.Add(paramConfig, paramConfig.Enabled); } else if (tabControl_action.SelectedTab == tabPage_transact_action) { checkedListBox_transact_action.Items.Add(paramConfig, paramConfig.Enabled); } } } }
public CSoundAction(IActionManager manager, IActionConfig config, IActionType type) : base(manager, config, type) { }
public CHKAlarmOutAction(IActionManager manager, IActionConfig config, IActionType type) : base(manager, config, type) { }
public CTrumpetAction(IActionManager manager, IActionConfig config, IActionType type) : base(manager, config, type) { }
public static void AddRemoteConfig(IMonitorSystemContext context, string name, string data, bool saveConfig) { IConfig config = null; if (data.StartsWith("<Monitor>")) { config = context.MonitorConfigManager.GetConfig(name); if (config == null) { IMonitorConfig monitorConfig = context.MonitorConfigManager.BuildConfigFromXml(data) as IMonitorConfig; if (monitorConfig != null) { context.MonitorConfigManager.Append(monitorConfig, saveConfig); } } } else if (data.StartsWith("<MonitorType>")) { config = context.MonitorTypeManager.GetConfig(name); if (config == null) { IMonitorType monitorType = context.MonitorTypeManager.BuildConfigFromXml(data) as IMonitorType; if (monitorType != null) { context.MonitorTypeManager.Append(monitorType, saveConfig); } } } else if (data.StartsWith("<VideoSource>")) { config = context.VideoSourceConfigManager.GetConfig(name); if (config == null) { IVideoSourceConfig vsConfig = context.VideoSourceConfigManager.BuildConfigFromXml(data) as IVideoSourceConfig; if (vsConfig != null) { context.VideoSourceConfigManager.Append(vsConfig, saveConfig); } } } else if (data.StartsWith("<VideoSourceType>")) { config = context.VideoSourceTypeManager.GetConfig(name); if (config == null) { IVideoSourceType vsType = context.VideoSourceTypeManager.BuildConfigFromXml(data) as IVideoSourceType; if (vsType != null) { context.VideoSourceTypeManager.Append(vsType, saveConfig); } } } else if (data.StartsWith("<Action>")) { config = context.ActionConfigManager.GetConfig(name); if (config == null) { IActionConfig actionConfig = context.ActionConfigManager.BuildConfigFromXml(data) as IActionConfig; if (actionConfig != null) { context.ActionConfigManager.Append(actionConfig, saveConfig); } } } else if (data.StartsWith("<ActionType>")) { config = context.ActionTypeManager.GetConfig(name); if (config == null) { IActionType actionType = context.ActionTypeManager.BuildConfigFromXml(data) as IActionType; if (actionType != null) { context.ActionTypeManager.Append(actionType, saveConfig); } } } else if (data.StartsWith("<Scheduler>")) { config = context.SchedulerConfigManager.GetConfig(name); if (config == null) { ISchedulerConfig schedulerConfig = context.SchedulerConfigManager.BuildConfigFromXml(data) as ISchedulerConfig; if (schedulerConfig != null) { context.SchedulerConfigManager.Append(schedulerConfig, saveConfig); } } } else if (data.StartsWith("<SchedulerType>")) { config = context.SchedulerTypeManager.GetConfig(name); if (config == null) { ISchedulerType schedulerType = context.SchedulerTypeManager.BuildConfigFromXml(data) as ISchedulerType; if (schedulerType != null) { context.SchedulerTypeManager.Append(schedulerType, saveConfig); } } } else if (data.StartsWith("<Task>")) { config = context.TaskConfigManager.GetConfig(name); if (config == null) { ITaskConfig taskConfig = context.TaskConfigManager.BuildConfigFromXml(data) as ITaskConfig; if (taskConfig != null) { context.TaskConfigManager.Append(taskConfig, saveConfig); } } } else if (data.StartsWith("<TaskType>")) { config = context.TaskTypeManager.GetConfig(name); if (config == null) { ITaskType taskType = context.TaskTypeManager.BuildConfigFromXml(data) as ITaskType; if (taskType != null) { context.TaskTypeManager.Append(taskType, saveConfig); } } } else if (data.StartsWith("<RemoteSystem>")) { config = context.RemoteSystemConfigManager.GetConfig(name); if (config == null) { IRemoteSystemConfig rsConfig = context.RemoteSystemConfigManager.BuildConfigFromXml(data) as IRemoteSystemConfig; if (rsConfig != null) { context.RemoteSystemConfigManager.Append(rsConfig, saveConfig); } } } else if (data.StartsWith("<Role>")) { config = context.RoleConfigManager.GetConfig(name); if (config == null) { IRoleConfig roleConfig = context.RoleConfigManager.BuildConfigFromXml(data) as IRoleConfig; if (roleConfig != null) { context.RoleConfigManager.Append(roleConfig, saveConfig); } } } else if (data.StartsWith("<User>")) { config = context.UserConfigManager.GetConfig(name); if (config == null) { IUserConfig userConfig = context.UserConfigManager.BuildConfigFromXml(data) as IUserConfig; if (userConfig != null) { context.UserConfigManager.Append(userConfig, saveConfig); } } } }
public CMonitorAction(IActionManager manager, IActionConfig config, IActionType type) : base(manager, config, type) { }
public CAction(IActionManager manager, IActionConfig config, IActionType type) { mSyncActionEvent = DoActionEvent; Init(manager, config, type); }
public CSchedulerAction(IActionManager manager, IActionConfig config, IActionType type) : base(manager, config, type) { }