예제 #1
0
        /// <summary>
        /// Get properties from selected objects and fill GraphicsProperties instance
        /// </summary>
        /// <returns></returns>
        private GraphicsProperties GetProperties()
        {
            GraphicsProperties 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);
        }