public static void Select(this ListControl control, string initial, bool findByText, int fallbackIndex) { control.ClearSelection(); if (findByText) { if (control.Items.FindByTextWithIgnoreCase(initial) != null) { control.Items.FindByTextWithIgnoreCase(initial).Selected = true; } else if (fallbackIndex > -1) { control.Items[fallbackIndex].Selected = true; } } else { if (control.Items.FindByValueWithIgnoreCase(initial) != null) { control.Items.FindByValueWithIgnoreCase(initial).Selected = true; } else if (fallbackIndex > -1) { control.Items[fallbackIndex].Selected = true; } } }
/** * \brief Collapses all passed indices to a single shared index. * */ public static bool MergeVertices(this pb_Object pb, int[] indices) { Vector3[] verts = pb.vertices; Vector3 cen = Vector3.zero; foreach(int i in indices) cen += verts[i]; cen /= (float)indices.Length; pb_IntArray[] sharedIndices = pb.sharedIndices; int newIndex = pb_IntArrayUtility.MergeSharedIndices(ref sharedIndices, indices); pb.SetSharedIndices(sharedIndices); int firstTriInSharedIndexArr = pb.sharedIndices[newIndex][0]; pb.SetSharedVertexPosition(firstTriInSharedIndexArr, cen); int[] mergedSharedIndex = pb.GetSharedIndices()[newIndex].array; int[] removedIndices = pb.RemoveDegenerateTriangles(); // get a non-deleted index to work with int ind = -1; for(int i = 0; i < mergedSharedIndex.Length; i++) if(!removedIndices.Contains(mergedSharedIndex[i])) ind = mergedSharedIndex[i]; int t = ind; for(int i = 0; i < removedIndices.Length; i++) if(ind > removedIndices[i]) t--; pb.ClearSelection(); if(t > -1) pb.SetSelectedTriangles(new int[1] { t }); return true; }
/// <summary> /// Clears the selection, and ignores the affected area. /// </summary> /// <param name="self">This selectable item</param> /// <returns>Boolean, true if members were removed from the selection</returns> public static bool ClearSelection(this ISelectable self) { IEnvelope ignoreMe; return self.ClearSelection(out ignoreMe); }