private void HopePopSelect_Load(object sender, EventArgs e) { //if (!DesignMode) if (a == 0 && !DesignMode && System.ComponentModel.LicenseManager.UsageMode != System.ComponentModel.LicenseUsageMode.Designtime) { try { this.getGV().DataSource = this.dtSource = getDataSource(); _colInCode = this.DataBindings["colInCode"].BindingMemberInfo.BindingField; _colDisplay = this.DataBindings["colDisplay"].BindingMemberInfo.BindingField; _colValue = this.DataBindings["colValue"].BindingMemberInfo.BindingField; _colExtend1 = this.DataBindings["colExtend1"] == null ? _colExtend1 : this.DataBindings["colExtend1"].BindingMemberInfo.BindingField; _colExtend2 = this.DataBindings["colExtend2"] == null ? _colExtend2 : this.DataBindings["colExtend2"].BindingMemberInfo.BindingField; //this.getGV().DoubleClick += this.gridControl1_DoubleClick; this.getGV().MouseDown += this.gridView1_MouseDown; this.getGV().PreviewKeyDown += this.gridView1_PreviewKeyDown; pop = new LISPop(getGV(), this); this.Height = this.popupContainerEdit1.Height + 1; this.getGV().Width = this.Width < 300 ? 300 : this.Width; SetDataGridStyle(this.getGV()); //当前控件gridview不能获得焦点,否则控件回车会有问题 getGV().TabStop = false; a++; } catch (Exception err) { Console.WriteLine(err); } } }
public PopupForm(LISPop popup) { mPopup = popup; SetStyle(ControlStyles.ResizeRedraw, true); FormBorderStyle = FormBorderStyle.None; StartPosition = FormStartPosition.Manual; this.ShowInTaskbar = false; this.DockPadding.All = BORDER_MARGIN; mControlSize = mPopup.mUserControl.Size; mPopup.mUserControl.Dock = DockStyle.Fill; Controls.Add(mPopup.mUserControl); mWindowSize.Width = mControlSize.Width + 2 * BORDER_MARGIN; mWindowSize.Height = mControlSize.Height + 2 * BORDER_MARGIN; this.Opacity = Convert.ToDouble(popup.mOpacity); //These are here to suppress warnings. this.DropDown += new EventHandler(DoNothing); this.DropDownClosed += new EventHandler(DoNothing); Form parentForm = mPopup.mParent.FindForm(); if (parentForm != null) { parentForm.AddOwnedForm(this); } if (mPopup.mResizable) { mResizingPanel = new Panel(); if (mBackgroundImage == null) { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(LISPop)); mBackgroundImage = (System.Drawing.Image)resources.GetObject("CornerPicture.Image"); } mResizingPanel.BackgroundImage = mBackgroundImage; mResizingPanel.Width = 12; mResizingPanel.Height = 12; mResizingPanel.BackColor = Color.Red; mResizingPanel.Left = mPopup.mUserControl.Width - 15; mResizingPanel.Top = mPopup.mUserControl.Height - 15; mResizingPanel.Cursor = Cursors.SizeNWSE; mResizingPanel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; mResizingPanel.Parent = this; mResizingPanel.BringToFront(); this.mResizingPanel.MouseUp += new MouseEventHandler(mResizingPanel_MouseUp); this.mResizingPanel.MouseDown += new MouseEventHandler(mResizingPanel_MouseDown); this.mResizingPanel.MouseMove += new MouseEventHandler(mResizingPanel_MouseMove); } mPlacement = mPopup.mPlacement; ReLocate(); Rectangle workingArea = Screen.FromControl(mPopup.mParent).WorkingArea; if (mNormalPos.X + this.Width > workingArea.Right) { if ((mPlacement & ePlacement.Right) != 0) { mPlacement = (mPlacement & ~ePlacement.Right) | ePlacement.Left; } } else { if (mNormalPos.X < workingArea.Left) { if ((mPlacement & ePlacement.Left) != 0) { mPlacement = (mPlacement & ~ePlacement.Left) | ePlacement.Right; } } } if (mNormalPos.Y + this.Height > workingArea.Bottom) { if ((mPlacement & ePlacement.Bottom) != 0) { mPlacement = (mPlacement & ~ePlacement.Bottom) | ePlacement.Top; } } else { if (mNormalPos.Y < workingArea.Top) { if ((mPlacement & ePlacement.Top) != 0) { mPlacement = (mPlacement & ~ePlacement.Top) | ePlacement.Bottom; } } } if (mPlacement != mPopup.mPlacement) { ReLocate(); } if (mNormalPos.X + mWindowSize.Width > workingArea.Right) { mNormalPos.X = workingArea.Right - mWindowSize.Width; } else { if (mNormalPos.X < workingArea.Left) { mNormalPos.X = workingArea.Left; } } if (mNormalPos.Y + mWindowSize.Height > workingArea.Bottom) { mNormalPos.Y = workingArea.Bottom - mWindowSize.Height; } else { if (mNormalPos.Y < workingArea.Top) { mNormalPos.Y = workingArea.Top; } } // Initialize the animation mProgress = 0; if (mPopup.mAnimationSpeed > 0) { mTimer = new Timer(); mTimer.Interval = 1000 / 25; mTimerStarted = DateTime.Now; mTimer.Tick += new EventHandler(Showing); mTimer.Start(); Showing(null, null); } else { SetFinalLocation(); } Show(); mPopup.OnDropDown(mPopup.mParent, new EventArgs()); }