// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElements() { if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); _build(); } int IndexToRemove; int NumberToAdd; List <int> RemovedIndexes = new List <int>(); for (int i = 0; i < ElementNumber;) { IndexToRemove = Random.Next(0, SetSize - (1 + RemovedIndexes.Count)); if (RemovedIndexes.IndexOf(IndexToRemove) == -1) { NumberToAdd = NumberList[IndexToRemove]; ElementList.Add(NumberToAdd); NumberList.RemoveAt(IndexToRemove); RemovedIndexes.Add(IndexToRemove); i++; } } ElementList.Sort(); }
/// <summary> /// Loads the preambles file /// </summary> public void LoadPreambles(string PreamblesFile) { ElementList.Clear(); try { if (File.Exists(PreamblesFile)) { XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(List <DynPreambleElement>)); using (TextReader tr = new StreamReader(PreamblesFile)) { List <DynPreambleElement> l = serializer.Deserialize(tr) as List <DynPreambleElement>; if (l != null) { foreach (var model in l) { ElementList.Add(new DynPreambleElementVM(model)); } // register property change handlers foreach (var vm in ElementList) { vm.PropertyChanged += (o, e) => NotifyPropertyChanged("Preamble"); } } } } } catch (Exception) { } }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElements() { if (ElementList.Count > 0) { //ElementList and NumberList call their clear method: ElementList.Clear(); NumberList.Clear(); //build method is called: this._build(); //6 random numbers are selected from NumberList, they are added to the ElementList and then removed from NumberList: IEnumerable <int> threeRandom = NumberList.OrderBy(x => Random.Next()).Take(this.ElementNumber); foreach (int y in threeRandom) { ElementList.Add(y); } ElementList.Sort(); NumberList.RemoveAll(c => ElementList.ToList().Exists(n => n == c)); } else { //build method is called: this._build(); //6 random numbers are selected from NumberList, they are added to the ElementList and then removed from NumberList: IEnumerable <int> threeRandom = NumberList.OrderBy(x => Random.Next()).Take(ElementNumber); foreach (int y in threeRandom) { ElementList.Add(y); } NumberList.RemoveAll(c => ElementList.ToList().Exists(n => n == c)); } }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // public PickElements method ---------------------------- public void PickElements() { //checking if list is not empty if (ElementList.Count > 0) { //then clear method is called by both the lists ElementList.Clear(); NumberList.Clear(); } //m_build is called to rebuilt the NumberList m_build(); m_random rn = new Random(); //loop is created to generate random numbers for (int randomNumber = 1; randomNumber <= elementNumber; randomNumber++) { // it will select element from ElementList int number = rn.Next(1, ElementList.Count); //Remove the selected element from ElementList ElementList.Remove(number); //Add the element in NumberList NumberList.Add(number); } }
public void PickElements() { int randIndex = -1; int uniqueNum = 0; // If ElementList has element(s) then clear both lists and rebuilt if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); _build(); // rebuild _numberList data } // Loop trhough number of elements need to add for (int i = 0; i < ElementNumber; i++) { // Generate a random index position between 1 to SetSize (inclusive) randIndex = _Random.Next(1, SetSize); uniqueNum = NumberList.ElementAt(randIndex); // Determine its a duplicate number while (ElementList.Contains(uniqueNum)) { // Then again generate number randIndex = _Random.Next(1, SetSize); uniqueNum = NumberList.ElementAt(randIndex); } // If its a unique number then add to element list ElementList.Add(uniqueNum); } // Sort the ElementList ElementList.Sort(); }
/// <summary> /// Deletes all elements efficiently. Calls Dispose() for each element /// </summary> public void DeleteAllElements(Func <Element, bool> keepFilter = null) { releaseMouseDragElement(null); releaseMouseEnteredElement(); m_LastMouseDownElement = null; ElementList kept = null; foreach (var elm in m_ElementList) { if (keepFilter != null && keepFilter(elm)) { if (kept == null) { kept = new ElementList(); } kept.Add(elm); continue; } elm.m_Host = null;//prevent elements from unregistering with host because it is slower than host.list.Clear() elm.Dispose(); } m_ElementList.Clear(); if (kept != null) { m_ElementList = kept; } Invalidate(); }
public void Execute(UIApplication app) { FilteredElementCollector collector = new FilteredElementCollector(RevitDocument, ElementList).WhereElementIsNotElementType(); try { using (Transaction t = new Transaction(RevitDocument)) { t.SetName("DKTools: parameter edition"); t.Start(); foreach (Element el in collector.ToElements()) { el.LookupParameter(ParameterName).Set(ParameterValue); } t.Commit(); } RevitDocument = null; ElementList.Clear(); ParameterName = string.Empty; ParameterValue = string.Empty; } catch (Exception ex) { MessageBox.Show("Exeption from ExternalEventSetParameterValue \r\nExeption message:\r\n" + ex.Message); } }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- /// <summary> /// PickElements method will grantee unique and random numbers are exist in number list /// </summary> public void PickElements() { if (ElementNumber > 0) { ElementList.Clear(); NumberList.Clear(); _build(); int counter = NumberList.Count; for (int i = 0; i < counter; i++) { int selectionPostion = random.Next(0, maxValue: NumberList.Count); int selection = NumberList[selectionPostion]; ElementList.Add(selection); NumberList.RemoveAt(selectionPostion); } } else { _build(); int counter = 0; do { int selectionPostion = random.Next(0, maxValue: NumberList.Count); int selection = NumberList[selectionPostion]; ElementList.Add(selection); NumberList.RemoveAt(selectionPostion); } while (counter < NumberList.Count); } }
/// <summary> /// Очистить представление /// </summary> public override void Clear() { base.Clear(); maxID = 0; SchemeParams.SetToDefault(); ElementList.Clear(); ElementDict.Clear(); ImageDict.Clear(); CnlsFilter.Clear(); }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- /* * build the _elementList with a set of random numbers. */ public void PickElements() { if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); _build(); } for (int i = 0; i < ElementNumber; i++) { int randomPosition = Random.Next(0, NumberList.Count); ElementList.Add(NumberList[randomPosition]); NumberList.RemoveAt(randomPosition); } ElementList.Sort(); }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElements() { if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); _build(); } for (int i = 1; i <= ElementNumber; i++) { int n = _random.Next(1, 50); NumberList.Remove(n); ElementList.Add(n); } ElementList.Sort(); }
/// <summary> /// Deletes all elements efficiently. Calls Dispose() for each element /// </summary> public void DeleteAllElements() { releaseMouseDragElement(null); releaseMouseEnteredElement(); m_LastMouseDownElement = null; foreach (var elm in m_ElementList) { elm.m_Host = null;//prevent elements from unregistering with host because it is slower than host.list.Clear() elm.Dispose(); } m_ElementList.Clear(); Invalidate(); }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElements() { if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); this._build(); } for (int i = 0; i < ElementNumber; i++) { int chance = this.random.Next(0, NumberList.Count); NumberList.Remove(chance); ElementList.Add(chance); } ElementList.Sort(); }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElements() { if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); _build(); } for (int i = 1; i <= ElementNumber; i++) { int r = _random.Next(NumberList.Count); ElementList.Add(NumberList[r]); NumberList.RemoveAt(r); } ElementList.Sort(); }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public void PickElements() { int count = 0; if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); _build(); } do { int selectnumber = _random.Next(_numberList.Count); _elementList.Add(selectnumber); _numberList.RemoveAt(selectnumber); _elementList.Sort(); count++; }while (count <= ElementNumber); }
// PUBLIC METHODS +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+ // CREATING the public PickElements method here -------------------------------------- public void PickElements() { if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); this._build(); } for (int i = 0; i < ElementNumber; i++) { int Number = aa_random.Next(NumberList.Count); ElementList.Add(NumberList[Number]); NumberList.RemoveAt(Number); } ElementList.Sort(); }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElements() { if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); _build(); } for (int i = 0; i < ElementNumber; i++) { int index = random.Next(NumberList.Count); ElementList.Add(NumberList[index]); NumberList.RemoveAt(index); } ElementList.Sort(); }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public void PickElements() { if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); _build(); } int j = 0; while (j < ElementNumber) { int randPosition = _random.Next(NumberList.Count); ElementList.Add(NumberList[randPosition]); NumberList.Remove(NumberList[randPosition]); j++; } ElementList.Sort(); }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElements() { if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); _build(); } for (int i = 0; i < ElementNumber; i++) { int lottery = _random.Next(NumberList.Count); // element list real number, numberlist = how many list you have ElementList.Add(NumberList[lottery]); // Add NumberList.RemoveAt(lottery); // remove above } ElementList.Sort(); }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElement() { /* using if statement to clean previously Element list and Number list, then create * new number list so that the newest Element list can be created through for statement */ if (ElementList.Count > 0) { ElementList.Clear(); NumberList.Clear(); _build(); } for (int i = 1; i <= ElementNumber; i++) { //Select random number between 1 to 49 int randomNumber = random.Next(1, 50); //Remove selected number from Number list to avoid selecting repeated number NumberList.Remove(randomNumber); //Add selected number to Element list ElementList.Add(randomNumber); //Sort element list ordered by ascending ElementList.Sort(); } }
private void Start() { ElementList.Clear(); var message = Resources.Message_BusyIndicator_Title; var result = _BusyWindow.ExecuteAndWait(message, InspectDirectory); if (_BusyWindow.IsSuccessfullyExecuted == true) { ElementList.Add(result); result.IsExpanded = true; RefreshElementsVisibilities(); } else { MessageBox.Show( string.Format(Resources.Message_Error_ParsingDirectoryFailed, _BusyWindow.ExecutionException.Message), Resources.Message_ApplicationTitle, MessageBoxButton.OK, MessageBoxImage.Error); } }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElements() { if (ElementList.Count > 0) { // clear if there is elements in ElementList ElementList.Clear(); NumberList.Clear(); // rebuild NumberList _build(); } // create loop to add number to ElementList & remove number from NumberList for (int i = 1; i <= ElementNumber; i++) { int num = random.Next(NumberList.Count); ElementList.Add(NumberList[num]); NumberList.RemoveAt(num); } // sort ascending order small to large ElementList.Sort(); }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- public void PickElements() { int currentRandom; bool ElementListempty = !ElementList.Any(); bool NumberListempty = !NumberList.Any(); //Checks if both elements assigned with boolean are empty or not if (ElementListempty != true || NumberListempty != true) { //ElementList.Clear() = Empty ElementList.Clear(); NumberList.Clear(); m_build();// will fill the numberList for (int j = 1; j <= ElementNumber; j++) { currentRandom = m_random.Next(1, NumberList.Count); NumberList.Remove(currentRandom); ElementList.Add(currentRandom); } ElementList.Sort();//Sort } }
// PUBLIC METHODS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // CREATE the public PickElements method here ---------------------------- /// <summary> /// pickElements this method generate random numbers. /// after generating remove from numberList and add to elementlist /// </summary> public void PickElements() { int currentRandom; bool ElementListempty = !ElementList.Any(); bool NumberListempty = !NumberList.Any(); //checking if the elementList and NumberList are empty or not if (ElementListempty != true || NumberListempty != true) { //if the lists contain some values the clear is used to make them empty ElementList.Clear(); NumberList.Clear(); m_build();// will fill the numberList for (int j = 1; j <= ElementNumber; j++) { currentRandom = m_random.Next(1, NumberList.Count); NumberList.Remove(currentRandom); ElementList.Add(currentRandom); } ElementList.Sort();//sorting the list } }