Idea Selection

Sep 9, 2009 at 12:37 AM

 

 

    public class CellSelection : SelectionBase
    {
        private RangeCollection m_selected = new RangeCollection();
public class CellSelection : SelectionBase
{
        private RangeCollection m_selected = new RangeCollection();
        public override void SelectRange(Range range, bool select)
        {
            if (range.IsEmpty())
                return;
            if (select)
                m_selected.Add(range);
            else
                m_selected.Remove(range);
        }
        public override bool IntersectWidth(Range range)
        {
            if (range.IsEmpty())
                return false;
            foreach (Range rng in m_selected)
            {
                if (rng.IntersectWith(range))
                    return true;
            }
            return false;
        }
}
public class DecoratorSelection : IDecorator
{
        private SelectionBase m_selection;
        public DecoratorSelection(SelectionBase selection)
        {
            m_selection = selection;
        }
        public bool IntersectWith(Range range)
        {
            return m_selection.IntersectWidth(range);
        }
        
public void Draw(RangePaintEventArgs e)
        {
RangeCollection selectionRegion = grid.Selection.GetSelectionRange(e.DrawingRange);
foreach (Range rng in selectionRegion.ToArray())
{
Rectangle drawRect = grid.RangeToRectangle(rng);
  Region drawRegion = new Region(drawRect);
  if (drawRect.IntersectsWith(focusRect))
drawRegion.Exclude(focusRect);
  xorRegion.Union(drawRegion);
}
            if (!xorRegion.IsEmpty(g))
                g.FillRegion(new SolidBrush(grid.Selection.RegionBackColor), xorRegion);
}
}

 

 

Coordinator
Sep 9, 2009 at 6:38 AM

Could you describe in words?

Sep 9, 2009 at 6:50 AM

I'm sorry.

I'm poor in English.

"RangeRegion" is a very good design.

Region.Union can also achieve the same effect

Sep 9, 2009 at 1:08 PM

what is your native language?

you could use a translator tool, like google translator.