/// <summary> /// Create a display configuration through <c>DisplayType</c> /// In <c>Split</c> mode, the minimum value is 30, the maximum value is 80, and the default value is 50 /// In <c>Editor</c> mode, the minimum value is 100, the maximum value is 100, and the default value is 100 /// In <c>Preview</c> mode, the minimum value is 0, the maximum value is 0, and the default value is 0 /// </summary> /// <param name="displayType">Control display mode</param> /// <returns>Display configuration</returns> public static DisplayOptions CreateOptions(EditBoxDisplayMode displayType) { DisplayOptions options = null; switch (displayType) { case EditBoxDisplayMode.Split: options = new DisplayOptions(); break; case EditBoxDisplayMode.Editor: options = new DisplayOptions { DisplayType = EditBoxDisplayMode.Editor, MinPercent = 100, MaxPercent = 100, DefaultPercent = 100 }; break; default: break; } return(options); }
/// <summary> /// Create a display configuration /// </summary> /// <param name="displayType">Control display mode</param> /// <param name="minPercent">The minimum percentage of the left panel (0 to 100)</param> /// <param name="maxPercent">The maxinum percentage of the left panel (0 to 100)</param> /// <param name="defaultPercent">The default percentage of the left panel (0 to 100)</param> /// <returns>Display configuration</returns> public static DisplayOptions CreateOptions(EditBoxDisplayMode displayType, double minPercent, double maxPercent, double defaultPercent) { if (minPercent > maxPercent) { throw new ArgumentException("The minimum value should be less than or equal to the maximum value"); } else if (minPercent < 0 || minPercent > 100) { throw new ArgumentOutOfRangeException("The minimum value is outside the preset range and should be between 0 and 100"); } else if (maxPercent > 100) { throw new ArgumentOutOfRangeException("The maxinum value is outside the preset range and should be between 0 and 100"); } else if (defaultPercent < minPercent || defaultPercent > maxPercent) { throw new ArgumentOutOfRangeException("The default value should be between the minimum and maximum"); } else { return(new DisplayOptions { DisplayType = displayType, MinPercent = minPercent, MaxPercent = maxPercent, DefaultPercent = defaultPercent }); } }