/// <summary> /// Helper method that creates a view for a specifice <see cref="Handler.OptionHandler"/>. /// </summary> /// <param name="forHandler">The handler to create a view for.</param> /// <param name="autoAdopt">if set to <see langword="true"/> value changes in /// the handler will automatically be adopted by the view.</param> /// <param name="autoCommit">if set to <see langword="true"/> value changes in /// the view will automatically be committed to the handler.</param> /// <returns>A new view.</returns> public static IModelView CreateView(OptionHandler forHandler, bool autoAdopt, bool autoCommit) { CopiedOptionHandler view2 = new CopiedOptionHandler(forHandler); view2.IsAutoAdopt = autoAdopt; view2.IsAutoCommit = autoCommit; return(view2); }
/// <summary> /// Callback that is triggered once the <see cref="OptionHandler"/> property changes. /// </summary> /// <param name="oldValue">The old value.</param> /// <param name="newValue">The new value.</param> protected virtual void OnOptionHandlerChanged(OptionHandler oldValue, OptionHandler newValue) { if (oldValue != null) { IModelView view = View; if (view is CopiedOptionHandler && view.Handler == oldValue) { CopiedOptionHandler oldView = (CopiedOptionHandler)view; if (newValue != null) { View = CreateView(newValue); } else { View = null; } oldView.Dispose(); } else { if (newValue != null) { View = CreateView(newValue); } else { View = null; } } } else { if (newValue != null) { View = CreateView(newValue); } else { View = null; } } if (newValue != null) { if (I18NFactory != null) { Title = I18NFactory.GetString(newValue.Name, newValue.Name); } else { Title = newValue.Name; } } else { Title = string.Empty; } }