Exemplo n.º 1
0
        /// <summary>
        /// Determines whether all color values of the specified
        /// ImageListViewColor are equal to this instance.
        /// </summary>
        /// <param name="obj">The object to compare with this instance.</param>
        /// <returns>true if the two instances have the same color values;
        /// otherwise false.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                throw new NullReferenceException();
            }

            SEListViewColor other = obj as SEListViewColor;

            if (other == null)
            {
                return(false);
            }

            foreach (PropertyInfo info in typeof(SEListViewColor).GetProperties())
            {
                // Walk through color properties
                if (info.PropertyType == typeof(Color))
                {
                    // Compare colors
                    Color color1 = (Color)info.GetValue(this, null);
                    Color color2 = (Color)info.GetValue(other, null);

                    if (color1 != color2)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the color palette to noir colors.
        /// </summary>
        private static SEListViewColor GetNoirTheme()
        {
            SEListViewColor c = new SEListViewColor();

            // control
            c.ControlBackColor = Color.Black;

            // item
            c.BackColor = Color.FromArgb(0x31, 0x31, 0x31);
            c.ForeColor = Color.LightGray;

            c.BorderColor = Color.DarkGray;

            c.UnFocusedColor1      = Color.FromArgb(16, SystemColors.GrayText);
            c.UnFocusedColor2      = Color.FromArgb(64, SystemColors.GrayText);
            c.UnFocusedBorderColor = Color.FromArgb(128, SystemColors.GrayText);
            c.UnFocusedForeColor   = Color.LightGray;

            c.HoverColor1      = Color.FromArgb(64, Color.White);
            c.HoverColor2      = Color.FromArgb(16, Color.White);
            c.HoverBorderColor = Color.FromArgb(64, SystemColors.Highlight);

            c.SelectedColor1      = Color.FromArgb(64, 96, 160);
            c.SelectedColor2      = Color.FromArgb(64, 64, 96, 160);
            c.SelectedBorderColor = Color.FromArgb(128, SystemColors.Highlight);
            c.SelectedForeColor   = Color.LightGray;

            c.InsertionCaretColor = Color.FromArgb(96, 144, 240);

            // thumbnails & pane
            c.ImageInnerBorderColor = Color.FromArgb(128, Color.White);
            c.ImageOuterBorderColor = Color.FromArgb(128, Color.Gray);

            // details view
            c.CellForeColor           = Color.WhiteSmoke;
            c.ColumnHeaderBackColor1  = Color.FromArgb(32, 128, 128, 128);
            c.ColumnHeaderBackColor2  = Color.FromArgb(196, 128, 128, 128);
            c.ColumnHeaderHoverColor1 = Color.FromArgb(64, 96, 144, 240);
            c.ColumnHeaderHoverColor2 = Color.FromArgb(196, 96, 144, 240);
            c.ColumnHeaderForeColor   = Color.White;
            c.ColumnSelectColor       = Color.FromArgb(96, 128, 128, 128);
            c.ColumnSeparatorColor    = Color.Gold;
            c.AlternateBackColor      = Color.FromArgb(0x31, 0x31, 0x31);
            c.AlternateCellForeColor  = Color.WhiteSmoke;

            // image pane
            c.PaneBackColor      = Color.FromArgb(0x31, 0x31, 0x31);
            c.PaneSeparatorColor = Color.Gold;
            c.PaneLabelColor     = SystemColors.GrayText;

            // selection rectangke
            c.SelectionRectangleColor1      = Color.FromArgb(160, 96, 144, 240);
            c.SelectionRectangleColor2      = Color.FromArgb(32, 96, 144, 240);
            c.SelectionRectangleBorderColor = Color.FromArgb(64, 96, 144, 240);

            return(c);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the color palette to mandarin colors.
        /// </summary>
        private static SEListViewColor GetMandarinTheme()
        {
            SEListViewColor c = new SEListViewColor();

            // control
            c.ControlBackColor = Color.White;

            // item
            c.BackColor   = Color.White;
            c.ForeColor   = Color.FromArgb(60, 60, 60);
            c.BorderColor = Color.FromArgb(187, 190, 183);

            c.UnFocusedColor1      = Color.FromArgb(235, 235, 235);
            c.UnFocusedColor2      = Color.FromArgb(217, 217, 217);
            c.UnFocusedBorderColor = Color.FromArgb(168, 169, 161);
            c.UnFocusedForeColor   = Color.FromArgb(40, 40, 40);

            c.HoverColor1      = Color.Transparent;
            c.HoverColor2      = Color.Transparent;
            c.HoverBorderColor = Color.Transparent;

            c.SelectedColor1      = Color.FromArgb(244, 125, 77);
            c.SelectedColor2      = Color.FromArgb(235, 110, 60);
            c.SelectedBorderColor = Color.FromArgb(240, 119, 70);
            c.SelectedForeColor   = Color.White;

            c.InsertionCaretColor = Color.FromArgb(240, 119, 70);

            // thumbnails & pane
            c.ImageInnerBorderColor = Color.Transparent;
            c.ImageOuterBorderColor = Color.White;

            // details view
            c.CellForeColor           = Color.FromArgb(60, 60, 60);
            c.ColumnHeaderBackColor1  = Color.FromArgb(247, 247, 247);
            c.ColumnHeaderBackColor2  = Color.FromArgb(235, 235, 235);
            c.ColumnHeaderHoverColor1 = Color.White;
            c.ColumnHeaderHoverColor2 = Color.FromArgb(245, 245, 245);
            c.ColumnHeaderForeColor   = Color.FromArgb(60, 60, 60);
            c.ColumnSelectColor       = Color.FromArgb(34, 128, 128, 128);
            c.ColumnSeparatorColor    = Color.FromArgb(106, 128, 128, 128);
            c.mAlternateBackColor     = Color.FromArgb(234, 234, 234);
            c.mAlternateCellForeColor = Color.FromArgb(40, 40, 40);

            // image pane
            c.PaneBackColor      = Color.White;
            c.PaneSeparatorColor = Color.FromArgb(216, 216, 216);
            c.PaneLabelColor     = Color.FromArgb(156, 156, 156);

            // selection rectangle
            c.SelectionRectangleColor1      = Color.FromArgb(64, 240, 116, 68);
            c.SelectionRectangleColor2      = Color.FromArgb(64, 240, 116, 68);
            c.SelectionRectangleBorderColor = Color.FromArgb(240, 119, 70);

            return(c);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a string that represents this instance.
        /// </summary>
        /// <returns>
        /// A string that represents this instance.
        /// </returns>
        public override string ToString()
        {
            SEListViewColor colors = this;

            // First check if the color matches a predefined color setting
            foreach (MemberInfo info in typeof(SEListViewColor).GetMembers(BindingFlags.Static | BindingFlags.Public))
            {
                if (info.MemberType == MemberTypes.Property)
                {
                    PropertyInfo propertyInfo = (PropertyInfo)info;
                    if (propertyInfo.PropertyType == typeof(SEListViewColor))
                    {
                        SEListViewColor presetValue = (SEListViewColor)propertyInfo.GetValue(null, null);
                        // If the color setting is equal to a preset value
                        // return the name of the preset
                        if (colors.Equals(presetValue))
                        {
                            return(string.Format("({0})", propertyInfo.Name));
                        }
                    }
                }
            }

            // Serialize all colors which are different from the default setting
            List <string> lines = new List <string>();

            foreach (PropertyInfo info in typeof(SEListViewColor).GetProperties())
            {
                // Walk through color properties
                if (info.PropertyType == typeof(Color))
                {
                    // Get property name
                    string name = info.Name;
                    // Get the current value
                    Color color = (Color)info.GetValue(colors, null);
                    // Find the default value atribute
                    Attribute[] attributes = (Attribute[])info.GetCustomAttributes(typeof(DefaultValueAttribute), false);
                    if (attributes.Length != 0)
                    {
                        // Get the default value
                        DefaultValueAttribute attribute = (DefaultValueAttribute)attributes[0];
                        Color defaultColor = (Color)attribute.Value;
                        // Serialize only if colors are different
                        if (color != defaultColor)
                        {
                            lines.Add(string.Format("{0} = {1}", name, color.Name));
                        }
                    }
                }
            }

            return(string.Join("; ", lines.ToArray()));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Copies color values from the given object.
 /// </summary>
 /// <param name="source">The source object.</param>
 public void CopyFrom(SEListViewColor source)
 {
     foreach (PropertyInfo info in typeof(SEListViewColor).GetProperties())
     {
         // Walk through color properties
         if (info.PropertyType == typeof(Color))
         {
             Color color = (Color)info.GetValue(source, null);
             info.SetValue(this, color, null);
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the ImageListViewColor class
        /// from its string representation.
        /// </summary>
        /// <param name="definition">String representation of the object.</param>
        public SEListViewColor(string definition)
            : this()
        {
            try
            {
                // First check if the color matches a predefined color setting
                foreach (MemberInfo info in typeof(SEListViewColor).GetMembers(BindingFlags.Static | BindingFlags.Public))
                {
                    if (info.MemberType == MemberTypes.Property)
                    {
                        PropertyInfo propertyInfo = (PropertyInfo)info;
                        if (propertyInfo.PropertyType == typeof(SEListViewColor))
                        {
                            // If the color setting is equal to a preset value
                            // return the preset
                            if (definition == string.Format("({0})", propertyInfo.Name) ||
                                definition == propertyInfo.Name)
                            {
                                SEListViewColor presetValue = (SEListViewColor)propertyInfo.GetValue(null, null);
                                CopyFrom(presetValue);
                                return;
                            }
                        }
                    }
                }

                // Convert color values
                foreach (string line in definition.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
                {
                    // Read the color setting
                    string[] pair  = line.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    string   name  = pair[0].Trim();
                    Color    color = Color.FromName(pair[1].Trim());
                    // Set the property value
                    PropertyInfo property = typeof(SEListViewColor).GetProperty(name);
                    property.SetValue(this, color, null);
                }
            }
            catch
            {
                throw new ArgumentException("Invalid string format", "definition");
            }
        }