Example #1
0
        /// <summary>
        /// 单元格点击事件
        /// </summary>
        /// <param name="cell">单元格</param>
        /// <param name="mp">坐标</param>
        /// <param name="button">按钮</param>
        /// <param name="clicks">点击次数</param>
        /// <param name="delta">滚轮值</param>
        public override void onCellClick(FCGridCell cell, FCTouchInfo touchInto)
        {
            base.onCellClick(cell, touchInto);
            List <FCGridRow> rows = m_rows;
            int rowsSize          = rows.Count;

            for (int i = 0; i < rowsSize; i++)
            {
                FCGridRow         row   = rows[i];
                List <FCGridCell> cells = row.getCells();
                int cellsSize           = cells.Count;
                for (int j = 0; j < cellsSize; j++)
                {
                    FCGridControlCell cCell = cells[j] as FCGridControlCell;
                    if (cCell != null)
                    {
                        if (row == cell.Row)
                        {
                            cCell.Control.TextColor = FCDraw.FCCOLORS_TEXTCOLOR4;
                        }
                        else
                        {
                            cCell.Control.TextColor = FCColor.Text;
                        }
                    }
                }
            }
            if (touchInto.m_firstTouch)
            {
                if (touchInto.m_clicks == 1)
                {
                    if (!cell.AllowEdit && cell is GridColorCell)
                    {
                        GridColorCell colorCell   = cell as GridColorCell;
                        ColorDialog   colorDialog = new ColorDialog();
                        colorDialog.AllowFullOpen  = true;
                        colorDialog.AnyColor       = true;
                        colorDialog.SolidColorOnly = false;
                        int a = 0, r = 0, g = 0, b = 0;
                        FCColor.toArgb(Native.Paint, FCStr.convertStrToColor(colorCell.getString()), ref a, ref r, ref g, ref b);
                        colorDialog.Color = Color.FromArgb(a, r, g, b);
                        if (colorDialog.ShowDialog() == DialogResult.OK)
                        {
                            Color newColor = colorDialog.Color;
                            a = newColor.A;
                            r = newColor.R;
                            g = newColor.G;
                            b = newColor.B;
                            colorCell.setString(FCStr.convertColorToStr(FCColor.argb(a, r, g, b)));
                            FCGridCell nameCell = cell.Row.getCell("PROPERTYNAME");
                            if (nameCell != null)
                            {
                                m_designerDiv.saveUndo();
                                String name        = nameCell.Name;
                                String value       = cell.Text;
                                int    targetsSize = m_targets.Count;
                                for (int i = 0; i < targetsSize; i++)
                                {
                                    FCView target = m_targets[i];
                                    m_xml.setProperty(target, name, value);
                                    if (m_collectionWindow != null)
                                    {
                                        m_collectionWindow.onPropertyChanged(name, value);
                                    }
                                    target.update();
                                }
                                //恢复正确的值
                                String rightValue = "", type = "";
                                for (int i = 0; i < targetsSize; i++)
                                {
                                    m_targets[i].getProperty(name.ToLower(), ref rightValue, ref type);
                                }
                                cell.Text = rightValue;
                                Native.update();
                                Native.invalidate();
                            }
                        }
                        colorDialog.Dispose();
                    }
                    //字体单元格
                    else if (!cell.AllowEdit && cell is GridFontCell)
                    {
                        GridFontCell fontCell   = cell as GridFontCell;
                        FontDialog   fontDialog = new FontDialog();
                        fontDialog.Font = getFont(FCStr.convertStrToFont(fontCell.getString()));
                        if (fontDialog.ShowDialog() == DialogResult.OK)
                        {
                            Font newFont = fontDialog.Font;
                            fontCell.setString(FCStr.convertFontToStr(new FCFont(newFont.Name, newFont.Size, newFont.Bold, newFont.Underline, newFont.Italic, newFont.Strikeout)));
                            FCGridCell nameCell = cell.Row.getCell("PROPERTYNAME");
                            if (nameCell != null)
                            {
                                m_designerDiv.saveUndo();
                                String name        = nameCell.Name;
                                String value       = cell.Text;
                                int    targetsSize = m_targets.Count;
                                for (int i = 0; i < targetsSize; i++)
                                {
                                    FCView target = m_targets[i];
                                    m_xml.setProperty(target, name, value);
                                    if (m_collectionWindow != null)
                                    {
                                        m_collectionWindow.onPropertyChanged(name, value);
                                    }
                                    target.update();
                                }
                                //恢复正确的值
                                String rightValue = "", type = "";
                                for (int i = 0; i < targetsSize; i++)
                                {
                                    m_targets[i].getProperty(name.ToLower(), ref rightValue, ref type);
                                }
                                cell.Text = rightValue;
                                Native.update();
                                Native.invalidate();
                            }
                        }
                    }
                    //单击编辑框
                    else if (cell is FCGridButtonCell)
                    {
                        FCButton cButton = (cell as FCGridButtonCell).Button;
                        if (cButton.Tag != null)
                        {
                            String collectionName = cButton.Tag.ToString();
                            int    targetsSize    = m_targets.Count;
                            if (targetsSize > 0)
                            {
                                FCView           target           = m_targets[0];
                                CollectionWindow collectionWindow = new CollectionWindow(m_native);
                                collectionWindow.CollectionName = collectionName;
                                collectionWindow.DesignerDiv    = m_designerDiv;
                                collectionWindow.Target         = target;
                                collectionWindow.Xml            = m_xml;
                                collectionWindow.IsWinForm      = false;
                                collectionWindow.showDialog();
                            }
                        }
                    }
                }
            }
        }
Example #2
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;
        }