public AssemblyInfo(Assembly assembly, Grid grid) { this.assembly = assembly; this.grid = grid; listBoxMain = (ListBox)grid.FindName("listBoxMain"); typeNow = TypeOfList.Types; }
void GetInterfaces(Type type) { if (type != null) { listBoxMain.ItemsSource = type.GetInterfaces(); typeNow = TypeOfList.Interfaces; } }
void GetConstructors(TypeInfo typeInfo) { if (typeInfo != null) { listBoxMain.ItemsSource = typeInfo.GetConstructors(); typeNow = TypeOfList.Constructors; } }
void GetProperties(TypeInfo typeInfo) { if (typeInfo != null) { listBoxMain.ItemsSource = typeInfo.GetProperties(); typeNow = TypeOfList.Properties; } }
void GetFields(TypeInfo typeInfo) { if (typeInfo != null) { listBoxMain.ItemsSource = typeInfo.GetFields(); typeNow = TypeOfList.Fields; } }
/// <summary> /// Updates the CURRENT ITEMS LIST, /// handles the opening or the closing of the autocompletion form on key input, /// it is only called when the user adds or delete a char /// </summary> public static void UpdateAutocompletion() { if (!Config.Instance.AutoCompleteOnKeyInputShowSuggestions && !_openedFromShortCut) return; // dont show in string/comments..? if (!_openedFromShortCut && !IsVisible && !Config.Instance.AutoCompleteShowInCommentsAndStrings && !Style.IsCarretInNormalContext(Npp.CurrentPosition)) return; // get current word, current previous word (table or database name) int nbPoints; string previousWord = ""; var strOnLeft = Npp.GetTextOnLeftOfPos(Npp.CurrentPosition); var keyword = Abl.ReadAblWord(strOnLeft, false, out nbPoints); var splitted = keyword.Split('.'); string lastCharBeforeWord = ""; switch (nbPoints) { case 0: int startPos = strOnLeft.Length - 1 - keyword.Length; lastCharBeforeWord = startPos >= 0 ? strOnLeft.Substring(startPos, 1) : String.Empty; break; case 1: previousWord = splitted[0]; keyword = splitted[1]; break; case 2: previousWord = splitted[1]; keyword = splitted[2]; break; default: keyword = splitted[nbPoints]; break; } // list of fields or tables if (!string.IsNullOrEmpty(previousWord)) { // are we entering a field from a known table? var foundTable = ParserHandler.FindAnyTableOrBufferByName(previousWord); if (foundTable != null) { if (CurrentTypeOfList != TypeOfList.Fields) { CurrentTypeOfList = TypeOfList.Fields; SetCurrentItems(DataBase.GetFieldsList(foundTable).ToList()); } ShowSuggestionList(keyword); return; } // are we entering a table from a connected database? var foundDatabase = DataBase.FindDatabaseByName(previousWord); if (foundDatabase != null) { if (CurrentTypeOfList != TypeOfList.Tables) { CurrentTypeOfList = TypeOfList.Tables; SetCurrentItems(DataBase.GetTablesList(foundDatabase).ToList()); } ShowSuggestionList(keyword); return; } } // close if there is nothing to suggest if ((!_openedFromShortCut || _openedFromShortCutPosition != Npp.CurrentPosition) && (String.IsNullOrEmpty(keyword) || keyword != null && keyword.Length < Config.Instance.AutoCompleteStartShowingListAfterXChar)) { Close(); return; } // if the current is directly preceded by a :, we are entering an object field/method if (lastCharBeforeWord.Equals(":")) { if (CurrentTypeOfList != TypeOfList.KeywordObject) { CurrentTypeOfList = TypeOfList.KeywordObject; SetCurrentItems(SavedAllItems); } ShowSuggestionList(keyword); return; } // show normal complete list if (CurrentTypeOfList != TypeOfList.Complete) { CurrentTypeOfList = TypeOfList.Complete; SetCurrentItems(SavedAllItems); } ShowSuggestionList(keyword); }
/// <summary> /// Method called when the event OnParseEnded triggers, i.e. when we just parsed the document and /// need to refresh the autocompletion /// </summary> public static void RefreshDynamicItems() { if (_itemsListLock.TryEnterWriteLock(-1)) { try { // init with static items _savedAllItems.Clear(); _savedAllItems = _staticItems.ToList(); // we add the dynamic items to the list _savedAllItems.AddRange(ParserHandler.ParserVisitor.ParsedCompletionItemsList.ToList()); } finally { _itemsListLock.ExitWriteLock(); } } // update the autocompletion (if shown) CurrentTypeOfList = TypeOfList.Reset; if (IsVisible) UpdateAutocompletion(); }
// Creating List Of Products 02 protected ArrayList CreatingListOfProducts02( DataTable ListOfProductsForCreating, TypeOfList TypeOfCreatingList) { //Console.WriteLine("CL"); // // Initializing Of List Products // ArrayList ListOfProducts = new ArrayList(); // // Filling Of List Products // foreach (DataRow CurrentProduct in ListOfProductsForCreating.Rows) { if (!(CurrentProduct["Name"] is DBNull) && (CurrentProduct["Name"] != null) && (CurrentProduct["Name"].GetType() == typeof(string))) { if (((string)CurrentProduct["Name"]).Length > 0) { ListOfProducts.Add(new ElementOfSorting(CurrentProduct)); } } } // // Addition Of Symbols Of Marking // string CurrentChar = ""; SortingOfList Sorting = new SortingOfList(); // // Addition Of Marking Of Names // Sorting.TypeOfSorting = "N"; ListOfProducts.Sort(Sorting); // for (int i = 0; i < ListOfProducts.Count; i++) { // string NewChar = ((ElementOfSorting)ListOfProducts[i]).Name[0].ToString(); // if (CurrentChar != NewChar) { // CurrentChar = NewChar; // ListOfProducts.Insert(i, new ElementOfSorting(CurrentChar, "N")); } } // // Addition Of Marking Of MNN // Sorting.TypeOfSorting = "M"; ListOfProducts.Sort(Sorting); // CurrentChar = ""; // for (int i = 0; i < ListOfProducts.Count; i++) { // // !!! // string NewChar = "", MNN = ((ElementOfSorting)ListOfProducts[i]).MNN; if (MNN.Length > 1) { NewChar = MNN[0].ToString(); } // if (CurrentChar != NewChar) { // CurrentChar = NewChar; // ListOfProducts.Insert(i, new ElementOfSorting(CurrentChar, "M")); } } // // Sorting Of List Of Products // Sorting.TypeOfSorting = "N"; ListOfProducts.Sort(Sorting); // // Return // return(ListOfProducts); }
public bool CheckListAndRequest(object sender) { // Initialize clicked button, selected item in the listBox and instance of comparer var button = sender as System.Windows.Controls.Button; var request = button.Content.ToString().Replace("Get ", ""); var requestType = (TypeOfList)Enum.Parse(typeof(TypeOfList), request); var selectedItem = listBoxMain.SelectedItem; var startItemSource = listBoxMain.ItemsSource; var comparer = new ItemSourceComparer(); // Check typeNow to determine what kind of list is in listBox now. switch (typeNow) { // Then check type of request (get types, get methods, etc) case TypeOfList.Types: switch (requestType) { case TypeOfList.Types: listBoxMain.ItemsSource = assembly.GetTypes(); typeNow = TypeOfList.Types; break; case TypeOfList.Methods: GetMethods(selectedItem as TypeInfo); break; case TypeOfList.Fields: GetFields(selectedItem as TypeInfo); break; case TypeOfList.Properties: GetProperties(selectedItem as TypeInfo); break; case TypeOfList.Constructors: GetConstructors(selectedItem as TypeInfo); break; case TypeOfList.Interfaces: GetInterfaces(selectedItem as Type); break; } break; case TypeOfList.Methods: switch (requestType) { case TypeOfList.Types: listBoxMain.ItemsSource = assembly.GetTypes(); typeNow = TypeOfList.Types; break; } break; case TypeOfList.Fields: switch (requestType) { case TypeOfList.Types: listBoxMain.ItemsSource = assembly.GetTypes(); typeNow = TypeOfList.Types; break; } break; case TypeOfList.Properties: switch (requestType) { case TypeOfList.Types: listBoxMain.ItemsSource = assembly.GetTypes(); typeNow = TypeOfList.Types; break; } break; case TypeOfList.Constructors: switch (requestType) { case TypeOfList.Types: listBoxMain.ItemsSource = assembly.GetTypes(); typeNow = TypeOfList.Types; break; } break; case TypeOfList.Interfaces: switch (requestType) { case TypeOfList.Types: listBoxMain.ItemsSource = assembly.GetTypes(); typeNow = TypeOfList.Types; break; case TypeOfList.Methods: GetMethods(selectedItem as TypeInfo); break; case TypeOfList.Fields: GetFields(selectedItem as TypeInfo); break; case TypeOfList.Properties: GetProperties(selectedItem as TypeInfo); break; case TypeOfList.Constructors: GetConstructors(selectedItem as TypeInfo); break; } break; } // In start of program startItemSource will initialized with null. In this case true will returned //if (startItemSource == null) //{ // return true; //} // In case when nothing was changed in ItemSource (it equal startItemSource), it no need to be backed up. False will returned. return(!comparer.Equals(startItemSource, listBoxMain.ItemsSource)); }
public void Back(IEnumerable itemSource, TypeOfList type) { typeNow = type; listBoxMain.ItemsSource = itemSource; }
void GetTypes() { listBoxMain.ItemsSource = assembly.GetTypes(); typeNow = TypeOfList.Types; }