/// <summary> /// Handles the SelectedIndexChanged event of the _styleManagerTypeCmb control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> /// <exception cref="System.InvalidOperationException"></exception> private void _styleManagerTypeCmb_SelectedIndexChanged(object sender, EventArgs e) { ComboBoxValue <Type> val = (ComboBoxValue <Type>)_styleManagerTypeCmb.SelectedItem; TilingController controller = _tilingController; if (controller == null) { return; } lock (_lock) { controller = _tilingController; if (controller == null) { return; } StyleManager currManager = controller.StyleManager; if (currManager.GetType() == val.Value) { return; } StyleManager newManager; if (val.Value == typeof(RandomStyleManager)) { newManager = new RandomStyleManager((int)_seedNum.Value, currManager.LineStyle, currManager.Styles); } else if (val.Value == typeof(RandomGreedyStyleManager)) { newManager = new RandomGreedyStyleManager( (int)_seedNum.Value, currManager.LineStyle, currManager.Styles); } else if (val.Value == typeof(GreedyStyleManager)) { newManager = new GreedyStyleManager(1, 1, 1, currManager.LineStyle, currManager.Styles); } else if (val.Value == typeof(SimpleStyleManager)) { // TODO filter styles properly when multiple shapes are supported newManager = new SimpleStyleManager(currManager.LineStyle, currManager.Styles.First()); } else { throw new InvalidOperationException(); } Debug.Assert(newManager.GetType() == val.Value); controller.Tiling.SetStyleManager(newManager, controller.Tiles); UpdateStyleManager(newManager); } }
/// <summary> /// Handles the ValueChanged event of the _greedyParamCTrack control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void _greedyParamCTrack_ValueChanged(object sender, EventArgs e) { GreedyStyleManager manager = _tilingController?.StyleManager as GreedyStyleManager; if (manager == null) { return; } manager.ParamC = _greedyParamCTrack.Value; }