Exemplo n.º 1
0
        // Override mouse and keyboard entry behaviour.
        protected override void WndProc(ref Message m)
        {
            bool handled = false;

            // WM_LBUTTONDOWN
            // Handle left mouse button down without changing selection, imortant for multi selected column aspect changing.
            // Using a MouseDown EventHandler unfortunately changes seletion.
            if (m.Msg == 0x0201)
            {
                int x = m.LParam.ToInt32() & 0xFFFF;
                int y = (m.LParam.ToInt32() >> 16) & 0xFFFF;
                OlvListViewHitTestInfo hti = this.OlvHitTest(x, y);
                handled = MouseLeftClick.Click(hti);
                //TODO: this method is being suppressed by override. may need it!
                //this.PossibleFinishCellEditing();
                //look at base.WndProc to see.
            }

            // WM_CONTEXTMENU
            // Temporarily disable all context menu creation until it is properly implemented.
            if (m.Msg == 0x7B)
            {
                //handled = true;
            }

            if (handled)
            {
                return;
            }
            else
            {
                base.WndProc(ref m);
            }
        }
Exemplo n.º 2
0
            /// <summary>
            /// Do the hit test
            /// </summary>
            /// <param name="g"></param>
            /// <param name="hti"></param>
            /// <param name="x"></param>
            /// <param name="y"></param>
            protected override void HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, int x, int y)
            {
                Branch br = this.Branch;

                Rectangle r = this.ApplyCellPadding(this.Bounds);

                if (br.CanExpand)
                {
                    r.Offset((br.Level - 1) * PIXELS_PER_LEVEL, 0);
                    r.Width = PIXELS_PER_LEVEL;
                    if (r.Contains(x, y))
                    {
                        hti.HitTestLocation = HitTestLocation.ExpandButton;
                        return;
                    }
                }

                r = this.Bounds;
                int indent = br.Level * PIXELS_PER_LEVEL;

                r.X     += indent;
                r.Width -= indent;

                // Ignore events in the indent zone
                if (x < r.Left)
                {
                    hti.HitTestLocation = HitTestLocation.Nothing;
                }
                else
                {
                    this.StandardHitTest(g, hti, r, x, y);
                }
            }
Exemplo n.º 3
0
 protected override void HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, int x, int y)
 {
     if (Bounds.Contains(x, y))
     {
         hti.HitTestLocation = HitTestLocation.Text;
     }
 }
Exemplo n.º 4
0
        protected override void HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, int x, int y)
        {
            Rectangle r = CalculateAlignedRectangle(g, Bounds);

            // Did they hit a check box?
            int       width = CalculateCheckBoxWidth(g);
            Rectangle r2    = r;

            r2.Width = width;
            if (r2.Contains(x, y))
            {
                hti.HitTestLocation = HitTestLocation.CheckBox;
                return;
            }

            // Did they hit the image? If they hit the image of a
            // non-primary column that has a checkbox, it counts as a
            // checkbox hit
            r.X     += width;
            r.Width -= width;
            width    = CalculateImageWidth(g, GetImageSelector());
            r2       = r;
            r2.Width = width;
            Image img = GetImageSelector() as Image;

            // fix for vertical hitting (w/o the entire vertical column surrounding the image)
            if (null != img)
            {
                r2.Y     += (r.Height - img.Height) / 2;
                r2.Height = img.Height;
            }
            // end fix
            if (r2.Contains(x, y))
            {
                if (Column.Index > 0 && Column.CheckBoxes)
                {
                    hti.HitTestLocation = HitTestLocation.CheckBox;
                }
                else
                {
                    hti.HitTestLocation = HitTestLocation.Image;
                }
                return;
            }

            // Did they hit the text?
            r.X     += width;
            r.Width -= width;
            width    = CalculateTextWidth(g, GetText());
            r2       = r;
            r2.Width = width;
            if (r2.Contains(x, y))
            {
                hti.HitTestLocation = HitTestLocation.Text;
                return;
            }

            hti.HitTestLocation = HitTestLocation.InCell;
        }
        /// <summary>
        /// Handle the HitTest request
        /// </summary>
        /// <param name="g"></param>
        /// <param name="hti"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        protected override void HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, int x, int y)
        {
            Rectangle r = this.CalculateCheckBoxBounds(g, this.Bounds);

            if (r.Contains(x, y))
            {
                hti.HitTestLocation = HitTestLocation.CheckBox;
            }
        }
Exemplo n.º 6
0
 protected override bool ProcessLButtonDoubleClick(OlvListViewHitTestInfo hti)
 {
     if (hti.HitTestLocation == HitTestLocation.CheckBox)
     {
         return(true);
     }
     if (hti.Column == null || !hti.Column.IsRowNumberColumn || hti.Item == null || hti.Item.Index < 0)
     {
         return(true);
     }
     if (RowNumberDblClick != null)
     {
         RowNumberDblClick(hti);
     }
     return(true);
 }
Exemplo n.º 7
0
        public NlmMaxColorPicker(OlvListViewHitTestInfo hti, Boolean applyToSelection, NlmTreeListView listView)
        {
            ListView = listView;

            this.CurrentColor = (Color)ListView.NlmColumns.ColorColumn.GetValue(hti.RowObject);

            TreeNodes = new List <BaseTreeNode>();
            if (applyToSelection)
            {
                TreeNodes.AddRange(listView.NodeControl.Query.SelectedNodes);
            }
            else
            {
                TreeNodes.Add(hti.RowObject as BaseTreeNode);
            }

            this.ColorConfirmed += new ConfirmColorEventHandler(onColorChanged);
        }
Exemplo n.º 8
0
		/// <summary>
		/// Perform normal hit testing relative to the given bounds
		/// </summary>
		/// <param name="g"></param>
		/// <param name="hti"></param>
		/// <param name="bounds"></param>
		/// <param name="x"></param>
		/// <param name="y"></param>
		protected void StandardHitTest(Graphics g, OlvListViewHitTestInfo hti, Rectangle bounds, int x, int y) {
			Rectangle r = bounds;

			// Did they hit a check box?
			int width = this.CalculateCheckBoxWidth(g);
			Rectangle r2 = r;
			r2.Width = width;
			if (r2.Contains(x, y)) {
				hti.HitTestLocation = HitTestLocation.CheckBox;
				return;
			}

			// Did they hit the image? If they hit the image of a 
			// non-primary column that has a checkbox, it counts as a 
			// checkbox hit
			r.X += width;
			r.Width -= width;
			width = this.CalculateImageWidth(g, this.GetImageSelector());
			r2 = r;
			r2.Width = width;
			if (r2.Contains(x, y)) {
				if (this.Column.Index > 0 && this.Column.CheckBoxes)
					hti.HitTestLocation = HitTestLocation.CheckBox;
				else
					hti.HitTestLocation = HitTestLocation.Image;
				return;
			}

			// Did they hit the text?
			r.X += width;
			r.Width -= width;
			width = this.CalculateTextWidth(g, this.GetText());
			r2 = r;
			r2.Width = width;
			if (r2.Contains(x, y)) {
				hti.HitTestLocation = HitTestLocation.Text;
				return;
			}

			hti.HitTestLocation = HitTestLocation.InCell;
		}
Exemplo n.º 9
0
		/// <summary>
		/// What is under the given point?
		/// </summary>
		/// <param name="hti"></param>
		/// <param name="x">x co-ordinate</param>
		/// <param name="y">y co-ordinate</param>
		/// <remarks>This method should only alter HitTestLocation and/or UserData.</remarks>
		public virtual void HitTest(OlvListViewHitTestInfo hti, int x, int y) {
		}
Exemplo n.º 10
0
		/// <summary>
		/// Calculate which part of this cell was hit
		/// </summary>
		/// <param name="hti"></param>
		/// <param name="x"></param>
		/// <param name="y"></param>
		public override void HitTest(OlvListViewHitTestInfo hti, int x, int y) {
			this.ClearState();

			this.ListView = hti.ListView;
			this.ListItem = hti.Item;
			this.SubItem = hti.SubItem;
			this.Column = hti.Column;
			this.RowObject = hti.RowObject;
			this.IsItemSelected = this.ListItem.Selected;
			if (this.SubItem == null)
				this.Bounds = this.ListItem.Bounds;
			else
				this.Bounds = this.ListItem.GetSubItemBounds(this.Column.Index);
			//this.Bounds = this.ListView.CalculateCellBounds(this.ListItem, this.Column.Index);

			using (Graphics g = this.ListView.CreateGraphics()) {
				this.HandleHitTest(g, hti, x, y);
			}
		}
Exemplo n.º 11
0
		/// <summary>
		/// Do the actual work of hit testing. Subclasses should override this rather than HitTest()
		/// </summary>
		/// <param name="g"></param>
		/// <param name="hti"></param>
		/// <param name="x"></param>
		/// <param name="y"></param>
		protected virtual void HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, int x, int y) {
			Rectangle r = this.CalculateAlignedRectangle(g, this.Bounds);
			this.StandardHitTest(g, hti, r, x, y);
		}
Exemplo n.º 12
0
		/// <summary>
		/// Do the actual work of hit testing. Subclasses should override this rather than HitTest()
		/// </summary>
		/// <param name="g"></param>
		/// <param name="hti"></param>
		/// <param name="x"></param>
		/// <param name="y"></param>
		protected override void HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, int x, int y) {
			IConvertible convertable = this.Aspect as IConvertible;
			if (convertable == null)
				return;

			Int32 v2 = convertable.ToInt32(NumberFormatInfo.InvariantInfo);

			Point pt = this.Bounds.Location;
			foreach (Int32 key in this.keysInOrder) {
				if ((v2 & key) == key) {
					Image image = this.GetImage(this.imageMap[key]);
					if (image != null) {
						Rectangle imageRect = new Rectangle(pt, image.Size);
						if (imageRect.Contains(x, y)) {
							hti.UserData = key;
							return;
						}
						pt.X += (image.Width + this.Spacing);
					}
				}
			}
		}
Exemplo n.º 13
0
		/// <summary>
		/// Handle the HitTest request
		/// </summary>
		/// <param name="g"></param>
		/// <param name="hti"></param>
		/// <param name="x"></param>
		/// <param name="y"></param>
		protected override void HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, int x, int y) {
			if (this.Bounds.Contains(x, y))
				hti.HitTestLocation = HitTestLocation.Text;
		}
Exemplo n.º 14
0
		/// <summary>
		/// Handle the HitTest request
		/// </summary>
		/// <param name="g"></param>
		/// <param name="hti"></param>
		/// <param name="x"></param>
		/// <param name="y"></param>
		protected override void HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, int x, int y) {
			Rectangle r = this.CalculateCheckBoxBounds(g, this.Bounds);
			if (r.Contains(x, y))
				hti.HitTestLocation = HitTestLocation.CheckBox;
		}
Exemplo n.º 15
0
 protected override void HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, int x, int y)
 {
     PIXELS_PER_LEVEL = IndentAmount;
     base.HandleHitTest(g, hti, x, y);
     PIXELS_PER_LEVEL = 17;
 }
Exemplo n.º 16
0
        public Boolean Click(OlvListViewHitTestInfo hti)
        {
            if (hti.ColumnIndex > 0)
            {
                if (hti.Column == ListView.NlmColumns.ColorColumn)
                {
                    // Should the check states be changed on the selection, or on an item outside of selection.
                    // If inside selection, suppress change in selection by returning true.
                    // If outside selection, change the single item and return false.
                    if (hti.Item.Selected)
                    {
                        NlmMaxColorPicker colorPicker = new NlmMaxColorPicker(hti, true, ListView);
                        colorPicker.ShowModeless();
                        return(true);
                    }
                    else
                    {
                        NlmMaxColorPicker colorPicker = new NlmMaxColorPicker(hti, false, ListView);
                        colorPicker.ShowModeless();
                        // Returning false annoyingly pushes the window to the back.
                        // TODO: Somehow make this dialog modal, or at least parented to 3ds Max, and sort out the focus issue.
                        return(true);
                    }
                }
                if (hti.Column == ListView.NlmColumns.CurrentColumn)
                {
                    BaseTreeNode treeNode = hti.RowObject as BaseTreeNode;
                    if (treeNode is LayerTreeNode)
                    {
                        ListView.BeginUpdate();
                        hti.Column.PutValue(treeNode, true);
                        ListView.EndUpdate();
                    }
                    return(hti.Item.Selected);
                }
                else
                {
                    Boolean    htiItemSelected = hti.Item.Selected;
                    INLMColumn column          = hti.Column as INLMColumn;

                    // Should the check states be changed on the selection, or on an item outside of selection.
                    // If inside selection, suppress change in selection by returning true.
                    // If outside selection, change the single item and return false.
                    if (htiItemSelected)
                    {
                        column.AspectEngine.ToggleCheckStates(hti.RowObject);
                        ListView.RefreshObjects(ListView.SelectedObjects);
                    }
                    else
                    {
                        column.AspectEngine.ToggleCheckState(hti.RowObject);
                        ListView.RefreshObject(hti.RowObject);
                    }

                    MaxUI.RedrawViewportsNow();
                    return(htiItemSelected);
                }
            }
            return(false);
            // Returning true means selection does not change, returning false means it does.
        }
Exemplo n.º 17
0
        /// <summary>
        /// When the mouse is at the given point, what should the target of the drop be?
        /// </summary>
        /// <remarks>This method should update the DropTarget* members of the given arg block</remarks>
        /// <param name="pt">The mouse point, in client co-ordinates</param>
        protected virtual void CalculateDropTarget(OlvDropEventArgs args, Point pt)
        {
            const int          SMALL_VALUE = 3;
            DropTargetLocation location    = DropTargetLocation.None;
            int targetIndex    = -1;
            int targetSubIndex = 0;

            if (this.CanDropOnBackground)
            {
                location = DropTargetLocation.Background;
            }

            // Which item is the mouse over?
            // If it is not over any item, it's over the background.
            //ListViewHitTestInfo info = this.ListView.HitTest(pt.X, pt.Y);
            OlvListViewHitTestInfo info = this.ListView.OlvHitTest(pt.X, pt.Y);

            if (info.Item != null && this.CanDropOnItem)
            {
                location    = DropTargetLocation.Item;
                targetIndex = info.Item.Index;
                if (info.SubItem != null && this.CanDropOnSubItem)
                {
                    targetSubIndex = info.Item.SubItems.IndexOf(info.SubItem);
                }
            }

            // Check to see if the mouse is "between" rows.
            // ("between" is somewhat loosely defined)
            if (this.CanDropBetween && this.ListView.GetItemCount() > 0)
            {
                // If the mouse is over an item, check to see if it is near the top or bottom
                if (location == DropTargetLocation.Item)
                {
                    if (pt.Y - SMALL_VALUE <= info.Item.Bounds.Top)
                    {
                        location = DropTargetLocation.AboveItem;
                    }
                    if (pt.Y + SMALL_VALUE >= info.Item.Bounds.Bottom)
                    {
                        location = DropTargetLocation.BelowItem;
                    }
                }
                else
                {
                    // Is there an item a little below the mouse?
                    // If so, we say the drop point is above that row
                    info = this.ListView.OlvHitTest(pt.X, pt.Y + SMALL_VALUE);
                    if (info.Item != null)
                    {
                        targetIndex = info.Item.Index;
                        location    = DropTargetLocation.AboveItem;
                    }
                    else
                    {
                        // Is there an item a little above the mouse?
                        info = this.ListView.OlvHitTest(pt.X, pt.Y - SMALL_VALUE);
                        if (info.Item != null)
                        {
                            targetIndex = info.Item.Index;
                            location    = DropTargetLocation.BelowItem;
                        }
                    }
                }
            }

            args.DropTargetLocation     = location;
            args.DropTargetIndex        = targetIndex;
            args.DropTargetSubItemIndex = targetSubIndex;
        }
Exemplo n.º 18
0
 public OLVContextMenuClickArgs(OlvListViewHitTestInfo hitInfo)
 {
     HitInfo = hitInfo;
 }