コード例 #1
0
ファイル: SortList.cs プロジェクト: yuva2achieve/WebGrid
 private void ClearList()
 {
     for (int i = 0; i < m_Columns.Length; i++)
     {
         m_Columns[i] = new SortColumn();
     }
 }
コード例 #2
0
ファイル: SortList.cs プロジェクト: yuva2achieve/WebGrid
        internal new string ToString()
        {
            // First sort them
            for (int i = 0; i < m_Columns.Length; i++)
            {
                for (int ii = 0; ii < m_Columns.Length; ii++)
                {
                    if (m_Columns[i].m_DisplayIndex > m_Columns[ii].m_DisplayIndex)
                    {
                        continue;
                    }
                    SortColumn m = m_Columns[i];
                    m_Columns[i]  = m_Columns[ii];
                    m_Columns[ii] = m;
                }
            }

            // Then add them up
            string s = string.Empty;

            for (int i = 0; i < m_Columns.Length; i++)
            {
                if (m_Columns[i].m_DisplayIndex < 0)
                {
                    continue;
                }

                string colname = m_Columns[i].m_ColumnName.Trim();

                if (colname.IndexOf("+") < 1)
                {
                    colname = string.Format("[{0}]", colname.Replace(".", "].["));
                }
                s += colname;
                if (m_Columns[i].m_Desc)
                {
                    s += " DESC";
                }
                s += ", ";
            }
            if (s.Length != 0) // remove last comma
            {
                s = s.Substring(0, s.Length - 2);
            }
            return(s);
        }
コード例 #3
0
ファイル: SortList.cs プロジェクト: yuva2achieve/WebGrid
 internal SortColumn[] ColumnsSorted()
 {
     // First sort them
     for (int i = 0; i < m_Columns.Length; i++)
     {
         for (int ii = 0; ii < m_Columns.Length; ii++)
         {
             if (m_Columns[i].m_DisplayIndex > m_Columns[ii].m_DisplayIndex)
             {
                 continue;
             }
             SortColumn m = m_Columns[i];
             m_Columns[i]  = m_Columns[ii];
             m_Columns[ii] = m;
         }
     }
     return(m_Columns);
 }
コード例 #4
0
ファイル: SortList.cs プロジェクト: webgrid/WebGrid
 private void ClearList()
 {
     for (int i = 0; i < m_Columns.Length; i++)
         m_Columns[i] = new SortColumn();
 }
コード例 #5
0
ファイル: SortList.cs プロジェクト: webgrid/WebGrid
        internal void Add(string colName)
        {
            colName = colName.Trim();

            if (string.IsNullOrEmpty(colName))
                return;

            bool pluss = (colName.IndexOf("+") > 0);
            if (pluss == false)
                colName = colName.Replace("[",string.Empty).Replace("]",string.Empty);

            // first check if it exists
            if (this[colName] == null)
            {
                // first move all columns
                int theOneWithTheHighestPriority = 0;
                for (int i = 0; i < m_Columns.Length; i++)
                {
                    if (m_Columns[i].m_DisplayIndex < 0)
                    {
                        theOneWithTheHighestPriority = i;
                        continue;
                    }
                    m_Columns[i].m_DisplayIndex++;
                    if (m_Columns[theOneWithTheHighestPriority].m_DisplayIndex >= 0 &&
                        m_Columns[i].m_DisplayIndex >= m_Columns[theOneWithTheHighestPriority].m_DisplayIndex)
                        theOneWithTheHighestPriority = i;
                }
                // then insert the new one
                m_Columns[theOneWithTheHighestPriority] = new SortColumn(colName);
            }
            else // it exists
            {
                if (this[colName].m_DisplayIndex == 0) // if it's first just revert DESC
                    this[colName].m_Desc = ! this[colName].m_Desc;
                else // if not move it to the top and set desc = false
                {
                    for (int i = 0; i < m_Columns.Length; i++) // only add the ones that are over
                    {
                        if (m_Columns[i].m_DisplayIndex < 0) continue;
                        if (this[colName].m_DisplayIndex < m_Columns[i].m_DisplayIndex) continue;
                        m_Columns[i].m_DisplayIndex++;
                    }
                    this[colName].m_DisplayIndex = 0;
                    this[colName].m_Desc = false;
                }
            }
        }
コード例 #6
0
ファイル: SortList.cs プロジェクト: yuva2achieve/WebGrid
        internal void Add(string colName)
        {
            colName = colName.Trim();

            if (string.IsNullOrEmpty(colName))
            {
                return;
            }

            bool pluss = (colName.IndexOf("+") > 0);

            if (pluss == false)
            {
                colName = colName.Replace("[", string.Empty).Replace("]", string.Empty);
            }

            // first check if it exists
            if (this[colName] == null)
            {
                // first move all columns
                int theOneWithTheHighestPriority = 0;
                for (int i = 0; i < m_Columns.Length; i++)
                {
                    if (m_Columns[i].m_DisplayIndex < 0)
                    {
                        theOneWithTheHighestPriority = i;
                        continue;
                    }
                    m_Columns[i].m_DisplayIndex++;
                    if (m_Columns[theOneWithTheHighestPriority].m_DisplayIndex >= 0 &&
                        m_Columns[i].m_DisplayIndex >= m_Columns[theOneWithTheHighestPriority].m_DisplayIndex)
                    {
                        theOneWithTheHighestPriority = i;
                    }
                }
                // then insert the new one
                m_Columns[theOneWithTheHighestPriority] = new SortColumn(colName);
            }
            else // it exists
            {
                if (this[colName].m_DisplayIndex == 0) // if it's first just revert DESC
                {
                    this[colName].m_Desc = !this[colName].m_Desc;
                }
                else // if not move it to the top and set desc = false
                {
                    for (int i = 0; i < m_Columns.Length; i++) // only add the ones that are over
                    {
                        if (m_Columns[i].m_DisplayIndex < 0)
                        {
                            continue;
                        }
                        if (this[colName].m_DisplayIndex < m_Columns[i].m_DisplayIndex)
                        {
                            continue;
                        }
                        m_Columns[i].m_DisplayIndex++;
                    }
                    this[colName].m_DisplayIndex = 0;
                    this[colName].m_Desc         = false;
                }
            }
        }