private async ValueTask DisposeImpl(bool isAsync) { if (ActiveTasks != null) { ActiveTasks.Clear(); ActiveTasks = null; } if (ProcessingTasks != null) { ProcessingTasks.Clear(); ProcessingTasks = null; } if (ActiveCommand != null) { if (isAsync) { await ActiveCommand.DisposeAsync().ConfigureAwait(false); } else { ActiveCommand.Dispose(); } ActiveCommand = null; } NotifyDisposed(); }
/// <summary> /// Converts a <see cref="ActiveCommand"/> to a string, using the specified context and culture information. /// </summary> /// <param name="context">A System.ComponentModel.ITypeDescriptorContext that provides a format context.</param> /// <param name="culture">A System.Globalization.CultureInfo. If null is passed, the current culture is assumed.</param> /// <param name="value">The <see cref="ActiveCommand"/> to convert.</param> /// <param name="destinationType">The System.Type to convert the value parameter to.</param> /// <returns> /// A string that represents the converted value. /// </returns> /// <remarks> /// <para>This method will convert to a string which is the name of the command.</para> /// </remarks> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { ActiveCommand ActiveCommand = (ActiveCommand)value; if (destinationType == typeof(string)) { return(ActiveCommand.Name); } return(base.ConvertTo(context, culture, value, destinationType)); }
public void ExecuteDelayedScripts() { lock (ListDelayedOnlineCommand) { foreach (DelayedExecutableOnlineScript ActiveCommand in ListDelayedOnlineCommand) { ActiveCommand.ExecuteOnMainThread(); } ListDelayedOnlineCommand.Clear(); } }
/// <summary> /// Compare a name with known command names and return the courresponding <see cref="ActiveCommand"/>. /// </summary> /// <param name="Name">The command name to compare.</param> /// <param name="Result">A <see cref="ActiveCommand"/> with this name, null if no command name matches <paramref name="Name"/>.</param> /// <returns> /// True if a match is found; otherwise, false. /// </returns> public static bool TryParseName(string Name, out ActiveCommand Result) { foreach (ActiveCommand Command in ActiveCommand.AllCommands) { if (Name == Command.Name) { Result = Command; return(true); } } Result = null; return(false); }
public void ExecuteDelayedScripts() { lock (ListDelayedOnlineCommand) { foreach (DelayedExecutableOnlineScript ActiveCommand in ListDelayedOnlineCommand) { ActiveCommand.ExecuteOnMainThread(); } ListDelayedOnlineCommand.Clear(); } foreach (CommunicationClient ActiveGroup in DicCrossServerCommunicationByGroupID.Values) { ActiveGroup.ExecuteDelayedScripts(); } }
public void Dispose() { if (ActiveTasks != null) { ActiveTasks.Clear(); ActiveTasks = null; } if (ProcessingTasks != null) { ProcessingTasks.Clear(); ProcessingTasks = null; } if (ActiveCommand != null) { ActiveCommand.Dispose(); ActiveCommand = null; } NotifyDisposed(); }
public void Update(GameTime gameTime) { lock (ListDelayedOnlineCommand) { foreach (DelayedExecutableOnlineScript ActiveCommand in ListDelayedOnlineCommand) { ActiveCommand.ExecuteOnMainThread(); } ListDelayedOnlineCommand.Clear(); } for (int A = ListVisualEffects.Count - 1; A >= 0; --A) { SimpleAnimation ActiveVisualEffect = ListVisualEffects[A]; ActiveVisualEffect.Update(gameTime); if (ActiveVisualEffect.HasEnded) { ListVisualEffects.RemoveAt(A); } } for (int A = 0; A < ListAttackCollisionBox.Count; A++) { AttackBox ActiveAttackBox = (AttackBox)ListAttackCollisionBox[A]; if (!ActiveAttackBox.IsAlive) { continue; } ActiveAttackBox.Update(gameTime); foreach (KeyValuePair <uint, RobotAnimation> ActiveRobot in DicRobot) { UpdateAttackCollisionWithRobot(gameTime, ActiveAttackBox, ActiveRobot.Value); } UpdateAttackCollisionWithWorld(ActiveAttackBox); ActiveAttackBox.Move(gameTime); } for (int A = ListImages.Count - 1; A >= 0; --A) { SimpleAnimation ActiveAnimation = ListImages[A]; ActiveAnimation.Update(gameTime); if (ActiveAnimation.HasEnded) { ListImages.RemoveAt(A); } } for (int P = ListProp.Count - 1; P >= 0; --P) { if (ListProp[P].HasEnded) { ListProp.RemoveAt(P); } else { ListProp[P].Update(gameTime); } } #region Robot Update foreach (RobotAnimation ActiveRobot in DicRobot.Values) { if (!ActiveRobot.IsUpdated) { continue; } if (ActiveRobot.RobotAI != null && !Owner.UsePreview) { ActiveRobot.RobotAI.UpdateStep(gameTime); } ActiveRobot.Update(gameTime, DicRobot); } foreach (RobotAnimation RobotToAdd in ListRobotToAdd) { SpawnRobot(RobotToAdd); } ListRobotToAdd.Clear(); for (int R = ListRobotToRemove.Count - 1; R >= 0; R--) { DicRobot.Remove(ListRobotToRemove[R]); ListRobotToRemove.RemoveAt(R); if (ListRobotToRemove.Count == 0) { Owner.CheckIfAllEnemiesAreDead(); } } #endregion }
/// <summary> /// Converter from a <see cref="ActiveCommand"/> to the associated content in a <see cref="DialogValidation"/>. /// </summary> /// <param name="values">The values to convert.</param> /// <param name="targetType">This parameter is not used.</param> /// <param name="parameter">This parameter is not used.</param> /// <param name="culture">This parameter is not used.</param> /// <returns> /// A System.Object that represents the converted value /// </returns> /// <remarks> /// <para>The first value must be a <see cref="DialogValidation"/>.</para> /// <para>The second value must be a <see cref="ActiveCommand"/>.</para> /// </remarks> public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { Assert.ValidateReference(values); if (values.Length > 1 && (values[0] is DialogValidation) && (values[1] is ActiveCommand)) { DialogValidation Control = (DialogValidation)values[0]; ActiveCommand Command = (ActiveCommand)values[1]; if (Command is ActiveCommandOk) { return(Control.ContentOk); } else if (Command is ActiveCommandCancel) { return(Control.ContentCancel); } else if (Command is ActiveCommandAbort) { return(Control.ContentAbort); } else if (Command is ActiveCommandRetry) { return(Control.ContentRetry); } else if (Command is ActiveCommandIgnore) { return(Control.ContentIgnore); } else if (Command is ActiveCommandYes) { return(Control.ContentYes); } else if (Command is ActiveCommandNo) { return(Control.ContentNo); } else if (Command is ActiveCommandClose) { return(Control.ContentClose); } else if (Command is ActiveCommandHelp) { return(Control.ContentHelp); } else if (Command is ActiveCommandTryAgain) { return(Control.ContentTryAgain); } else if (Command is ActiveCommandContinue) { return(Control.ContentContinue); } } return(null); }
private void ConvertActiveCommand(TypeConverter converter, object from, out bool isConvertedFrom, ActiveCommand to, out bool isConvertedTo) { isConvertedFrom = true; try { converter.ConvertFrom(from); } catch { isConvertedFrom = false; } isConvertedTo = true; try { converter.ConvertTo(to, from.GetType()); } catch { isConvertedTo = false; } }
/// <summary> /// Add commands to a shortcut menu. /// </summary> /// <param name="hMenu">A handle to the shortcut menu.</param> /// <param name="iMenu">The zero-based position at which to insert the first new menu item.</param> /// <param name="idCmdFirst">The minimum value that the handler can specify for a menu item ID.</param> /// <param name="idCmdLast">The maximum value that the handler can specify for a menu item ID.</param> /// <param name="uFlags">Optional flags that specify how the shortcut menu can be changed.</param> /// <returns> /// If successful, returns an HRESULT value that has its severity value set /// to SEVERITY_SUCCESS and its code value set to the offset of the largest /// command identifier that was assigned, plus one. /// </returns> public int QueryContextMenu(IntPtr hMenu, uint iMenu, uint idCmdFirst, uint idCmdLast, uint uFlags) { // If uFlags include CMF_DEFAULTONLY then we should not do anything. if (((uint)CMF.CMF_DEFAULTONLY & uFlags) != 0) { return(NativeHelpers.MakeHResult(WinError.SEVERITY_SUCCESS, 0, 0)); } // Check if the user wants to see the extended context menu (i.e. pressing Shift while opening the context menu). this.isExtendedContextMenu = ((uint)CMF.CMF_EXTENDEDVERBS & uFlags) != 0; this.activeCommands.Clear(); var maxItems = (idCmdLast - idCmdFirst) + 1 - 2 /* Subtract 2 for the separators */; if (maxItems > 0) { var menuIndex = iMenu; // Add a separator. var beginSeparator = new MENUITEMINFO(); beginSeparator.cbSize = (uint)Marshal.SizeOf(beginSeparator); beginSeparator.fMask = MIIM.MIIM_TYPE; beginSeparator.fType = MFT.MFT_SEPARATOR; if (!NativeMethods.InsertMenuItem(hMenu, menuIndex++, true, ref beginSeparator)) { return(Marshal.GetHRForLastWin32Error()); } // Add the commands. var context = new CommandContext(this.selectedShellItems, this.isExtendedContextMenu); var commandOffset = default(uint); foreach (var command in CommandFactory.GetAvailableCommands()) { try { var commandState = command.GetState(context); if (commandState != null && commandState.IsVisible) { var verb = Guid.NewGuid().ToString(); // Create a unique verb to be able to retrieve the right command later on based on that verb. var activeCommand = new ActiveCommand(command, verb, commandOffset++); this.activeCommands.Add(activeCommand); var mii = new MENUITEMINFO(); mii.cbSize = (uint)Marshal.SizeOf(mii); mii.fMask = MIIM.MIIM_BITMAP | MIIM.MIIM_STRING | MIIM.MIIM_FTYPE | MIIM.MIIM_ID | MIIM.MIIM_STATE; mii.wID = idCmdFirst + activeCommand.Offset; mii.fType = MFT.MFT_STRING; mii.dwTypeData = commandState.MenuText; if (!commandState.IsEnabled) { mii.fState = MFS.MFS_DISABLED; } else if (commandState.IsChecked) { mii.fState = MFS.MFS_CHECKED; } else { mii.fState = MFS.MFS_ENABLED; } if (!NativeMethods.InsertMenuItem(hMenu, menuIndex++, true, ref mii)) { return(Marshal.GetHRForLastWin32Error()); } if (this.activeCommands.Count >= maxItems) { break; } } } catch (Exception exc) { Logger.LogError($"Error querying command \"{command.Name}\": {exc.ToString()}"); } } // Add a separator. var endSeparator = new MENUITEMINFO(); endSeparator.cbSize = (uint)Marshal.SizeOf(endSeparator); endSeparator.fMask = MIIM.MIIM_TYPE; endSeparator.fType = MFT.MFT_SEPARATOR; if (!NativeMethods.InsertMenuItem(hMenu, menuIndex++, true, ref endSeparator)) { return(Marshal.GetHRForLastWin32Error()); } } // Return an HRESULT value with the severity set to SEVERITY_SUCCESS. // Set the code value to the offset of the largest command identifier // that was assigned, plus one (1). return(NativeHelpers.MakeHResult(WinError.SEVERITY_SUCCESS, 0, (uint)this.activeCommands.Count)); }