public void SetTreeNodes() { Tree.Nodes = nodes; nodes.BeginUpdate(); var test_item = new TreeViewItem("added"); var test_node = new TreeNode <TreeViewItem>(test_item); nodes.Add(test_node); nodes[1].IsVisible = false; nodes[2].Nodes[1].IsVisible = false; nodes.EndUpdate(); }
public bool ChangePosition <T>(ObservableList <TreeNode <T> > nodes, Predicate <TreeNode <T> > match, int position) { var findedNode = nodes.Find(match); if (findedNode != null) { nodes.BeginUpdate(); nodes.Remove(findedNode); nodes.Insert(position, findedNode); nodes.EndUpdate(); return(true); } foreach (var node in nodes) { if (node.Nodes == null) { continue; } if (ChangePosition(node.Nodes as ObservableList <TreeNode <T> >, match, position)) { return(true); } } return(false); }
public void PopulateBeginEndMaximum([Values(256, 512, 1024, 2048)] int maximum) { //**************************************** var MySeed = Environment.TickCount; var MyRandom = new Random(MySeed); var MyRecords = new ObservableList <int>(1024); //**************************************** var MyView = new ObservableListView <int>(MyRecords, maximum); MyRecords.BeginUpdate(); for (int Index = 0; Index < 1024; Index++) { MyRecords.Add(MyRandom.Next(short.MaxValue)); } MyRecords.EndUpdate(); //**************************************** var MySortedRecords = MyRecords.ToArray(); Array.Sort(MySortedRecords); if (MySortedRecords.Length > maximum) { Array.Resize(ref MySortedRecords, maximum); } CollectionAssert.AreEqual(MySortedRecords, MyView, "Bad Seed was {0}", MySeed); Thread.Sleep(1); }
public void PopulateBeginEndFilter() { //**************************************** var MySeed = Environment.TickCount; var MyRandom = new Random(MySeed); var MyRecords = new ObservableList <int>(1024); //**************************************** var MyView = new ObservableListView <int>(MyRecords, FilterLessThan512); MyRecords.BeginUpdate(); for (int Index = 0; Index < 1024; Index++) { MyRecords.Add(MyRandom.Next(short.MaxValue)); } MyRecords.EndUpdate(); //**************************************** var MySortedRecords = MyRecords.Where(FilterLessThan512).ToArray(); Array.Sort(MySortedRecords); CollectionAssert.AreEqual(MySortedRecords, MyView, "Bad Seed was {0}", MySeed); Thread.Sleep(1); }
/// <summary> /// Toggle nodes state. /// </summary> /// <param name="nodes">Nodes list.</param> /// <param name="isExpanded">Expanded state.</param> public void ToggleNodes(ObservableList <TreeNode <TreeViewItem> > nodes, bool isExpanded) { if ((nodes == null) || (nodes.Count == 0)) { return; } nodes.BeginUpdate(); nodes.ForEach(node => { node.IsExpanded = isExpanded; ToggleNodes(node.Nodes, isExpanded); }); nodes.EndUpdate(); }
/// <summary> /// Load data from url. /// </summary> /// <param name="start">Start index.</param> /// <returns>Coroutine.</returns> protected virtual IEnumerator LoadData(int start) { if (start == 0) { Data.Clear(); } WWW www = new WWW("https://ilih.ru/steamspy/?start=" + start.ToString()); yield return(www); var lines = www.text.Split('\n'); www.Dispose(); Data.BeginUpdate(); lines.ForEach(ParseLine); Data.EndUpdate(); }
/// <summary> /// Load data from url. /// </summary> /// <param name="start">Start index.</param> /// <returns>Coroutine.</returns> protected virtual IEnumerator LoadData(int start) { if (start == 0) { Data.Clear(); } var lines = new string[] { }; var url = "https://ilih.ru/steamspy/?start=" + start.ToString(); #if UNITY_2018_3_OR_NEWER using (var www = UnityEngine.Networking.UnityWebRequest.Get(url)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { lines = www.downloadHandler.text.Split('\n'); } } #else WWW www = new WWW(url); yield return(www); lines = www.text.Split('\n'); www.Dispose(); #endif Data.BeginUpdate(); lines.ForEach(ParseLine); Data.EndUpdate(); }
public void SortAsc() { nodes.BeginUpdate(); ApplyNodesSort(nodes, comparisonAsc); nodes.EndUpdate(); }