static SystemInfo[] getSortedSystemInfos(SystemInfo[] systemInfos, SortMethod sortMethod)
        {
            if (sortMethod == SortMethod.Name) {
                return systemInfos
                    .OrderBy(systemInfo => systemInfo.systemName)
                    .ToArray();
            }
            if (sortMethod == SortMethod.NameDescending) {
                return systemInfos
                    .OrderByDescending(systemInfo => systemInfo.systemName)
                    .ToArray();
            }

            if (sortMethod == SortMethod.ExecutionTime) {
                return systemInfos
                    .OrderBy(systemInfo => systemInfo.averageExecutionDuration)
                    .ToArray();
            }
            if (sortMethod == SortMethod.ExecutionTimeDescending) {
                return systemInfos
                    .OrderByDescending(systemInfo => systemInfo.averageExecutionDuration)
                    .ToArray();
            }

            return systemInfos;
        }
 static double GetSortingTime(SortMethod method, int[] list)
 {
     int startTime, stopTime;
     startTime = Environment.TickCount;
     method(list);
     stopTime = Environment.TickCount;
     return (stopTime - startTime) / 1000.0;
 }
 static void ShowSortingTimes(String methodName, SortMethod method, int[] list)
 {
     double sortTime;
     Console.WriteLine("{0} of {1} items:", methodName, list.Length);
     FillRandom(list, 10000);
     sortTime = GetSortingTime(method, list);
     Console.WriteLine("\t{0} seconds for a scrambled list", sortTime);
     sortTime = GetSortingTime(method, list);
     Console.WriteLine("\t{0} seconds for a sorted list\n", sortTime);
 }
예제 #4
0
        public bool SearchCollection(string query, SortedList list,
            SongListBox resultBox, bool text, bool matchCase, bool whole, bool trans, SortMethod sortMethod)
        {
            DirectoryInfo indexDir = new DirectoryInfo(this.indexDir);
            IndexSearcher searcher = new IndexSearcher(indexDir.FullName);
            QueryParser parser = new QueryParser(text ? "text" : "title", this.indexAnalyzer);

            LyraQuery lQuery = SearchUtil.CreateLyraQuery(query, whole);
            List<ISong> numberSongs = new List<ISong>();
            // search for nr
            if (lQuery.Numbers != null)
            {
                foreach (int nr in lQuery.Numbers)
                {
                    Song song = this.nrIndex[nr] as Song;
                    if (song != null)
                    {
                        numberSongs.Add(song);
                    }
                }
            }

            List<ISong> songs = new List<ISong>();

            if (!string.IsNullOrEmpty(lQuery.LuceneQuery))
            {
                Query luceneQuery = parser.Parse(lQuery.LuceneQuery);
                Hits hits = searcher.Search(luceneQuery);
                resultBox.Ratings.Clear();

                for (int i = 0; i < hits.Length(); i++)
                {
                    Document doc = hits.Doc(i);
                    int nr = Int32.Parse(doc.GetField("nr").StringValue());
                    Song song = (Song)this.nrIndex[nr];
                    if (song != null)
                    {
                        songs.Add(song);
                        resultBox.Ratings.Add(song, hits.Score(i));
                    }
                }

            }
            searcher.Close();

            lock (resultBox)
            {
                resultBox.BeginUpdate();
                resultBox.Items.Clear();
                resultBox.SetSearchTags(GetTags(query));
                resultBox.ShowSongs(numberSongs, songs, sortMethod);
                resultBox.EndUpdate();
            }
            return true;
        }
예제 #5
0
        public int[] Sort(SortMethod method)
        {
            if (method == SortMethod.ASC)
            {
                SortAsc();
            }
            else
            {
                SortDesc();
            }

            return this.numbers;
        }
예제 #6
0
 public ISortStrategy Get(SortMethod sortMethod)
 {
     switch (sortMethod)
     {
         case SortMethod.FemalesFirst:
             return new FemalesFirstSortStrategy();
         case SortMethod.Birthdate:
             return new BirthDateSortStrategy();
         case SortMethod.LastName:
             return new LastNameSortStrategy();
         default:
             return new DoNotSortStrategy();
     }
 }
예제 #7
0
파일: Extensions.cs 프로젝트: abel/sinan
 /// <summary>
 /// Test Coverage: Included
 /// </summary>
 /// <param name="val"></param>
 /// <param name="sortMethod">ALgorithm to use for sorting</param>
 /// <returns>Sorted List</returns>
 public static IEnumerable<decimal> Sort(this IEnumerable<decimal> val, SortMethod sortMethod)
 {
     IList<decimal> list = val.ToList<decimal>();
     switch (sortMethod)
     {
         case SortMethod.Bubble:
             BubbleSort.Sort(ref list);
             break;
         case SortMethod.Insertion:
             InsertionSort.Sort(ref list);
             break;
         case SortMethod.Selection:
             SelectionSort.Sort(ref list);
             break;
     }
     return list;
 }
예제 #8
0
파일: FastSearch.cs 프로젝트: ogirard/lyra2
        public bool SearchCollection(string query, SortedList list, SongListBox resultBox, bool text, bool matchCase, bool whole, bool trans, SortMethod sortMethod)
        {
            LyraQuery lQuery = SearchUtil.CreateLyraQuery(query, whole, !text);
              List<ISong> numberSongs = new List<ISong>();

              // search for nr
              if (lQuery.Numbers != null)
              {
            foreach (int nr in lQuery.Numbers)
            {
              IList<Song> nrMatches = this.nrIndex.ContainsKey(nr) ? this.nrIndex[nr] : null;
              if (nrMatches != null)
              {
            numberSongs.AddRange(nrMatches);
              }
            }
              }

              List<ISong> songs = new List<ISong>();
              resultBox.Ratings.Clear();
              if (!string.IsNullOrEmpty(lQuery.Query))
              {
            foreach (RatedResult<Song> songResult in this.indexer.SearchObjects(query, !text))
            {
              if (numberSongs.Contains(songResult.Result)) continue;
              resultBox.Ratings.Add(songResult.Result, (float)songResult.Rating);
              songs.Add(songResult.Result);
            }
              }

              lock (resultBox)
              {
            resultBox.BeginUpdate();
            resultBox.Items.Clear();
            resultBox.SetSearchTags(GetTags(query));
            resultBox.ShowSongs(numberSongs, songs, sortMethod);
            resultBox.EndUpdate();
              }
              return true;
        }
예제 #9
0
        public bool SearchCollection(string query, SortedList list, SongListBox resultBox,
            bool text, bool matchCase, bool whole, bool trans, SortMethod sortMethod)
        {
            long start = Util.getCurrentTicks();
            IDictionaryEnumerator en = list.GetEnumerator();
            en.Reset();
            string target;
            Song song;
            bool found = false;
            while (en.MoveNext())
            {
                song = (Song) en.Value;

                // only title?
                target = text ? (song.Title + " " + song.Text) : song.Title;

                // with translations?
                if (trans)
                {
                    target += (" " + this.queryTrans(song.Translations, text));
                }

                // if case doesn't need to be matched, make all letters small ones...
                if (!matchCase)
                {
                    target = target.ToLower();
                    query = query.ToLower();
                }

                if (this.Or(query, this.cleanTarget(target), whole))
                {
                    resultBox.Items.Add(song);
                    found = true;
                }
            }
            Util.addSearchTime(Util.getCurrentTicks() - start);
            return found;
        }
예제 #10
0
파일: Sort.cs 프로젝트: dustrider/Idol.net
 internal Sort(Field field, SortMethod sortMethod)
 {
     SortField = field;
     Order = null;
     Method = sortMethod;
 }
 public ICanSetReturnedOrdersInclusion SortBy(SortMethod sortBy)
 {
     _sortBy = sortBy;
     return(this);
 }
예제 #12
0
 // Search
 public void Search(string query, SongListBox resultBox, bool text, bool matchCase, bool whole, bool trans, SortMethod sortMethod)
 {
     if (!this.search.SearchCollection(query, this.SongList, resultBox, text, matchCase, whole, trans, sortMethod))
     {
         resultBox.Items.Add("Leider keinen passenden Eintrag gefunden.");
         this.owner.Status = "query done - no results :-(";
     }
     else
     {
         this.owner.Status = "query done - successful :-)";
     }
 }
예제 #13
0
 public void SetSortMethod(SortMethod sortMethod, SortOrder sortOrder)
 {
     AppManager.Instance.UserData.UsingSortMethod = CurSortMethod = sortMethod;
     AppManager.Instance.UserData.UsingSortOrder  = CurSortOrder = sortOrder;
 }
예제 #14
0
        public int Compare(GUIListItem item1, GUIListItem item2)
        {
            if (item1 == item2)
            {
                return(0);
            }
            if (item1 == null)
            {
                return(-1);
            }
            if (item2 == null)
            {
                return(-1);
            }
            if (item1.IsFolder && item1.Label == "..")
            {
                return(-1);
            }
            if (item2.IsFolder && item2.Label == "..")
            {
                return(1);
            }
            if (item1.IsFolder && !item2.IsFolder)
            {
                return(-1);
            }
            if (!item1.IsFolder && item2.IsFolder)
            {
                return(1);
            }


            SortMethod method     = currentSortMethod;
            bool       bAscending = m_bSortAscending;
            Channel    channel1   = item1.MusicTag as Channel;
            Channel    channel2   = item2.MusicTag as Channel;

            switch (method)
            {
            case SortMethod.Name:
                if (bAscending)
                {
                    return(String.Compare(item1.Label, item2.Label, true));
                }
                return(String.Compare(item2.Label, item1.Label, true));

            case SortMethod.Type:
                string strURL1 = "0";
                string strURL2 = "0";
                if (item1.IconImage.ToLower().Equals("defaultmyradiostream.png"))
                {
                    strURL1 = "1";
                }
                if (item2.IconImage.ToLower().Equals("defaultmyradiostream.png"))
                {
                    strURL2 = "1";
                }
                if (strURL1.Equals(strURL2))
                {
                    if (bAscending)
                    {
                        return(String.Compare(item1.Label, item2.Label, true));
                    }
                    return(String.Compare(item2.Label, item1.Label, true));
                }
                if (bAscending)
                {
                    if (strURL1.Length > 0)
                    {
                        return(1);
                    }
                    return(-1);
                }
                if (strURL1.Length > 0)
                {
                    return(-1);
                }
                return(1);

            //break;

            case SortMethod.Number:
                if (channel1 != null && channel2 != null)
                {
                    RadioGroupMap channel1GroupMap  = (RadioGroupMap)item1.AlbumInfoTag;
                    RadioGroupMap channel2GroupMap  = (RadioGroupMap)item2.AlbumInfoTag;
                    int           channel1GroupSort = channel1GroupMap.SortOrder;
                    int           channel2GroupSort = channel2GroupMap.SortOrder;
                    if (bAscending)
                    {
                        if (channel1GroupSort > channel2GroupSort)
                        {
                            return(1);
                        }
                        return(-1);
                    }
                    if (channel2GroupSort > channel1GroupSort)
                    {
                        return(1);
                    }
                    return(-1);
                }

                if (channel1 != null)
                {
                    return(-1);
                }
                return(channel2 != null ? 1 : 0);

            //break;
            case SortMethod.Bitrate:
                IList <TuningDetail> details1 = channel1.ReferringTuningDetail();
                TuningDetail         detail1  = details1[0];
                IList <TuningDetail> details2 = channel2.ReferringTuningDetail();
                TuningDetail         detail2  = details2[0];
                if (detail1 != null && detail2 != null)
                {
                    if (bAscending)
                    {
                        if (detail1.Bitrate > detail2.Bitrate)
                        {
                            return(1);
                        }
                        return(-1);
                    }
                    if (detail2.Bitrate > detail1.Bitrate)
                    {
                        return(1);
                    }
                    return(-1);
                }
                return(0);
            }
            return(0);
        }
예제 #15
0
 private string SortToString(SortMethod sort)
 {
     switch (sort)
     {
         case SortMethod.ARRIVAL: return "ARRIVAL";
         case SortMethod.CC: return "CC";
         case SortMethod.DATE: return "DATE";
         case SortMethod.FROM: return "FROM";
         case SortMethod.SIZE: return "SIZE";
         case SortMethod.SUBJECT: return "SUBJECT";
         default: return string.Empty;
     }
 }
        private static IEnumerable <SystemInfo> GetSortedSystemInfos(IEnumerable <SystemInfo> systemInfos, SortMethod sortMethod)
        {
            switch (sortMethod)
            {
            case SortMethod.Name:
                return(systemInfos.OrderBy(systemInfo => systemInfo.SystemName));

            case SortMethod.NameDescending:
                return(systemInfos.OrderByDescending(systemInfo => systemInfo.SystemName));

            case SortMethod.ExecutionTime:
                return(systemInfos.OrderBy(systemInfo => systemInfo.AverageUpdateDuration));

            case SortMethod.ExecutionTimeDescending:
                return(systemInfos.OrderByDescending(systemInfo => systemInfo.AverageUpdateDuration));

            default:
                return(systemInfos);
            }
        }
예제 #17
0
파일: Sort.cs 프로젝트: dustrider/Idol.net
 internal Sort(Field field, SortMethod sortMethod)
 {
     SortField = field;
     Order     = null;
     Method    = sortMethod;
 }
예제 #18
0
        public static int CalculateSortedInsertIndex <TOrder>(IList <TOrder> sortedList, TOrder orderValue, SortMethod method, IComparer <TOrder> comparer = null)
        {
            if (comparer == null)
            {
                comparer = Comparer <TOrder> .Default;
            }
            var index = BinarySearchHelper.BinarySearch(sortedList, orderValue, comparer);

            if (index < 0)
            {
                return(~index);
            }
            if (method == SortMethod.BisectLeft)
            {
                while (index - 1 >= 0 && comparer.Compare(orderValue, sortedList[index - 1]) == 0)
                {
                    --index;
                }
            }
            if (method == SortMethod.BisectRight)
            {
                while (index + 1 < sortedList.Count && comparer.Compare(orderValue, sortedList[++index]) == 0)
                {
                }
            }
            return(index);
        }
        public bool SortData(SortMethod sortMethod)
        {
            if (_personnelList.Count == 0)
            {
                Error = String.Format("The list is empty.");
                return false;
            }

            switch (sortMethod)
            {
                case SortMethod.Gender:
                    _personnelList.Sort(
                        delegate(Person prior, Person next)
                        {
                            return prior.Gender.CompareTo(next.Gender);
                        });
                    break;
                case SortMethod.BirthDate:
                    _personnelList.Sort(
                        delegate(Person prior, Person next)
                        {
                            return prior.DateOfBirth.CompareTo(next.DateOfBirth);
                        });
                    break;
                case SortMethod.LastName:
                    _personnelList.Sort(
                        delegate(Person prior, Person next)
                        {
                            return -prior.LastName.CompareTo(next.LastName);
                        });
                    break;
                default:
                    Error = String.Format("File could not be sorted.");
                    return false;
            }

            return true;
        }
예제 #20
0
    void OnGUI()
    {
        GUILayout.Space(7f);

        GUI.skin.label.alignment = TextAnchor.MiddleLeft;
        if (stringStats != null)
        {
            EditorGUILayout.HelpBox(stringStats.ToString(), MessageType.None);
            GUILayout.Space(5f);

            sortMethod       = (SortMethod)EditorGUILayout.EnumPopup("Sort Method:", sortMethod);
            displayMethod    = (DisplayMethod)EditorGUILayout.EnumPopup("Display Mode:", displayMethod);
            ignoreEmptyLines = EditorGUILayout.Toggle("Ignore Empty Lines:", ignoreEmptyLines);

            GUILayout.Space(4f);

            if (displayMethod != DisplayMethod.Graph)
            {
                search = EditorGUILayout.TextField("Search Script Name:", search);

                if (displayMethod == DisplayMethod.Default)
                {
                    EditorGUI.indentLevel += 1;
                    displayMatchesOnly     = EditorGUILayout.Toggle("Display Matches Only:", displayMatchesOnly);

                    if (displayMatchesOnly)
                    {
                        comparisonMode = EditorGUILayout.Toggle("Comparison Mode:", comparisonMode);
                    }
                    else
                    {
                        comparisonMode = false;
                    }
                    EditorGUI.indentLevel -= 1;
                }
            }
            else
            {
                search = string.Empty;
            }

            GUILayout.Space(5f);
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            if (fileStats != null)
            {
                string    builtString  = string.Empty;
                int       displayCount = 0;
                Texture2D barTex       = Texture2D.whiteTexture;

                for (int i = 0; i < fileStats.Count; i++)
                {
                    float alphaMod    = 1f;
                    float finalHeight = 15f;
                    if (!string.IsNullOrEmpty(search) && !fileStats[i].displayName.ToLowerInvariant().Contains(search.ToLowerInvariant()))
                    {
                        if (displayMethod == DisplayMethod.TextOnly)
                        {
                            continue;
                        }

                        if (comparisonMode)
                        {
                            finalHeight = 1f;
                            alphaMod    = 0.5f;
                        }
                        else if (displayMatchesOnly)
                        {
                            continue;
                        }
                        else
                        {
                            alphaMod = 0.3f;
                        }
                    }

                    displayCount++;

                    if (displayMethod == DisplayMethod.TextOnly)
                    {
                        builtString += (i + 1).ToString() + ": " + fileStats[i].displayName + " [" + fileStats[i].numLines.ToString() + "]";

                        if (i < fileStats.Count - 1)
                        {
                            builtString += "\n";
                        }
                    }
                    else
                    {
                        if (displayMethod == DisplayMethod.Graph)
                        {
                            finalHeight = 1f;
                        }

                        Rect  displayRect = EditorGUILayout.GetControlRect(true, GUILayout.MaxHeight(finalHeight));
                        float oddFactor   = (i % 2 == 1) ? 0.3f : 0f;

                        GUI.color = new Color(oddFactor, oddFactor, oddFactor, alphaMod * 0.1f);
                        GUI.DrawTexture(displayRect, barTex);
                        GUI.color = new Color(1f, 1f, 1f, alphaMod);

                        GUI.depth += 1;

                        GUI.color = (EditorGUIUtility.isProSkin) ? new Color(0.375f, 0.6f, 0.3f, alphaMod * 0.5f) : new Color(0.475f, 0.725f, 0.35f, alphaMod * 0.75f);
                        float oldWidth = displayRect.width;
                        displayRect.width *= (fileStats[i].numLines / (float)largestLineCountRef.numLines);
                        displayRect.width  = Mathf.Round(displayRect.width);

                        if (Event.current.type == EventType.Repaint && displayRect.width > 1f)
                        {
                            GUI.DrawTexture(displayRect, barTex);
                        }

                        displayRect.width = oldWidth;

                        GUI.depth += 1;

                        GUI.color = (EditorGUIUtility.isProSkin) ? new Color(0.6f, 0.5f, 0.3f, alphaMod * 0.5f) : new Color(0.75f, 0.6f, 0.45f, alphaMod * 0.75f);
                        float oldWidth2 = displayRect.width;
                        displayRect.width *= (fileStats[i].numLines / (float)totalLines);
                        displayRect.width  = Mathf.Round(displayRect.width);

                        if (Event.current.type == EventType.Repaint && displayRect.width > 1f)
                        {
                            GUI.DrawTexture(displayRect, barTex);
                        }

                        displayRect.width = oldWidth2;
                        GUI.color         = new Color(1f, 1f, 1f, alphaMod);

                        GUI.depth += 1;

                        displayRect.y += 1;

                        if (displayMethod != DisplayMethod.Graph)
                        {
                            int oldFontSize = GUI.skin.label.fontSize;
                            GUI.skin.label.fontSize  = 9;
                            GUI.skin.label.alignment = TextAnchor.MiddleLeft;
                            GUI.Label(displayRect, (i + 1).ToString() + ": " + fileStats[i].displayName);
                            GUI.skin.label.alignment = TextAnchor.MiddleRight;
                            GUI.Label(displayRect, "[" + fileStats[i].numLines.ToString() + " lines]  (" + (fileStats[i].numLines * 100 / (float)totalLines).ToString("F3") + "%)");
                            GUI.skin.label.alignment = TextAnchor.MiddleLeft;
                            GUI.skin.label.fontSize  = oldFontSize;
                        }

                        GUI.depth -= 3;
                    }
                }

                if (displayCount <= 0)
                {
                    EditorGUILayout.HelpBox("No results...", MessageType.None);
                }
                else if (!string.IsNullOrEmpty(builtString) && displayMethod == DisplayMethod.TextOnly)
                {
                    EditorGUILayout.TextArea(builtString);
                }
            }

            EditorGUILayout.EndScrollView();
        }
        else
        {
            for (int y = 0; y < Screen.height / 18; y++)
            {
                EditorGUILayout.BeginHorizontal();

                for (int x = 0; x <= Screen.width / 370; x++)
                {
                    EditorGUILayout.LabelField("REFRESH THE WINDOW BY PRESSING CTRL+ALT+C", EditorStyles.boldLabel, GUILayout.Width(370f));
                }

                EditorGUILayout.EndHorizontal();
            }
        }

        if (GUI.changed)
        {
            EditorPrefs.SetString("LC_SavedSearch", search);
            EditorPrefs.SetBool("LC_DisplayMatchesOnly", displayMatchesOnly);
            EditorPrefs.SetBool("LC_ComparisonMode", comparisonMode);
        }
    }
예제 #21
0
 /// <summary>
 /// Maps each enum value to a sort function
 /// </summary>
 /// <param name="sortMethod"></param>
 /// <returns></returns>
 public static SortFunction GetSortFunction(this SortMethod sortMethod) => sorters[sortMethod];
예제 #22
0
파일: GUI.cs 프로젝트: ogirard/lyra2
 private void SortMethodChanged(object sender, EventArgs e)
 {
     SortMethod newSortMethod = (SortMethod)this.sortCombo.SelectedIndex;
       if (this.sortMethod != newSortMethod)
       {
     this.sortMethod = newSortMethod;
     this.searchListBox.BeginUpdate();
     this.searchListBox.Sort(newSortMethod);
     this.searchListBox.EndUpdate();
       }
 }
예제 #23
0
 public OrderedElementsSet(IEnumerable <ElementInstance> elements, SortMethod sorting)
 {
     Elements = elements;
     Sorting  = sorting;
 }
예제 #24
0
        public HouseRaffleManagementGump(HouseRaffleStone stone, SortMethod sort, int page)
            : base(40, 40)
        {
            m_Stone = stone;
            m_Page  = page;

            m_List = new List <RaffleEntry>(m_Stone.Entries);
            m_Sort = sort;

            switch (m_Sort)
            {
            case SortMethod.Name:
            {
                m_List.Sort(NameComparer.Instance);

                break;
            }

            case SortMethod.Account:
            {
                m_List.Sort(AccountComparer.Instance);

                break;
            }

            case SortMethod.Address:
            {
                m_List.Sort(AddressComparer.Instance);

                break;
            }
            }

            AddPage(0);

            AddBackground(0, 0, 618, 354, 9270);
            AddAlphaRegion(10, 10, 598, 334);

            AddHtml(10, 10, 598, 20, Color(Center("Raffle Management"), LabelColor), false, false);

            AddHtml(45, 35, 100, 20, Color("Location:", LabelColor), false, false);
            AddHtml(145, 35, 250, 20, Color(m_Stone.FormatLocation(), LabelColor), false, false);

            AddHtml(45, 55, 100, 20, Color("Ticket Price:", LabelColor), false, false);
            AddHtml(145, 55, 250, 20, Color(m_Stone.FormatPrice(), LabelColor), false, false);

            AddHtml(45, 75, 100, 20, Color("Total Entries:", LabelColor), false, false);
            AddHtml(145, 75, 250, 20, Color(m_Stone.Entries.Count.ToString(), LabelColor), false, false);

            AddButton(440, 33, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0);
            AddHtml(474, 35, 120, 20, Color("Sort by name", LabelColor), false, false);

            AddButton(440, 53, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0);
            AddHtml(474, 55, 120, 20, Color("Sort by account", LabelColor), false, false);

            AddButton(440, 73, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0);
            AddHtml(474, 75, 120, 20, Color("Sort by address", LabelColor), false, false);

            AddImageTiled(13, 99, 592, 242, 9264);
            AddImageTiled(14, 100, 590, 240, 9274);
            AddAlphaRegion(14, 100, 590, 240);

            AddHtml(14, 100, 590, 20, Color(Center("Entries"), LabelColor), false, false);

            if (page > 0)
            {
                AddButton(567, 104, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(567, 104, 0x25EA);
            }

            if ((page + 1) * 10 < m_List.Count)
            {
                AddButton(584, 104, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0);
            }
            else
            {
                AddImage(584, 104, 0x25E6);
            }

            AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor), false, false);
            AddHtml(47, 120, 250, 20, Color("Name", LabelColor), false, false);
            AddHtml(295, 120, 100, 20, Color(Center("Address"), LabelColor), false, false);
            AddHtml(395, 120, 150, 20, Color(Center("Date"), LabelColor), false, false);
            AddHtml(545, 120, 60, 20, Color(Center("Num"), LabelColor), false, false);

            int    idx    = 0;
            Mobile winner = m_Stone.Winner;

            for (int i = page * 10; i >= 0 && i < m_List.Count && i < (page + 1) * 10; ++i, ++idx)
            {
                RaffleEntry entry = m_List[i];

                if (entry == null)
                {
                    continue;
                }

                AddButton(13, 138 + (idx * 20), 4002, 4004, 6 + i, GumpButtonType.Reply, 0);

                int x     = 45;
                int color = (winner != null && entry.From == winner) ? HighlightColor : LabelColor;

                string name = null;

                if (entry.From != null)
                {
                    Account acc = entry.From.Account as Account;

                    if (acc != null)
                    {
                        name = String.Format("{0} ({1})", entry.From.Name, acc);
                    }
                    else
                    {
                        name = entry.From.Name;
                    }
                }

                if (name != null)
                {
                    AddHtml(x + 2, 140 + (idx * 20), 250, 20, Color(name, color), false, false);
                }

                x += 250;

                if (entry.Address != null)
                {
                    AddHtml(x, 140 + (idx * 20), 100, 20, Color(Center(entry.Address.ToString()), color), false, false);
                }

                x += 100;

                AddHtml(x, 140 + (idx * 20), 150, 20, Color(Center(entry.Date.ToString()), color), false, false);
                x += 150;

                AddHtml(x, 140 + (idx * 20), 60, 20, Color(Center("1"), color), false, false);
                x += 60;
            }
        }
예제 #25
0
        public IReadOnlyCollection <FileResult> QueryReplayFiles(string[] keywords, SortMethod sort, int maxEntries, int skip)
        {
            if (keywords == null)
            {
                throw new ArgumentNullException(nameof(keywords));
            }

            Query sortQuery;

            switch (sort)
            {
            default:
                sortQuery = Query.All("FileCreationTime", Query.Ascending);
                break;

            case SortMethod.DateDesc:
                sortQuery = Query.All("FileCreationTime", Query.Descending);
                break;

            case SortMethod.SizeAsc:
                sortQuery = Query.All("FileSizeBytes", Query.Ascending);
                break;

            case SortMethod.SizeDesc:
                sortQuery = Query.All("FileSizeBytes", Query.Descending);
                break;

            case SortMethod.NameAsc:
                // Query either filename or alternative name
                sortQuery = Query.All(_settings.RenameAction == RenameAction.File ? "FileName" : "AlternativeName", Query.Ascending);
                break;

            case SortMethod.NameDesc:
                sortQuery = Query.All(_settings.RenameAction == RenameAction.File ? "FileName" : "AlternativeName", Query.Descending);
                break;
            }

            // Create queries trying to match keywords into search string
            List <Query> queries = new List <Query>();

            foreach (var word in keywords)
            {
                queries.Add
                (
                    Query.Where("SearchKeywords", fileKeywords => fileKeywords.AsString.Contains(word.ToUpper(CultureInfo.InvariantCulture)))
                );
            }

            // Comebine all keyword queries using AND keyword, then AND by sort query
            Query endQuery;

            if (queries.Any())
            {
                if (queries.Count == 1)
                {
                    endQuery = Query.And(sortQuery, queries[0]);
                }
                else
                {
                    var combinedPlayerQuery = Query.And(queries.ToArray());
                    endQuery = Query.And(sortQuery, combinedPlayerQuery);
                }
            }
            else
            {
                endQuery = sortQuery;
            }

            // Query the database
            using (var db = new LiteDatabase(_filePath))
            {
                var fileResults = db.GetCollection <FileResult>("fileResults");

                return(fileResults.IncludeAll().Find(endQuery, limit: maxEntries, skip: skip).ToList());
            }
        }
예제 #26
0
 public Program(string inputFileName, SortMethod sortMethod)
 {
     InputFileName = inputFileName;
     _sortMethod   = sortMethod;
 }
예제 #27
0
        protected override void OnClicked(int controlId, GUIControl control, global::MediaPortal.GUI.Library.Action.ActionType actionType)
        {
            base.OnClicked(controlId, control, actionType);

            if (control == _searchButton)
            {
                _selectedTitleIndex   = 0;
                _selectedProgramIndex = 0;

                if (_rules.Count > 0)
                {
                    GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                    if (dlgYesNo != null)
                    {
                        dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.Attention));
                        dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.ContinueWithPrevResults));
                        dlgYesNo.SetDefaultToYes(true);
                        dlgYesNo.DoModal(GetID);
                        if (!dlgYesNo.IsConfirmed)
                        {
                            _rules.Clear();
                            if (_viewsList != null && _viewsList.Count > 0)
                            {
                                _viewsList.Clear();
                            }
                        }
                    }
                }

                VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                if (keyboard != null)
                {
                    keyboard.Reset();
                    keyboard.IsSearchKeyboard = true;
                    keyboard.Text             = String.Empty;
                    keyboard.DoModal(GetID);
                    if (keyboard.IsConfirmed)
                    {
                        if (keyboard.Text == string.Empty)
                        {
                            GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                            if (dlgOk != null)
                            {
                                dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information));
                                dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoValidSearchText));
                                dlgOk.DoModal(GetID);
                            }
                        }
                        else
                        {
                            switch (_currentSearchMethod)
                            {
                            case SearchInMethod.Title:
                                _rules.Add(ScheduleRuleType.TitleContains, keyboard.Text);
                                break;

                            case SearchInMethod.Description:
                                _rules.Add(ScheduleRuleType.DescriptionContains, keyboard.Text);
                                break;

                            case SearchInMethod.ProgramInfo:
                                _rules.Add(ScheduleRuleType.ProgramInfoContains, keyboard.Text);
                                break;

                            case SearchInMethod.Actor:
                                _rules.Add(ScheduleRuleType.WithActor, keyboard.Text);
                                break;

                            case SearchInMethod.DirectedBy:
                                _rules.Add(ScheduleRuleType.DirectedBy, keyboard.Text);
                                break;
                            }
                            ShowSearchResults(string.Empty);
                        }
                    }
                }
            }
            else if (control == _searchMethodButton)
            {
                GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                if (dlg == null)
                {
                    return;
                }
                dlg.Reset();
                dlg.SetHeading(467);
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnTitle));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDescription));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnProgramInfo));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnActor));
                dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDirectedBy));

                dlg.SelectedLabel = (int)_currentSearchMethod;
                // show dialog and wait for result
                dlg.DoModal(GetID);
                if (dlg.SelectedId == -1)
                {
                    return;
                }
                _currentSearchMethod = (SearchInMethod)(dlg.SelectedLabel);
                UpdateButtonStates();
            }
            else if (control == _selectChannelsButton)
            {
                List <ChannelGroup> groups         = new List <ChannelGroup>(PluginMain.Navigator.GetGroups(this._channelType));
                ChannelGroup        _selectedGroup = new ChannelGroup();

                if (groups.Count > 0)
                {
                    if (groups.Count > 1)
                    {
                        GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                        if (dlg == null)
                        {
                            return;
                        }

                        dlg.Reset();
                        dlg.SetHeading(Utility.GetLocalizedText(TextId.SelectGroup));
                        foreach (ChannelGroup group in groups)
                        {
                            dlg.Add(group.GroupName);
                        }

                        // show dialog and wait for result
                        dlg.DoModal(GetID);
                        if (dlg.SelectedId == -1)
                        {
                            return;
                        }
                        _selectedGroup = groups[dlg.SelectedId - 1];
                    }
                    else
                    {
                        _selectedGroup = groups[0];
                    }

                    List <Channel> channels = new List <Channel>();
                    if (_channelArguments.Count > 0)
                    {
                        List <Channel> channels2 = new List <Channel>(SchedulerAgent.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true));
                        foreach (Channel channel in channels2)
                        {
                            if (!_channelArguments.Contains(channel.ChannelId))
                            {
                                channels.Add(channel);
                            }
                        }
                    }
                    else
                    {
                        channels = new List <Channel>(SchedulerAgent.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true));
                    }

                    if (channels.Count > 0)
                    {
                        GUIDialogMenu dlg2 = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                        if (dlg2 == null)
                        {
                            return;
                        }

                        dlg2.Reset();
                        dlg2.SetHeading(GetChannelArgumentsString(true));
                        foreach (Channel channel in channels)
                        {
                            dlg2.Add(channel.DisplayName);
                        }

                        // show dialog and wait for result
                        dlg2.DoModal(GetID);
                        if (dlg2.SelectedId == -1)
                        {
                            return;
                        }
                        _channelArguments.Add(channels[dlg2.SelectedId - 1].ChannelId);
                        UpdateButtonStates();
                    }
                    else
                    {
                        GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                        if (dlgOk != null)
                        {
                            dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information));
                            dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreChannelsToAdd));
                            dlgOk.DoModal(GetID);
                        }
                    }
                }
            }
            else if (control == _selectCategoriesButton)
            {
                List <string> categories  = new List <string>();
                string[]      _categories = new string[0];
                _categories = GuideAgent.GetAllCategories();

                foreach (string categorie in _categories)
                {
                    if (!_categorieArguments.Contains(categorie))
                    {
                        categories.Add(categorie);
                    }
                }

                if (categories.Count > 0)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }

                    dlg.Reset();
                    dlg.SetHeading(GetCategorieArgumentString(true));
                    foreach (string categorie in categories)
                    {
                        dlg.Add(categorie);
                    }

                    // show dialog and wait for result
                    dlg.DoModal(GetID);
                    if (dlg.SelectedId == -1)
                    {
                        return;
                    }
                    _categorieArguments.Add(dlg.SelectedLabelText);
                    UpdateButtonStates();
                }
                else
                {
                    GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
                    if (dlgOk != null)
                    {
                        dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information));
                        dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreCategoriesToAdd));
                        dlgOk.DoModal(GetID);
                    }
                }
            }
            else if (control == _clearButton)
            {
                OnClearRules(true);
                ShowSearchResults(string.Empty);
                UpdateButtonStates();
            }
            else if (control == _sortByButton)
            {
                if (_isInSubDirectory)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
                    if (dlg == null)
                    {
                        return;
                    }
                    dlg.Reset();
                    dlg.SetHeading(495);         //Sort Options
                    dlg.AddLocalizedString(620); //channel
                    dlg.AddLocalizedString(621); //date
                    dlg.AddLocalizedString(268); //title/name

                    // set the focus to currently used sort method
                    dlg.SelectedLabel = (int)_currentSortMethod;

                    // show dialog and wait for result
                    dlg.DoModal(GetID);
                    if (dlg.SelectedId == -1)
                    {
                        return;
                    }
                    _currentSortMethod = (SortMethod)dlg.SelectedLabel;
                    OnSort();
                }
            }
            else if (control == _viewsList)
            {
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECTED, GetID, 0, control.GetID, 0, 0, null);
                OnMessage(msg);
                int iItem = (int)msg.Param1;
                if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    OnSelectItem(iItem);
                }
                if (actionType == Action.ActionType.ACTION_SHOW_INFO)
                {
                    OnShowContextMenu();
                }
            }
        }
예제 #28
0
        private void RefreshList()
        {
            SortMethod method = (SortMethod)ComboSortPlaylist.SelectedIndex;

            List <Song> songList   = DgrPlaylist.DataSource as List <Song>;
            List <Song> sortedList = new List <Song>();

            switch (method)
            {
            case SortMethod.Default:
                sortedList.AddRange(songList);
                break;

            case SortMethod.DefaultReverse:
                sortedList.AddRange(songList);
                sortedList.Reverse();
                break;

            case SortMethod.Album:
                sortedList.AddRange(from s in songList orderby s.Album ascending select s);
                break;

            case SortMethod.AlbumReverse:
                sortedList.AddRange(from s in songList orderby s.Album descending select s);
                break;

            case SortMethod.Artist:
                sortedList.AddRange(from s in songList orderby s.Artist ascending select s);
                break;

            case SortMethod.ArtistReverse:
                sortedList.AddRange(from s in songList orderby s.Artist descending select s);
                break;

            case SortMethod.Song:
                sortedList.AddRange(from s in songList orderby s.Title ascending select s);
                break;

            case SortMethod.SongReverse:
                sortedList.AddRange(from s in songList orderby s.Title descending select s);
                break;

            default:
                break;
            }

            DgrPlaylist.DataSource = null;
            DgrPlaylist.DataSource = sortedList;

            DgrPlaylist.ClearSelection();
            foreach (DataGridViewRow s in DgrPlaylist.Rows)
            {
                var song = s.DataBoundItem as Song;
                if (song == CurrentSong)
                {
                    s.Selected = true;
                }
            }

            InitShuffleIndex();
            if (ChkShuffle.Checked)
            {
                MakeShuffleIndex();
            }
        }
 // TODO:
 private bool SortData(SortMethod sortMethod)
 {
     switch (sortMethod)
     {
         case SortMethod.Gender:
             //_personnelList.Sort();
             break;
         case SortMethod.BirthDate:
             break;
         case SortMethod.LastName:
             break;
         default:
             Error = String.Format("File could not be sorted.");
             return false;
     }
     return true;
 }
 public ShoppingListView()
 {
     InitializeComponent();
     BindingContext    = this;
     CurrentingSorting = SortMethod.Alphabetical;
 }
예제 #31
0
 public VideoSort(SortMethod sortMethod, bool ascending)
 {
     currentSortMethod = sortMethod;
     sortAscending     = ascending;
 }
예제 #32
0
        private void DrawSystemList(DebugScenario systems)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.BeginHorizontal();
                {
                    DebugScenario.AvgResetInterval = (AvgResetInterval)EditorGUILayout.EnumPopup("Reset average duration Ø", DebugScenario.AvgResetInterval);
                    if (GUILayout.Button("Reset Ø now", GUILayout.Width(88), GUILayout.Height(14)))
                    {
                        systems.ResetDurations();
                    }
                }
                EditorGUILayout.EndHorizontal();

                _threshold        = EditorGUILayout.Slider("Threshold Ø ms", _threshold, 0f, 33f);
                _systemSortMethod = (SortMethod)EditorGUILayout.EnumPopup("Sort by ", _systemSortMethod);
                _hideEmptySystems = EditorGUILayout.Toggle("Hide empty systems", _hideEmptySystems);
                EditorGUILayout.Space();

                EditorGUILayout.BeginHorizontal();
                {
                    _systemNameSearchTerm = EditorGUILayout.TextField("Search", _systemNameSearchTerm);

                    const string clearButtonControlName = "Clear Button";
                    GUI.SetNextControlName(clearButtonControlName);
                    if (GUILayout.Button("x", GUILayout.Width(19), GUILayout.Height(14)))
                    {
                        _systemNameSearchTerm = string.Empty;
                        GUI.FocusControl(clearButtonControlName);
                    }
                }
                EditorGUILayout.EndHorizontal();

                _showInitializeSystems = EditorGUILayout.Foldout(_showInitializeSystems, "Initialize Systems");
                if (_showInitializeSystems && ShouldShowSystems(systems, true))
                {
                    EditorGUILayout.BeginVertical(GUI.skin.box);
                    {
                        var systemsDrawn = DrawSystemInfos(systems, true, false);
                        if (systemsDrawn == 0)
                        {
                            EditorGUILayout.LabelField(string.Empty);
                        }
                    }
                    EditorGUILayout.EndVertical();
                }

                _showExecuteSystems = EditorGUILayout.Foldout(_showExecuteSystems, "Execute Systems");
                if (_showExecuteSystems && ShouldShowSystems(systems, false))
                {
                    EditorGUILayout.BeginVertical(GUI.skin.box);
                    {
                        var systemsDrawn = DrawSystemInfos(systems, false, false);
                        if (systemsDrawn == 0)
                        {
                            EditorGUILayout.LabelField(string.Empty);
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
            }
            EditorGUILayout.EndVertical();
        }
예제 #33
0
        private void SetSort(SortMethod method, bool ascending)
        {
            string s = ascending ? "" : "-";

            Request?.AddQueryParameter("sort", $"{s}{method}");
        }
 /// <summary>
 /// Сортировка
 /// </summary>
 /// <param name="method">Метод сортировки</param>
 private void Sort(SortMethod method)
 {
     method();
 }
예제 #35
0
 public StationSort(SortMethod method, bool asc)
 {
     currentSortMethod = method;
     sortAscending     = asc;
 }
예제 #36
0
        void drawSystemList(DebugSystems systems)
        {
            _showSystemsList = EntitasEditorLayout.DrawSectionHeaderToggle("Systems", _showSystemsList);
            if (_showSystemsList)
            {
                EntitasEditorLayout.BeginSectionContent();
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        DebugSystems.avgResetInterval = (AvgResetInterval)EditorGUILayout.EnumPopup("Reset average duration Ø", DebugSystems.avgResetInterval);
                        if (GUILayout.Button("Reset Ø now", EditorStyles.miniButton, GUILayout.Width(88)))
                        {
                            systems.ResetDurations();
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    _threshold = EditorGUILayout.Slider("Threshold Ø ms", _threshold, 0f, 33f);

                    _hideEmptySystems = EditorGUILayout.Toggle("Hide empty systems", _hideEmptySystems);
                    EditorGUILayout.Space();

                    EditorGUILayout.BeginHorizontal();
                    {
                        _systemSortMethod       = (SortMethod)EditorGUILayout.EnumPopup(_systemSortMethod, EditorStyles.popup, GUILayout.Width(150));
                        _systemNameSearchString = EntitasEditorLayout.SearchTextField(_systemNameSearchString);
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.Space();

                    _showInitializeSystems = EntitasEditorLayout.DrawSectionHeaderToggle("Initialize Systems", _showInitializeSystems);
                    if (_showInitializeSystems && shouldShowSystems(systems, SystemInterfaceFlags.IInitializeSystem))
                    {
                        EntitasEditorLayout.BeginSectionContent();
                        {
                            var systemsDrawn = drawSystemInfos(systems, SystemInterfaceFlags.IInitializeSystem);
                            if (systemsDrawn == 0)
                            {
                                EditorGUILayout.LabelField(string.Empty);
                            }
                        }
                        EntitasEditorLayout.EndSectionContent();
                    }

                    _showExecuteSystems = EntitasEditorLayout.DrawSectionHeaderToggle("Execute Systems", _showExecuteSystems);
                    if (_showExecuteSystems && shouldShowSystems(systems, SystemInterfaceFlags.IExecuteSystem))
                    {
                        EntitasEditorLayout.BeginSectionContent();
                        {
                            var systemsDrawn = drawSystemInfos(systems, SystemInterfaceFlags.IExecuteSystem);
                            if (systemsDrawn == 0)
                            {
                                EditorGUILayout.LabelField(string.Empty);
                            }
                        }
                        EntitasEditorLayout.EndSectionContent();
                    }

                    _showCleanupSystems = EntitasEditorLayout.DrawSectionHeaderToggle("Cleanup Systems", _showCleanupSystems);
                    if (_showCleanupSystems && shouldShowSystems(systems, SystemInterfaceFlags.ICleanupSystem))
                    {
                        EntitasEditorLayout.BeginSectionContent();
                        {
                            var systemsDrawn = drawSystemInfos(systems, SystemInterfaceFlags.ICleanupSystem);
                            if (systemsDrawn == 0)
                            {
                                EditorGUILayout.LabelField(string.Empty);
                            }
                        }
                        EntitasEditorLayout.EndSectionContent();
                    }

                    _showTearDownSystems = EntitasEditorLayout.DrawSectionHeaderToggle("TearDown Systems", _showTearDownSystems);
                    if (_showTearDownSystems && shouldShowSystems(systems, SystemInterfaceFlags.ITearDownSystem))
                    {
                        EntitasEditorLayout.BeginSectionContent();
                        {
                            var systemsDrawn = drawSystemInfos(systems, SystemInterfaceFlags.ITearDownSystem);
                            if (systemsDrawn == 0)
                            {
                                EditorGUILayout.LabelField(string.Empty);
                            }
                        }
                        EntitasEditorLayout.EndSectionContent();
                    }
                }
                EntitasEditorLayout.EndSectionContent();
            }
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 public lvwColumnSorter()
 {
     ColumnToSort = 0;// 默认按第一列排序
     OrderOfSort = SortOrder.None;// 排序方式为不排序
     ObjectCompare = new CaseInsensitiveComparer();// 初始化CaseInsensitiveComparer类对象
     mCompareMethod = SortMethod.StringCompare; //是否使用Size比较
 }
        private void drawSystemList(DebugSystems system)
        {
            CustomEditorLayout.BeginVerticalBox();
            {
                CustomEditorLayout.BeginHorizontal();
                {
                    DebugSystems.avgResetInterval = (AvgResetInterval)EditorGUILayout.EnumPopup("Reset average duration Ø", DebugSystems.avgResetInterval);
                    if (GUILayout.Button("Reset Ø now", GUILayout.Width(88), GUILayout.Height(14)))
                    {
                        system.ResetDuration();
                    }
                }
                CustomEditorLayout.EndHorizontal();

                _threshold        = EditorGUILayout.Slider("Threshold Ø ms", _threshold, 0f, 33f);
                _systemSortMethod = (SortMethod)EditorGUILayout.EnumPopup("Sort by ", _systemSortMethod);
                _hideEmptySystems = EditorGUILayout.Toggle("Hide empty systems", _hideEmptySystems);
                EditorGUILayout.Space();

                _systemNameSearchString = CustomEditorLayout.SearchTextField(_systemNameSearchString);
                EditorGUILayout.Space();

                _showStartSystems = CustomEditorLayout.Foldout(_showStartSystems, "OnStart Systems");
                if (_showStartSystems && shouldShowSystems(system, start: true))
                {
                    CustomEditorLayout.BeginVerticalBox();
                    {
                        var systemsDrawn = drawSystemInfos(system, false, start: true);
                        if (systemsDrawn == 0)
                        {
                            EditorGUILayout.LabelField(string.Empty);
                        }
                    }
                    CustomEditorLayout.EndVertical();
                }

                _showUpdateSystems = CustomEditorLayout.Foldout(_showUpdateSystems, "OnUpdate Systems");
                if (_showUpdateSystems && shouldShowSystems(system, update: true))
                {
                    CustomEditorLayout.BeginVerticalBox();
                    {
                        var systemsDrawn = drawSystemInfos(system, false, update: true);
                        if (systemsDrawn == 0)
                        {
                            EditorGUILayout.LabelField(string.Empty);
                        }
                    }
                    CustomEditorLayout.EndVertical();
                }

                _showFixedUpdateSystems = CustomEditorLayout.Foldout(_showFixedUpdateSystems, "OnFixedUpdate Systems");
                if (_showFixedUpdateSystems && shouldShowSystems(system, fixedUpdate: true))
                {
                    CustomEditorLayout.BeginVerticalBox();
                    {
                        var systemsDrawn = drawSystemInfos(system, false, fixedUpdate: true);
                        if (systemsDrawn == 0)
                        {
                            EditorGUILayout.LabelField(string.Empty);
                        }
                    }
                    CustomEditorLayout.EndVertical();
                }
            }
            CustomEditorLayout.EndVertical();
        }
예제 #39
0
 /// <summary>
 /// Obtains a sorted collection of messages from a mailbox.
 /// </summary>
 /// <param name="sort">A value of type SortMethod.</param>
 /// <param name="order">A value of type SortOrder that specifies ascending or descending.</param>
 /// <returns>Returns a ImapMailbox object containing the messages.</returns>
 public ImapMailbox Sort(SortMethod sort, SortOrder order)
 {
     if (!(Connection.ConnectionState == ConnectionState.Open))
         NoOpenConnection();
     Connection.Write(string.Format("SORT ({0){1}) US-ASCII ALL\r\n", OrderToString(order), SortToString(sort)));
     string response = Connection.Read();
     if (response.StartsWith("*")) {
         Connection.Read();
         MatchCollection matches = Regex.Matches(response, @"\d+");
         if (matches.Count > 0) {
             int[] ids = new int[matches.Count];
             for (int i = 0; i < matches.Count; i++)
                 ids[i] = Convert.ToInt16(matches[i].Value);
             return Fetch(ids);
         }
     }
     return new ImapMailbox();
 }
예제 #40
0
 /// <summary>
 ///     Sorts the jodels.
 /// </summary>
 /// <param name="jodels">The jodels.</param>
 /// <param name="method">The method.</param>
 /// <returns>List&lt;Jodels&gt;.</returns>
 public List <Jodels> Sort(List <Jodels> jodels, SortMethod method)
 {
     return(method == SortMethod.MostCommented
         ? jodels.OrderByDescending(o => o.CommentsCount).ToList()
         : jodels.OrderByDescending(o => o.VoteCount).ToList());
 }
예제 #41
0
        private async Task <T> GetFilteredAlbumsSongsAsync <T, E>(string methodName,
                                                                  bool ignorearticle,
                                                                  SortMethod sortMethod,
                                                                  SortOrder sortOrder,
                                                                  int start, int end,
                                                                  IEnumerable <E> fields,
                                                                  int?artistId = null,
                                                                  int?albumId  = null,
                                                                  int?genreId  = null)
        {
            string[] properties = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray();

            if (!properties.Any())
            {
                properties = Enum.GetNames(typeof(E));
            }

            Filter filter = null;

            if (artistId != null)
            {
                filter = new Filter {
                    ArtistId = artistId
                }
            }
            ;

            if (albumId != null)
            {
                filter = new Filter {
                    AlbumId = albumId
                }
            }
            ;

            if (genreId != null)
            {
                filter = new Filter {
                    GenreId = genreId
                }
            }
            ;

            var method = new ParameteredMethodMessage <FilteredPropertiesParameters>
            {
                Method     = methodName,
                Parameters = new FilteredPropertiesParameters
                {
                    Filter     = filter,
                    Properties = properties,
                    Limits     = new ListLimits {
                        Start = start, End = end
                    },
                    Sort = new ListSort
                    {
                        IgnoreArticle = ignorearticle,
                        Order         = sortOrder.ToString().ToLowerInvariant(),
                        Method        = sortMethod.ToString().ToLowerInvariant()
                    }
                }
            };

            var result = await _request.SendRequestAsync <BasicResponseMessage <T> >(method);

            return(result.Result);
        }
 /// <summary>
 /// Creates an instance of the ImapMailboxMessageComparer class.
 /// </summary>
 /// <param name="Sort">The property to sort on.</param>
 /// <param name="Order">The direction of the sort.</param>
 public ImapMailboxMessageComparer(SortBy Sort, SortMethod Order)
 {
     _sort  = Sort;
     _order = Order;
 }
        void drawSystemList(DebugSystems systems)
        {
            EntitasEditorLayout.BeginVerticalBox();
            {
                EntitasEditorLayout.BeginHorizontal();
                {
                    DebugSystems.avgResetInterval = (AvgResetInterval)EditorGUILayout.EnumPopup("Reset average duration Ø", DebugSystems.avgResetInterval);
                    if (GUILayout.Button("Reset Ø now", GUILayout.Width(88), GUILayout.Height(14))) {
                        systems.ResetDurations();
                    }
                }
                EntitasEditorLayout.EndHorizontal();

                _threshold = EditorGUILayout.Slider("Threshold Ø ms", _threshold, 0f, 33f);
                _systemSortMethod = (SortMethod)EditorGUILayout.EnumPopup("Sort by ", _systemSortMethod);
                _hideEmptySystems = EditorGUILayout.Toggle("Hide empty systems", _hideEmptySystems);
                EditorGUILayout.Space();

                EntitasEditorLayout.BeginHorizontal();
                {
                    _systemNameSearchTerm = EditorGUILayout.TextField("Search", _systemNameSearchTerm);

                    const string clearButtonControlName = "Clear Button";
                    GUI.SetNextControlName(clearButtonControlName);
                    if (GUILayout.Button("x", GUILayout.Width(19), GUILayout.Height(14))) {
                        _systemNameSearchTerm = string.Empty;
                        GUI.FocusControl(clearButtonControlName);
                    }
                }
                EntitasEditorLayout.EndHorizontal();

                _showInitializeSystems = EditorGUILayout.Foldout(_showInitializeSystems, "Initialize Systems");
                if (_showInitializeSystems && shouldShowSystems(systems, true)) {
                    EntitasEditorLayout.BeginVerticalBox();
                    {
                        var systemsDrawn = drawSystemInfos(systems, true, false);
                        if (systemsDrawn == 0) {
                            EditorGUILayout.LabelField(string.Empty);
                        }
                    }
                    EntitasEditorLayout.EndVertical();
                }

                _showExecuteSystems = EditorGUILayout.Foldout(_showExecuteSystems, "Execute Systems");
                if (_showExecuteSystems && shouldShowSystems(systems, false)) {
                    EntitasEditorLayout.BeginVerticalBox();
                    {
                        var systemsDrawn = drawSystemInfos(systems, false, false);
                        if (systemsDrawn == 0) {
                            EditorGUILayout.LabelField(string.Empty);
                        }
                    }
                    EntitasEditorLayout.EndVertical();
                }
            }
            EntitasEditorLayout.EndVertical();
        }
예제 #44
0
 /// <summary>
 /// Sort items in the inventory according to a specific method.
 /// </summary>
 /// <param name="method">The method to sort items by</param>
 public void Sort(SortMethod method)
 {
     Item[] NewItems = new Item[0];
     Array.Copy(this.Items, NewItems, this.Items.Length);
     throw new NotImplementedException("Item sorting not implemented yet");
 }
예제 #45
0
        public ActiveExperts SortListBy(SortBy sortBy, SortMethod sortMethod)
        {
            if (sortMethod == SortMethod.Ascending)
            {
                switch (sortBy)
                {
                case SortBy.OrcaUserID:
                    //Experts.Sort((y, x) => x.OrcaUserID.CompareTo(y.OrcaUserID));
                    Experts = Experts.OrderBy(x => x.OrcaUserID).ToList();
                    break;

                case SortBy.OrcaUserName:
                    //Experts.Sort((y, x) => x.OrcaUserName.CompareTo(y.OrcaUserName));
                    Experts = Experts.OrderBy(x => x.OrcaUserName).ToList();
                    break;

                case SortBy.FirstName:
                    //Experts.Sort((y, x) => x.FirstName.CompareTo(y.FirstName));
                    Experts = Experts.OrderBy(x => x.FirstName).ToList();
                    break;

                case SortBy.LastName:
                    //Experts.Sort((y, x) => x.LastName.CompareTo(y.LastName));
                    Experts = Experts.OrderBy(x => x.LastName).ToList();
                    break;

                case SortBy.TitleDegree:
                    //Experts.Sort((y, x) => x.TitleDegree.CompareTo(y.TitleDegree));
                    Experts = Experts.OrderBy(x => x.TitleDegree).ToList();
                    break;

                case SortBy.FieldOfExpertise:
                    //Experts.Sort((y, x) => x.FieldOfExpertise.CompareTo(y.FieldOfExpertise));
                    Experts = Experts.OrderBy(x => x.FieldOfExpertise).ToList();
                    break;

                default:
                    //Experts.Sort((y, x) => x.FieldOfExpertise.CompareTo(y.FieldOfExpertise));
                    Experts = Experts.OrderBy(x => x.FieldOfExpertise).ToList();
                    break;
                }
            }
            else
            {
                switch (sortBy)
                {
                case SortBy.OrcaUserID:
                    //Experts.Sort((y, x) => x.OrcaUserID.CompareTo(y.OrcaUserID));
                    Experts = Experts.OrderByDescending(x => x.OrcaUserID).ToList();
                    break;

                case SortBy.OrcaUserName:
                    //Experts.Sort((y, x) => x.OrcaUserName.CompareTo(y.OrcaUserName));
                    Experts = Experts.OrderByDescending(x => x.OrcaUserName).ToList();
                    break;

                case SortBy.FirstName:
                    //Experts.Sort((y, x) => x.FirstName.CompareTo(y.FirstName));
                    Experts = Experts.OrderByDescending(x => x.FirstName).ToList();
                    break;

                case SortBy.LastName:
                    //Experts.Sort((y, x) => x.LastName.CompareTo(y.LastName));
                    Experts = Experts.OrderByDescending(x => x.LastName).ToList();
                    break;

                case SortBy.TitleDegree:
                    //Experts.Sort((y, x) => x.TitleDegree.CompareTo(y.TitleDegree));
                    Experts = Experts.OrderByDescending(x => x.TitleDegree).ToList();
                    break;

                case SortBy.FieldOfExpertise:
                    //Experts.Sort((y, x) => x.FieldOfExpertise.CompareTo(y.FieldOfExpertise));
                    Experts = Experts.OrderByDescending(x => x.FieldOfExpertise).ToList();
                    break;

                default:
                    //Experts.Sort((y, x) => x.FieldOfExpertise.CompareTo(y.FieldOfExpertise));
                    Experts = Experts.OrderByDescending(x => x.FieldOfExpertise).ToList();
                    break;
                }
            }

            return(this);
        }
예제 #46
0
 public PlayListItemComparer(SortMethod sortBy)
 {
     _SortBy = sortBy;
 }
예제 #47
0
 public MusicSort(SortMethod method, bool ascending)
 {
     currentSortMethod = method;
     sortAscending     = ascending;
 }
예제 #48
0
        public int Compare(GUIListItem item1, GUIListItem item2)
        {
            if (item1 == item2)
            {
                return(0);
            }
            if (item1 == null)
            {
                return(-1);
            }
            if (item2 == null)
            {
                return(-1);
            }
            if (item1.IsFolder && item1.Label == "..")
            {
                return(-1);
            }
            if (item2.IsFolder && item2.Label == "..")
            {
                return(1);
            }
            if (item1.IsFolder && !item2.IsFolder)
            {
                return(-1);
            }
            else if (!item1.IsFolder && item2.IsFolder)
            {
                return(1);
            }

            MusicTag tag1 = (MusicTag)item1.MusicTag;
            MusicTag tag2 = (MusicTag)item2.MusicTag;

            string strSize1        = "";
            string strSize2        = "";
            string strAlbum1       = "";
            string strAlbum2       = "";
            string strAlbumArtist1 = "";
            string strAlbumArtist2 = "";
            string strArtist1      = "";
            string strArtist2      = "";
            int    iDisc1          = 0;
            int    iDisc2          = 0;
            int    iTrack1         = 0;
            int    iTrack2         = 0;
            int    iRating1        = 0;
            int    iRating2        = 0;
            int    iDuration1      = 0;
            int    iDuration2      = 0;
            int    iTimesPlayed1   = 0;
            int    iTimesPlayed2   = 0;

            if (item1.FileInfo != null)
            {
                strSize1 = Util.Utils.GetSize(item1.FileInfo.Length);
            }
            if (item2.FileInfo != null)
            {
                strSize2 = Util.Utils.GetSize(item2.FileInfo.Length);
            }

            SortMethod method     = currentSortMethod;
            bool       bAscending = sortAscending;

            switch (method)
            {
            case SortMethod.Name:
                if (bAscending)
                {
                    return(Util.StringLogicalComparer.Compare(item1.Label, item2.Label));
                }
                else
                {
                    return(Util.StringLogicalComparer.Compare(item2.Label, item1.Label));
                }


            case SortMethod.Date:
                if (item1.FileInfo == null || item2.FileInfo == null)
                {
                    // We didn't get a FileInfo. So it's a DB View and we sort on Date Added from DB
                    DateTime time1 = DateTime.MinValue;
                    DateTime time2 = DateTime.MinValue;
                    if (tag1 != null)
                    {
                        time1 = tag1.DateTimeModified;
                    }
                    if (tag2 != null)
                    {
                        time2 = tag2.DateTimeModified;
                    }

                    if (bAscending)
                    {
                        return(DateTime.Compare(time1, time2));
                    }
                    else
                    {
                        return(DateTime.Compare(time2, time1));
                    }
                }
                else
                {
                    // Do sorting on File Date. Needed for Shares View
                    if (bAscending)
                    {
                        return(DateTime.Compare(item1.FileInfo.CreationTime, item2.FileInfo.CreationTime));
                    }
                    else
                    {
                        return(DateTime.Compare(item2.FileInfo.CreationTime, item1.FileInfo.CreationTime));
                    }
                }

            case SortMethod.Year:
                // When sorting on Year, we need to take also the Label into account and sort on that as well
                string compVal1 = item1.Year.ToString() + item1.Label;
                string compVal2 = item2.Year.ToString() + item2.Label;
                if (bAscending)
                {
                    if (item1.Year == item2.Year)
                    {
                        // When the Year is equal just sort on the Label
                        return(Util.StringLogicalComparer.Compare(item1.Label, item2.Label));
                    }
                    return(Util.StringLogicalComparer.Compare(compVal1, compVal2));
                }
                else
                {
                    if (item1.Year == item2.Year)
                    {
                        // When the Year is equal, sort on label ASCENDING, altough sorting on year is DESC
                        return(Util.StringLogicalComparer.Compare(item1.Label, item2.Label));
                    }
                    return(Util.StringLogicalComparer.Compare(compVal2, compVal1));
                }

            case SortMethod.Rating:
                if (tag1 != null)
                {
                    iRating1 = tag1.Rating;
                }
                if (tag2 != null)
                {
                    iRating2 = tag2.Rating;
                }
                if (bAscending)
                {
                    return((int)(iRating1 - iRating2));
                }
                else
                {
                    return((int)(iRating2 - iRating1));
                }

            case SortMethod.Size:
                if (item1.FileInfo == null)
                {
                    return(-1);
                }
                if (item2.FileInfo == null)
                {
                    return(-1);
                }
                if (bAscending)
                {
                    long compare = (item1.FileInfo.Length - item2.FileInfo.Length);
                    return(compare == 0 ? 0 : compare < 0 ? -1 : 1);
                }
                else
                {
                    long compare = (item2.FileInfo.Length - item1.FileInfo.Length);
                    return(compare == 0 ? 0 : compare < 0 ? -1 : 1);
                }

            case SortMethod.Track:
                if (tag1 != null)
                {
                    iTrack1 = tag1.Track;
                    iDisc1  = tag1.DiscID;
                }
                if (tag2 != null)
                {
                    iTrack2 = tag2.Track;
                    iDisc2  = tag2.DiscID;
                }
                if (bAscending)
                {
                    if (iDisc1 != iDisc2)
                    {
                        return(iDisc1.CompareTo(iDisc2));
                    }
                    else
                    {
                        return(iTrack1.CompareTo(iTrack2));
                    }
                }
                else
                {
                    if (iDisc1 != iDisc2)
                    {
                        return(iDisc2.CompareTo(iDisc1));
                    }
                    else
                    {
                        return(iTrack2.CompareTo(iTrack1));
                    }
                }

            case SortMethod.Duration:
                if (tag1 != null)
                {
                    iDuration1 = tag1.Duration;
                }
                if (tag2 != null)
                {
                    iDuration2 = tag2.Duration;
                }
                if (bAscending)
                {
                    return((int)(iDuration1 - iDuration2));
                }
                else
                {
                    return((int)(iDuration2 - iDuration1));
                }

            case SortMethod.Title:
                string strTitle1 = item1.Label;
                string strTitle2 = item2.Label;
                if (tag1 != null)
                {
                    strTitle1 = tag1.Title;
                }
                if (tag2 != null)
                {
                    strTitle2 = tag2.Title;
                }
                if (bAscending)
                {
                    return(Util.StringLogicalComparer.Compare(strTitle1, strTitle2));
                }
                else
                {
                    return(Util.StringLogicalComparer.Compare(strTitle2, strTitle1));
                }

            case SortMethod.Artist:
                if (tag1 != null)
                {
                    strArtist1 = tag1.Artist;
                }
                if (tag2 != null)
                {
                    strArtist2 = tag2.Artist;
                }
                if (bAscending)
                {
                    return(Util.StringLogicalComparer.Compare(strArtist1, strArtist2));
                }
                else
                {
                    return(Util.StringLogicalComparer.Compare(strArtist2, strArtist1));
                }

            case SortMethod.AlbumArtist:
                // sort by AlbumArtist => Album
                if (tag1 != null)
                {
                    strAlbumArtist1 = tag1.AlbumArtist + " - " + tag1.Album;
                }
                if (tag2 != null)
                {
                    strAlbumArtist2 = tag2.AlbumArtist + " - " + tag2.Album;
                }
                if (bAscending)
                {
                    return(Util.StringLogicalComparer.Compare(strAlbumArtist1, strAlbumArtist2));
                }
                else
                {
                    return(Util.StringLogicalComparer.Compare(strAlbumArtist2, strAlbumArtist1));
                }

            case SortMethod.Album:
            case SortMethod.DiscID:
                //sort by album => album artist => disc# => track
                if (tag1 != null)
                {
                    strAlbum1       = tag1.Album;
                    strAlbumArtist1 = tag1.AlbumArtist;
                    iDisc1          = tag1.DiscID;
                    iTrack1         = tag1.Track;
                }
                if (tag2 != null)
                {
                    strAlbum2       = tag2.Album;
                    strAlbumArtist2 = tag2.AlbumArtist;
                    iDisc2          = tag2.DiscID;
                    iTrack2         = tag2.Track;
                }
                if (bAscending)
                {
                    if (strAlbum1 == strAlbum2)
                    {
                        if (strAlbumArtist1 == strAlbumArtist2)
                        {
                            if (iDisc1 == iDisc2)
                            {
                                return(iTrack1 - iTrack2);
                            }
                            else
                            {
                                return(iDisc1 - iDisc2);
                            }
                        }
                        else
                        {
                            return(Util.StringLogicalComparer.Compare(strAlbumArtist1, strAlbumArtist2));
                        }
                    }
                    else
                    {
                        return(Util.StringLogicalComparer.Compare(strAlbum1, strAlbum2));
                    }
                }
                else
                {
                    if (strAlbum1 == strAlbum2)
                    {
                        if (strAlbumArtist1 == strAlbumArtist2)
                        {
                            if (iDisc1 == iDisc2)
                            {
                                return(iTrack2 - iTrack1);
                            }
                            else
                            {
                                return(iDisc2 - iDisc1);
                            }
                        }
                        else
                        {
                            return(Util.StringLogicalComparer.Compare(strAlbumArtist2, strAlbumArtist1));
                        }
                    }
                    else
                    {
                        return(Util.StringLogicalComparer.Compare(strAlbum2, strAlbum1));
                    }
                }


            case SortMethod.Filename:
                string strFile1 = Util.Utils.GetFilename(item1.Path);
                string strFile2 = Util.Utils.GetFilename(item2.Path);
                if (bAscending)
                {
                    return(Util.StringLogicalComparer.Compare(strFile1, strFile2));
                }
                else
                {
                    return(Util.StringLogicalComparer.Compare(strFile2, strFile1));
                }

            case SortMethod.Composer:
                string strComposer1 = "";
                string strComposer2 = "";
                if (tag1 != null)
                {
                    strComposer1 = tag1.Composer;
                }
                if (tag2 != null)
                {
                    strComposer2 = tag2.Composer;
                }

                if (bAscending)
                {
                    return(Util.StringLogicalComparer.Compare(strComposer1, strComposer2));
                }
                else
                {
                    return(Util.StringLogicalComparer.Compare(strComposer2, strComposer1));
                }

            case SortMethod.TimesPlayed:
                if (tag1 != null)
                {
                    iTimesPlayed1 = tag1.TimesPlayed;
                }
                if (tag2 != null)
                {
                    iTimesPlayed2 = tag2.TimesPlayed;
                }

                if (bAscending)
                {
                    return(iTimesPlayed1.CompareTo(iTimesPlayed2));
                }
                else
                {
                    return(iTimesPlayed2.CompareTo(iTimesPlayed1));
                }

            case SortMethod.FileType:
                // sort by FileType => Album
                string strFileType1 = "";
                string strFileType2 = "";

                if (tag1 != null)
                {
                    strFileType1 = tag1.FileType + " - " + tag1.Album;
                }
                if (tag2 != null)
                {
                    strFileType2 = tag2.FileType + " - " + tag2.Album;
                }

                if (bAscending)
                {
                    return(Util.StringLogicalComparer.Compare(strFileType1, strFileType2));
                }
                else
                {
                    return(Util.StringLogicalComparer.Compare(strFileType2, strFileType1));
                }
            }
            return(0);
        }
예제 #49
0
 /// <summary>
 /// Obtains a sorted collection of messages from a mailbox.
 /// </summary>
 /// <param name="sort">A value of type SortMethod.</param>
 /// <param name="order">A value of type SortOrder that specifies ascending or descending.</param>
 /// <param name="records">An interger value containing the number of messages to return.</param>
 /// <param name="page">An integer value representing the page to display.</param>
 /// <returns>Returns a ImapMailbox object containing the messages.</returns>
 public ImapMailbox Sort(SortMethod sort, SortOrder order, int records, int page)
 {
     if (!(Connection.ConnectionState == ConnectionState.Open))
         NoOpenConnection();
     Connection.Write(string.Format("SORT ({0}{1}) US-ASCII ALL\r\n", OrderToString(order), SortToString(sort)));
     string response = Connection.Read();
     if (response.StartsWith("*"))
     {
         Connection.Read();
         MatchCollection matches = Regex.Matches(response, @"\d+");
         if (matches.Count > 0)
         {
             int[] ids;
             if ((page + 1) * records > matches.Count)
             {
                 page = matches.Count / records;
                 ids = new int[matches.Count % records];
             }
             else
                 ids = new int[records];
             for (int i = page * records; i < matches.Count && i < (page + 1) * records; i++)
                 ids[i - page * records] = Convert.ToInt16(matches[i].Value);
             return Fetch(ids);
         }
     }
     return new ImapMailbox();
 }