public void EhView_ScaleTypeChanged() { var scaleType = (Type)_scaleTypes.FirstSelectedNode.Tag; try { if (scaleType != ScaleToEdit.GetType()) { // replace the current scale by a new scale of the type axistype Scale oldScale = ScaleToEdit; var newScale = (Scale)System.Activator.CreateInstance(scaleType); OnDocumentInstanceChanged(oldScale, newScale); ScaleToEdit = newScale; // Try to set the same org and end as the axis before // this will fail for instance if we switch from linear to logarithmic with negative bounds try { if (ScaleToEdit.RescalingObject is Altaxo.Main.ICopyFrom) { ScaleToEdit.RescalingObject.CopyFrom(oldScale.RescalingObject); } } catch (Exception) { } InitScaleController(true); // now we have also to replace the controller and the control for the axis boundaries InitRescalingController(true); InitTickSpacingTypes(true); InitTickSpacingController(true); } } catch (Exception) { } }
public void InitScaleTypes(bool initData) { if (initData) { _scaleTypes = new SelectableListNodeList(); Type[] classes; if (_lockScaleType) // if the scale type is locked (i.e.) can not be chosen by the user, we simply offer only the one scale type we have now { classes = new Type[] { _doc.GetType() } } ; else { classes = Altaxo.Main.Services.ReflectionService.GetNonAbstractSubclassesOf(typeof(Scale)); } for (int i = 0; i < classes.Length; i++) { if (classes[i] == typeof(LinkedScale)) { continue; } var node = new SelectableListNode(Current.Gui.GetUserFriendlyClassName(classes[i]), classes[i], ScaleToEdit.GetType() == classes[i]); _scaleTypes.Add(node); } } if (null != _view) { _view.InitializeAxisType(_scaleTypes); } }