Ejemplo n.º 1
0
        void item_SelectChanged(object sender, SelectEventArgs e)
        {
            if (_ignoreSelectChanged) return;
           
            DirectoryItem di = sender as DirectoryItem;
            if (di == null) return;

            if ((e.Modifiers & Keys.Control) == Keys.Control && (e.Modifiers & Keys.Shift) != Keys.Shift)
            {
                if (_selectedItem != null)
                {
                    _selectedItem.IsOutlined = false;
                }
                _selectionStart = di;
                _selectedItem = di;
                _selectedItem.IsOutlined = true;
                Invalidate();
                return; 
            }
            _ignoreSelectChanged = true;


            if (((e.Modifiers & Keys.Shift) == Keys.Shift) && ((e.Modifiers & Keys.Control) != Keys.Control))
            {
                ClearSelection();
                _selectedItem.IsOutlined = false;
                int iOld;
                if (_selectionStart != null)
                {
                    iOld = _items.IndexOf(_selectionStart);
                }
                else
                {
                    _selectionStart = _items[0];
                    iOld = 0;
                }
                int iNew = _items.IndexOf(di);

                int start = Math.Min(iOld, iNew);
                int end = Math.Max(iOld, iNew);

                for (int i = start; i <= end; i++)
                {
                    _items[i].IsSelected = true;
                }
                _selectionStart.IsOutlined = false;
                
               
            }

            // With no control keys or both.
            if ((((e.Modifiers & Keys.Shift) == Keys.Shift) && ((e.Modifiers & Keys.Control) == Keys.Control)) ||
                (((e.Modifiers & Keys.Shift) != Keys.Shift) && ((e.Modifiers & Keys.Control) != Keys.Control)))
            {
                if (_selectedItem != null)
                {
                    _selectedItem.IsOutlined = false;
                }
                ClearSelection();
                di.IsSelected = true;
                _selectionStart = di;
                di.IsOutlined = true;
            }
            _selectedItem = di;
            di.IsOutlined = true;
            Invalidate();

            _ignoreSelectChanged = false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the buffer in order to correctly re-draw this item, if it is on the page, and then invalidates
        /// the area where this will be drawn.
        /// </summary>
        /// <param name="item">The directory item to invalidate</param>
        public void RefreshItem(DirectoryItem item)
        {
            Graphics g = Graphics.FromImage(Page);
            Brush b = new SolidBrush(item.BackColor);
            g.FillRectangle(b, DocumentToClient(item.Bounds));
            b.Dispose();

            // first translate into document coordinates
            System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
            mat.Translate(ClientRectangle.X, ClientRectangle.Y);
            g.Transform = mat;
           
            item.Draw(new PaintEventArgs(g, item.Bounds));

            g.Dispose();

        }