Ejemplo n.º 1
0
        void AddButtonInToolBar(XmlDocument xmldoc)
        {
            XmlNodeList btnNodes = xmldoc.SelectNodes("/root/Action/Buttons/Button");

            if (btnNodes == null)
            {
                return;
            }
            foreach (XmlNode node in btnNodes)
            {
                CMenuItem mnu     = new CMenuItem(frm.strUid);
                XmlNode   evtnode = node.SelectSingleNode("evt");
                if (evtnode == null)
                {
                    mnu.MnuName   = XmlUtil.GetSubNodeText(node, ".");
                    mnu.LinkValue = XmlUtil.GetSubNodeText(node, "@onclick");
                    mnu.MnuId     = XmlUtil.GetSubNodeText(node, "@id");
                }
                else
                {
                    mnu = MenuProcess.GetMenu(null, evtnode, frm.strUid);
                }

                toolbarbld.AddToolBarItem(mnu, ToolBarItemType.Button, frm.ToolBarBtn_Click);
                toolbarbld.AddToolBarItem(null, ToolBarItemType.Separator);

                /* //用AddToolBarItem替代,期待实现
                 * ToolStripItem tsi;
                 * tsi = new ToolStripButton(mnu.MnuName);
                 * tsi.Tag = mnu;
                 * tsi.Click += new EventHandler(ToolBarBtn_Click);
                 * if (this.toolStrip1.Items.Count > 0)
                 *  this.toolStrip1.Items.Add(new ToolStripSeparator());
                 * this.toolStrip1.Items.Add(tsi);*/
            }
        }
Ejemplo n.º 2
0
        public virtual void FillGrid(XmlNode cmbNode)
        {
            //grid列处理
            if (XmlUtil.GetSubNodeText(cmbNode, "@sum") != null)
            {
                listViewObj.AllowSum = XmlUtil.GetSubNodeText(cmbNode, "@sum") == "1";
            }
            if (XmlUtil.GetSubNodeText(cmbNode, "@allowgroup") != null)
            {
                listViewObj.AllowGroup = XmlUtil.GetSubNodeText(cmbNode, "@allowgroup") == "1";
            }
            listViewObj.GroupBy  = XmlUtil.GetSubNodeText(cmbNode, "@groupby");
            listViewObj.SumItems = XmlUtil.GetSubNodeText(cmbNode, "@sumitems");
            XmlNodeList nodes = cmbNode.SelectNodes("cols/f");

            if (nodes.Count > 0)
            {
                //listobj.Columns = new ListGrid.ListGridColumnHeaderCollection(this.listViewObj);
                ClearItems();

                foreach (XmlNode node in nodes)
                {
                    ViewItem vi = new ViewItem();
                    vi.LoadXml(node);

                    IDataFieldHeaderColumn ch = GetHeaderColumn();
                    ch.Text  = vi.Text;
                    ch.Width = vi.Width;
                    if (!vi.Perm)
                    {
                        ch.Width = 0;
                    }

                    DataGridColumn dgc = new DataGridColumn(this);
                    dgc.LoadXml(node);

                    dgc.Text      = ch.Text;
                    dgc.Width     = ch.Width;
                    dgc.DataField = vi.Name;


                    ch.DataType  = dgc.DataType;
                    ch.NeedSum   = dgc.Sum;
                    ch.DataField = dgc.dpt.Name;
                    AddColumnItem(ch);
                    this.Columns.Add(dgc);

                    if (ViewList.ContainsKey(vi.Name))
                    {
                        continue;
                    }
                    ViewList.Add(vi.Name, vi);
                    if (!listViewObj.DataGridColumns.ContainsKey(dgc.dpt.Name))
                    {
                        listViewObj.DataGridColumns.Add(dgc.dpt.Name, dgc);
                    }
                }

                //AcceptRejectRule
            }
            //事件初始化
            XmlNodeList evtnodes = cmbNode.SelectNodes("action/evt");

            if (evtnodes.Count > 0)
            {
                foreach (XmlNode node in evtnodes)
                {
                    CMenuItem mnu        = MenuProcess.GetMenu(null, node, frmhandle.strUid);
                    string    strEvtName = XmlUtil.GetSubNodeText(node, "@id");
                    //'mnu = CMenuItem.
                    switch (strEvtName)
                    {
                    case "dbclick":
                    {
                        this.ItemDbClickedMenu = mnu;
                        //this.listView1.DoubleClick += new EventHandler(listView1_DoubleClick);
                        break;
                    }
                    }
                }
            }
            listViewObj.Tag = this;
        }