示例#1
0
        /// <summary>
        /// Get properties from selected objects and fill GraphicsProperties instance
        /// </summary>
        /// <returns></returns>
        private GraphicsProperties GetProperties()
        {
            GraphicsProperties properties = new GraphicsProperties();

            //int n = SelectionCount;

            //if (n < 1)
            //    return properties;

            //DrawObject o = GetSelectedObject(0);

            //int firstColor = o.Color.ToArgb();
            //int firstPenWidth = o.PenWidth;

            //bool allColorsAreEqual = true;
            //bool allWidthAreEqual = true;

            //for (int i = 1; i < n; i++)
            //{
            //    if (GetSelectedObject(i).Color.ToArgb() != firstColor)
            //        allColorsAreEqual = false;

            //    if (GetSelectedObject(i).PenWidth != firstPenWidth)
            //        allWidthAreEqual = false;
            //}

            //if (allColorsAreEqual)
            //{
            //    properties.ColorDefined = true;
            //    properties.Color = Color.FromArgb(firstColor);
            //}

            //if (allWidthAreEqual)
            //{
            //    properties.PenWidthDefined = true;
            //    properties.PenWidth = firstPenWidth;
            //}

            return(properties);
        }
示例#2
0
        /// <summary>
        /// Show Properties dialog. Return true if list is changed
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public bool ShowPropertiesDialog(IWin32Window parent)
        {
            if (SelectionCount < 1)
            {
                return(false);
            }

            GraphicsProperties properties = GetProperties();
            PropertiesDialog   dlg        = new PropertiesDialog();

            dlg.Properties = properties;

            if (dlg.ShowDialog(parent) !=
                DialogResult.OK)
            {
                return(false);
            }

            ApplyProperties();

            return(true);
        }