Example #1
0
        /// <summary>
        /// 更新编辑器
        /// </summary>
        /// <param name="parent">控件</param>
        private void updateScintilla()
        {
            FCNative native = m_parentDiv.Native;

            if (native != null)
            {
                if (m_parentDiv.isPaintVisible(m_parentDiv))
                {
                    ShowWindow(Handle, SW_SHOWNOACTIVATE);
                    float     scaleFactorX = 1, scaleFactorY = 1;
                    FCSize    scaleSize = native.ScaleSize;
                    WinHostEx winHost   = native.Host as WinHostEx;
                    Control   control   = Control.FromHandle(winHost.HWnd);
                    FCSize    size      = new FCSize(control.ClientSize.Width, control.ClientSize.Height);
                    if (size.cx > 0 & size.cy > 0)
                    {
                        scaleFactorX = (float)scaleSize.cx / size.cx;
                        scaleFactorY = (float)scaleSize.cy / size.cy;
                    }
                    int x  = (int)(native.clientX(m_parentDiv) / scaleFactorX);
                    int y  = (int)(native.clientY(m_parentDiv) / scaleFactorY);
                    int cx = (int)(m_parentDiv.Width / scaleFactorX);
                    int cy = (int)(m_parentDiv.Height / scaleFactorY);
                    MoveWindow(Handle, x, y, cx, cy, true);
                }
                else
                {
                    ShowWindow(Handle, SW_HIDE);
                }
            }
        }
Example #2
0
 /// <summary>
 /// 创建窗体
 /// </summary>
 public MainForm()
 {
     InitializeComponent();
     //创建XML解析器
     m_designer = new Designer();
     //链接控件库
     m_designer.createNative();
     m_designer.Script     = new DesignerScript(m_designer);
     m_native              = m_designer.Native;
     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);
     m_designer.resetScaleSize(getClientSize());
     m_native.invalidate();
     //加载Xml
     m_host.LoadingDesigner = true;
     m_designer.load(Path.Combine(DataCenter.GetAppPath(), "config\\MainFrame.html"));
     m_host.LoadingDesigner = false;
 }
Example #3
0
        /// <summary>
        /// Windows下的鼠标事件
        /// </summary>
        /// <param name="var">变量</param>
        /// <returns>状态</returns>
        private double WIN_MOUSEEVENT(CVariable var)
        {
            int    dx = 0, dy = 0, data = 0;
            int    vlen    = var.m_parameters.Length;
            String eventID = "";

            if (vlen >= 1)
            {
                eventID = m_indicator.getText(var.m_parameters[0]);
            }
            if (vlen >= 2)
            {
                dx = (int)m_indicator.getValue(var.m_parameters[1]);
            }
            if (vlen >= 3)
            {
                dy = (int)m_indicator.getValue(var.m_parameters[2]);
            }
            if (vlen >= 4)
            {
                data = (int)m_indicator.getValue(var.m_parameters[3]);
            }
            WinHostEx.mouseEvent(eventID, dx, dy, data);
            return(1);
        }
Example #4
0
        /// <summary>
        /// Windows下获取控件数值
        /// </summary>
        /// <param name="var">变量</param>
        /// <returns>数值</returns>
        private double WIN_GETVALUE(CVariable var)
        {
            double value = 0;
            String text  = WinHostEx.getText();

            value = FCStr.convertStrToDouble(text);
            return(value);
        }
Example #5
0
        /// <summary>
        /// 读取头部
        /// </summary>
        /// <param name="node">XML节点</param>
        /// <param name="control">控件</param>
        public override void readHead(XmlNode node, FCView control)
        {
            WinHostEx host = Native.Host as WinHostEx;

            if (host.LoadingDesigner)
            {
                base.readHead(node, control);
            }
        }
Example #6
0
        /// <summary>
        /// Windows下的键盘事件
        /// </summary>
        /// <param name="var">变量</param>
        /// <returns>状态</returns>
        private double WIN_SENDKEY(CVariable var)
        {
            int    vlen = var.m_parameters.Length;
            String key  = "";

            if (vlen >= 1)
            {
                key = m_indicator.getText(var.m_parameters[0]);
            }
            WinHostEx.sendKey(key);
            return(1);
        }
Example #7
0
        /// <summary>
        /// Windows下的鼠标点击事件
        /// </summary>
        /// <param name="var">变量</param>
        /// <returns>状态</returns>

        private double WIN_MOUSECLICK(CVariable var)
        {
            int dx = 0, dy = 0;
            int vlen = var.m_parameters.Length;

            if (vlen >= 1)
            {
                dx = (int)m_indicator.getValue(var.m_parameters[0]);
            }
            if (vlen >= 2)
            {
                dy = (int)m_indicator.getValue(var.m_parameters[1]);
            }
            WinHostEx.mouseEvent("SETCURSOR", dx, dy, 0);
            WinHostEx.mouseEvent("LEFTDOWN", 0, 0, 0);
            WinHostEx.mouseEvent("LEFTUP", 0, 0, 0);
            return(1);
        }
Example #8
0
 /// <summary>
 ///  创建图形控件
 /// </summary>
 public MainForm()
 {
     InitializeComponent();
     m_juhe = new Juhe();
     m_juhe.createNative();
     m_juhe.Script           = new FaceCatScript(m_juhe);
     m_native                = m_juhe.Native;
     m_native.Paint          = new GdiPlusPaintEx();
     m_host                  = new WinHostEx();
     m_host.Native           = m_native;
     m_native.Host           = m_host;
     m_host.HWnd             = Handle;
     m_native.AllowScaleSize = true;
     m_native.DisplaySize    = new FCSize(ClientSize.Width, ClientSize.Height);
     m_juhe.resetScaleSize(getClientSize());
     Invalidate();
     m_juhe.load(DataCenter.getAppPath() + "\\config\\MainFrame.html");
     m_native.update();
 }
Example #9
0
 /// <summary>
 /// 添加控件方法
 /// </summary>
 public override void onLoad()
 {
     base.onLoad();
     if (m_designerTabPage == null)
     {
         m_designerTabPage = new FCTabPage();
         addControl(m_designerTabPage);
         m_designerTabPage.BorderColor         = FCColor.None;
         m_designerTabPage.HeaderButton.Size   = new FCSize(60, 20);
         m_designerTabPage.HeaderButton.Margin = new FCPadding(1, -1, 0, 2);
         m_designerTabPage.ShowHScrollBar      = true;
         m_designerTabPage.ShowVScrollBar      = true;
         m_designerTabPage.Text      = "设计";
         m_designerTabPage.BackColor = FCColor.argb(75, 51, 153, 255);
         m_resizeDiv        = new ResizeDiv();
         m_resizeDiv.Native = Native;
         m_designerTabPage.addControl(m_resizeDiv);
     }
     if (m_sourceCodeTabPage == null)
     {
         m_sourceCodeTabPage             = new FCTabPage();
         m_sourceCodeTabPage.BorderColor = FCColor.None;
         //创建编辑器
         m_scintilla         = new ScintillaX();
         m_scintilla.Visible = false;
         FCNative  native    = Native;
         WinHostEx host      = native.Host as WinHostEx;
         Control   container = Control.FromHandle(host.HWnd);
         container.Controls.Add(m_scintilla);
         m_scintilla.ParentDiv    = m_sourceCodeTabPage;
         m_scintilla.TextChanged += new EventHandler <EventArgs>(scintilla_TextChanged);
         addControl(m_sourceCodeTabPage);
         m_sourceCodeTabPage.Text = "源";
         m_sourceCodeTabPage.HeaderButton.Size   = new FCSize(60, 20);
         m_sourceCodeTabPage.HeaderButton.Margin = new FCPadding(1, -1, 0, 2);
     }
     if (Parent != null)
     {
         Parent.addEvent(m_parentVisibleChangedEvent, FCEventID.VISIBLECHANGED);
     }
     SelectedIndex = 0;
 }
Example #10
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();
 }
Example #11
0
 /// <summary>
 /// 销毁控件方法
 /// </summary>
 public override void delete()
 {
     if (m_scintilla != null)
     {
         FCNative  native    = Native;
         WinHostEx host      = native.Host as WinHostEx;
         Control   container = Control.FromHandle(host.HWnd);
         if (container != null)
         {
             container.Controls.Remove(m_scintilla);
             m_scintilla.Dispose();
             m_scintilla = null;
         }
     }
     if (m_xml != null)
     {
         m_xml.delete();
         m_xml = null;
     }
     base.delete();
 }
Example #12
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();
 }
Example #13
0
        /// <summary>
        /// 创建属性
        /// </summary>
        public void createProperties()
        {
            WinHostEx host = Native.Host as WinHostEx;

            host.LoadingDesigner = true;
            int rowSize = m_rows.Count;

            if (rowSize > 0)
            {
                //清除所有行
                for (int i = 0; i < rowSize; i++)
                {
                    m_rows[i].clearCells();
                    m_rows[i].delete();
                }
                m_rows.Clear();
            }
            int targetsSize = m_targets.Count;

            if (targetsSize > 0)
            {
                FCView target = m_targets[0];
                //获取属性名称
                List <String> propertiesName = UIXmlEx.getUnionProperties(m_targets);
                Dictionary <String, String> addProperties = new Dictionary <String, String>();
                if (targetsSize == 1)
                {
                    if (target is FCTabControl)
                    {
                        addProperties["TabPages"] = "collection";
                    }
                    else if (target is FCGrid)
                    {
                        addProperties["Columns"] = "collection";
                    }
                    foreach (String addName in addProperties.Keys)
                    {
                        propertiesName.Add(addName);
                    }
                }
                propertiesName.Sort();
                int psize = propertiesName.Count;
                for (int i = 0; i < psize; i++)
                {
                    String name  = propertiesName[i];
                    String value = "";
                    String type  = "";
                    if (addProperties.ContainsKey(name))
                    {
                        value = "单击以编辑...";
                        type  = addProperties[name];
                    }
                    else
                    {
                        target.getProperty(name.ToLower(), ref value, ref type);
                    }
                    String text = name;
                    if (m_chNames.ContainsKey(name.ToLower()))
                    {
                        text = m_chNames[name.ToLower()];
                    }
                    if (value == null)
                    {
                        value = "";
                    }
                    FCGridRow row = new FCGridRow();
                    addRow(row);
                    //序号
                    GridNoCell orderCell = new GridNoCell();
                    row.addCell("NO", orderCell);
                    //属性名称
                    FCGridStringCell nameCell = new FCGridStringCell(text);
                    nameCell.Name = name;
                    row.addCell("PROPERTYNAME", nameCell);
                    //英文名称
                    FCGridStringCell enNameCell = new FCGridStringCell(name);
                    row.addCell("ENNAME", enNameCell);
                    //属性值
                    //布尔
                    if (type == "bool")
                    {
                        FCGridCheckBoxCell checkBoxCell = new FCGridCheckBoxCell();
                        checkBoxCell.Control = new CheckBoxM();
                        row.addCell("PROPERTYVALUE", checkBoxCell);
                        checkBoxCell.setBool(value.ToLower() == "true" ? true : false);
                        checkBoxCell.CheckBox.Tag         = name;
                        checkBoxCell.CheckBox.ButtonAlign = FCHorizontalAlign.Left;
                        checkBoxCell.CheckBox.addEvent(new FCEvent(checkBoxCheckedChanged), FCEventID.CHECKEDCHANGED);
                    }
                    //枚举
                    else if (type.StartsWith("enum:"))
                    {
                        String             strEnum      = "FaceCat." + type.Replace("enum:", "");
                        String[]           names        = Enum.GetNames(m_assembly.GetType(strEnum));
                        FCGridComboBoxCell comboBoxCell = new FCGridComboBoxCell();
                        row.addCell("PROPERTYVALUE", comboBoxCell);
                        comboBoxCell.ComboBox.BackColor = FCColor.None;
                        int nameSize = names.Length;
                        for (int j = 0; j < nameSize; j++)
                        {
                            comboBoxCell.ComboBox.DropDownMenu.addItem(new FCMenuItem(names[j]));
                        }
                        comboBoxCell.ComboBox.SelectedText = value;
                        comboBoxCell.ComboBox.ReadOnly     = true;
                        comboBoxCell.ComboBox.Tag          = name;
                        comboBoxCell.ComboBox.addEvent(new FCEvent(comboBoxSelectedIndexChanged), FCEventID.SELECTEDINDEXCHANGED);
                    }
                    //集合
                    else if (type == "collection")
                    {
                        FCGridButtonCell buttonCell = new FCGridButtonCell();
                        row.addCell("PROPERTYVALUE", buttonCell);
                        buttonCell.setString(value);
                        buttonCell.Button.Tag       = name;
                        buttonCell.Button.BackColor = FCColor.None;
                        buttonCell.Button.TextAlign = FCContentAlignment.MiddleLeft;
                        buttonCell.Button.Font      = new FCFont("微软雅黑", 12, false, false, false);
                    }
                    //颜色
                    else if (type == "color")
                    {
                        GridColorCell colorCell = new GridColorCell();
                        colorCell.AllowEdit = true;
                        row.addCell("PROPERTYVALUE", colorCell);
                        colorCell.setString(value);
                        colorCell.Button.Font = new FCFont("微软雅黑", 12, true, false, false);
                    }
                    //字体
                    else if (type == "font")
                    {
                        GridFontCell fontCell = new GridFontCell();
                        fontCell.AllowEdit = true;
                        row.addCell("PROPERTYVALUE", fontCell);
                        fontCell.setString(value);
                        fontCell.Button.Font = new FCFont("微软雅黑", 12, true, false, false);
                    }
                    //输入框
                    else
                    {
                        FCGridStringCell textCell = new FCGridStringCell();
                        textCell.AllowEdit = true;
                        row.addCell("PROPERTYVALUE", textCell);
                        textCell.Text = value;
                    }
                }
                propertiesName.Clear();
                update();
                invalidate();
            }
            host.LoadingDesigner = false;
        }
Example #14
0
        /// <summary>
        /// 创建控件
        /// </summary>
        /// <param name="node">节点</param>
        /// <param name="type">类型</param>
        /// <returns>控件</returns>
        public override FCView createControl(XmlNode node, String type)
        {
            WinHostEx host = Native.Host as WinHostEx;

            if (host.LoadingDesigner)
            {
                //事件编辑
                if (type == "eventgrid")
                {
                    EventGrid eventGrid = new EventGrid();
                    eventGrid.Xml = this;
                    return(eventGrid);
                }
                //属性编辑
                else if (type == "propertygrid")
                {
                    PropertyGrid propertyGrid = new PropertyGrid();
                    propertyGrid.Xml = this;
                    return(propertyGrid);
                }
                //拖动层
                else if (type == "resizediv")
                {
                    ResizeDiv resizeDiv = new ResizeDiv();
                    resizeDiv.Xml = this;
                    return(resizeDiv);
                }
                //工具箱
                else if (type == "toolboxlist")
                {
                    ToolBoxList toolBoxList = new ToolBoxList();
                    toolBoxList.Xml = this;
                    return(toolBoxList);
                }
                //图片按钮
                else if (type == "imagebutton")
                {
                    return(new ImageButton());
                }
                //透明按钮
                else if (type == "ribbonbutton")
                {
                    return(new RibbonButton());
                }
                //透明按钮2
                else if (type == "ribbonbutton2")
                {
                    return(new RibbonButton2());
                }
                //窗体
                else if (type == "window")
                {
                    return(new WindowEx());
                }
            }
            else
            {
                //透明按钮
                if (type == "ribbonbutton")
                {
                    return(new RibbonButton());
                }
                //透明按钮2
                else if (type == "ribbonbutton2")
                {
                    return(new RibbonButton2());
                }
            }
            return(base.createControl(node, type));
        }
Example #15
0
 /// <summary>
 /// Windows下设置文字
 /// </summary>
 /// <param name="var">变量</param>
 /// <returns>状态</returns>
 private double WIN_SETTEXT(CVariable var)
 {
     WinHostEx.setText(m_indicator.getText(var.m_parameters[0]));
     return(1);
 }
Example #16
0
 /// <summary>
 /// Windows下执行程序
 /// </summary>
 /// <param name="var">变量</param>
 /// <returns>状态</returns>
 private double WIN_EXECUTE(CVariable var)
 {
     WinHostEx.execute(m_indicator.getText(var.m_parameters[0]));
     return(1);
 }
Example #17
0
        /// <summary>
        /// 创建属性
        /// </summary>
        public void createProperties()
        {
            WinHostEx host = Native.Host as WinHostEx;

            host.LoadingDesigner = true;
            int rowSize = m_rows.Count;

            if (rowSize > 0)
            {
                //清除所有行
                for (int i = 0; i < rowSize; i++)
                {
                    m_rows[i].clearCells();
                    m_rows[i].delete();
                }
                m_rows.Clear();
            }
            int targetsSize = m_targets.Count;

            if (targetsSize > 0)
            {
                FCView target = m_targets[0];
                //获取属性名称
                List <String> eventNames = target.getEventNames();
                Dictionary <String, String> attributes = m_xml.getAttributes(m_xml.Nodes[target]);
                eventNames.Sort();
                int psize = eventNames.Count;
                for (int i = 0; i < psize; i++)
                {
                    String name      = eventNames[i];
                    String eventName = "on" + name.ToLower();
                    String value     = "";
                    if (attributes.ContainsKey(eventName))
                    {
                        value = attributes[eventName];
                    }
                    String text = name;
                    if (m_chNames.ContainsKey(name.ToLower()))
                    {
                        text = m_chNames[name.ToLower()];
                    }
                    if (value == null)
                    {
                        value = "";
                    }
                    FCGridRow row = new FCGridRow();
                    addRow(row);
                    //序号
                    GridNoCell orderCell = new GridNoCell();
                    row.addCell("NO", orderCell);
                    //属性名称
                    FCGridStringCell nameCell = new FCGridStringCell(text);
                    nameCell.Name = name;
                    row.addCell("PROPERTYNAME", nameCell);
                    FCGridStringCell enNameCell = new FCGridStringCell(name);
                    row.addCell("ENNAME", enNameCell);
                    FCGridStringCell textCell = new FCGridStringCell();
                    textCell.AllowEdit = true;
                    row.addCell("PROPERTYVALUE", textCell);
                    textCell.Text = value;
                }
                eventNames.Clear();
                update();
                invalidate();
            }
            host.LoadingDesigner = false;
        }