日期:2014-05-18 浏览次数:20991 次
private bool _mouseflag = false; private Point _locationp; private void ctrImageBox_MouseDown(object sender, MouseEventArgs e) { _mouseflag = true; _locationp.X = MousePosition.X; _locationp.Y = MousePosition.Y; } private void ctrImageBox_MouseMove(object sender, MouseEventArgs e) { if (_mouseflag) { if (ChangeSizeToolStripMenuItem.Text == "调整位置") { this.Width += MousePosition.X - _locationp.X; this.Height += MousePosition.Y - _locationp.Y; } if (ChangeSizeToolStripMenuItem.Text == "调整大小") { this.Left += MousePosition.X - _locationp.X; this.Top += MousePosition.Y - _locationp.Y; } _locationp.X = MousePosition.X; _locationp.Y = MousePosition.Y; } } private void ctrImageBox_MouseUp(object sender, MouseEventArgs e) { _mouseflag = false; _locationp = new Point(0, 0); } private void ctrImageBox_MouseLeave(object sender, EventArgs e) { _mouseflag = false; } private void RemoveToolStripMenuItem_Click(object sender, EventArgs e) { this.Visible = false; } private void ChangeSizeToolStripMenuItem_Click(object sender, EventArgs e) { if (ChangeSizeToolStripMenuItem.Text == "调整位置") { ChangeSizeToolStripMenuItem.Text = "调整大小"; } else { if (ChangeSizeToolStripMenuItem.Text == "调整大小") { ChangeSizeToolStripMenuItem.Text = "调整位置"; } else { ChangeSizeToolStripMenuItem.Text = "调整大小"; } } }
private void EquipmentImage_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; m_dragnode = (TreeNode)(e.Data.GetData(typeof(TreeNode))); m_imageindex = m_dragnode.ImageIndex; filename = path + m_dragnode.Text + ".jpeg"; } private void EquipmentImage_DragDrop(object sender, DragEventArgs e) { try { OperationAndMaintenance.Control.ctrImageBox imagebox = new OperationAndMaintenance.Control.ctrImageBox(); this.Controls.Add(imagebox); ImageIDMax++; imagebox.Name = m_dragnode.Text + "-" + ImageIDMax.ToString(); Image myimage = Image.FromFile(filename); imagebox.Size = new Size(myimage.Width, myimage.Height); imagebox.BackgroundImage = myimage; imagebox.Location = PointToClient(MousePosition); imagebox.Show(); EquipmentList.Add(imagebox); filename = pa