/// <summary> /// Get properties from selected objects and fill GraphicsProperties instance /// </summary> /// <returns> </returns> private GraphicsProperties GetProperties() { var properties = new GraphicsProperties(); bool bFirst = true; int firstColor = 0; int firstPenWidth = 1; bool allColorsAreEqual = true; bool allWidthAreEqual = true; foreach (DrawObject o in Selection) { if (bFirst) { firstColor = o.Color.ToArgb(); firstPenWidth = o.PenWidth; bFirst = false; } else { if (o.Color.ToArgb() != firstColor) { allColorsAreEqual = false; } if (o.PenWidth != firstPenWidth) { allWidthAreEqual = false; } } } if (allColorsAreEqual) { properties.Color = Color.FromArgb(firstColor); } if (allWidthAreEqual) { properties.PenWidth = firstPenWidth; } return(properties); }
/// <summary> /// Apply properties for all selected objects. Returns TRue if at least one property is changed. /// </summary> private bool ApplyProperties(GraphicsProperties properties) { bool changed = false; foreach (DrawObject o in _graphicsList) { if (o.Selected) { if (properties.Color.HasValue) { if (o.Color != properties.Color.Value) { o.Color = properties.Color.Value; DrawObject.LastUsedColor = properties.Color.Value; changed = true; } } if (properties.PenWidth.HasValue) { if (o.PenWidth != properties.PenWidth.Value) { o.PenWidth = properties.PenWidth.Value; DrawObject.LastUsedPenWidth = properties.PenWidth.Value; changed = true; } } } } return changed; }
/// <summary> /// Get properties from selected objects and fill GraphicsProperties instance /// </summary> /// <returns> </returns> private GraphicsProperties GetProperties() { var properties = new GraphicsProperties(); bool bFirst = true; int firstColor = 0; int firstPenWidth = 1; bool allColorsAreEqual = true; bool allWidthAreEqual = true; foreach (DrawObject o in Selection) { if (bFirst) { firstColor = o.Color.ToArgb(); firstPenWidth = o.PenWidth; bFirst = false; } else { if (o.Color.ToArgb() != firstColor) { allColorsAreEqual = false; } if (o.PenWidth != firstPenWidth) { allWidthAreEqual = false; } } } if (allColorsAreEqual) { properties.Color = Color.FromArgb(firstColor); } if (allWidthAreEqual) { properties.PenWidth = firstPenWidth; } return properties; }