示例#1
0
 void winForm_onDelegateClosedEvt(CustomWinForm winForm)
 {
     if (onDelegateClosedEvt != null)
     {
         onDelegateClosedEvt(winForm.Id);
     }
 }
示例#2
0
        void winForm_onDelegatePosChangedEvt(CustomWinForm winForm, int xPos, int yPos)
        {
            if (winForm.LatestRelativePos.X == xPos &&
                winForm.LatestRelativePos.Y == yPos)
            {
                return;
            }

            if (onDelegatePosChangedEvt != null)
            {
                Point actual     = getActualPoint(xPos, yPos);
                Size  actualSize = getActualSize(winForm.Width, winForm.Height);

                // save the size as well
                int adjustedX, adjustedY;
                if (checkActualEdges(actual.X, actual.Y, out adjustedX, out adjustedY))
                {
                    Trace.WriteLine(String.Format("delegatePosChange - {0},{1} : {2},{3}, adjusted {4},{5}",
                                                  xPos, yPos, actual.X, actual.Y, adjustedX, adjustedY));
                }

                winForm.LatestPos         = new Point(adjustedX, adjustedY);
                winForm.LatestRelativePos = new Point(xPos, yPos);

                onDelegatePosChangedEvt(winForm.Id, adjustedX, adjustedY, actualSize.Width, actualSize.Height);
            }
        }
示例#3
0
        void winForm_onDelegateSizeChangedEvt(CustomWinForm winForm, Size size)
        {
            if (winForm.LatestRelativeSize == size)
            {
                return;
            }

            if (onDelegateSizeChangedEvt != null)
            {
                // update the latest actual size passed to server, assuming the passing MUST succeed
                Point actualPos  = getActualPoint(winForm.Location.X, winForm.Location.Y);
                Size  actualSize = getActualSize(size.Width, size.Height);

                // todo: check the left edges
                int actualX, actualY;
                if (checkActualEdges(actualPos.X, actualPos.Y, out actualX, out actualY))
                {
                    winForm.LatestRelativePos = new Point(actualX, actualY);
                    onDelegatePosChangedEvt(winForm.Id, actualX, actualY, actualSize.Width, actualSize.Height);
                }

                // check the right edges which might snap to boundary
                int actualRight, actualBottom;
                if (checkActualEdges(actualX + actualSize.Width, actualY + actualSize.Height, out actualRight, out actualBottom))
                {
                    actualSize.Width  = actualRight - actualX;
                    actualSize.Height = actualBottom - actualY;
                }

                winForm.LatestRelativeSize = size;
                winForm.LatestSize         = actualSize;
                onDelegateSizeChangedEvt(winForm.Id, actualSize);
            }
        }
示例#4
0
        public ControlAttributes GetTopMostControl()
        {
            ControlAttributes attr = new ControlAttributes();

            int largestIndex = 0;

            foreach (Control control in this.Controls)
            {
                CustomWinForm winForm = control as CustomWinForm;
                if (winForm != null)
                {
                    int index = this.Controls.IndexOf(control);
                    if (index >= largestIndex)
                    {
                        largestIndex = index;

                        // update the attr
                        attr.Id = winForm.Id;

                        Point actualPt = getActualPoint(winForm.Location.X, winForm.Location.Y);
                        attr.Xpos = actualPt.X;
                        attr.Ypos = actualPt.Y;

                        Size actualSize = getActualSize(winForm.Size.Width, winForm.Size.Height);
                        attr.Width  = actualSize.Width;
                        attr.Height = actualSize.Height;

                        attr.Style = winForm.Style;
                    }
                }
            }

            return(attr);
        }
示例#5
0
        public ControlAttributes GetControl(int controlId)
        {
            ControlAttributes attr = new ControlAttributes();

            foreach (Control control in this.Controls)
            {
                CustomWinForm winForm = control as CustomWinForm;
                if (winForm != null &&
                    winForm.Id == controlId)
                {
                    attr.Id = winForm.Id;

                    Point actualPt = getActualPoint(winForm.Location.X, winForm.Location.Y);
                    attr.Xpos = actualPt.X;
                    attr.Ypos = actualPt.Y;

                    Size actualSize = getActualSize(winForm.Size.Width, winForm.Size.Height);
                    attr.Width  = actualSize.Width;
                    attr.Height = actualSize.Height;

                    attr.Style = winForm.Style;

                    break;
                }
            }

            return(attr);
        }
示例#6
0
        public void AddControl(ControlAttributes controlAttr)
        {
            try
            {
                CustomWinForm winForm = new CustomWinForm(controlAttr.Id, controlAttr.Style, this);
                mControlsDic.Add(controlAttr.Id, winForm);

                this.Controls.Add(winForm);
                this.Controls.SetChildIndex(winForm, controlAttr.ZOrder);

                // set the win size
                winForm.LatestSize = new Size(controlAttr.Width, controlAttr.Height);
                Size relativeSize = getRelativeSize(controlAttr.Width, controlAttr.Height);
                winForm.LatestRelativeSize = relativeSize;
                winForm.SetWindowSize(relativeSize);

                // set the win pos
                winForm.LatestPos = new Point(controlAttr.Xpos, controlAttr.Ypos);
                Point relativePoint = getRelativePoint(controlAttr.Xpos, controlAttr.Ypos);
                winForm.LatestRelativePos = relativePoint;
                winForm.SetWindowLocation(relativePoint.X, relativePoint.Y);

                // add the tooltip control
                windowToolTip.SetToolTip(winForm, controlAttr.WindowName);

                winForm.SetWindowName(controlAttr.WindowName);
                winForm.Style = (int)(controlAttr.Style);

                // register the event callback
                winForm.onDelegateClosedEvt      += winForm_onDelegateClosedEvt;
                winForm.onDelegateMaximizedEvt   += winForm_onDelegateMaximizedEvt;
                winForm.onDelegateMinimizedEvt   += winForm_onDelegateMinimizedEvt;
                winForm.onDelegatePosChangedEvt  += winForm_onDelegatePosChangedEvt;
                winForm.onDelegateRestoredEvt    += winForm_onDelegateRestoredEvt;
                winForm.onDelegateSizeChangedEvt += winForm_onDelegateSizeChangedEvt;

                Trace.WriteLine(String.Format("Add control - pos:{0},{1} size:{2},{3} : {4},{5}",
                                              relativePoint.X, relativePoint.Y, relativeSize.Width, relativeSize.Height, controlAttr.Width, controlAttr.Height));
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
            }
        }