1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using FastReport.Utils;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Windows.Forms;
- namespace FastReport.FastQueryBuilder
- {
- internal class DataBaseView : ListBox
- {
- private Rectangle dragBoxFromMouseDown;
- public Table SelectedTable => SelectedItem as Table;
- public DataBaseView()
- {
- DrawMode = DrawMode.OwnerDrawFixed;
- IntegralHeight = false;
- }
- public void FillTableList(List<Table> tl)
- {
- BeginUpdate();
- Items.Clear();
- foreach (Table tbl in tl)
- {
- Items.Add(tbl);
- }
- EndUpdate();
- }
- protected override void OnDrawItem(DrawItemEventArgs e)
- {
- e.DrawBackground();
- if (e.Index >= 0)
- {
- this.DrawImageAndText(e, this.GetImage(222), Items[e.Index].ToString());
- }
- }
- protected override void OnMouseDown(MouseEventArgs e)
- {
- base.OnMouseDown(e);
- if (SelectedItem != null)
- {
- Size dragSize = SystemInformation.DragSize;
- dragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width / 2),
- e.Y - (dragSize.Height / 2)), dragSize);
- }
- else
- dragBoxFromMouseDown = Rectangle.Empty;
- }
- protected override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
- {
- if ((dragBoxFromMouseDown != Rectangle.Empty) &&
- !dragBoxFromMouseDown.Contains(e.X, e.Y))
- {
- DoDragDrop(SelectedItem, DragDropEffects.Copy);
- }
- }
- }
- protected override void OnMouseUp(MouseEventArgs e)
- {
- base.OnMouseUp(e);
- dragBoxFromMouseDown = Rectangle.Empty;
- }
- public void UpdateDpiDependencies()
- {
- ItemHeight = this.LogicalToDevice(18);
- }
- }
- }
|