/// ------------------------------------------------------------------------------------
        /// <summary>
        /// Draws just the text portion of a feature list resultView item.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void DrawText(DrawListViewItemEventArgs e, FeatureItemInfo info)
        {
            bool selected = (SelectedItems.Count > 0 && e.Item == SelectedItems[0]);
            var  rc       = e.Item.GetBounds(ItemBoundsPortion.Label);

            rc.X += 2;

            // Determine whether or not to use the emphasized font.
            var fnt = (EmphasizeCheckedItems && GetIsItemSet(info) ? _emphasizedFont : Font);

            // First, draw the text's background.
            rc.Width = TextRenderer.MeasureText(info.Name, fnt).Width + 3;
            var clrText = (selected ? SystemColors.HighlightText : ForeColor);

            if (selected && !Focused)
            {
                clrText = SystemColors.ControlText;
                e.Graphics.FillRectangle(SystemBrushes.Control, rc);
            }
            else if (DrawItemBackgroundAndGetForeColor != null)
            {
                clrText = DrawItemBackgroundAndGetForeColor(e.Graphics,
                                                            rc, selected, GetIsItemNotInDefaultState(info));
            }
            else if (selected)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, rc);
                ControlPaint.DrawFocusRectangle(e.Graphics, rc);
            }

            // Now draw the text.
            rc.Y--;
            TextRenderer.DrawText(e.Graphics, info.Name, fnt, rc, clrText,
                                  TextFormatFlags.VerticalCenter | TextFormatFlags.PreserveGraphicsClipping);
        }
Beispiel #2
0
        /// ------------------------------------------------------------------------------------
        protected override bool GetIsItemNotInDefaultState(FeatureItemInfo itemInfo)
        {
            var isDefaultFeature = _defaultFeatures.Contains(itemInfo.Name);
            var isItemSet        = GetIsItemSet(itemInfo);

            return((isDefaultFeature && !isItemSet) || (!isDefaultFeature && isItemSet));
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Draw the check box with a plus, minus or nothing.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void DrawFeatureState(Graphics g, FeatureItemInfo itemInfo, Rectangle rc)
        {
            // Draw an empty checkbox.
            CheckBoxRenderer.DrawCheckBox(g, rc.Location, CheckBoxState.UncheckedNormal);

            if (itemInfo == null || itemInfo.TriStateValue == BinaryFeatureValue.None)
            {
                return;
            }

            // Draw a plus or minus in the empty check box.
            using (Pen pen = new Pen(_glyphColor, 1))
            {
                var ptCenter = new Point(rc.X + (rc.Width / 2), rc.Y + (rc.Height / 2));

                // Draw the minus
                g.DrawLine(pen, ptCenter.X - 3, ptCenter.Y, ptCenter.X + 3, ptCenter.Y);

                // Draw the vertical line to make a plus if the feature's value is such.
                if (itemInfo.TriStateValue == BinaryFeatureValue.Plus)
                {
                    g.DrawLine(pen, ptCenter.X, ptCenter.Y - 3, ptCenter.X, ptCenter.Y + 3);
                }
            }
        }
        /// ------------------------------------------------------------------------------------
        protected override bool GetIsItemNotInDefaultState(FeatureItemInfo itemInfo)
        {
            var currentFeaturesName = GetFormattedFeatureName(itemInfo, false);
            var defaultListContainsNameWithoutPrefix = _defaultFeatures.Any(n => n.Substring(1) == itemInfo.Name);
            var isItemSet = GetIsItemSet(itemInfo);

            return(!_defaultFeatures.Contains(currentFeaturesName) && (isItemSet || defaultListContainsNameWithoutPrefix));
        }
 /// ------------------------------------------------------------------------------------
 protected override void InitializeLoadedItem(Feature feature, FeatureItemInfo itemInfo)
 {
     itemInfo.Name     = feature.Name.TrimStart('-', '+');
     itemInfo.FullName = feature.Name.TrimStart('-', '+');
     itemInfo.PlusBit  = feature.Bit;
     itemInfo.MinusBit = App.BFeatureCache.GetOppositeFeature(feature).Bit;
     itemInfo.IsBinary = true;
 }
 /// ------------------------------------------------------------------------------------
 protected void LoadFeatures()
 {
     foreach (var feature in GetFeaturesToLoad())
     {
         var info = new FeatureItemInfo();
         info.Name       = feature.Name;
         info.FullName   = feature.Name;
         info.CacheEntry = feature;
         InitializeLoadedItem(feature, info);
         Items.Add(new ListViewItem(info.Name)).Tag = info;
     }
 }
        /// ------------------------------------------------------------------------------------
        protected override string GetFormattedFeatureName(FeatureItemInfo itemInfo,
                                                          bool includeBrackets)
        {
            if (itemInfo.TriStateValue == BinaryFeatureValue.None)
            {
                return(itemInfo.Name);
            }

            var fmt = (includeBrackets ? "[{0}{1}]" : "{0}{1}");

            return(string.Format(fmt, (char)itemInfo.TriStateValue, itemInfo.Name));
        }
 /// ------------------------------------------------------------------------------------
 protected override void SetFeatureInfoStateFromMask(FeatureItemInfo itemInfo, FeatureMask mask)
 {
     if (mask[itemInfo.PlusBit])
     {
         itemInfo.TriStateValue = BinaryFeatureValue.Plus;
     }
     else if (mask[itemInfo.MinusBit])
     {
         itemInfo.TriStateValue = BinaryFeatureValue.Minus;
     }
     else
     {
         itemInfo.TriStateValue = BinaryFeatureValue.None;
     }
 }
        /// ------------------------------------------------------------------------------------
        protected override void CycleFeatureStateValue(FeatureItemInfo itemInfo, FeatureMask mask)
        {
            switch (itemInfo.TriStateValue)
            {
            case BinaryFeatureValue.None:
                itemInfo.TriStateValue  = BinaryFeatureValue.Plus;
                mask[itemInfo.MinusBit] = false;
                mask[itemInfo.PlusBit]  = true;
                break;

            case BinaryFeatureValue.Plus:
                itemInfo.TriStateValue  = BinaryFeatureValue.Minus;
                mask[itemInfo.MinusBit] = true;
                mask[itemInfo.PlusBit]  = false;
                break;

            default:
                itemInfo.TriStateValue  = BinaryFeatureValue.None;
                mask[itemInfo.MinusBit] = false;
                mask[itemInfo.PlusBit]  = false;
                break;
            }
        }
 /// ------------------------------------------------------------------------------------
 protected virtual string GetFormattedFeatureName(FeatureItemInfo itemInfo, bool includeBrackets)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
 /// ------------------------------------------------------------------------------------
 protected override void SetFeatureInfoStateFromMask(FeatureItemInfo itemInfo, FeatureMask mask)
 {
     itemInfo.Checked = mask[itemInfo.Bit];
 }
Beispiel #12
0
 /// ------------------------------------------------------------------------------------
 protected override void CycleFeatureStateValue(FeatureItemInfo itemInfo, FeatureMask mask)
 {
     itemInfo.Checked   = !itemInfo.Checked;
     mask[itemInfo.Bit] = itemInfo.Checked;
 }
Beispiel #13
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Draw normal checked/unchecked check box.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected override void DrawFeatureState(Graphics g, FeatureItemInfo itemInfo, Rectangle rc)
 {
     CheckBoxRenderer.DrawCheckBox(g, rc.Location, (itemInfo != null && itemInfo.Checked ?
                                                    CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal));
 }
 /// ------------------------------------------------------------------------------------
 protected override bool GetIsItemSet(FeatureItemInfo itemInfo)
 {
     return(itemInfo != null && itemInfo.TriStateValue != BinaryFeatureValue.None);
 }
 /// ------------------------------------------------------------------------------------
 protected virtual void InitializeLoadedItem(Feature feature, FeatureItemInfo itemInfo)
 {
     throw new NotImplementedException();
 }
Beispiel #16
0
 /// ------------------------------------------------------------------------------------
 protected override bool GetIsItemSet(FeatureItemInfo itemInfo)
 {
     return(itemInfo != null && itemInfo.Checked);
 }
 /// ------------------------------------------------------------------------------------
 protected virtual void CycleFeatureStateValue(FeatureItemInfo itemInfo, FeatureMask mask)
 {
     throw new NotImplementedException();
 }
 /// ------------------------------------------------------------------------------------
 protected virtual void SetFeatureInfoStateFromMask(FeatureItemInfo itemInfo, FeatureMask mask)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
 /// ------------------------------------------------------------------------------------
 protected override void InitializeLoadedItem(Feature feature, FeatureItemInfo itemInfo)
 {
     itemInfo.Bit = feature.Bit;
 }
 /// ------------------------------------------------------------------------------------
 protected virtual bool GetIsItemNotInDefaultState(FeatureItemInfo info)
 {
     throw new NotImplementedException();
 }
 /// ------------------------------------------------------------------------------------
 protected virtual void DrawFeatureState(Graphics g, FeatureItemInfo info, Rectangle rc)
 {
     throw new NotImplementedException();
 }
 /// ------------------------------------------------------------------------------------
 protected virtual bool GetIsItemSet(FeatureItemInfo itemInfo)
 {
     throw new NotImplementedException();
 }
Beispiel #23
0
        /// ------------------------------------------------------------------------------------
        protected override string GetFormattedFeatureName(FeatureItemInfo itemInfo, bool includeBrackets)
        {
            var fmt = (includeBrackets ? "[{0}]" : "{0}");

            return(string.Format(fmt, itemInfo.Name));
        }