Beispiel #1
0
        public object getData(VirtualGridHeaderColumn header)
        {
            if (header == null)
            {
                return(null);                //is this correct ??
            }

            if (dataCache.ContainsKey(header.ColumnName.ToLower()))
            {
                return(dataCache[header.ColumnName.ToLower()]);
            }

            VirtualGridCell cell = getCell(header);

            if (cell != null)
            {
                //DL rempixbuf
//				if (Grid.OnGetData != null)
//				{
//					object o;
//					Grid.OnGetData(header.ColumnName,cell.Data,out o);
//					if (o != null)
//					{
//						return o;
//					}
//				}

                return(cell.Data);
            }

            return(null);
        }
Beispiel #2
0
 private static void addHeaderColumns(ref List <VirtualGridHeaderColumn> lst, VirtualGridHeaderColumn parent)
 {
     if (parent.ChildColumn != null)
     {
         lst.Add(parent.ChildColumn);
         addHeaderColumns(ref lst, parent.ChildColumn);
     }
 }
Beispiel #3
0
 public VirtualGridCell(VirtualTreeList grid, VirtualGridRow row, VirtualGridHeaderColumn headercolumn, object data)
 {
     HeaderColumn = headercolumn;
     Row          = row;
     Grid         = grid;
     Data         = data;
     Changed      = false;
     CustomOption = String.Empty;
 }
Beispiel #4
0
 public VirtualGridCell(VirtualTreeList grid, VirtualGridRow row, VirtualGridHeaderColumn headercolumn, object data)
 {
     HeaderColumn = headercolumn;
     Row = row;
     Grid = grid;
     Data = data;
     Changed = false;
     CustomOption = String.Empty;
 }
Beispiel #5
0
        /// <summary>
        /// load data from inputdocumet
        /// </summary>
        /// <param name="inputdocument"></param>
        public virtual void loadData(XmlDocument inputdocument)
        {
            XmlNodeList rows = inputdocument.SelectNodes("//row");

            foreach (XmlNode nd in rows)
            {
                VirtualGridRow row = this.newRow(); //TODO rename to NewRow ?

                if ((nd.Attributes["customoption"] != null) && (!String.IsNullOrEmpty(nd.Attributes["customoption"].Value)))
                {
                    row.CustomOption = nd.Attributes["customoption"].Value;
                }

                XmlNodeList columns = nd.SelectNodes(".//column");
                foreach (XmlNode nd2 in columns)
                {
                    object data       = null;
                    String columnname = nd2.SelectSingleNode("name").InnerText;
                    String columndata = nd2.SelectSingleNode("data").InnerText;

                    if (columnname == null)
                    {
                        throw new Exception("columnname is null");
                    }

                    //Console.WriteLine("col" + columnname);
                    VirtualGridHeaderColumn header = getHeaderByName(columnname);
                    if ((OnGetData == null) && (header != null) && (!String.IsNullOrEmpty(header.ColumnType)))
                    {
                        Type tp = Type.GetType(header.ColumnType);
                        data = Convert.ChangeType(columndata, tp);
                    }
                    else
                    {
                        if (OnGetData != null)
                        {
                            OnGetData(columnname, columndata, out data);
                        }
                        else
                        {
                            data = columndata;
                        }
                    }
                    if (data == null)                     //TODO correct ??
                    {
                        throw new Exception("data is null");
                    }

                    VirtualGridCell cell = row.addGridColumn(columnname, data);
                    if (cell != null)
                    {
                        cell.CustomOption = XmlHelper.getAttributeValue(nd2, "customoption");
                    }
                }
            }
        }
Beispiel #6
0
        /*
         * public void addChild(VirtualTreeRow row)
         * {
         *      Children.Add(row);
         *      row.Parent = this;
         * }
         */

        /*
         * private bool containsItem(String nodevalue)
         * {
         *      foreach(VirtualTreeRow row in Children)
         *      {
         *              if (row.NodeValue == nodevalue)
         *              {
         *                      return true;
         *              }
         *      }
         *      return false;
         * }
         */

        private void addData(String nodename, String nodevalue, VirtualGridHeaderColumn headercolumn, VirtualGridRow baserow)
        {
            if ((!String.IsNullOrEmpty(nodevalue)) && (!children.ContainsKey(nodevalue)))
            {
                VirtualTreeRow tr = new VirtualTreeRow(Grid, headercolumn.ColumnName, nodevalue);
                tr.HeaderColumn = headercolumn;                 //TODO in constructor
                tr.Parent       = this;
                tr.BaseRow      = baserow;
                Children.Add(nodevalue, tr);
            }
        }
Beispiel #7
0
 public String[] getValues(VirtualGridHeaderColumn without)
 {
     String[] ret = new String[Cells.Count];
     for (int i = 0; i < Cells.Count; i++)
     {
         if (!Cells[i].HeaderColumn.isParentOf(without))
         {
             ret[i] = (String)Cells[i].Data;
         }
     }
     return(ret);
 }
Beispiel #8
0
 /// <summary>
 /// returns the index of the column with the given name ... -1 if not found
 /// </summary>
 /// <returns>
 /// The column index.
 /// </returns>
 /// <param name='columnname'>
 /// Columnname.
 /// </param>
 public int getColumnIndex(string columnname)
 {
     for (int i = 0; i < HeaderColumns.Count; i++)
     {
         VirtualGridHeaderColumn c = HeaderColumns[i];
         if (c.ColumnName.Equals(columnname, StringComparison.OrdinalIgnoreCase))
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #9
0
 public VirtualGridCell getCell(VirtualGridHeaderColumn header)
 {
     foreach (VirtualGridCell cell in Cells)
     {
         if (cell.HeaderColumn == header)
         {
             if (!dataCache.ContainsKey(header.ColumnName.ToLower()))
             {
                 dataCache.Add(header.ColumnName.ToLower(), cell.Data);
             }
             return(cell);
         }
     }
     return(null);
 }
Beispiel #10
0
        public object getData(String columnName)
        {
            if (dataCache.ContainsKey(columnName.ToLower()))
            {
                return(dataCache[columnName.ToLower()]);
            }


            VirtualGridHeaderColumn h = Grid.getHeaderByName(columnName);

            if (h != null)
            {
                return(getData(h));
            }
            return(null);
        }
Beispiel #11
0
        public virtual VirtualGridCell addGridColumn(String headername, object data)
        {
            VirtualGridHeaderColumn hc = Grid.getHeaderByName(headername);

            if (hc != null)
            {
                VirtualGridCell cell = new VirtualGridCell(Grid, this, hc, null);
                //dataCache.Add(headername.ToLower(),cell.Data);
                addCell(cell);

                setData(headername, data, false);               //??

                return(cell);
                //hc.addRow(this);
            }
            return(null);
        }
Beispiel #12
0
        /// <summary>
        /// load the structure from an xmlfile
        /// </summary>
        /// <param name="filename">
        /// A <see cref="String"/>
        /// </param>
        public void loadStructure(XmlDocument gridStructure)
        {
            //gridStructure = new XmlDocument();
            //gridStructure.Load(filename);

            XmlNodeList columns = gridStructure.SelectNodes("//column");

            foreach (XmlNode nd in columns)
            {
                String columnname         = nd.SelectSingleNode("name").InnerText;
                VirtualGridHeaderColumn c = new VirtualGridHeaderColumn(this, columnname);

                XmlAttribute at = nd.Attributes["visible"];
                if ((at != null) && (!String.IsNullOrEmpty(at.Value)))
                {
                    if (at.Value.Equals("false", StringComparison.OrdinalIgnoreCase))
                    {
                        c.Visible = false;
                    }
                }

                at = nd.Attributes["editable"];
                if ((at != null) && (!String.IsNullOrEmpty(at.Value)))
                {
                    if (at.Value.Equals("true", StringComparison.OrdinalIgnoreCase))
                    {
                        c.Editable = true;
                    }

                    c.EditableColumn = XmlHelper.getAttributeValue(nd, "editablecolumn");
                }
                c.Renderer = XmlHelper.getAttributeValue(nd, "renderer");

                at = nd.Attributes["customoption"];
                if ((at != null) && (!String.IsNullOrEmpty(at.Value)))
                {
                    c.CustomOption = at.Value;
                }

                c.ColumnType = XmlHelper.getAttributeValue(nd, "type");

                addHeaderColumn(c);
            }
        }
Beispiel #13
0
        /*
         * public void addRow(VirtualGridRow row)
         * {
         *      if (!Rows.Contains(row))
         *      {
         *              Rows.Add(row);
         *      }
         * }
         */

        public bool isParentOf(VirtualGridHeaderColumn col)
        {
            if (col == this)
            {
                return(true);
            }

            if (col.ParentColumn != null)
            {
                if (col.ParentColumn == this)
                {
                    return(true);
                }
                else
                {
                    return(isParentOf(col.ParentColumn));
                }
            }

            return(false);
        }
Beispiel #14
0
        private DatafieldContainer[] createDataFields(String xml, bool fromResource)
        {
            XmlDocument doc = getXmlDocument(xml,fromResource);
            XmlNodeList lst = doc.SelectNodes("//field");
            DatafieldContainer[] ret = new DatafieldContainer[lst.Count + 1];
            int idx=0;
            foreach (XmlNode nd in lst)
            {
                String typename = nd.Attributes["type"].Value;
                IDataField df = createDataField(typename);
                String title = nd.Attributes["title"].Value;
                ret[idx] = new DatafieldContainer(df,title,typename);

                VirtualGridHeaderColumn c = new VirtualGridHeaderColumn(this,title);
                addHeaderColumn(c);

                idx++;
            }
            //VirtualGridRow
            ret[idx] = new DatafieldContainer(createDataField("Sharpend.Utils.VirtualGridRow,Sharpend"),"row","Sharpend.Utils.VirtualGridRow,Sharpend");
            return ret;
        }
Beispiel #15
0
 /*
 public void addChild(VirtualTreeRow row)
 {
     Children.Add(row);
     row.Parent = this;
 }
 */
 /*
 private bool containsItem(String nodevalue)
 {
     foreach(VirtualTreeRow row in Children)
     {
         if (row.NodeValue == nodevalue)
         {
             return true;
         }
     }
     return false;
 }
 */
 private void addData(String nodename, String nodevalue, VirtualGridHeaderColumn headercolumn,VirtualGridRow baserow)
 {
     if ((!String.IsNullOrEmpty(nodevalue)) &&  (!children.ContainsKey(nodevalue)))
     {
         VirtualTreeRow tr = new VirtualTreeRow(Grid, headercolumn.ColumnName, nodevalue);
         tr.HeaderColumn = headercolumn; //TODO in constructor
         tr.Parent = this;
         tr.BaseRow = baserow;
         Children.Add(nodevalue,tr);
     }
 }
Beispiel #16
0
 /// <summary>
 /// add a new headercolumn into the headercolumns list
 /// </summary>
 /// <param name="headercolumn">
 /// A <see cref="VirtualGridHeaderColumn"/>
 /// </param>
 protected virtual void addHeaderColumn(VirtualGridHeaderColumn headercolumn)
 {
     HeaderColumns.Add(headercolumn);
 }
Beispiel #17
0
 /// <summary>
 /// add a new headercolumn into the headercolumns list
 /// </summary>
 /// <param name="headercolumn">
 /// A <see cref="VirtualGridHeaderColumn"/>
 /// </param>
 protected virtual void addHeaderColumn(VirtualGridHeaderColumn headercolumn)
 {
     HeaderColumns.Add(headercolumn);
 }
Beispiel #18
0
 public String[] getValues(VirtualGridHeaderColumn without)
 {
     String[] ret = new String[Cells.Count];
     for (int i=0;i<Cells.Count;i++)
     {
         if (! Cells[i].HeaderColumn.isParentOf(without))
         {
             ret[i] = (String)Cells[i].Data;
         }
     }
     return ret;
 }
 private static void addHeaderColumns(ref List<VirtualGridHeaderColumn> lst, VirtualGridHeaderColumn parent)
 {
     if (parent.ChildColumn != null)
     {
         lst.Add(parent.ChildColumn);
         addHeaderColumns(ref lst, parent.ChildColumn);
     }
 }
Beispiel #20
0
 protected override void addHeaderColumn(VirtualGridHeaderColumn column)
 {
     base.addHeaderColumn(column);
 }
Beispiel #21
0
        /// <summary>
        /// load the structure from an xmlfile
        /// </summary>
        /// <param name="filename">
        /// A <see cref="String"/>
        /// </param>
        public void loadStructure(XmlDocument gridStructure)
        {
            //gridStructure = new XmlDocument();
            //gridStructure.Load(filename);

            XmlNodeList columns = gridStructure.SelectNodes("//column");
            foreach(XmlNode nd in columns)
            {
                String columnname = nd.SelectSingleNode("name").InnerText;
                VirtualGridHeaderColumn c = new VirtualGridHeaderColumn(this,columnname);

                XmlAttribute at = nd.Attributes["visible"];
                if ((at != null) && (!String.IsNullOrEmpty(at.Value)))
                {
                    if (at.Value.Equals("false", StringComparison.OrdinalIgnoreCase))
                    {
                        c.Visible = false;
                    }
                }

                at = nd.Attributes["editable"];
                if ((at != null) && (!String.IsNullOrEmpty(at.Value)))
                {
                    if (at.Value.Equals("true", StringComparison.OrdinalIgnoreCase))
                    {
                        c.Editable = true;
                    }

                    c.EditableColumn = XmlHelper.getAttributeValue(nd,"editablecolumn");

                }
                c.Renderer = XmlHelper.getAttributeValue(nd,"renderer");

                at = nd.Attributes["customoption"];
                if ((at != null) && (!String.IsNullOrEmpty(at.Value)))
                {
                    c.CustomOption = at.Value;
                }

                c.ColumnType = XmlHelper.getAttributeValue(nd,"type");

                addHeaderColumn(c);
            }
        }
Beispiel #22
0
 protected override void addHeaderColumn(VirtualGridHeaderColumn column)
 {
     base.addHeaderColumn(column);
 }
Beispiel #23
0
 public VirtualGridCell getCell(VirtualGridHeaderColumn header)
 {
     foreach (VirtualGridCell cell in Cells)
     {
         if (cell.HeaderColumn == header)
         {
             if (!dataCache.ContainsKey(header.ColumnName.ToLower()))
             {
               dataCache.Add(header.ColumnName.ToLower(),cell.Data);
             }
             return cell;
         }
     }
     return null;
 }
Beispiel #24
0
        public object getData(VirtualGridHeaderColumn header)
        {
            if (header == null)
            {
                return null; //is this correct ??
            }

            if (dataCache.ContainsKey(header.ColumnName.ToLower()))
            {
                return dataCache[header.ColumnName.ToLower()];
            }

            VirtualGridCell cell = getCell(header);
            if (cell != null)
            {
                //DL rempixbuf
            //				if (Grid.OnGetData != null)
            //				{
            //					object o;
            //					Grid.OnGetData(header.ColumnName,cell.Data,out o);
            //					if (o != null)
            //					{
            //						return o;
            //					}
            //				}

                return cell.Data;
            }

            return null;
        }
Beispiel #25
0
        protected override void addHeaderColumn(VirtualGridHeaderColumn headercolumn)
        {
            //throw new Exception("is it used ??");
            base.addHeaderColumn(headercolumn);

            Gtk.TreeViewColumn column = new Gtk.TreeViewColumn();
            column.Visible = headercolumn.Visible;
            column.Title = headercolumn.ColumnName;
            column.Resizable = true;
            //Gtk.CellRendererText artistNameCell = new Gtk.CellRendererText();
            Gtk.CellRenderer renderer;
            //Gtk.CellRendererCombo artistNameCell = new Gtk.CellRendererCombo();

            if (!String.IsNullOrEmpty(headercolumn.Renderer))
            {
                Type tp = Type.GetType(headercolumn.Renderer);
                renderer = (Gtk.CellRenderer)Sharpend.Utils.Reflection.createInstance(tp);
            }
            else
            {
                renderer = new Gtk.CellRendererText();
                //renderer = treecellrenderer;
            }

            column.PackStart(renderer, true);
            Tree.AppendColumn(column);

            String attribute = "text";

            if (headercolumn.ColumnType.Equals("Gdk.Pixbuf,gdk-sharp", StringComparison.OrdinalIgnoreCase))
            {
                attribute = "pixbuf";
            }

            if (OnTreeCellData != null)
            {
                column.SetCellDataFunc(renderer, OnTreeCellData);
            }

            column.AddAttribute(renderer, attribute, HeaderColumns.Count - 1);
        }
        /*
        public void addRow(VirtualGridRow row)
        {
            if (!Rows.Contains(row))
            {
                Rows.Add(row);
            }
        }
        */
        public bool isParentOf(VirtualGridHeaderColumn col)
        {
            if (col == this)
            {
                return true;
            }

            if (col.ParentColumn != null)
            {
                if (col.ParentColumn == this)
                {
                    return true;
                }
                else
                {
                    return isParentOf(col.ParentColumn);
                }
            }

            return false;
        }