void CreateOrderConflict(ListBoxData item, ListBoxData dep)
        {
            item.TitleBlock.Foreground = System.Windows.Media.Brushes.Red;

            var text = string.Format("\"{0}\" must be after \"{1}\" because it's listed as a dependency.", item.Info.Query.Name, dep.Info.Query.Name);

            CreateConflictToolTip(item, text);
        }
        void CreateStatusConflict(ListBoxData item, ListBoxData dep)
        {
            item.TitleBlock.Foreground = System.Windows.Media.Brushes.Red;

            var text = string.Format("\"{0}\" has \"{1}\" listed as a dependency but it's not enabled.", item.Info.Query.Name, dep.Info.Query.Name);

            CreateConflictToolTip(item, text);
        }
        void CreateExistanceConflict(ListBoxData item, string dep)
        {
            item.TitleBlock.Foreground = System.Windows.Media.Brushes.Red;

            var text = string.Format("\"{0}\" has \"{1}\" listed as a dependency but it doesn't exist.", item.Info.Query.Name, dep);

            CreateConflictToolTip(item, text);
        }
        void CreateConflictToolTip(ListBoxData item, string text)
        {
            if (item.BoxItem.ToolTip == null)
            {
                item.BoxItem.ToolTip = "";
            }

            else
            {
                item.BoxItem.ToolTip += "\n";
            }

            item.BoxItem.ToolTip += text;
        }
        void LoadExtensionsFromPath(string path, bool enabled)
        {
            var exts = SDR.ExtensionLoader.LoadAll(path);

            foreach (var item in exts)
            {
                var data = new ListBoxData();
                data.Info    = item;
                data.Enabled = enabled;

                SDR.QueryData.FillNullStrings(ref data.Info.Query);

                Extensions.Add(data);
            }
        }
示例#6
0
        List <ListBoxData> Searcher(int Dir, int File, string NewDirectory)
        {
            currentDir = NewDirectory;
            var data = new List <ListBoxData>();

            if (Dir == 1)
            {
                string[] dir = Directory.GetDirectories(NewDirectory);

                foreach (var filePath in dir)
                {
                    var itm = new ListBoxData()
                    {
                        ItemIcon = FolderIcon(), ItemText = System.IO.Path.GetFileName(filePath), ItemPath = filePath, ItemType = "Dir"
                    };
                    data.Add(itm);
                }
            }

            if (File == 1)
            {
                string[] file = Directory.GetFiles(NewDirectory);
                foreach (var filePath in file)
                {
                    var sysicon = System.Drawing.Icon.ExtractAssociatedIcon(filePath);
                    var bmpSrc  = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
                        sysicon.Handle,
                        System.Windows.Int32Rect.Empty,
                        System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
                    sysicon.Dispose();

                    var itm = new ListBoxData()
                    {
                        ItemIcon = bmpSrc, ItemText = System.IO.Path.GetFileName(filePath), ItemPath = filePath, ItemType = "File"
                    };
                    data.Add(itm);
                }
            }
            return(data);
        }
        private void SortStarredWordList()
        {
            int orderByIndex = ListPicker_OrderBy.SelectedIndex;
            int ascOrDescIndex = ListPicker_AscOrDesc.SelectedIndex;
            int cardType = ListPicker_CardType.SelectedIndex + 1;

            List<ListBoxData> orderedList = null;
            if (orderByIndex == 0) // order by add time
            {
                if (ascOrDescIndex == 0)        // ascending
                {
                    orderedList = new List<ListBoxData>(starredWordList.OrderBy(data => data.AddTime));
                }
                else if (ascOrDescIndex == 1)   // descending
                {
                    orderedList = new List<ListBoxData>(starredWordList.OrderByDescending(data => data.AddTime));
                }
                else
                {
                    return;
                }
            }
            else if (orderByIndex == 1) // order by alphabet
            {
                if (ascOrDescIndex == 0)        // ascending
                {
                    orderedList = new List<ListBoxData>(starredWordList.OrderBy(data => data.Word.word));
                }
                else if (ascOrDescIndex == 1)   // descending
                {
                    orderedList = new List<ListBoxData>(starredWordList.OrderByDescending(data => data.Word.word));
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }


            starredWordList = new ObservableCollection<ListBoxData>();
            for (int i = 0; i < orderedList.Count; i++)
            {
                ListBoxData data = new ListBoxData
                {
                    SourceId = orderedList[i].SourceId,
                    SourceTitle = orderedList[i].SourceTitle,
                    WordId = orderedList[i].WordId,
                    Word = orderedList[i].Word,
                    WordCard = null,
                    AddTime = orderedList[i].AddTime,
                    AddTimeString = orderedList[i].AddTimeString
                };
                switch (cardType)
                {
                    case 1:
                        data.WordCard = UserControlHelper.GenerateOneSideWordCard(data.Word, 0.9, 0.9);
                        break;
                    case 2:
                        data.WordCard = UserControlHelper.GenerateTwoSideWordCard(data.Word, true, 0.9, 0.9);
                        break;
                    case 3:
                        data.WordCard = UserControlHelper.GenerateTwoSideWordCard(data.Word, false, 0.9, 0.9);
                        break;
                }
                starredWordList.Add(data);
            }
            ListBox_StarredWord.ItemsSource = starredWordList;
            
        }
 private void ReadDataFromDB()
 {
     List<StarredWordItem> starredWordItemList = StarredWordOperations.GetListDescByAddTime();
     for (int i = 0; i < starredWordItemList.Count; i++)
     {
         List<WordSource> wordSourceList = (Application.Current as App).wordSourceList;
         WordSource wordSource = WordSourceHelper.GetWordSourceById(wordSourceList, starredWordItemList[i].WordSourceId);
         if (wordSource != null)
         {
             Word word = WordFileHelper.GetWordById(wordSourceList, wordSource.sourceId, starredWordItemList[i].WordIdOfWordSource);
             if (word != null)
             {
                 ListBoxData data = new ListBoxData
                 {
                     SourceId = wordSource.sourceId,
                     SourceTitle = wordSource.title,
                     WordId = word.wordId,
                     Word = word,
                     WordCard = null,
                     AddTime = starredWordItemList[i].AddTime,
                     AddTimeString = starredWordItemList[i].AddTime.ToString()
                 };
                 starredWordList.Add(data);
             }
         }
     }
 }
        public TerminalDropdown() : base(MenuControls.DropdownControl)
        {
            var listData = GetOrSetMember(null, (int)ListControlAccessors.ListAccessors) as ApiMemberAccessor;

            List = new ListBoxData <T>(listData);
        }