/// <summary> /// Handles button widget events. /// </summary> /// <param name="b"></param> public void OnButtonHit(object sender, Button b) { ButtonHit?.Invoke(sender, b); if (b.Name == "StartStop") // start or stop sample { if (b.Caption == "Start Sample") { if (this.LoadedSamples.Count == 0) { this.TrayManager.ShowOkDialog("Error!", "No sample selected!"); } // use the sample pointer we stored inside the thumbnail else { RunSample((Sample)(this.Thumbs[this.SampleMenu.SelectionIndex].UserData)); } } else { RunSample(null); } } else if (b.Name == "UnloadReload") // unload or reload sample plugins and update controls { if (b.Caption == "Unload Samples") { if (CurrentSample != null) { this.TrayManager.ShowYesNoDialog("Warning!", "This will stop the current sample. Unload anyway?"); } else { // save off current view and try to restore it on the next reload this.LastViewTitle = this.SampleMenu.SelectionIndex; this.LastViewCategory = this.CategoryMenu.SelectionIndex; UnloadSamples(); PopulateSampleMenus(); b.Caption = "Reload Samples"; } } else { LoadSamples(); PopulateSampleMenus(); if (!(this.LoadedSamples.Count == 0)) { b.Caption = "Unload Samples"; } try // attempt to restore the last view before unloading samples { this.CategoryMenu.SelectItem(this.LastViewCategory); this.SampleMenu.SelectItem(this.LastViewTitle); } catch (Exception) { // swallowing Exception on purpose } } } else if (b.Name == "Configure") // enter configuration screen { this.TrayManager.RemoveWidgetFromTray("StartStop"); this.TrayManager.RemoveWidgetFromTray("UnloadReload"); this.TrayManager.RemoveWidgetFromTray("Configure"); this.TrayManager.RemoveWidgetFromTray("Quit"); this.TrayManager.MoveWidgetToTray("Apply", TrayLocation.Right); this.TrayManager.MoveWidgetToTray("Back", TrayLocation.Right); for (int i = 0; i < this.Thumbs.Count; i++) { this.Thumbs[i].Hide(); } while (this.TrayManager.TrayContainer[(int)TrayLocation.Center].IsVisible) { this.TrayManager.RemoveWidgetFromTray(TrayLocation.Center, 0); } while (this.TrayManager.TrayContainer[(int)TrayLocation.Left].IsVisible) { this.TrayManager.RemoveWidgetFromTray(TrayLocation.Left, 0); } this.TrayManager.MoveWidgetToTray("ConfigLabel", TrayLocation.Left); this.TrayManager.MoveWidgetToTray(this.RendererMenu, TrayLocation.Left); this.TrayManager.MoveWidgetToTray("ConfigSeparator", TrayLocation.Left); this.RendererMenu.SelectItem(Root.RenderSystem.Name); WindowResized(RenderWindow); } else if (b.Name == "Back") // leave configuration screen { while (this.TrayManager.GetWidgetCount(this.RendererMenu.TrayLocation) > 3) { this.TrayManager.DestroyWidget(this.RendererMenu.TrayLocation, 3); } while (this.TrayManager.GetWidgetCount(TrayLocation.None) != 0) { this.TrayManager.MoveWidgetToTray(TrayLocation.None, 0, TrayLocation.Left); } this.TrayManager.RemoveWidgetFromTray("Apply"); this.TrayManager.RemoveWidgetFromTray("Back"); this.TrayManager.RemoveWidgetFromTray("ConfigLabel"); this.TrayManager.RemoveWidgetFromTray(this.RendererMenu); this.TrayManager.RemoveWidgetFromTray("ConfigSeparator"); this.TrayManager.MoveWidgetToTray("StartStop", TrayLocation.Right); this.TrayManager.MoveWidgetToTray("UnloadReload", TrayLocation.Right); this.TrayManager.MoveWidgetToTray("Configure", TrayLocation.Right); this.TrayManager.MoveWidgetToTray("Quit", TrayLocation.Right); WindowResized(RenderWindow); } else if (b.Name == "Apply") // apply any changes made in the configuration screen { bool reset = false; string selectedRenderSystem = string.Empty; switch (this.RendererMenu.SelectedItem) { case "Axiom DirectX9 Rendering Subsystem": selectedRenderSystem = "DirectX9"; break; case "Axiom Xna Rendering Subsystem": selectedRenderSystem = "Xna"; break; case "Axiom OpenGL (OpenTK) Rendering Subsystem": selectedRenderSystem = "OpenGL"; break; default: throw new NotImplementedException(); } if (selectedRenderSystem != string.Empty) { var options = Root.RenderSystems[selectedRenderSystem].ConfigOptions; var newOptions = new Collections.NameValuePairList(); // collect new settings and decide if a reset is needed if (this.RendererMenu.SelectedItem != Root.RenderSystem.Name) { reset = true; } for (int i = 3; i < this.TrayManager.GetWidgetCount(this.RendererMenu.TrayLocation); i++) { var menu = (SelectMenu)this.TrayManager.GetWidget(this.RendererMenu.TrayLocation, i); if (menu.SelectedItem != options[menu.Caption].Value) { reset = true; } newOptions[menu.Caption] = menu.SelectedItem; } // reset with new settings if necessary if (reset) { Reconfigure(selectedRenderSystem, newOptions); } } } else { Root.QueueEndRendering(); // exit browser } }
void ReleaseDesignerOutlets() { if (ButtonStick != null) { ButtonStick.Dispose(); ButtonStick = null; } if (ButtonHit != null) { ButtonHit.Dispose(); ButtonHit = null; } if (LabelPlayerScore != null) { LabelPlayerScore.Dispose(); LabelPlayerScore = null; } if (LabelDealerScore != null) { LabelDealerScore.Dispose(); LabelDealerScore = null; } if (LabelDealersHandTotal != null) { LabelDealersHandTotal.Dispose(); LabelDealersHandTotal = null; } if (LabelPlayersHandTotal != null) { LabelPlayersHandTotal.Dispose(); LabelPlayersHandTotal = null; } if (LabelConvoText != null) { LabelConvoText.Dispose(); LabelConvoText = null; } if (DealerFirstCard != null) { DealerFirstCard.Dispose(); DealerFirstCard = null; } if (DealerSecondCard != null) { DealerSecondCard.Dispose(); DealerSecondCard = null; } if (DealerThirdCard != null) { DealerThirdCard.Dispose(); DealerThirdCard = null; } if (DealerFourthCard != null) { DealerFourthCard.Dispose(); DealerFourthCard = null; } if (DealerFifthCard != null) { DealerFifthCard.Dispose(); DealerFifthCard = null; } if (PlayerFirstCard != null) { PlayerFirstCard.Dispose(); PlayerFirstCard = null; } if (PlayerSecondCard != null) { PlayerSecondCard.Dispose(); PlayerSecondCard = null; } if (PlayerThirdCard != null) { PlayerThirdCard.Dispose(); PlayerThirdCard = null; } if (PlayerFourthCard != null) { PlayerFourthCard.Dispose(); PlayerFourthCard = null; } if (PlayerFifthCard != null) { PlayerFifthCard.Dispose(); PlayerFifthCard = null; } }