Пример #1
0
 /// <summary>
 /// 可见状态改变方法
 /// </summary>
 public override void onVisibleChanged()
 {
     base.onVisibleChanged();
     if (Visible)
     {
         if (m_popup)
         {
             FCHScrollBar hScrollBar = HScrollBar;
             FCVScrollBar vScrollBar = VScrollBar;
             if (hScrollBar != null)
             {
                 hScrollBar.Pos = 0;
             }
             if (vScrollBar != null)
             {
                 vScrollBar.Pos = 0;
             }
             focus();
             //修正显示位置
             adjust(this);
         }
         startTimer(m_timerID, 10);
     }
     else
     {
         stopTimer(m_timerID);
         bool     close  = closeMenus(m_items);
         FCNative native = Native;
         if (native != null)
         {
             native.invalidate();
         }
     }
 }
Пример #2
0
 /// <summary>
 /// 加载XML
 /// </summary>
 /// <param name="fileName">文件名</param>
 public void loadFile(String fileName)
 {
     //创建XML解析器
     m_xml = new UIXmlEx3();
     //链接控件库
     m_xml.createNative();
     m_native             = m_xml.Native;
     m_xml.Script         = new DesignerScript(m_xml);
     m_native.Paint       = new GdiPlusPaintEx();
     m_native.Host        = new WinHostEx();
     m_native.Host.Native = m_native;
     m_host                  = m_native.Host as WinHostEx;
     m_host.HWnd             = Handle;
     m_native.AllowScaleSize = true;
     m_native.DisplaySize    = new FCSize(ClientSize.Width, ClientSize.Height);
     m_xml.resetScaleSize(getClientSize());
     m_native.invalidate();
     m_xml.loadFile(fileName, null);
     m_native.update();
     m_native.invalidate();
 }
Пример #3
0
        /// <summary>
        /// 显示右键菜单
        /// </summary>
        /// <param name="var">变量</param>
        /// <returns>状态</returns>
        private double SHOWRIGHTMENU(CVariable var)
        {
            DesignerScript designerScript = m_xml.Script as DesignerScript;
            FCNative       native         = m_xml.Native;
            FCView         control        = m_xml.findControl(designerScript.getSender());
            int            clientX        = native.clientX(control);
            int            clientY        = native.clientY(control);
            FCMenu         menu           = m_xml.getMenu(m_indicator.getText(var.m_parameters[0]));

            menu.Location = new FCPoint(clientX, clientY + control.Height);
            menu.Visible  = true;
            menu.Focused  = true;
            menu.bringToFront();
            native.invalidate();
            return(0);
        }
Пример #4
0
        /// <summary>
        /// 菜单触摸移动方法
        /// </summary>
        /// <param name="item">菜单项</param>
        /// <param name="touchInfo">触摸信息</param>
        public virtual void onMenuItemTouchMove(FCMenuItem item, FCTouchInfo touchInfo)
        {
            FCNative native = Native;
            ArrayList <FCMenuItem> items      = null;
            FCMenuItem             parentItem = item.ParentItem;

            if (parentItem != null)
            {
                items = parentItem.getItems();
            }
            else
            {
                items = m_items;
            }
            //关闭其他表格
            bool close = closeMenus(items);

            if (item.getItems().size() > 0)
            {
                FCMenu dropDownMenu = item.DropDownMenu;
                //获取位置和大小
                if (dropDownMenu != null)
                {
                    dropDownMenu.Native = native;
                    FCLayoutStyle layoutStyle = LayoutStyle;
                    FCPoint       location    = new FCPoint(native.clientX(item) + item.Width, native.clientY(item));
                    if (layoutStyle == FCLayoutStyle.LeftToRight || layoutStyle == FCLayoutStyle.RightToLeft)
                    {
                        location.x = native.clientX(item);
                        location.y = native.clientY(item) + item.Height;
                    }
                    //设置弹出位置
                    dropDownMenu.Opacity  = Opacity;
                    dropDownMenu.Location = location;
                    dropDownMenu.bringToFront();
                    dropDownMenu.focus();
                    dropDownMenu.show();
                    adjust(dropDownMenu);
                }
            }
            native.invalidate();
        }
Пример #5
0
 /// <summary>
 /// 添加镜像
 /// </summary>
 /// <param name="native">库</param>
 /// <param name="target">目标</param>
 public void addMirror(FCNative native, FCView target)
 {
     if (m_native == null)
     {
         m_native              = new FCNative();
         m_native.MirrorMode   = FCMirrorMode.Shadow;
         m_native.Paint        = new GdiPlusPaintEx();
         m_native.Host         = new WinHostEx();
         m_native.Host.Native  = m_native;
         m_native.ResourcePath = WinHostEx.getAppPath() + "\\config";
         m_host      = m_native.Host as WinHostEx;
         m_host.HWnd = Handle;
         //设置尺寸
         m_native.AllowScaleSize = true;
         m_native.DisplaySize    = new FCSize(ClientSize.Width, ClientSize.Height);
         resetScaleSize(getClientSize());
     }
     m_native.addMirror(native, target);
     m_native.invalidate();
 }
Пример #6
0
        /// <summary>
        /// 秒表方法
        /// </summary>
        /// <param name="timerID">秒表ID</param>
        public override void onTimer(int timerID)
        {
            base.onTimer(timerID);
            if (m_timerID == timerID)
            {
                FCNative native = Native;
                FCHost   host = native.Host;
                FCSize   nativeSize = native.DisplaySize;
                int      x = Left, y = Top, width = Width, height = Height;
                if (m_animateType == 0)
                {
                    int   xSub    = nativeSize.cx / 4;
                    int   ySub    = nativeSize.cy / 4;
                    int   mx      = (nativeSize.cx - width) / 2;
                    int   my      = (nativeSize.cy - height) / 2;
                    float opacity = Opacity;
                    opacity += 0.1F;
                    if (opacity > 1)
                    {
                        opacity = 1;
                    }
                    Opacity = opacity;
                    bool stop = false;
                    switch (m_animateDirection)
                    {
                    //从左向右
                    case 0:
                        if (x + xSub >= mx)
                        {
                            x    = mx;
                            stop = true;
                        }
                        else
                        {
                            x += xSub;
                        }
                        break;

                    //从右向左
                    case 1:
                        if (x - xSub <= mx)
                        {
                            x    = mx;
                            stop = true;
                        }
                        else
                        {
                            x -= xSub;
                        }
                        break;

                    //从上往下
                    case 2:
                        if (y + ySub >= my)
                        {
                            y    = my;
                            stop = true;
                        }
                        else
                        {
                            y += ySub;
                        }
                        break;

                    //从下往上
                    case 3:
                        if (y - ySub <= my)
                        {
                            y    = my;
                            stop = true;
                        }
                        else
                        {
                            y -= ySub;
                        }
                        break;
                    }
                    if (stop)
                    {
                        Opacity         = 1;
                        m_animateMoving = false;
                        stopTimer(m_timerID);
                        host.AllowOperate = true;
                    }
                }
                else
                {
                    int   xSub    = nativeSize.cx / 4;
                    int   ySub    = nativeSize.cy / 4;
                    float opacity = Opacity;
                    opacity -= 0.1F;
                    if (opacity < 0)
                    {
                        opacity = 0;
                    }
                    Opacity = opacity;
                    bool stop = false;
                    switch (m_animateDirection)
                    {
                    //从右向左
                    case 0:
                        if (x - xSub <= -width)
                        {
                            x    = 0;
                            stop = true;
                        }
                        else
                        {
                            x -= xSub;
                        }
                        break;

                    //从左向右
                    case 1:
                        if (x + xSub >= nativeSize.cx)
                        {
                            x    = 0;
                            stop = true;
                        }
                        else
                        {
                            x += xSub;
                        }
                        break;

                    //从下往上
                    case 2:
                        if (y - ySub <= -height)
                        {
                            y    = 0;
                            stop = true;
                        }
                        else
                        {
                            y -= ySub;
                        }
                        break;

                    //从上往下
                    case 3:
                        if (y + ySub >= nativeSize.cy)
                        {
                            y    = 0;
                            stop = true;
                        }
                        else
                        {
                            y += ySub;
                        }
                        break;
                    }
                    if (stop)
                    {
                        Opacity         = 0;
                        m_animateMoving = false;
                        stopTimer(m_timerID);
                        host.AllowOperate = true;
                        hide();
                    }
                }
                FCPoint location = new FCPoint(x, y);
                Location = location;
                native.invalidate();
            }
        }
Пример #7
0
        /// <summary>
        /// 鼠标抬起方法
        /// </summary>
        /// <param name="touchInto">触摸信息</param>
        public override void onTouchUp(FCTouchInfo touchInto)
        {
            m_point2 = Native.TouchPoint;
            base.onTouchUp(touchInto);
            if (!IsDragging)
            {
                FCView divDesigner = Parent;
                if (m_resizePoint != -1)
                {
                    FCRect nowRect = convertBoundsToPRect(Bounds);
                    //移动控件
                    int targetsSize = m_targets.Count;
                    if (targetsSize > 0)
                    {
                        m_designerDiv.saveUndo();
                        for (int i = 0; i < targetsSize; i++)
                        {
                            FCView  target      = m_targets[i];
                            FCPoint oldLocation = target.Location;
                            FCSize  oldSize     = target.Size;
                            oldLocation.x += nowRect.left - m_startRect.left;
                            oldLocation.y += nowRect.top - m_startRect.top;
                            oldSize.cx    += (nowRect.right - nowRect.left) - (m_startRect.right - m_startRect.left);
                            oldSize.cy    += (m_startRect.top - m_startRect.bottom) - (nowRect.top - nowRect.bottom);
                            if (oldSize.cx < 4)
                            {
                                oldSize.cx = 4;
                            }
                            else if (oldSize.cy < 4)
                            {
                                oldSize.cy = 4;
                            }
                            m_xml.setProperty(target, "location", FCStr.convertPointToStr(oldLocation));
                            m_xml.setProperty(target, "size", FCStr.convertSizeToStr(oldSize));
                            target.update();
                        }
                    }
                    m_designerDiv.Designer.refreshProperties();
                }
                else
                {
                    if (m_targets.Count == 1)
                    {
                        if (Math.Abs(m_point1.x - m_point2.x) > 5 && Math.Abs(m_point1.y - m_point2.y) > 5)
                        {
                            //获取选中控件
                            FCView        target = m_targets[0];
                            FCRect        moveRect = getRectangle(pointToControl(m_point1), pointToControl(m_point2));
                            List <FCView> newTargets = new List <FCView>();
                            List <FCView> subControls = target.getControls();
                            int           left = 0, top = 0, right = 0, bottom = 0, idx = 0;
                            int           subControlsSize = subControls.Count;
                            for (int i = 0; i < subControlsSize; i++)
                            {
                                FCView subControl = subControls[i];
                                FCRect bounds     = subControl.Bounds;
                                FCRect tempRect   = new FCRect();
                                if (Native.Host.getIntersectRect(ref tempRect, ref moveRect, ref bounds) > 0)
                                {
                                    newTargets.Add(subControl);
                                    if (idx == 0)
                                    {
                                        left   = bounds.left;
                                        top    = bounds.top;
                                        right  = bounds.right;
                                        bottom = bounds.bottom;
                                    }
                                    else
                                    {
                                        if (left > bounds.left)
                                        {
                                            left = bounds.left;
                                        }
                                        if (top > bounds.top)
                                        {
                                            top = bounds.top;
                                        }
                                        if (right < bounds.right)
                                        {
                                            right = bounds.right;
                                        }
                                        if (bottom < bounds.bottom)
                                        {
                                            bottom = bounds.bottom;
                                        }
                                    }
                                    idx++;
                                }
                            }
                            if (newTargets.Count > 0)
                            {
                                FCPoint p1 = target.pointToNative(new FCPoint(left, top));
                                FCPoint p2 = target.pointToNative(new FCPoint(right, bottom));
                                p1     = divDesigner.pointToControl(p1);
                                p2     = divDesigner.pointToControl(p2);
                                Bounds = convertPRectToBounds(new FCRect(p1.x, p1.y, p2.x, p2.y));
                                clearTargets();
                                addTargets(newTargets);
                                m_designerDiv.Designer.refreshProperties(newTargets);
                            }
                        }
                    }
                }
            }
            refreshStatusBar();
            m_resizePoint = -1;
            Cursor        = FCCursors.Arrow;
            FCNative native = Native;

            native.Host.setCursor(FCCursors.Arrow);
            native.update();
            native.invalidate();
        }