コード例 #1
0
        private void                PanelForm_VisibleChanged(object aSender, EventArgs aEventArgs)
        {
            if (Visible)
            {
                mPanel = mSimObject.getPanel(mPanelName);

                var lControl = mPanel.UserControl;
                Controls.Add(lControl);
                ClientSize = new Size(lControl.Width, lControl.Height);

                mSimObject.ChangedValues     += new EventHandler(onValueChanged);
                mSimObject.ChangedProperties += new EventHandler(onPropertiesChanged);

                mPanel.updateValues();
                mPanel.updateProperties();

                var lPoint = Cursor.Position;
                int lX     = lPoint.X - Width / 2;
                int lY     = lPoint.Y - Height / 2;

                int lMax = SystemInformation.VirtualScreen.Width - Width;
                if (lX > lMax)
                {
                    lX = lMax;
                }
                else if (lX < 0)
                {
                    lX = 0;
                }

                lMax = SystemInformation.VirtualScreen.Height - Height;
                if (lY > lMax)
                {
                    lY = lMax;
                }
                else if (lY < 0)
                {
                    lY = 0;
                }
                SetDesktopLocation(lX, lY);
            }
            else
            {
                mSimObject.ChangedValues     -= onValueChanged;
                mSimObject.ChangedProperties -= onPropertiesChanged;

                Controls.Remove(mPanel.UserControl);
                mPanel.Dispose();
            }
        }