private void removeToolStripMenuItem_Click(object sender, EventArgs e) { if (listViewSceneChanges.SelectedItems.Count == 0) { return; } string askText = listViewSceneChanges.SelectedItems.Count > 1 ? string.Format(LanguageSettings.Current.Main.DeleteXLinesPrompt, listViewSceneChanges.SelectedItems.Count) : LanguageSettings.Current.Main.DeleteOneLinePrompt; if (Configuration.Settings.General.PromptDeleteLines && MessageBox.Show(askText, string.Empty, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) { return; } var indices = new List <int>(); foreach (ListViewItem selectedItem in listViewSceneChanges.SelectedItems) { indices.Add(selectedItem.Index); } foreach (var index in indices.OrderByDescending(p => p)) { SceneChanges.RemoveAt(index); } FillListView(); }
/// <summary> /// Changes the current visible GroupBox. /// </summary> /// <param name="scnChng">Scene to change to</param> private void ChangeScene(SceneChanges scnChng) { foreach (GroupBox control in Controls.OfType <GroupBox>()) { control.SynchronizedInvoke(() => control.Visible = false); } switch (scnChng) { case SceneChanges.Opening: OpenOpening(); break; case SceneChanges.LobbyHost: OpenLobbyHost(); break; case SceneChanges.LobbyClient: OpenLobbyClient(); break; case SceneChanges.Search: OpenSearch(); break; case SceneChanges.Game: OpenGame(); break; } }
/// <summary> /// Calls <see cref="OnSceneChanged(SceneChangedEventArgs)"/>. /// </summary> /// <param name="sceneNode">The scene node that was added/removed/modified.</param> /// <param name="changes">The changes.</param> private void OnSceneChanged(SceneNode sceneNode, SceneChanges changes) { var args = SceneChangedEventArgs.Create(sceneNode, changes); OnSceneChanged(args); args.Recycle(); }
/// <summary> /// Creates an instance of the <see cref="SceneChangedEventArgs"/> class. (This method reuses a /// previously recycled instance or allocates a new instance if necessary.) /// </summary> /// <param name="sceneNode">The scene node.</param> /// <param name="changes">The changes.</param> /// <returns> /// A new or reusable instance of the <see cref="SceneChangedEventArgs"/> class. /// </returns> /// <remarks> /// <para> /// This method tries to obtain a previously recycled instance from a resource pool if resource /// pooling is enabled (see <see cref="ResourcePool.Enabled">ResourcePool.Enabled</see>). If no /// object is available, a new instance is automatically allocated on the heap. /// </para> /// <para> /// The owner of the object should call <see cref="Recycle"/> when the instance is no longer /// needed. /// </para> /// </remarks> /// <exception cref="ArgumentNullException"> /// <paramref name="sceneNode"/> is <see langword="null"/>. /// </exception> public static SceneChangedEventArgs Create(SceneNode sceneNode, SceneChanges changes) { if (sceneNode == null) throw new ArgumentNullException("sceneNode"); var args = Pool.Obtain(); args.SceneNode = sceneNode; args.Changes = changes; return args; }
/// <summary> /// Creates an instance of the <see cref="SceneChangedEventArgs"/> class. (This method reuses a /// previously recycled instance or allocates a new instance if necessary.) /// </summary> /// <param name="sceneNode">The scene node.</param> /// <param name="changes">The changes.</param> /// <returns> /// A new or reusable instance of the <see cref="SceneChangedEventArgs"/> class. /// </returns> /// <remarks> /// <para> /// This method tries to obtain a previously recycled instance from a resource pool if resource /// pooling is enabled (see <see cref="ResourcePool.Enabled">ResourcePool.Enabled</see>). If no /// object is available, a new instance is automatically allocated on the heap. /// </para> /// <para> /// The owner of the object should call <see cref="Recycle"/> when the instance is no longer /// needed. /// </para> /// </remarks> /// <exception cref="ArgumentNullException"> /// <paramref name="sceneNode"/> is <see langword="null"/>. /// </exception> public static SceneChangedEventArgs Create(SceneNode sceneNode, SceneChanges changes) { if (sceneNode == null) { throw new ArgumentNullException("sceneNode"); } var args = Pool.Obtain(); args.SceneNode = sceneNode; args.Changes = changes; return(args); }