⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tree_widget.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 5 页
字号:
                        this.draw_item(this.m_hover_item);
                    }
                    if (this.OnHoverItemChanged != null)
                    {
                        this.OnHoverItemChanged(this);
                    }
                }
            }
        }

        public void clear(bool fRepaint)
        {
            for (tree<item_type>.iterator item = this.m_items.begin; item != this.m_items.end; item = tree<item_type>.iterator.op_Increment(item))
            {
                if (item.data != null)
                {
                    item.data.dispose();
                }
            }
            this.change_hover_item(this.end, false);
            this.change_focus_item(this.end, false);
            this.m_items.clear();
            this.m_hover_item.reset();
            this.m_focus_item.reset();
            this.clear_selecteditems(false, true);
            this.m_first_visible_item.reset();
            if (fRepaint)
            {
                win32api_wrapper.PostMessage(base.Handle, 0x40a, (IntPtr) 2, IntPtr.Zero);
            }
        }

        private void clear_selecteditems(bool fRepaint, bool fireEvent)
        {
            if (this.m_selected_items.get_Count() > 0)
            {
                tree<item_type>.iterator[] iteratorArray = null;
                if (fRepaint)
                {
                    iteratorArray = new tree<item_type>.iterator[this.m_selected_items.get_Count()];
                    this.m_selected_items.CopyTo(iteratorArray);
                }
                this.m_selected_items.Clear();
                if (fireEvent && (this.OnSelectedItemsChanged != null))
                {
                    this.OnSelectedItemsChanged(this);
                }
                if (fRepaint)
                {
                    foreach (tree<item_type>.iterator iterator in iteratorArray)
                    {
                        this.draw_item(iterator);
                    }
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        protected void do_paint()
        {
            Rectangle rect = base.ClientRectangle;
            if ((0 < rect.Width) && (0 < rect.Height))
            {
                using (Graphics graphics = Graphics.FromHwnd(base.Handle))
                {
                    using (Bitmap image = new Bitmap(rect.Width, rect.Height))
                    {
                        using (Graphics graphics2 = Graphics.FromImage(image))
                        {
                            Rectangle clipRect = new Rectangle(0, 0, image.Width, image.Height);
                            using (PaintEventArgs args = new PaintEventArgs(graphics2, clipRect))
                            {
                                this.do_paint(args);
                            }
                            graphics.DrawImage(image, rect);
                        }
                    }
                }
            }
        }

        protected void do_paint(PaintEventArgs args)
        {
            try
            {
                this.PaintBackground(args.Graphics, base.ClientRectangle);
                win32api_wrapper.SCROLLINFO si = new win32api_wrapper.SCROLLINFO();
                si.cbSize = 0x1c;
                si.fMask = 20;
                win32api_wrapper.GetScrollInfo(base.Handle, 1, ref si);
                win32api_wrapper.SCROLLINFO scrollinfo2 = new win32api_wrapper.SCROLLINFO();
                scrollinfo2.cbSize = 0x1c;
                scrollinfo2.fMask = 20;
                win32api_wrapper.GetScrollInfo(base.Handle, 0, ref scrollinfo2);
                paint_context context = new paint_context();
                Rectangle clipRectangle = args.ClipRectangle;
                int width = -3;
                clipRectangle.Inflate(width, width);
                context.canvas = clipRectangle;
                context.voffset = -si.nPos;
                context.hoffset = -scrollinfo2.nPos;
                context.graphics = args.Graphics;
                this.m_first_visible_item.reset(true);
                this.browse_items(new browse_item_handler(this.draw_item_handler), context);
                this.update_inner_edit_bounds();
                if (this.m_fIsScrolling)
                {
                    this.m_fIsScrolling = false;
                }
                else
                {
                    if (this.m_fVScrollable)
                    {
                        int num2 = context.items_height + 6;
                        if (num2 > args.ClipRectangle.Height)
                        {
                            win32api_wrapper.SCROLLINFO scrollinfo3 = new win32api_wrapper.SCROLLINFO();
                            scrollinfo3.cbSize = 0x1c;
                            scrollinfo3.fMask = 3;
                            scrollinfo3.nMin = 0;
                            scrollinfo3.nPage = (uint) args.ClipRectangle.Height;
                            scrollinfo3.nPos = 0;
                            scrollinfo3.nTrackPos = 0;
                            scrollinfo3.nMax = num2;
                            win32api_wrapper.ShowScrollBar(base.Handle, 1, true);
                            win32api_wrapper.SetScrollInfo(base.Handle, 1, ref scrollinfo3, true);
                            this.m_fVCanScroll = true;
                        }
                        else
                        {
                            this.m_fVCanScroll = false;
                            win32api_wrapper.ShowScrollBar(base.Handle, 1, false);
                            win32api_wrapper.SCROLLINFO scrollinfo4 = new win32api_wrapper.SCROLLINFO();
                            scrollinfo4.cbSize = 0x1c;
                            scrollinfo4.fMask = 4;
                            scrollinfo4.nPos = 0;
                            win32api_wrapper.SetScrollInfo(base.Handle, 1, ref scrollinfo4, true);
                        }
                    }
                    if (this.m_fHScrollable)
                    {
                        if (context.max_item_width > args.ClipRectangle.Width)
                        {
                            win32api_wrapper.SCROLLINFO scrollinfo5 = new win32api_wrapper.SCROLLINFO();
                            scrollinfo5.cbSize = 0x1c;
                            scrollinfo5.fMask = 3;
                            scrollinfo5.nMin = 0;
                            scrollinfo5.nPage = (uint) args.ClipRectangle.Width;
                            scrollinfo5.nPos = 0;
                            scrollinfo5.nTrackPos = 0;
                            scrollinfo5.nMax = context.max_item_width;
                            win32api_wrapper.ShowScrollBar(base.Handle, 0, true);
                            win32api_wrapper.SetScrollInfo(base.Handle, 0, ref scrollinfo5, true);
                            this.m_fHCanScroll = true;
                        }
                        else
                        {
                            this.m_fHCanScroll = false;
                            win32api_wrapper.ShowScrollBar(base.Handle, 0, false);
                            win32api_wrapper.SCROLLINFO scrollinfo6 = new win32api_wrapper.SCROLLINFO();
                            scrollinfo6.cbSize = 0x1c;
                            scrollinfo6.fMask = 4;
                            scrollinfo6.nPos = 0;
                            win32api_wrapper.SetScrollInfo(base.Handle, 0, ref scrollinfo6, true);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        protected void draw_item(tree<item_type>.iterator item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (!item.is_end && (item.data != null))
            {
                tree<item_type>.iterator iterator = this.parent(item);
                if (iterator.is_end || iterator.data.expand)
                {
                    Rectangle clientRectangle = base.ClientRectangle;
                    Rectangle rcClip = item.data.bounds;
                    if (item.data.width <= 0)
                    {
                        if (iterator.is_end)
                        {
                            rcClip = new Rectangle(rcClip.Left, rcClip.Top, rcClip.Width, rcClip.Height);
                        }
                        else
                        {
                            rcClip = new Rectangle(iterator.data.bounds.Left + 1, rcClip.Top, iterator.data.bounds.Width - 2, rcClip.Height);
                        }
                    }
                    if (((clientRectangle.Width > 0) && (clientRectangle.Height > 0)) && ((rcClip.Width > 0) && (rcClip.Height > 0)))
                    {
                        using (Graphics graphics = Graphics.FromHwnd(base.Handle))
                        {
                            using (Bitmap image = new Bitmap(rcClip.Width + 1, rcClip.Height + 1))
                            {
                                using (Graphics g = Graphics.FromImage(image))
                                {
                                    g.ResetTransform();
                                    g.TranslateTransform((float) -rcClip.Left, (float) -rcClip.Top, MatrixOrder.Prepend);
                                    this.PaintBackground(g, rcClip);
                                    this.draw_item(g, item, rcClip);
                                }
                                graphics.DrawImage(image, rcClip.Location);
                            }
                        }
                    }
                }
            }
        }

        private void draw_item(Graphics g, tree<item_type>.iterator item, Rectangle rcClip)
        {
            if (item.data.ColoredBlock)
            {
                using (Brush brush = new SolidBrush(Color.FromArgb(0xf4, 0xf7, 0xf9)))
                {
                    g.FillRectangle(brush, rcClip.Left, rcClip.Top, rcClip.Width + 1, rcClip.Height + 1);
                }
            }
            item_state state = item_state.normal;
            int width = item.data.width;
            if (this.m_selected_items.Contains(item))
            {
                state |= item_state.selected;
                if (width == 0)
                {
                    crystal_band_tools.draw_crystal_band(g, rcClip, this.m_select_band_colors, false);
                }
            }
            if (tree<item_type>.iterator.is_equal(this.m_hover_item, item))
            {
                state |= item_state.hover;
                if (width == 0)
                {
                    if (item_state.focused == (item_state.focused & state))
                    {
                        crystal_band_colors colors = new crystal_band_colors();
                        colors.border_color = Color.FromArgb(80, this.m_hover_band_colors.border_color);
                        colors.toppart_up_color = Color.FromArgb(80, this.m_hover_band_colors.toppart_up_color);
                        colors.toppart_down_color = Color.FromArgb(80, this.m_hover_band_colors.toppart_down_color);
                        colors.bottompart_up_color = Color.FromArgb(80, this.m_hover_band_colors.bottompart_up_color);
                        colors.bottompart_down_color = Color.FromArgb(80, this.m_hover_band_colors.bottompart_down_color);
                        crystal_band_tools.draw_crystal_band(g, rcClip, colors, false);
                    }
                    else
                    {
                        crystal_band_tools.draw_crystal_band(g, rcClip, this.m_hover_band_colors, false);
                    }
                }
            }
            if (tree<item_type>.iterator.is_equal(this.m_focus_item, item))
            {
                state |= item_state.focused;
                if (width == 0)
                {
                    Imps.Client.Pc.DrawHelper.DrawFocusRect(g, rcClip, Color.FromArgb(160, 160, 160));
                }
            }
            item.data.draw(g, item.data.bounds, state);
        }

        private void draw_item_handler(browse_item_helper_arg arg)
        {
            paint_context context = (paint_context) arg.context;
            int height = arg.item.data.height;
            int width = arg.item.data.width;
            Rectangle rcClip = this.CalcItemRect(arg);
            if (context.max_item_width < arg.item_rect.Right)
            {
                context.max_item_width = arg.item_rect.Right;
            }
            if (((arg.item.data.ColoredBlock && (arg.item_rect.Bottom > context.canvas.Top)) && ((arg.item_rect.Top < context.canvas.Bottom) && (arg.item_rect.Right > context.canvas.Left))) && (arg.item_rect.Left < context.canvas.Right))
            {
                Imps.Client.Pc.DrawHelper.DrawAndFillRoundRect(context.graphics, arg.item_rect, 5, Color.Transparent, Color.FromArgb(0xec, 240, 0xf4), 3, false);
            }
            if (((rcClip.Bottom > context.canvas.Top) && (rcClip.Top < context.canvas.Bottom)) && ((rcClip.Right > context.canvas.Left) && (rcClip.Left < context.canvas.Right)))
            {
                if (this.m_first_visible_item.is_end)
                {
                    this.m_first_visible_item.copy(arg.item);
                }
                this.draw_item(context.graphics, arg.item, rcClip);
            }
        }

        private void edit_cancel_edit()
        {
            if ((this.m_item_edit != null) && this.m_item_edit.Visible)
            {
                this.m_item_edit.cancel();
            }
        }

        public void edit_focus_item(object initParam)
        {
            if ((this.m_focus_item != null) && (!this.m_focus_item.is_end && (this.m_focus_item.host == this.m_items)))
            {
                Rectangle rcEdit = this.m_focus_item.data.bounds;
                string strInitText = string.Empty;
                object context = null;
                bool fCancel = false;
                this.m_focus_item.data.on_before_edit(initParam, ref rcEdit, ref strInitText, ref context, ref fCancel);
                if (!fCancel)
                {
                    rcEdit.Inflate(-1, -2);
                    this.on_focus_edit(rcEdit, strInitText, context);
                }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -