示例#1
0
        void drawingarea_ButtonPressEvent(object o, ButtonPressEventArgs args)
        {
            var evnt = args.Event;

            if (evnt.TriggersContextMenu())
            {
                if (OwnerDrawPopupEvent != null)
                {
                    Menu menu    = new Menu();
                    var  item    = new TaggedLocalizedMenuItem("Header");
                    var  submenu = PrepareHeaderSelectPopupMenu();
                    item.Submenu = submenu;
                    menu.Add(item);
                    menu.Add(new SeparatorMenuItem());
                    OwnerDrawPopupEvent(menu, evnt.Time);
                }
                else
                {
                    ShowDockPopupMenu(evnt.Time);
                }
            }

            else if (evnt.Button == Mouse.LEFT_MOUSE_BUTTON)
            {
                int row = (int)evnt.Y / ConstantHeight + (int)vscrollbar1.Value;
                OffsetCursor(row - CurrentRow, true);
                if (!HasFocus)
                {
                    GrabFocus();
                }

                if (ItemClickedEvent != null)
                {
                    // genereate event ItemClicked(row, column)
                    ColumnControl.Column[] columns = mColumnControl.GetVisibleColumnsInDrawOrder();
                    int dx = -(int)hscrollbar1.Value;
                    for (int c = 0; c < columns.Length; c++)
                    {
                        ColumnControl.Column column = columns[c];
                        int columnIndex             = column.SortOrder;
                        int xwidth = column.Width + mColumnControl.GripperWidth;

                        if (evnt.X >= dx && evnt.X <= dx + xwidth)
                        {
                            ItemClickedEvent(args, CurrentRow, column.Tag);
                            break;
                        }
                        dx += xwidth;
                    }
                }
            }
        }
        void drawingarea_ButtonPressEvent(object o, ButtonPressEventArgs args)
        {
            var evnt = args.Event;
             if (evnt.TriggersContextMenu())
             {
            if (OwnerDrawPopupEvent != null)
            {
               Menu menu = new Menu();
               var item = new TaggedLocalizedMenuItem("Header");
               var submenu = PrepareHeaderSelectPopupMenu();
               item.Submenu = submenu;
               menu.Add(item);
               menu.Add(new SeparatorMenuItem());
               OwnerDrawPopupEvent(menu, evnt.Time);
            }
            else
            {
               ShowDockPopupMenu(evnt.Time);
            }
             }

             else if (evnt.Button == LEFT_MOUSE_BUTTON)
             {
            int row = (int)evnt.Y / ConstantHeight + (int)vscrollbar1.Value;
            OffsetCursor(row - CurrentRow, true);
            if (!HasFocus)
               GrabFocus();

            if (ItemClickedEvent != null)
            {
               // genereate event ItemClicked(row, column)
               ColumnControl.Column[] columns = mColumnControl.GetVisibleColumnsInDrawOrder();
               int dx = -(int)hscrollbar1.Value;
               for (int c = 0; c < columns.Length; c++)
               {
                  ColumnControl.Column column = columns[c];
                  int columnIndex = column.SortOrder;
                  int xwidth = column.Width + mColumnControl.GripperWidth;

                  if (evnt.X >= dx && evnt.X <= dx + xwidth)
                  {
                     ItemClickedEvent(args, CurrentRow, column.Tag);
                     break;
                  }
                  dx += xwidth;
               }
            }
             }
        }