private unsafe void EtwEnableCallBack([In] ref Guid sourceId, [In] int isEnabled, [In] byte setLevel, [In] long anyKeyword, [In] long allKeyword, [In] ManifestEtw.EVENT_FILTER_DESCRIPTOR *filterData, [In] void *callbackContext) { byte[] buffer; int num; this.m_enabled = isEnabled; this.m_level = setLevel; this.m_anyKeywordMask = anyKeyword; this.m_allKeywordMask = allKeyword; ControllerCommand update = ControllerCommand.Update; IDictionary <string, string> arguments = null; if (this.GetDataFromController(filterData, out update, out buffer, out num)) { arguments = new Dictionary <string, string>(4); while (num < buffer.Length) { int num2 = FindNull(buffer, num); int idx = num2 + 1; int num4 = FindNull(buffer, idx); if (num4 < buffer.Length) { string str = Encoding.UTF8.GetString(buffer, num, num2 - num); string str2 = Encoding.UTF8.GetString(buffer, idx, num4 - idx); arguments[str] = str2; } num = num4 + 1; } } this.OnControllerCommand(update, arguments); }
public void Notify(ControllerCommand cmd) { if (controlledMap != null) { switch (cmd) { } } }
public void Notify(ControllerCommand cmd) { if (controlledSpellbook != null) { switch (cmd) { case ControllerCommand.Spellbook_SelectNext: descriptionList.SelectNext(); break; case ControllerCommand.Spellbook_SelectPrevious: descriptionList.SelectPrevious(); break; case ControllerCommand.Spellbook_SelectNextPage: descriptionList.SelectNextPage(); break; case ControllerCommand.Spellbook_SelectPreviousPage: descriptionList.SelectPreviousPage(); break; case ControllerCommand.Spellbook_Close: ValidIndex = false; this.Hide(); gamePanel.Show(); FocusOnMap(); Opened = false; break; case ControllerCommand.Spellbook_Pick: ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; case ControllerCommand.Spellbook_Open: Opened = true; gamePanel.Hide(); this.Show(); descriptionList.Items = controlledSpellbook.ToList(); this.Refresh(); this.Focus(); break; } } descriptionList.Refresh(); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindow"/> class. /// </summary> public MainWindow() { if (Environment.GetCommandLineArgs().Length > 1) { var CommandLinePasre = new ControllerCommand(Environment.GetCommandLineArgs()); System.Environment.Exit(0); } else { InitializeComponent(); MainBackupFolderTextBox.Text = Properties.Settings.Default.MainBackupFolder; ProgressPanel.Visibility = Visibility.Collapsed; ProgressController.MainWindow = this; new WindowController(WindowController.Windows.Desktop); OldDayTextBox.PreviewTextInput += new TextCompositionEventHandler(OnlyNum); FOldDayTextBox.PreviewTextInput += new TextCompositionEventHandler(OnlyNum); switch (Properties.Settings.Default.ComLvl) { case 0: CompressionNope.IsChecked = true; break; case 1: CompressionDefault.IsChecked = true; break; case 2: CompressionLevel1.IsChecked = true; break; case 3: CompressionLevel4.IsChecked = true; break; case 4: CompressionBestSpeed.IsChecked = true; break; case 5: CompressionBestCompression.IsChecked = true; break; } } }
public void Notify(ControllerCommand cmd) { switch (cmd) { case ControllerCommand.Menu_PreviousItem: controlledMenu.SelectPreviousItem(); break; case ControllerCommand.Menu_NextItem: controlledMenu.SelectNextItem(); break; case ControllerCommand.Menu_ExecuteSelectItem: controlledMenu.ExecuteSelected(); break; } }
private void DoExecute() { CommandDescriptor commandDescriptor = PublicCommandsHelper.GetCommandDescriptor(ControllerCommandType); commandDescriptor.ClearParameterValues(); OperationParametersControlCreator.ReadParameterValues(commandDescriptor, controls); foreach (ParameterDescriptor parameterDescriptor in commandDescriptor.Parameters) { if (parameterDescriptor.ParameterPropertyInfo == commandDescriptor.ScopeProperty) { parameterDescriptor.ParameterValue = ((ExolutioObject)this.ScopeObject).ID; } } CreateControllerCommand(); CommandSerializer.FillParameters(ControllerCommand, commandDescriptor); ControllerCommand.CanExecuteChanged -= OnControllerCommandCanExecuteChanged; if (!ControllerCommand.CanExecute()) { #if SILVERLIGHT ExolutioErrorMsgBox.Show("Command can not be executed", ControllerCommand.ErrorDescription); #else ExolutioErrorMsgBox.Show("Command can not be executed", ControllerCommand.ErrorDescription); #endif } else { if (ControllerCommand is StackedCommand) { if (((StackedCommand)ControllerCommand).Controller == null) { ((StackedCommand)ControllerCommand).Controller = Current.Controller; } } try { ControllerCommand.Execute(); } catch (ExolutioCommandException e) { ExolutioErrorMsgBox.Show("Command " + e.Command.GetType().ToString() + " can not be executed", e.Command.ErrorDescription); } } ControllerCommand = null; }
private ControllerCommand SendEmulatorGameStateToController(TcpClient cl) { ControllerCommand cc = new ControllerCommand(); try { NetworkStream stream = cl.GetStream(); byte[] bytes = new byte[1024]; // Encode the data string into a byte array. GameState gs = GetCurrentState(); string data = JsonConvert.SerializeObject(gs); byte[] msg = Encoding.ASCII.GetBytes(data); stream.Write(msg, 0, msg.Length); StringBuilder myCompleteMessage = new StringBuilder(); if (stream.CanRead) { byte[] myReadBuffer = new byte[1024]; int numberOfBytesRead = 0; // Incoming message may be larger than the buffer size. do { numberOfBytesRead = stream.Read(myReadBuffer, 0, myReadBuffer.Length); myCompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead)); }while (stream.DataAvailable); } cc = JsonConvert.DeserializeObject <ControllerCommand>(myCompleteMessage.ToString()); } catch (ArgumentNullException ane) { cc.type = "__err__" + ane.ToString(); } catch (SocketException se) { cc.type = "__err__" + se.ToString(); } catch (Exception e) { cc.type = "__err__" + e.ToString(); } return(cc); }
private unsafe bool GetDataFromController(int etwSessionId, UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR* filterData, out ControllerCommand command, out byte[] data, out int dataStart) { data = null; dataStart = 0; if (filterData == null) { #if !ES_BUILD_PCL && !FEATURE_PAL string regKey = @"\Microsoft\Windows\CurrentVersion\Winevt\Publishers\{" + m_providerId + "}"; if (System.Runtime.InteropServices.Marshal.SizeOf(typeof(IntPtr)) == 8) regKey = @"HKEY_LOCAL_MACHINE\Software" + @"\Wow6432Node" + regKey; else regKey = @"HKEY_LOCAL_MACHINE\Software" + regKey; string valueName = "ControllerData_Session_" + etwSessionId.ToString(CultureInfo.InvariantCulture); // we need to assert this permission for partial trust scenarios (new RegistryPermission(RegistryPermissionAccess.Read, regKey)).Assert(); data = Microsoft.Win32.Registry.GetValue(regKey, valueName, null) as byte[]; if (data != null) { // We only used the persisted data from the registry for updates. command = ControllerCommand.Update; return true; } #endif } else { if (filterData->Ptr != 0 && 0 < filterData->Size && filterData->Size <= 1024) { data = new byte[filterData->Size]; Marshal.Copy((IntPtr)filterData->Ptr, data, 0, data.Length); } command = (ControllerCommand)filterData->Type; return true; } command = ControllerCommand.Update; return false; }
private static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Not enough arguments !"); return; } Config.Model = args[0].ToLower().UppercaseFirst(); var command = ""; if (args.Length > 1) { command = args[1].ToLower(); } if (args.Length > 2) { Config.Area = args[2].ToLower().UppercaseFirst(); } Config.ModelsPath = Environment.CurrentDirectory + "\\"; Config.ViewModelsPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.FullName + "\\ViewModels\\"; Config.RepositoryPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.FullName + "\\Repository\\"; Config.ServicePath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.FullName + "\\Service\\"; if (string.IsNullOrEmpty(Config.Area)) { Config.ControllerPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Controllers\\"; Config.ViewsPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Views\\" + Config.Model + "\\"; } else { Config.ControllerPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Areas\\" + Config.Area + "\\Controllers\\"; Config.ViewsPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Areas\\" + Config.Area + "\\Views\\" + Config.Model + "\\"; } var viewsDir = new System.IO.DirectoryInfo(Config.ViewsPath); if (!viewsDir.Exists) { viewsDir.Create(); } Config.PropertyNames = ClassHelper.GetPropertyNames(Config.ModelsPath + Config.Model + ".cs"); Config.PropertyTypes = ClassHelper.GetPropertyTypes(Config.ModelsPath + Config.Model + ".cs"); Config.PropertyDeclarations = ClassHelper.GetPropertyDeclarations(Config.ModelsPath + Config.Model + ".cs"); switch (command) { case "sr": case "service": var iserviceCommand = new IServiceCommand(); var serviceCommand = new ServiceCommand(); iserviceCommand.Execute(); serviceCommand.Execute(); break; case "rp": case "repository": var irepositoryCommand = new IRepositoryCommand(); var repositoryCommand = new RepositoryCommand(); irepositoryCommand.Execute(); repositoryCommand.Execute(); break; case "vm": case "viewmodel": var viewModelCommand = new ViewModelCommand(); viewModelCommand.Execute(); break; case "ad": case "addmodel": var addModel = new AddModelCommand(); addModel.Execute(); break; case "vi": case "views": var indexCommand = new IndexCommand(); var createCommand = new CreateCommand(); var editCommand = new EditCommand(); var deleteCommand = new DeleteCommand(); var detailsCommand = new DetailsCommand(); indexCommand.Execute(); createCommand.Execute(); editCommand.Execute(); deleteCommand.Execute(); detailsCommand.Execute(); break; case "cr": case "controller": var controllerCommand = new ControllerCommand(); controllerCommand.Execute(); break; case "go": default: var goCommand = new GoCommand(); goCommand.Execute(); break; } }
// New in CLR4.0 protected virtual void OnControllerCommand(ControllerCommand command, IDictionary <string, string> arguments, int sessionId, int etwSessionId) { }
internal void SendCommand(EventProviderDataStream outputStream, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary<string, string> commandArguments) { this.InsureInitialized(); if ((this.m_OutputStreams != null) && (this.m_eventCallbackArgs == null)) { this.m_eventCallbackArgs = new EventWrittenEventArgs(this); } this.m_providerEnabled = enable; this.m_level = level; this.m_matchAnyKeyword = matchAnyKeyword; EventProviderDataStream outputStreams = this.m_OutputStreams; if (outputStreams == null) { goto Label_0062; } Label_0042: if (outputStreams == null) { throw new ArgumentException("outputStream not found"); } if (outputStreams.m_MasterStream != outputStream) { outputStreams = outputStreams.m_Next; goto Label_0042; } Label_0062: if (enable) { if (outputStreams != null) { if (!outputStreams.m_ManifestSent) { outputStreams.m_ManifestSent = true; this.SendManifest(this.m_rawManifest, outputStreams); } } else if (!this.m_ETWManifestSent && this.m_completelyInited) { this.m_ETWManifestSent = true; this.SendManifest(this.m_rawManifest, outputStreams); } } else if (outputStreams != null) { outputStreams.m_ManifestSent = false; } else { this.m_ETWManifestSent = false; } for (int i = 0; i < this.m_eventData.Length; i++) { this.SetEnabled(outputStreams, i, this.IsEnabledDefault(i, level, matchAnyKeyword)); } if (commandArguments == null) { commandArguments = new Dictionary<string, string>(); } this.OnControllerCommand(outputStreams, command, commandArguments); }
internal void SendCommand(EventProviderDataStream outputStream, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary<string, string> commandArguments) { InsureInitialized(); if (m_OutputStreams != null && m_eventCallbackArgs == null) m_eventCallbackArgs = new EventWrittenEventArgs(this); m_providerEnabled = enable; m_level = level; m_matchAnyKeyword = matchAnyKeyword; // Find the per-Provider stream cooresponding to registered outputStream EventProviderDataStream providerOutputStream = m_OutputStreams; if (providerOutputStream != null) { for (; ; ) { if (providerOutputStream == null) throw new ArgumentException("outputStream not found"); if (providerOutputStream.m_MasterStream == outputStream) break; providerOutputStream = providerOutputStream.m_Next; } } if (enable) { // Send the manifest if the stream once per stream if (providerOutputStream != null) { if (!providerOutputStream.m_ManifestSent) { providerOutputStream.m_ManifestSent = true; SendManifest(m_rawManifest, providerOutputStream); } } else { // providerOutputStream == null means this is the ETW manifest // If we are not completely initalized we can't send the manifest because WriteEvent // will fail (handle was not returned from OS API). We will try again after the // constuctor completes. if (!m_ETWManifestSent && m_completelyInited) { m_ETWManifestSent = true; SendManifest(m_rawManifest, providerOutputStream); } } } else { // if (providerOutputStream != null) providerOutputStream.m_ManifestSent = false; else m_ETWManifestSent = false; } // Set it up using the 'standard' filtering bitfields for (int i = 0; i < m_eventData.Length; i++) SetEnabled(providerOutputStream, i, IsEnabledDefault(i, level, matchAnyKeyword)); if (commandArguments == null) commandArguments = new Dictionary<string, string>(); // Allow subclasses to fiddle with it from there. OnControllerCommand(providerOutputStream, command, commandArguments); }
/// <summary> /// This method is called when the provider is updated by the controller. /// </summary> protected virtual void OnControllerCommand(EventProviderDataStream outputStream, ControllerCommand command, IDictionary<string, string> arguments) { }
public void Notify(ControllerCommand cmd) { if (controlledPg != null) { var acted = false; switch (cmd) { #region MOVEMENT case ControllerCommand.Player_MoveNorth: controlledPg.Move(Direction.North, out acted); break; case ControllerCommand.Player_MoveWest: controlledPg.Move(Direction.West, out acted); break; case ControllerCommand.Player_MoveSouth: controlledPg.Move(Direction.South, out acted); break; case ControllerCommand.Player_MoveEast: controlledPg.Move(Direction.East, out acted); break; #endregion #region OBJECT_MANAGEMENT case ControllerCommand.Player_PickUp: controlledPg.PickUp(); break; case ControllerCommand.Backpack_Open: backpackController.Notify(ControllerCommand.Backpack_Open); this.WaitForRefocusThenDo(() => { if (backpackController.ValidIndex) { var item = controlledPg.Backpack[backpackController.SelectedIndex]; switch (backpackController.RapidOperation) { case RapidOperation.Embrace: controlledPg.EmbraceShield(item); break; case RapidOperation.Handle: controlledPg.HandleWeapon(item); break; case RapidOperation.PutOn: controlledPg.WearArmor(item); break; case RapidOperation.Use: controlledPg.UseItem(item); break; case RapidOperation.None: default: break; } } }); break; case ControllerCommand.Player_HandleWeapon: backpackController.Notify(ControllerCommand.Backpack_Open); this.WaitForRefocusThenDo(() => { if (backpackController.ValidIndex) { controlledPg.HandleWeapon(controlledPg.Backpack[backpackController.SelectedIndex]); } }); break; case ControllerCommand.Player_UnhandleWeapon: controlledPg.UnhandleWeapon(); break; case ControllerCommand.Player_ActivateWeaponPower: controlledPg.ActivateSpecialAttack(); break; case ControllerCommand.Player_PutOn: backpackController.Notify(ControllerCommand.Backpack_Open); this.WaitForRefocusThenDo(() => { if (backpackController.ValidIndex) { controlledPg.WearArmor(controlledPg.Backpack[backpackController.SelectedIndex]); } }); break; case ControllerCommand.Player_PutOff: controlledPg.RemoveArmor(); break; case ControllerCommand.Player_EmbraceShield: backpackController.Notify(ControllerCommand.Backpack_Open); this.WaitForRefocusThenDo(() => { if (backpackController.ValidIndex) { controlledPg.EmbraceShield(controlledPg.Backpack[backpackController.SelectedIndex]); } }); break; case ControllerCommand.Player_PutAwayShield: controlledPg.DisembraceShield(); break; case ControllerCommand.Player_UseItem: backpackController.Notify(ControllerCommand.Backpack_Open); this.WaitForRefocusThenDo(() => { if (backpackController.ValidIndex) { controlledPg.UseItem(controlledPg.Backpack[backpackController.SelectedIndex]); } }); break; #endregion #region DEITY case ControllerCommand.Player_Pray: controlledPg.Pray(out acted); break; #endregion #region AIs case ControllerCommand.AI_Turn: aiCharacters.ForEach(aiChar => { if (aiChar.BlockedTurns > 0) { aiChar.SkipTurn(); } else { aiChar.AI.ExecuteAction(); } }); break; #endregion #region MSG_CONSOLE_HANDLING case ControllerCommand.Player_ScrollMsgsUp: controlledPg.ScrollUpMessages(); break; case ControllerCommand.Player_ScrollMsgsDown: controlledPg.ScrollDownMessages(); break; #endregion #region SELECTION case ControllerCommand.Player_EnterSelectionMode: EnterSelectionMode(); break; case ControllerCommand.Player_ExitSelectionModeWithoutSelection: CurrentAfterValidSelectionOperation = defaultAfterSelectionOp; CurrentAfterInvalidSelectionOperation(selPos: selectorCursor.Position); CurrentAfterInvalidSelectionOperation = defaultAfterSelectionOp; ExitSelectionMode(); break; case ControllerCommand.SelectionCursor_MoveNorth: selectorCursor.Move(Direction.North, out acted); break; case ControllerCommand.SelectionCursor_MoveEast: selectorCursor.Move(Direction.East, out acted); break; case ControllerCommand.SelectionCursor_MoveSouth: selectorCursor.Move(Direction.South, out acted); break; case ControllerCommand.SelectionCursor_MoveWest: selectorCursor.Move(Direction.West, out acted); break; case ControllerCommand.SelectionCursor_PickedCell: ExitSelectionMode(); acted = CurrentAfterValidSelectionOperation(selPos: selectorCursor.Position); if (!invalidSelection) { ExitSelectionMode(); } invalidSelection = false; break; case ControllerCommand.SelectionCursor_PickedCellOneOfMany: ExitSelectionMode(); acted = CurrentAfterValidSelectionOperation(selPos: selectorCursor.Position, allowOtherSelection: true); break; #endregion #region SPELLS case ControllerCommand.Player_CastSpell: spellbookController.Notify(ControllerCommand.Spellbook_Open); this.WaitForRefocusThenDo(() => { if (spellbookController.ValidIndex) { var spellBuilder = (SpellBuilder)controlledPg.Spellbook[spellbookController.SelectedIndex]; var target = spellBuilder.Target; var issues = false; switch(target.TargetType) { case TargetType.NumberOfTargets: { #region NUMBER_OF_TARGETS var maxEnemies = target.NumericParameter; var chosenEnemies = 0; var targets = new List<Atom>(); targets.Clear(); spellBuilder.NotifyListeners("Select target"); AfterSelectionOperation op = null; #region OP op = (selPos, allowOtherSel) => { if(invalidSelection) { allowOtherSel = true; } var selTarget = controlledPg.Map[selPos]; var spellType = spellBuilder.SpellToBuildType; var permittedType = typeof(Atom); if (typeof(HealSpell).IsAssignableFrom(spellType)) { permittedType = typeof(IDamageable); } else if (typeof(UtilitySpell).IsAssignableFrom(spellType)) { } else if (typeof(AttackSpell).IsAssignableFrom(spellType)) { permittedType = typeof(IDamageable); } // If target is of the expected family type if (permittedType.IsAssignableFrom(selTarget.GetType())) { if (!targets.Contains(selTarget)) { chosenEnemies++; targets.Add(selTarget); } else { spellBuilder.NotifyListeners("Target already selected"); } if ((!allowOtherSel && targets.Count() > 0) || maxEnemies == chosenEnemies) { spellBuilder.SetTargets(targets); var spell = spellBuilder.Create(out issues); if (!issues) { controlledPg.CastSpell(spell, out acted); this.Refresh(); return acted; } return !issues; } spellBuilder.NotifyListeners("Select next target"); // Select next target CurrentAfterValidSelectionOperation = (AfterSelectionOperation)op.Clone(); EnterSelectionMode(); } else { spellBuilder.NotifyListeners("Invalid target"); // Select next target //CurrentAfterValidSelectionOperation = (AfterSelectionOperation)op.Clone(); invalidSelection = true; CurrentAfterValidSelectionOperation = (AfterSelectionOperation)op.Clone(); EnterSelectionMode(); } return acted; }; #endregion CurrentAfterValidSelectionOperation = op; CurrentAfterInvalidSelectionOperation = (selPos, allowOtherSel) => { acted = false; targets.Clear(); spellBuilder.NotifyListeners("Spell dismissed"); return true; }; EnterSelectionMode(); #endregion } break; case TargetType.Personal: { var targets = new List<Atom>() { controlledPg }; spellBuilder.SetTargets(targets); var spell = spellBuilder.Create(out issues); if (!issues) { controlledPg.CastSpell(spell, out acted); this.Refresh(); } } break; case TargetType.AllEnemiesInRange: { #region ALL_ENEMIES var targets = new List<Atom>(); var circlePerception = new FilledCircle(controlledPg.Position, controlledPg.PerceptionRange); var permittedType = typeof(Character); var map = controlledPg.Map; foreach (Coord pt in circlePerception) { if (pt.X >= 0 && pt.Y >= 0 && pt.X < map.Width && pt.Y < map.Height) { var cur = map[pt]; var curType = cur.GetType(); if (permittedType.IsAssignableFrom(curType)) { if (((Character)cur).AlliedTo == Allied.Enemy) { targets.Add(cur); } } } } // If more than permitted targets if (targets.Count > target.NumericParameter) { var sortedTargets = targets.OrderBy(t => t.Position.ManhattanDistance(controlledPg.Position)); targets = sortedTargets.Take(targets.Count).ToList(); } spellBuilder.SetTargets(targets); var spell = spellBuilder.Create(out issues); if (!issues) { controlledPg.CastSpell(spell, out acted); this.Refresh(); } #endregion } break; case TargetType.AllAlliesInRange: { #region ALL_ALLIES var targets = new List<Atom>(); var circlePerception = new FilledCircle(controlledPg.Position, controlledPg.PerceptionRange); var permittedType = typeof(Character); foreach (Coord pt in circlePerception) { var cur = controlledPg.Map[pt]; var curType = cur.GetType(); if (permittedType.IsAssignableFrom(curType)) { if (((Character)cur).AlliedTo == Allied.Pg) { targets.Add(cur); } } } // If more than permitted targets if (targets.Count > target.NumericParameter) { var sortedTargets = targets.OrderBy(t => t.Position.ManhattanDistance(controlledPg.Position)); targets = sortedTargets.Take(targets.Count).ToList(); } spellBuilder.SetTargets(targets); var spell = spellBuilder.Create(out issues); if (!issues) { controlledPg.CastSpell(spell, out acted); this.Refresh(); } #endregion } break; default: throw new Exception(); } } }); break; #endregion #region SAVE case ControllerCommand.Player_SaveGame: //controlledPg.Map.Save(@"currentLevel.map"); Game.Current.Save(@"current.game"); controlledPg.NotifyListeners("*GAME SAVED*"); break; #endregion #region TRIGGERABLES case ControllerCommand.Player_TriggerCurrent: controlledPg.TriggerCurrent(); mode = Modes.Normal; break; #endregion case ControllerCommand.Player_BackToMainMenu: Game.Current.InitialMenu(true); break; case ControllerCommand.Player_IsDead: controlledPg.PostDeathOperation(); transparentPanel.Transparency = 0; Game.Current.InitialMenu(); break; case ControllerCommand.Player_ExitGame: gameForm.Close(); break; } var blocked = controlledPg.BlockedTurns > 0; if (acted || blocked) { controlledPg.EffectOfTurn(); if (blocked) { controlledPg.SkipTurn(); #if DEBUG_BLOCKED controlledPg.NotifyListeners(String.Format("Blocked {0}", controlledPg.BlockedTurns)); #endif } #if !PREVENT_AI Notify(ControllerCommand.AI_Turn); #endif aiCharacters.RemoveAll(aiChar => aiChar.Dead); this.Refresh(); } } else // Some commands work without player too { switch (cmd) { case ControllerCommand.Player_ExitGame: gameForm.Close(); break; } } }
private unsafe bool GetDataFromController(ManifestEtw.EVENT_FILTER_DESCRIPTOR* filterData, out ControllerCommand command, out byte[] data, out int dataStart) { data = null; if (filterData == null) { string regKey = @"\Microsoft\Windows\CurrentVersion\Winevt\Publishers\{" + m_providerId + "}"; if (System.Runtime.InteropServices.Marshal.SizeOf(typeof(IntPtr)) == 8) regKey = @"HKEY_LOCAL_MACHINE\Software" + @"\Wow6432Node" + regKey; else regKey = @"HKEY_LOCAL_MACHINE\Software" + regKey; data = Microsoft.Win32.Registry.GetValue(regKey, "ControllerData", null) as byte[]; if (data != null && data.Length >= 4) { // command = (ControllerCommand)(((data[3] << 8 + data[2]) << 8 + data[1]) << 8 + data[0]); dataStart = 4; return true; } } else { if (filterData->Ptr != 0 && 0 < filterData->Size && filterData->Size <= 1024) { data = new byte[filterData->Size]; Marshal.Copy((IntPtr)filterData->Ptr, data, 0, data.Length); } command = (ControllerCommand) filterData->Type; dataStart = 0; return true; } dataStart = 0; command = ControllerCommand.Update; return false; }
public void SendCommand(Guid providerGuid, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary<string, string> commandArguments) { List<EventProviderBase> list = new List<EventProviderBase>(); lock (EventProviderStreamsLock) { foreach (WeakReference reference in s_providers) { EventProviderBase target = reference.Target as EventProviderBase; if ((target != null) && ((target.Guid == providerGuid) || (providerGuid == Guid.Empty))) { list.Add(target); } } } foreach (EventProviderBase base3 in list) { base3.SendCommand(this, enable, level, matchAnyKeyword, command, commandArguments); } }
public void Notify(ControllerCommand cmd) { RapidOperation = RapidOperation.None; if(controlledBackpack != null) { switch(cmd) { case ControllerCommand.Backpack_SelectNext: descriptionList.SelectNext(); break; case ControllerCommand.Backpack_SelectPrevious: descriptionList.SelectPrevious(); break; case ControllerCommand.Backpack_SelectNextPage: descriptionList.SelectNextPage(); break; case ControllerCommand.Backpack_SelectPreviousPage: descriptionList.SelectPreviousPage(); break; case ControllerCommand.Backpack_Close: ValidIndex = false; this.Hide(); gamePanel.Show(); FocusOnMap(); Opened = false; break; case ControllerCommand.Backpack_Pick: ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; case ControllerCommand.Backpack_Open: Opened = true; gamePanel.Hide(); this.Show(); descriptionList.Items = controlledBackpack.ToList(); this.Refresh(); this.Focus(); break; case ControllerCommand.Backpack_PutOnArmor: RapidOperation = RapidOperation.PutOn; ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; case ControllerCommand.Backpack_EmbraceShield: RapidOperation = RapidOperation.Embrace; ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; case ControllerCommand.Backpack_UseItem: RapidOperation = RapidOperation.Use; ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; case ControllerCommand.Backpack_HandleWeapon: RapidOperation = RapidOperation.Handle; ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; } } descriptionList.Refresh(); }
public void SendCommand(Guid providerGuid, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary <string, string> commandArguments) { List <EventProviderBase> list = new List <EventProviderBase>(); lock (EventProviderStreamsLock) { foreach (WeakReference reference in s_providers) { EventProviderBase target = reference.Target as EventProviderBase; if ((target != null) && ((target.Guid == providerGuid) || (providerGuid == Guid.Empty))) { list.Add(target); } } } foreach (EventProviderBase base3 in list) { base3.SendCommand(this, enable, level, matchAnyKeyword, command, commandArguments); } }
public void Notify(ControllerCommand cmd) { switch(cmd) { case ControllerCommand.Menu_PreviousItem: controlledMenu.SelectPreviousItem(); break; case ControllerCommand.Menu_NextItem: controlledMenu.SelectNextItem(); break; case ControllerCommand.Menu_ExecuteSelectItem: controlledMenu.ExecuteSelected(); break; } }
public void Notify(ControllerCommand cmd) { var tryedExchange = false; if (ControlledBackpack[SelectedListIndex] != null) { switch (cmd) { case ControllerCommand.Merchant_SelectNext: descriptionList[SelectedListIndex].SelectNext(); break; case ControllerCommand.Merchant_SelectPrevious: descriptionList[SelectedListIndex].SelectPrevious(); break; case ControllerCommand.Merchant_SelectNextPage: descriptionList[SelectedListIndex].SelectNextPage(); break; case ControllerCommand.Merchant_SelectPreviousPage: descriptionList[SelectedListIndex].SelectPreviousPage(); break; case ControllerCommand.Merchant_SelectPreviousList: descriptionList[SelectedListIndex].HideSelection(); SelectedListIndex = SelectedListIndex - 1; descriptionList[SelectedListIndex].ShowSelection(); this.Refresh(); break; case ControllerCommand.Merchant_SelectNextList: descriptionList[SelectedListIndex].HideSelection(); SelectedListIndex = SelectedListIndex + 1; descriptionList[SelectedListIndex].ShowSelection(); this.Refresh(); break; case ControllerCommand.Merchant_Close: ValidIndex = false; this.Hide(); gamePanel.Show(); FocusOnMap(); Opened = false; controlledMerchant.FarewellMessage(); break; case ControllerCommand.Merchant_PurchaseSell: if (SelectedIndex != -1) { var locIx = SelectedIndex; var item = ControlledBackpack[SelectedListIndex][locIx]; if (SelectedListIndex == 0) // Merchant buy from Pg { if (controlledMerchant.Purchase(item, controlledPg)) { controlledMerchant.GoodPurchaseSpeech(); controlledMerchant.SaysWhatPurchased(controlledPg); } else { controlledMerchant.BadPurchaseSpeech(); } } else // Merchant sell to Pg { if (controlledMerchant.Sell(item, controlledPg)) { Notify(ControllerCommand.Merchant_SelectPrevious); controlledMerchant.GoodSellSpeech(); controlledMerchant.SaysWhatSold(controlledPg); } else { controlledMerchant.BadSellSpeech(); } } tryedExchange = true; var b = controlledBackpack[selectedListIndex]; var c = b.Count; locIx = c == 0 ? -1 : Math.Min(locIx, c); descriptionList[SelectedListIndex].SelectNext(locIx); } break; case ControllerCommand.Merchant_Open: Opened = true; gamePanel.Hide(); SelectedListIndex = 0; this.Show(); for (int i = 0; i < controlledBackpack.Length; i++) { if (i == 0) { descriptionList[i].ShowSelection(); } else { descriptionList[i].HideSelection(); } descriptionList[i].Items = controlledBackpack[i].ToList(); } this.Refresh(); this.Focus(); controlledMerchant.GreetingsMessage(); break; } } if (!tryedExchange) { var ix = descriptionList[SelectedListIndex].SelectedIndex; if (ix != -1) { if (SelectedListIndex == 0) { controlledMerchant.ProposePurchase(controlledBackpack[SelectedListIndex][ix]); } else { controlledMerchant.ProposeSell(controlledBackpack[SelectedListIndex][ix]); } } else { controlledMerchant.NoProposal(); } } tryedExchange = false; descriptionList[SelectedListIndex].Refresh(); }
private unsafe void EtwEnableCallBack([In] ref Guid sourceId, [In] int controlCode, [In] byte setLevel, [In] long anyKeyword, [In] long allKeyword, [In] UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR *filterData, [In] void *callbackContext) { try { ControllerCommand command = ControllerCommand.Update; IDictionary <string, string> arguments = (IDictionary <string, string>)null; bool flag1 = false; if (controlCode == 1) { this.m_enabled = true; this.m_level = setLevel; this.m_anyKeywordMask = anyKeyword; this.m_allKeywordMask = allKeyword; List <Tuple <EventProvider.SessionInfo, bool> > sessions = this.GetSessions(); foreach (Tuple <EventProvider.SessionInfo, bool> tuple in sessions) { int num1 = tuple.Item1.sessionIdBit; int etwSessionId = tuple.Item1.etwSessionId; bool flag2 = tuple.Item2; flag1 = true; arguments = (IDictionary <string, string>)null; if (sessions.Count > 1) { filterData = (UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR *)null; } byte[] data; int dataStart; if (flag2 && this.GetDataFromController(etwSessionId, filterData, out command, out data, out dataStart)) { arguments = (IDictionary <string, string>) new Dictionary <string, string>(4); int null1; for (; dataStart < data.Length; dataStart = null1 + 1) { int null2 = EventProvider.FindNull(data, dataStart); int num2 = null2 + 1; null1 = EventProvider.FindNull(data, num2); if (null1 < data.Length) { string string1 = Encoding.UTF8.GetString(data, dataStart, null2 - dataStart); string string2 = Encoding.UTF8.GetString(data, num2, null1 - num2); arguments[string1] = string2; } } } this.OnControllerCommand(command, arguments, flag2 ? num1 : -num1, etwSessionId); } } else if (controlCode == 0) { this.m_enabled = false; this.m_level = (byte)0; this.m_anyKeywordMask = 0L; this.m_allKeywordMask = 0L; this.m_liveSessions = (List <EventProvider.SessionInfo>)null; } else { if (controlCode != 2) { return; } command = ControllerCommand.SendManifest; } if (flag1) { return; } this.OnControllerCommand(command, arguments, 0, 0); } catch (Exception ex) { } }
protected override void OnControllerCommand(ControllerCommand command, IDictionary<string, string> arguments) { // We use null to represent the ETW EventProviderDataStream. We may want change this if it // is too confusing, but it avoids making another sentinal. EventProviderDataStream etwStream = null; m_eventProviderBase.SendCommand(etwStream, IsEnabled(), Level, MatchAnyKeyword, command, arguments); }
protected virtual void OnControllerCommand(EventProviderDataStream outputStream, ControllerCommand command, IDictionary <string, string> arguments) { }
private void Update(bool fast) { if (_dontUpdateValues) { return; } if (_isBotting) { if (is_round_over() && game_in_progress) { _post_round_wait_time--; game_in_progress = false; _totalGames = _totalGames + 1; if (get_round_result() == "P1") { _wins = _wins + 1; _lastResult = "P1 Win"; _p2_losses = _p2_losses + 1; } else { _losses = _losses + 1; _lastResult = "P1 Loss"; _p2_wins = _p2_wins + 1; } _winsToLosses = (float)_wins / _totalGames; _p2_winsToLosses = (float)_p2_wins / _totalGames; GlobalWin.OSD.ClearGUIText(); GlobalWin.OSD.AddMessageForTime("Game #: " + _totalGames + " | Last Result: " + _lastResult + " | P1 Wins-Losses: " + _wins + "-" + _losses + " (" + _winsToLosses + ") | P2 Wins-Losses: " + _p2_wins + "-" + _p2_losses + " (" + _p2_winsToLosses + ")", _OSDMessageTimeInSeconds); } if (_post_round_wait_time < Global.Config.round_over_delay) { if (_post_round_wait_time < 1) { _post_round_wait_time = Global.Config.round_over_delay; if (Global.Config.pause_after_round) { GlobalWin.MainForm.PauseEmulator(); return; } } else { _post_round_wait_time--; return; } } string command_type = ""; do { // send over the current game state ControllerCommand command = SendEmulatorGameStateToController(this.client); ControllerCommand command_p2; command_type = command.type; if (Global.Config.use_two_controllers) { do { command_p2 = SendEmulatorGameStateToController(this.client_p2); //Console.WriteLine("p1 command: " + command.type + "p2 command: " + command_p2.type); // send the game state to the controller // if the commands don't match, wait until they do. } while (command_p2.type != command_type); // if we get a buttons command, replace the buttons of first emulator's set for it's p2 (which // is null) with the buttons we want to actually play from this emulator's set of buttons. // we do this so we only need one command object after this code block. if (command_type == "buttons") { command.p2 = command_p2.p2; } } // get a command back // act on the command if (command_type == "reset") { GlobalWin.MainForm.LoadState(command.savegamepath, Path.GetFileName(command.savegamepath)); game_in_progress = true; } else if (command_type == "processing") { // just do nothing, we're waiting for feedback from the controller. // XXX how do we tell the emulator to not advance the frame? } else { SetJoypadButtons(command.p1, 1); if (Global.Config.use_two_controllers) { SetJoypadButtons(command.p2, 2); } } } while (command_type == "processing"); // press the buttons if need be //PressButtons(); } }
protected override void OnControllerCommand(ControllerCommand command, IDictionary<string, string> arguments) { EventProviderDataStream outputStream = null; this.m_eventProviderBase.SendCommand(outputStream, base.IsEnabled(), base.Level, base.MatchAnyKeyword, command, arguments); }
private unsafe bool GetDataFromController(int etwSessionId, UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR *filterData, out ControllerCommand command, out byte[] data, out int dataStart) { data = (byte[])null; dataStart = 0; if ((IntPtr)filterData == IntPtr.Zero) { string str1 = "\\Microsoft\\Windows\\CurrentVersion\\Winevt\\Publishers\\{" + (object)this.m_providerId + "}"; string str2 = Marshal.SizeOf(typeof(IntPtr)) != 8 ? "HKEY_LOCAL_MACHINE\\Software" + str1 : "HKEY_LOCAL_MACHINE\\Software\\Wow6432Node" + str1; string valueName = "ControllerData_Session_" + etwSessionId.ToString((IFormatProvider)CultureInfo.InvariantCulture); new RegistryPermission(RegistryPermissionAccess.Read, str2).Assert(); data = Registry.GetValue(str2, valueName, (object)null) as byte[]; if (data != null) { command = ControllerCommand.Update; return(true); } command = ControllerCommand.Update; return(false); } if (filterData->Ptr != 0L && 0 < filterData->Size && filterData->Size <= 1024) { data = new byte[filterData->Size]; Marshal.Copy((IntPtr)filterData->Ptr, data, 0, data.Length); } command = (ControllerCommand)filterData->Type; return(true); }
private unsafe void EtwEnableCallBack([In] ref Guid sourceId, [In] int controlCode, [In] byte setLevel, [In] long anyKeyword, [In] long allKeyword, [In] UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR *filterData, [In] void *callbackContext) { try { ControllerCommand command = ControllerCommand.Update; IDictionary <string, string> dictionary = null; bool flag = false; if (controlCode == 1) { this.m_enabled = true; this.m_level = setLevel; this.m_anyKeywordMask = anyKeyword; this.m_allKeywordMask = allKeyword; List <Tuple <EventProvider.SessionInfo, bool> > sessions = this.GetSessions(); using (List <Tuple <EventProvider.SessionInfo, bool> > .Enumerator enumerator = sessions.GetEnumerator()) { while (enumerator.MoveNext()) { Tuple <EventProvider.SessionInfo, bool> tuple = enumerator.Current; int sessionIdBit = tuple.Item1.sessionIdBit; int etwSessionId = tuple.Item1.etwSessionId; bool item = tuple.Item2; flag = true; dictionary = null; if (sessions.Count > 1) { filterData = null; } byte[] array; int i; if (item && this.GetDataFromController(etwSessionId, filterData, out command, out array, out i)) { dictionary = new Dictionary <string, string>(4); while (i < array.Length) { int num = EventProvider.FindNull(array, i); int num2 = num + 1; int num3 = EventProvider.FindNull(array, num2); if (num3 < array.Length) { string @string = Encoding.UTF8.GetString(array, i, num - i); string string2 = Encoding.UTF8.GetString(array, num2, num3 - num2); dictionary[@string] = string2; } i = num3 + 1; } } this.OnControllerCommand(command, dictionary, item ? sessionIdBit : (-sessionIdBit), etwSessionId); } goto IL_162; } } if (controlCode == 0) { this.m_enabled = false; this.m_level = 0; this.m_anyKeywordMask = 0L; this.m_allKeywordMask = 0L; this.m_liveSessions = null; } else { if (controlCode != 2) { return; } command = ControllerCommand.SendManifest; } IL_162: if (!flag) { this.OnControllerCommand(command, dictionary, 0, 0); } } catch (Exception) { } }
protected override void OnControllerCommand(ControllerCommand command, IDictionary <string, string> arguments) { EventProviderDataStream outputStream = null; this.m_eventProviderBase.SendCommand(outputStream, base.IsEnabled(), base.Level, base.MatchAnyKeyword, command, arguments); }
private unsafe bool GetDataFromController(ManifestEtw.EVENT_FILTER_DESCRIPTOR* filterData, out ControllerCommand command, out byte[] data, out int dataStart) { data = null; if (filterData == null) { string keyName = @"\Microsoft\Windows\CurrentVersion\Winevt\Publishers\{" + this.m_providerId + "}"; if (Marshal.SizeOf(typeof(IntPtr)) == 8) { keyName = @"HKEY_LOCAL_MACHINE\Software\Wow6432Node" + keyName; } else { keyName = @"HKEY_LOCAL_MACHINE\Software" + keyName; } data = Registry.GetValue(keyName, "ControllerData", null) as byte[]; if ((data != null) && (data.Length >= 4)) { command = (ControllerCommand) (((data[3] << ((8 + data[2]) & 0x1f)) << ((8 + data[1]) & 0x1f)) << (8 + data[0])); dataStart = 4; return true; } } else { if (((filterData.Ptr != 0L) && (0 < filterData.Size)) && (filterData.Size <= 0x400)) { data = new byte[filterData.Size]; Marshal.Copy((IntPtr) filterData.Ptr, data, 0, data.Length); } command = (ControllerCommand) filterData.Type; dataStart = 0; return true; } dataStart = 0; command = ControllerCommand.Update; return false; }
internal void SendCommand(EventProviderDataStream outputStream, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary <string, string> commandArguments) { this.InsureInitialized(); if ((this.m_OutputStreams != null) && (this.m_eventCallbackArgs == null)) { this.m_eventCallbackArgs = new EventWrittenEventArgs(this); } this.m_providerEnabled = enable; this.m_level = level; this.m_matchAnyKeyword = matchAnyKeyword; EventProviderDataStream outputStreams = this.m_OutputStreams; if (outputStreams == null) { goto Label_0062; } Label_0042: if (outputStreams == null) { throw new ArgumentException("outputStream not found"); } if (outputStreams.m_MasterStream != outputStream) { outputStreams = outputStreams.m_Next; goto Label_0042; } Label_0062: if (enable) { if (outputStreams != null) { if (!outputStreams.m_ManifestSent) { outputStreams.m_ManifestSent = true; this.SendManifest(this.m_rawManifest, outputStreams); } } else if (!this.m_ETWManifestSent && this.m_completelyInited) { this.m_ETWManifestSent = true; this.SendManifest(this.m_rawManifest, outputStreams); } } else if (outputStreams != null) { outputStreams.m_ManifestSent = false; } else { this.m_ETWManifestSent = false; } for (int i = 0; i < this.m_eventData.Length; i++) { this.SetEnabled(outputStreams, i, this.IsEnabledDefault(i, level, matchAnyKeyword)); } if (commandArguments == null) { commandArguments = new Dictionary <string, string>(); } this.OnControllerCommand(outputStreams, command, commandArguments); }
protected virtual void OnControllerCommand(ControllerCommand command, IDictionary<string, string> arguments) { }
unsafe void EtwEnableCallBack( [In] ref System.Guid sourceId, [In] int controlCode, [In] byte setLevel, [In] long anyKeyword, [In] long allKeyword, [In] UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR *filterData, [In] void *callbackContext ) { ControllerCommand command = ControllerCommand.Update; IDictionary <string, string> args = null; byte[] data; int keyIndex; bool skipFinalOnControllerCommand = false; EventSource.OutputDebugString(string.Format("EtwEnableCallBack(ctrl {0}, lvl {1}, any {2:x}, all {3:x})", controlCode, setLevel, anyKeyword, allKeyword)); if (controlCode == UnsafeNativeMethods.ManifestEtw.EVENT_CONTROL_CODE_ENABLE_PROVIDER) { m_enabled = true; m_level = setLevel; m_anyKeywordMask = anyKeyword; m_allKeywordMask = allKeyword; List <Tuple <SessionInfo, bool> > sessionsChanged = GetSessions(); foreach (var session in sessionsChanged) { int sessionChanged = session.Item1.sessionIdBit; int etwSessionId = session.Item1.etwSessionId; bool bEnabling = session.Item2; EventSource.OutputDebugString(string.Format(CultureInfo.InvariantCulture, "EtwEnableCallBack: session changed {0}:{1}:{2}", sessionChanged, etwSessionId, bEnabling)); skipFinalOnControllerCommand = true; args = null; // reinitialize args for every session... // if we get more than one session changed we have no way // of knowing which one "filterData" belongs to if (sessionsChanged.Count > 1) { filterData = null; } // read filter data only when a session is being *added* if (bEnabling && GetDataFromController(etwSessionId, filterData, out command, out data, out keyIndex)) { args = new Dictionary <string, string>(4); while (keyIndex < data.Length) { int keyEnd = FindNull(data, keyIndex); int valueIdx = keyEnd + 1; int valueEnd = FindNull(data, valueIdx); if (valueEnd < data.Length) { string key = System.Text.Encoding.UTF8.GetString(data, keyIndex, keyEnd - keyIndex); string value = System.Text.Encoding.UTF8.GetString(data, valueIdx, valueEnd - valueIdx); args[key] = value; } keyIndex = valueEnd + 1; } } // execute OnControllerCommand once for every session that has changed. try { OnControllerCommand(command, args, (bEnabling ? sessionChanged : -sessionChanged), etwSessionId); } catch (Exception) { // We want to ignore any failures that happen as a result of turning on this provider as to // not crash the app. } } } else if (controlCode == UnsafeNativeMethods.ManifestEtw.EVENT_CONTROL_CODE_DISABLE_PROVIDER) { m_enabled = false; m_level = 0; m_anyKeywordMask = 0; m_allKeywordMask = 0; m_liveSessions = null; } else if (controlCode == UnsafeNativeMethods.ManifestEtw.EVENT_CONTROL_CODE_CAPTURE_STATE) { command = ControllerCommand.SendManifest; } else { return; // per spec you ignore commands you don't recognise. } try { if (!skipFinalOnControllerCommand) { OnControllerCommand(command, args, 0, 0); } } catch (Exception) { // We want to ignore any failures that happen as a result of turning on this provider as to // not crash the app. } }
private unsafe bool GetDataFromController(ManifestEtw.EVENT_FILTER_DESCRIPTOR *filterData, out ControllerCommand command, out byte[] data, out int dataStart) { data = null; if (filterData == null) { string keyName = @"\Microsoft\Windows\CurrentVersion\Winevt\Publishers\{" + this.m_providerId + "}"; if (Marshal.SizeOf(typeof(IntPtr)) == 8) { keyName = @"HKEY_LOCAL_MACHINE\Software\Wow6432Node" + keyName; } else { keyName = @"HKEY_LOCAL_MACHINE\Software" + keyName; } data = Registry.GetValue(keyName, "ControllerData", null) as byte[]; if ((data != null) && (data.Length >= 4)) { command = (ControllerCommand)(((data[3] << ((8 + data[2]) & 0x1f)) << ((8 + data[1]) & 0x1f)) << (8 + data[0])); dataStart = 4; return(true); } } else { if (((filterData.Ptr != 0L) && (0 < filterData.Size)) && (filterData.Size <= 0x400)) { data = new byte[filterData.Size]; Marshal.Copy((IntPtr)filterData.Ptr, data, 0, data.Length); } command = (ControllerCommand)filterData.Type; dataStart = 0; return(true); } dataStart = 0; command = ControllerCommand.Update; return(false); }
private unsafe bool GetDataFromController(int etwSessionId, UnsafeNativeMethods.ManifestEtw.EVENT_FILTER_DESCRIPTOR *filterData, out ControllerCommand command, out byte[] data, out int dataStart) { data = null; dataStart = 0; if (filterData == null) { string regKey = @"\Microsoft\Windows\CurrentVersion\Winevt\Publishers\{" + m_providerId + "}"; if (System.Runtime.InteropServices.Marshal.SizeOf(typeof(IntPtr)) == 8) { regKey = @"HKEY_LOCAL_MACHINE\Software" + @"\Wow6432Node" + regKey; } else { regKey = @"HKEY_LOCAL_MACHINE\Software" + regKey; } string valueName = "ControllerData_Session_" + etwSessionId.ToString(CultureInfo.InvariantCulture); data = Microsoft.Win32.Registry.GetValue(regKey, valueName, null) as byte[]; if (data != null) { // We only used the persisted data from the registry for updates. command = ControllerCommand.Update; return(true); } } else { if (filterData->Ptr != 0 && 0 < filterData->Size && filterData->Size <= 1024) { data = new byte[filterData->Size]; Marshal.Copy((IntPtr)filterData->Ptr, data, 0, data.Length); } command = (ControllerCommand)filterData->Type; return(true); } command = ControllerCommand.Update; return(false); }
protected virtual void OnControllerCommand(ControllerCommand command, IDictionary <string, string> arguments) { }
// New in CLR4.0 protected virtual void OnControllerCommand(ControllerCommand command, IDictionary<string, string> arguments, int sessionId, int etwSessionId) { }
public CodeGenerationControllerAppService(ControllerCommand controllerCommand) { _controllerCommand = controllerCommand; }
protected override void OnControllerCommand(ControllerCommand command, IDictionary<string, string> arguments) { // We use null to represent the ETW EventListener. EventListener listener = null; m_eventSource.SendCommand(listener, (EventCommand)command, IsEnabled(), Level, MatchAnyKeyword, arguments); }
/// <summary> /// Send a command to a provider (from a particular stream). The most important command is simply /// to turn a particular provider on or off. However particular providers might implement /// additional commands (like dumping particular data structures in response to a command. /// </summary> /// <param name="providerGuid">The GUID for the event provider that the command is to be sent to. /// Guid.Empty is defined to be a wildcard that means all providers. </param> /// <param name="enable">Indicates if the provider is to be turned on or off. The rest of the /// arguments are only appicable if enabled=true.</param> /// <param name="level">The level (verbosity) of the logging desired.</param> /// <param name="matchAnyKeyword">Providers define groups of events and each such group is given a /// bit in a 64 bit enumeration. This parameter indicates which groups should be truned on. Events /// have are not assigned any group are never filtered by the matchAnyKeyword value.</param> /// <param name="command">The command to be given to the provider. Typically it is Command.Update. /// Individual providers can define their own commands</param> /// <param name="commandArguments">This is a set of key-value pairs that are interpreted by the /// provider. It is a way of passing arbitrary arguments to the provider when issuing a command</param> public void SendCommand(Guid providerGuid, bool enable, EventLevel level, EventKeywords matchAnyKeyword, ControllerCommand command, IDictionary<string, string> commandArguments) { // Copy it to list so I can make the callback without holding the EventProviderStreamsLock. List<EventProviderBase> providerBases = new List<EventProviderBase>(); lock (EventProviderStreamsLock) { foreach (WeakReference providerRef in s_providers) { EventProviderBase providerBase = providerRef.Target as EventProviderBase; if (providerBase != null && (providerBase.Guid == providerGuid || providerGuid == Guid.Empty)) providerBases.Add(providerBase); } } foreach (EventProviderBase providerBase in providerBases) providerBase.SendCommand(this, enable, level, matchAnyKeyword, command, commandArguments); }
public void Notify(ControllerCommand cmd) { var tryedExchange = false; if (ControlledBackpack[SelectedListIndex] != null) { switch (cmd) { case ControllerCommand.Merchant_SelectNext: descriptionList[SelectedListIndex].SelectNext(); break; case ControllerCommand.Merchant_SelectPrevious: descriptionList[SelectedListIndex].SelectPrevious(); break; case ControllerCommand.Merchant_SelectNextPage: descriptionList[SelectedListIndex].SelectNextPage(); break; case ControllerCommand.Merchant_SelectPreviousPage: descriptionList[SelectedListIndex].SelectPreviousPage(); break; case ControllerCommand.Merchant_SelectPreviousList: descriptionList[SelectedListIndex].HideSelection(); SelectedListIndex = SelectedListIndex - 1; descriptionList[SelectedListIndex].ShowSelection(); this.Refresh(); break; case ControllerCommand.Merchant_SelectNextList: descriptionList[SelectedListIndex].HideSelection(); SelectedListIndex = SelectedListIndex + 1; descriptionList[SelectedListIndex].ShowSelection(); this.Refresh(); break; case ControllerCommand.Merchant_Close: ValidIndex = false; this.Hide(); gamePanel.Show(); FocusOnMap(); Opened = false; controlledMerchant.FarewellMessage(); break; case ControllerCommand.Merchant_PurchaseSell: if (SelectedIndex != -1) { var locIx = SelectedIndex; var item = ControlledBackpack[SelectedListIndex][locIx]; if (SelectedListIndex == 0) // Merchant buy from Pg { if (controlledMerchant.Purchase(item, controlledPg)) { controlledMerchant.GoodPurchaseSpeech(); controlledMerchant.SaysWhatPurchased(controlledPg); } else { controlledMerchant.BadPurchaseSpeech(); } } else // Merchant sell to Pg { if (controlledMerchant.Sell(item, controlledPg)) { Notify(ControllerCommand.Merchant_SelectPrevious); controlledMerchant.GoodSellSpeech(); controlledMerchant.SaysWhatSold(controlledPg); } else { controlledMerchant.BadSellSpeech(); } } tryedExchange = true; var b = controlledBackpack[selectedListIndex]; var c = b.Count; locIx = c == 0 ? -1 : Math.Min(locIx, c); descriptionList[SelectedListIndex].SelectNext(locIx); } break; case ControllerCommand.Merchant_Open: Opened = true; gamePanel.Hide(); SelectedListIndex = 0; this.Show(); for (int i = 0; i < controlledBackpack.Length; i++) { if(i == 0) { descriptionList[i].ShowSelection(); } else { descriptionList[i].HideSelection(); } descriptionList[i].Items = controlledBackpack[i].ToList(); } this.Refresh(); this.Focus(); controlledMerchant.GreetingsMessage(); break; } } if (!tryedExchange) { var ix = descriptionList[SelectedListIndex].SelectedIndex; if (ix != -1) { if (SelectedListIndex == 0) { controlledMerchant.ProposePurchase(controlledBackpack[SelectedListIndex][ix]); } else { controlledMerchant.ProposeSell(controlledBackpack[SelectedListIndex][ix]); } } else { controlledMerchant.NoProposal(); } } tryedExchange = false; descriptionList[SelectedListIndex].Refresh(); }
public void Notify(ControllerCommand cmd) { RapidOperation = RapidOperation.None; if (controlledBackpack != null) { switch (cmd) { case ControllerCommand.Backpack_SelectNext: descriptionList.SelectNext(); break; case ControllerCommand.Backpack_SelectPrevious: descriptionList.SelectPrevious(); break; case ControllerCommand.Backpack_SelectNextPage: descriptionList.SelectNextPage(); break; case ControllerCommand.Backpack_SelectPreviousPage: descriptionList.SelectPreviousPage(); break; case ControllerCommand.Backpack_Close: ValidIndex = false; this.Hide(); gamePanel.Show(); FocusOnMap(); Opened = false; break; case ControllerCommand.Backpack_Pick: ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; case ControllerCommand.Backpack_Open: Opened = true; gamePanel.Hide(); this.Show(); descriptionList.Items = controlledBackpack.ToList(); this.Refresh(); this.Focus(); break; case ControllerCommand.Backpack_PutOnArmor: RapidOperation = RapidOperation.PutOn; ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; case ControllerCommand.Backpack_EmbraceShield: RapidOperation = RapidOperation.Embrace; ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; case ControllerCommand.Backpack_UseItem: RapidOperation = RapidOperation.Use; ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; case ControllerCommand.Backpack_HandleWeapon: RapidOperation = RapidOperation.Handle; ValidIndex = true; this.Hide(); FocusOnMap(); Opened = false; break; } } descriptionList.Refresh(); }