public void TestIEnumerable() { Selection<object> test = new Selection<object>(); CollectionAssert.IsEmpty(test); test.Add("a"); Utilities.TestSequenceEqual(test, "a"); test.Add("b"); Utilities.TestSequenceEqual(test, "a", "b"); }
public void TestContains() { Selection<object> test = new Selection<object>(); Assert.False(test.Contains("a")); test.Add("a"); Assert.True(test.Contains("a")); test.Add("b"); Assert.True(test.Contains("b")); }
public void TestCount() { Selection<object> test = new Selection<object>(); Assert.True(test.Count == 0); test.Add("a"); Assert.True(test.Count == 1); test.Add("b"); Assert.True(test.Count == 2); }
public void TestRemove() { Selection<object> test = new Selection<object>(); test.Add("a"); test.Add("b"); Assert.False(test.Remove("c")); Assert.True(test.Remove("a")); Utilities.TestSequenceEqual(test, "b"); Assert.False(test.Remove("a")); Assert.True(test.Remove("b")); CollectionAssert.IsEmpty(test); }
public void TestAdd() { Selection<object> test = new Selection<object>(); test.Add("a"); Utilities.TestSequenceEqual(test, "a"); test.Add("b"); Utilities.TestSequenceEqual(test, "a", "b"); // On 1/12/2012, contractor Brandon Ehle wanted to use Selection<int>. I agreed that it would be // useful because GridView was doing a lot of casting to 'object' and boxing ints. By changing // Selection<T> to work with value types, I removed the requirement that 'null' not be added // so that value types and reference types are treated equivalently, and to allow for default // value-types to be added. For example, I think Selection<int> should be able to hold 0. // --Ron Little //Assert.Throws<ArgumentNullException>(delegate() { test.Add(null); }); }
public void TestAdd() { Selection <object> test = new Selection <object>(); test.Add("a"); Utilities.TestSequenceEqual(test, "a"); test.Add("b"); Utilities.TestSequenceEqual(test, "a", "b"); // On 1/12/2012, contractor Brandon Ehle wanted to use Selection<int>. I agreed that it would be // useful because GridView was doing a lot of casting to 'object' and boxing ints. By changing // Selection<T> to work with value types, I removed the requirement that 'null' not be added // so that value types and reference types are treated equivalently, and to allow for default // value-types to be added. For example, I think Selection<int> should be able to hold 0. // --Ron Little //Assert.Throws<ArgumentNullException>(delegate() { test.Add(null); }); }
// select features in feature collection private void SelectFeatureCollection(IResultSetFeatureCollection fc) { // force map to update mapControl1.Update(); _selection.Clear(); _selection.Add(fc); }
private void OnSelectModule(IModule moduleBase) { Collection.Remove(moduleBase); Selection.Add(moduleBase); CheckOrdering(); OnPropertyChanged(nameof(CanSelectMore)); }
public static void Add(Object obj) { SelectionManager.currentInlineEditorCurve = null; if (!Selection.Contains(obj)) { Selection.Add(obj); } }
public void AddSelection(SmartSelectItem item) { var copy = item.Copy(); Selection.Add(copy); item.IsActive = false; }
/// <summary> /// Only documents that have the <see cref="SearchDocument.Url"/> property set should be returned. /// </summary> public void ShowOnlyDocumentsWithUrls() { Selection.Add(new SearchQuerySelection { FieldName = DocumentFieldNames.HasUrl, Values = new [] { "1" } }); }
/* * * private void CPanelEditionSymbole_MouseUp(object sender, MouseEventArgs e) * { * Point mousePoint = GetMouseLogicalPoint(new Point(e.X, e.Y)); * Refresh(); * if (this.ObjetEdite != null) * { * if (ModeEdition == EModeEditeurSymbole.Selection) * { * Refresh(); * } * * if (ModeEdition == EModeEditeurSymbole.EditionModificationPoint && m_ligneEditee != null && m_SelectedPoint != null) * { * m_ligneEditee.ReplacePoint((Point)m_SelectedPoint, mousePoint); * // m_SelectedPoint = null; * // m_ligneEditee.UnSelectPoint(); * Refresh(); * ModeEdition = EModeEditeurSymbole.EditionLigne; * * } * if (ModeEdition == EModeEditeurSymbole.EditionLigne && m_ligneEditee != null) * { * * m_ligneEditee.SetModeSelection(false); * Point pt = mousePoint; * * if ((ModifierKeys & Keys.Control) == Keys.Control) * { * Point? prevPointOnLine; * if ((prevPointOnLine = m_ligneEditee.PointOnlineAfterPoint(pt)) != null) * { * //if (CFormAlerte.Afficher("Do you want to add a new point on the line", EFormAlerteType.Question) == DialogResult.Yes) * if (MessageBox.Show(I.T("Do you want to add a new point on the line ?|30032"), "", MessageBoxButtons.YesNo) == DialogResult.Yes) * m_ligneEditee.InsertAfterPoint((Point)prevPointOnLine, pt); * * } * else * m_ligneEditee.AddPoint(pt); * * } * else * { * * m_SelectedPoint = m_ligneEditee.SelectPoint(mousePoint); * * if (((ModifierKeys & Keys.Shift) == Keys.Shift) && (m_SelectedPoint != null)) * { * if (m_ligneEditee.RemovePoint((Point)m_SelectedPoint)) * { * m_SelectedPoint = null; * m_ligneEditee.UnSelectPoint(); * Refresh(); * } * else * MessageBox.Show(I.T("Impossible to remove the point|30033")); * } * * } * * Refresh(); * * } * * } * } */ public void EditeLine(C2iSymboleLigne ligne) { Selection.Clear(); Selection.Add(ligne); ModeEdition = EModeEditeurSymbole.EditionLigne; m_ligneEditee = ligne; m_ligneEditee.SetModeSelection(false); Refresh(); }
public void GroupShapes() { if (Selection.Count > 0) { GroupShape group = CreateGroupShape(); Selection.Add(group); AddShape(group); } }
private void RestoreShapesFromGroup(GroupShape group) { foreach (var shape in group.Shapes) { shape.TransformMatrix.Multiply(group.TransformMatrix); Selection.Add(shape); Shapes.Add(shape); } }
/// <summary> /// Filters the results, so only entity tokens that have at least one of the given entity tokens /// as an ancestor, will be returned. This enables searching for the child elements in the console /// and searching for data that belongs to a specific website on frontend. /// </summary> public void FilterByAncestors(params EntityToken[] entityTokens) { Selection.Add(new SearchQuerySelection { FieldName = DocumentFieldNames.Ancestors, Operation = SearchQuerySelectionOperation.Or, Values = entityTokens.Select(SearchDocumentBuilder.GetEntityTokenHash).ToArray() }); }
public void FindByShape(Type type) { foreach (var item in ShapeList) { if (item.GetType() == type) { Selection.Add(item); } } }
public void FindByPanel(List <Shape> shapePanel) { foreach (var shape in ShapeList) { if (shapePanel.Contains(shape)) { Selection.Add(shape); } } }
public static ISelection GetSelectionFromComplexArray(Complex[] complexArray){ ISelection selection = new Selection(); foreach (Complex c in complexArray) { double[] v = {c.R}; selection.Add(new Vector(v)); } return selection; }
/// <summary> /// 创建一个工作用的Part 文件 /// </summary> /// <param name="CatApplication">CATIA程序框架</param> /// <param name="CatDocument">CATIA 活动文档</param> /// <param name="PartID">待创建的CATIA 零件目标</param> public void CreatWorkPart(INFITF.Application CatApplication, ProductDocument CatDocument, ref Part PartID) { // 添加一个新零件 string Name = "RXFastDesignTool"; try { PartID = ((PartDocument)CatApplication.Documents.Item(Name + ".CATPart")).Part; } catch (Exception) { try { CatDocument.Product.Products.AddNewComponent("Part", Name); PartID = ((PartDocument)CatApplication.Documents.Item(Name + ".CATPart")).Part; } catch (Exception) { return; // throw; } } HybridBodies HBS = PartID.HybridBodies; if (HBS.Count < 1) { HybridBody HB = HBS.Add(); HB.set_Name("Geometrical Set.1"); } OriginElements Tpart = PartID.OriginElements; AnyObject dxy = Tpart.PlaneXY; AnyObject dyz = Tpart.PlaneYZ; AnyObject dzx = Tpart.PlaneZX; Selection SelectT = CatDocument.Selection; VisPropertySet VP = SelectT.VisProperties; SelectT.Add(dxy); SelectT.Add(dyz); SelectT.Add(dzx); VP = (VisPropertySet)VP.Parent; VP.SetShow(CatVisPropertyShow.catVisPropertyNoShowAttr); SelectT.Clear(); }
// -------------------------------------------------------------------- private void Select(SceneObject obj) { if (ModifierKeys.HasFlag(Keys.Control)) { Selection.Add(obj); } else { Selection.ActiveObject = obj; } }
/// <summary> /// 高亮线对象 /// </summary> public static void HighLightLine(this Map MapObj, string LayerName, int SMID, GeoStyle Style) { Selection selection = new Selection(); selection.Add(SMID); selection.Style = Style; Layer tagLayer = MapObj.Layers[LayerName]; selection.Dataset = (DatasetVector)tagLayer.Dataset; tagLayer.Selection = selection; }
/// <summary> /// Filters search results by page types. /// </summary> /// <param name="pageTypes"></param> public void FilterByPageTypes(params string[] pageTypes) { Verify.ArgumentNotNull(pageTypes, nameof(pageTypes)); Selection.Add(new SearchQuerySelection { FieldName = DocumentFieldNames.GetFieldName(typeof(IPage), nameof(IPage.PageTypeId)), Operation = SearchQuerySelectionOperation.Or, Values = pageTypes }); }
/// <summary> /// Filters search results by data types. /// </summary> /// <param name="dataTypes"></param> public void FilterByDataTypes(params Type[] dataTypes) { Verify.ArgumentNotNull(dataTypes, nameof(dataTypes)); Selection.Add(new SearchQuerySelection { FieldName = DocumentFieldNames.DataType, Operation = SearchQuerySelectionOperation.Or, Values = dataTypes.Select(type => type.GetImmutableTypeId().ToString()).ToArray() }); }
/// <summary> /// 清空机器人Home预制坐标信息_Yecc /// </summary> /// <param name="FM"></param> /// <param name="DSystem"></param> /// <param name="product"></param> /// <param name="RobotName"></param> /// <param name="progressBar"></param> /// <param name="CreateCable"></param> public void ClearRobotHomeList(Form FM, DataType.Dsystem DSystem, Product product, String RobotName, ProgressBar progressBar, bool CreateCable = false) { //Workbench TheKinWorkbench = DSystem.CDSActiveDocument.GetWorkbench("KinematicsWorkbench"); Mechanisms cTheMechanisms = null; ProductDocument partDocument = GetProductPath(product, DSystem, false); Selection selection = partDocument.Selection; selection.Clear(); try { BasicDevice basicDevice = (BasicDevice)product.GetTechnologicalObject("BasicDevice"); System.Array homePositions = null; //for (int i = 0; i < 100; i++) // add New Robot Home Position //{ // object[] HomePos = { 0, 0, 0, 0, 0, 0 }; // basicDevice.SetHomePosition("RobotHome_" + i, HomePos); //} basicDevice.GetHomePositions(out homePositions); int HomePosNum = homePositions.Length; if (HomePosNum > 1) //当对象运动机构数量>1时 清除全部机构对象 { foreach (HomePosition homePosition in homePositions) { selection.Add(homePosition); //Array AtoolTip = null; //homePosition.GetAssociatedToolTip(out AtoolTip); //selection.Add(homePosition); } selection.Delete(); } } catch (Exception e) { MessageBox.Show(e.Message + ";请在帮助-》问题反馈与建议中反馈该问题,谢谢!"); //选定的对象不存在任何运动机构 } //Mechanisms TheMechanismsList = TheKinWorkbench.Mechanisms; RobGenericController Rgcr = (RobGenericController)product.GetTechnologicalObject("RobGenericController"); RobControllerFactory CRM = (RobControllerFactory)product.GetTechnologicalObject("RobControllerFactory"); GenericMotionProfile genericMotion = null; int ProfileCount = 0; Rgcr.GetMotionProfileCount(out ProfileCount); if (ProfileCount > 0) { string ProfileName = "DNBRobController"; Rgcr.GetMotionProfile(ProfileName, out genericMotion); } InitController(Rgcr, CRM, 10, progressBar); Mechanism mechanism = cTheMechanisms.Add(); //mechanism.FixedPart= ///RefDocument//mk:@MSITStore:F:\02%20我的知识库\05%20学习&总结资料\01%20CAA开发资料\V5Automation.chm::/online/CAAScdDmuUseCases/CAAKiiMechanismCreationSource.htm //string GetName = CRM.get_Name(); }
private void UpdateRubberbandSelection() { var selected_area = BoundedRectangle(selection_start, selection_end); // Restore initial selection var initial_selection = Selection.ToBitArray(); Selection.Clear(false); foreach (int i in start_select_selection) { Selection.Add(i, false); } // Set selection int first = -1; foreach (var cell_num in CellsInRect(selected_area)) { if (first == -1) { first = cell_num; } if ((selection_modifier & ModifierType.ControlMask) == 0) { Selection.Add(cell_num, false); } else { Selection.ToggleCell(cell_num, false); } } if (first != -1) { FocusCell = first; } // fire events for cells which have changed selection flag var new_selection = Selection.ToBitArray(); var selection_changed = initial_selection.Xor(new_selection); var changed = new List <int>(); for (int i = 0; i < selection_changed.Length; i++) { if (selection_changed.Get(i)) { changed.Add(i); } } if (changed.Count != 0) { Selection.SignalChange(changed.ToArray()); } }
public void FindByName() { string name = ShowDialog("Find by name", "Find Shapes"); foreach (var shape in ShapeList) { if (shape.Name == name) { Selection.Add(shape); } } }
/// <summary> /// Performs custom actions on DragEnter events</summary> /// <param name="e">DragEventArgs containing event data</param> protected virtual void OnDragEnter(DragEventArgs e) { var converted = new List <ITimelineObject>(ConvertDrop(e)); m_timelineControl.DragDropObjects = converted; Selection.Clear(); foreach (IEvent draggedEvent in converted.AsIEnumerable <IEvent>()) { Selection.Add(new TimelinePath(draggedEvent)); } }
public ISelection GetSelectionFromRange(double min, double max, int count) { var range = new Range(min, max); ISelection result = new Selection(); for (double i = range.Min; i < range.Max; i += (range.Length / (double)count)) { IVector v = new Vector(2); v[0] = i; v[1] = GetValueForX(i); result.Add(v); } return result; }
void SelectHexesAround(Hex center) { GameObject go = Instantiate(selectionPrefab, center.transform); selection = go.GetComponent <Selection>(); foreach (Hex neighbor in center.Position.Neighbors.Select(pos => hexesByCoord[pos])) { neighbor.transform.SetParent(go.transform); neighbor.Selected = true; selection.Add(neighbor); selection.map = this; } selectionCenter = center.Position; }
private void MainWindow_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { EndAnimationsInProgress(); // Move in progress? if (pmm != null) { MainGrid.MouseMove -= MainGrid_MouseMoveWhenDown; MainGrid.MouseMove += MainGrid_MouseMoveWhenUp; pmm = null; Mouse.Capture(null); // Restore position of selected WordCanvas foreach (var wac in m_Sel.WordAndCanvasList) { double top = wac.WordPosition.StartRow * UnitSize; double left = wac.WordPosition.StartColumn * UnitSize; wac.WordCanvas.SetValue(Canvas.TopProperty, top); wac.WordCanvas.SetValue(Canvas.LeftProperty, left); } return; } // CLear selection if any if (m_Sel.WordAndCanvasList?.Count > 0) { m_Sel.Clear(); } } else if (e.Key == Key.A && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { // Select all m_Sel.Add(m_WordAndCanvasList); } }
private void itemClick(BinListItem item) { Main.SetFocus(this); if (lastSelectedBin != null && Main.KeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift)) { int start = Math.Min(lastSelectedBin.Offset, item.Bin.Offset); int end = Math.Max(lastSelectedBin.Offset, item.Bin.Offset); if (end - start > 0) { for (int i = start; i <= end; i++) { Bin rangeItem = bins[i]; if (!Selection.ContainsKey(rangeItem.Offset)) { Selection.Add(rangeItem.Offset, rangeItem); } } Layout(); } } if (lastSelectedBin != null) { lastSelectedBin.Selected = false; itemSelectedCallback(null); } if (item.Selected) { lastSelectedBin = item.Bin; lastSelectedBin.Selected = true; if (!Selection.ContainsKey(item.Bin.Offset)) { Selection.Add(item.Bin.Offset, item.Bin); } itemSelectedCallback(item); } else { if (Selection.ContainsKey(item.Bin.Offset)) { Selection.Remove(item.Bin.Offset); } lastSelectedBin = null; } }
public void SelectionnerElement(IElementDeProjet ele) { I2iObjetGraphique o = null; foreach (I2iObjetGraphique objet in ObjetEdite.Childs) { switch (ele.TypeElementDeProjet.Code) { case ETypeElementDeProjet.Projet: if (objet is CWndProjetBrique && ele.Equals(((CWndProjetBrique)objet).Projet)) { o = objet; } break; case ETypeElementDeProjet.Intervention: if (objet is CWndIntervention && ele.Equals(((CWndIntervention)objet).Intervention)) { o = objet; } break; case ETypeElementDeProjet.Lien: if (objet is CWndLienDeProjet && ele.Equals(((CWndLienDeProjet)objet).LienDeProjet)) { o = objet; } break; default: return; } if (o != null) { break; } } if (BeforeSelectElement != null && !BeforeSelectElement()) { return; } Selection.Clear(); Selection.Add(o); if (AfterSelectElement != null) { AfterSelectElement(o); } }
internal void SearchByName(string name) { RemoveSelectedItems(); foreach (var s in ShapeList) { if (s.ShapeName != null) { if (s.ShapeName.Equals(name)) { Selection.Add(s); s.BorderColor = Color.Red; } } } }
/// <summary> /// 隐藏孔创建的草图并修改孔颜色 /// </summary> /// <param name="Thole">目标孔</param> private void ChangeHoleColor(Hole Thole, RxHoleType HoleType) { //隐藏孔创建的草图并修改孔颜色 Selection HoleSelection = CatActiveDoc.Selection; HoleSelection.Clear(); VisPropertySet HoleSet = HoleSelection.VisProperties; Sketch HoleSketch = Thole.Sketch; HoleSelection.Add(HoleSketch); HoleSet.SetShow(CatVisPropertyShow.catVisPropertyNoShowAttr); HoleSelection.Clear(); HoleSelection.Add(Thole); switch (HoleType) { case RxHoleType.PinHole: //销孔 HoleSet.SetVisibleColor(251, 146, 248, 0); break; case RxHoleType.NSmoothHole: //光孔 HoleSet.SetVisibleColor(167, 230, 182, 0); break; case RxHoleType.ISmoothHole: //沉头孔 HoleSet.SetVisibleColor(167, 230, 182, 0); break; case RxHoleType.ThreadHole: //螺纹孔 HoleSet.SetVisibleColor(128, 0, 255, 0); break; default: break; } HoleSelection.Clear(); }
/// <summary> /// Метод загрузки списка фигур из файла на диске /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static IEnumerable <Figure> LoadSelection(string fileName) { var layer = LoadFromFile(fileName); var selection = new Selection(); foreach (var fig in layer.Figures) { selection.Add(fig); } var location = selection.GetTransformedPath().Path.GetBounds().Location; selection.Translate(-location.X, -location.Y); selection.PushTransformToSelectedFigures(); return(layer.Figures); }
public bool Select(TaggedAnimationClip clip, bool notify = true) { if (!Selection.Contains(clip)) { Selection.Add(clip); if (notify) { SelectionChanged?.Invoke(); } return(true); } return(false); }
public static void AddObject(Object obj) { if (obj == null) { return; } currentInlineEditorCurve = null; if (Selection.Contains(obj)) { return; } Selection.Add(obj); }
public void TestCopyTo() { Selection<object> test = new Selection<object>(); test.Add("a"); test.Add("b"); object[] array1 = new object[2]; test.CopyTo(array1, 0); Assert.AreEqual(array1, new object[] { "a", "b" }); object[] array2 = new object[3]; test.CopyTo(array2, 1); Assert.AreEqual(array2, new object[] { null, "a", "b" }); }
private ISelection generateSourceSelection(int n, generateMethod func) { ISelection selection = new Selection(); for (int i = 0; i < n; i++) { selection.Add(func(i, n)); } return selection; }
public void TestRemoveAt() { Selection<object> test = new Selection<object>(); test.Add("a"); test.Add("b"); Assert.Throws<ArgumentOutOfRangeException>(delegate() { test.RemoveAt(2); }); test.RemoveAt(1); Utilities.TestSequenceEqual(test, "a"); Assert.Throws<ArgumentOutOfRangeException>(delegate() { test.RemoveAt(1); }); test.RemoveAt(0); CollectionAssert.IsEmpty(test); Assert.Throws<ArgumentOutOfRangeException>(delegate() { test.RemoveAt(0); }); }
public void TestIndexOf() { Selection<object> test = new Selection<object>(); Assert.True(test.IndexOf("a") == -1); test.Add("a"); Assert.True(test.IndexOf("a") == 0); Assert.True(test.IndexOf("b") == -1); test.Add("b"); Assert.True(test.IndexOf("b") == 1); }
void AddOrRemoveFromSelection(ISpatialObject so) { Selection sel = new Selection(this.SpatialSelection.Items); if (!sel.Remove(so)) sel.Add(so); SetSelection(sel); }
public void TestAsIEnumerable() { Selection<object> test = new Selection<object>(); CollectionAssert.IsEmpty(test.AsIEnumerable<object>()); test.Add("a"); test.Add(this); Utilities.TestSequenceEqual(test.AsIEnumerable<string>(), "a"); Utilities.TestSequenceEqual(test.AsIEnumerable<object>(), "a", this); }
public void TestChangeEvents() { Selection<object> test = new Selection<object>(); test.Changing += new EventHandler(test_Changing); test.Changed += new EventHandler(test_Changed); test.Add("a"); Assert.True(m_changedEvents == 1); test.Add("a"); Assert.True(m_changedEvents == 1); // no change! test.Add("b"); Assert.True(m_changedEvents == 2); test[0] = "b"; Assert.True(m_changedEvents == 3); }
public void TestIndexer() { Selection<object> test = new Selection<object>(); Assert.Throws<ArgumentOutOfRangeException>(delegate() { object temp = test[0]; }); test.Add("a"); test.Add("b"); Assert.AreEqual(test[0], "a"); Assert.AreEqual(test[1], "b"); Assert.Throws<ArgumentOutOfRangeException>(delegate() { object temp = test[2]; }); test[0] = "c"; Assert.AreEqual(test[0], "c"); test[1] = "d"; Assert.AreEqual(test[1], "d"); }
public void TestItemsChangedEvents() { Selection<object> test = new Selection<object>(); test.ItemsChanged += new EventHandler<ItemsChangedEventArgs<object>>(test_ItemsChanged); test.Add("a"); Assert.NotNull(ItemsChangedEventArgs); Utilities.TestSequenceEqual(ItemsChangedEventArgs.AddedItems, "a"); CollectionAssert.IsEmpty(ItemsChangedEventArgs.RemovedItems); CollectionAssert.IsEmpty(ItemsChangedEventArgs.ChangedItems); ItemsChangedEventArgs = null; test.Set("b"); Assert.NotNull(ItemsChangedEventArgs); Utilities.TestSequenceEqual(ItemsChangedEventArgs.AddedItems, "b"); Utilities.TestSequenceEqual(ItemsChangedEventArgs.RemovedItems, "a"); CollectionAssert.IsEmpty(ItemsChangedEventArgs.ChangedItems); }
private ISelection generateXYSourceSelection(int count, generateMethod meth) { ISelection selection = new Selection(); for (int i = 0; i < count; i++) { selection.Add(meth(i, count)); } return selection; }
public void TestUniqueness() { Selection<object> test = new Selection<object>(); test.Add("a"); test.Add("a"); Utilities.TestSequenceEqual(test, "a"); object b = new object(); test.Add("b"); Utilities.TestSequenceEqual(test, "a", "b"); test[1] = "a"; // overwrite b with a, should also remove first instance of a Utilities.TestSequenceEqual(test, "a"); }
public void TestLastSelected() { Selection<object> test = new Selection<object>(); Assert.Null(test.LastSelected); test.Add("a"); Assert.AreSame(test.LastSelected, "a"); test.Add("b"); Assert.AreSame(test.LastSelected, "b"); test.Remove("b"); Assert.AreSame(test.LastSelected, "a"); }
public void TestClear() { Selection<object> test = new Selection<object>(); test.Add("a"); test.Add("b"); test.Clear(); CollectionAssert.IsEmpty(test); }
public void TestGetLastSelected() { Selection<object> test = new Selection<object>(); Assert.Null(test.GetLastSelected<string>()); test.Add("a"); Assert.AreSame(test.GetLastSelected<string>(), "a"); test.Add(this); // any non-string Assert.AreSame(test.GetLastSelected<string>(), "a"); Assert.AreSame(test.GetLastSelected<TestSelection>(), this); }
internal string SaveSurfaceAndFixedPoints(ref List<double[]> FixedPoints, ref double[] oPlane) { string StlPath= System.IO.Path.GetTempPath() + "STLFileBlankCalculator"; ; oPartDoc = (PartDocument)CATIA.ActiveDocument; oSel = oPartDoc.Selection; oSpa = (SPAWorkbench)oPartDoc.GetWorkbench("SPAWorkbench"); FixedPoints = new List<double[]>(); oSel.Clear(); oSel.Add(SelectSurface("Selecione qual a superficie que pretende planificar. Esc para sair.")); oSel.Copy(); oSel.Clear(); PartDocument NewPart = (PartDocument)CATIA.Documents.Add("Part"); NewPart.Selection.Clear(); NewPart.Selection.Add(NewPart.Part); NewPart.Selection.PasteSpecial("CATPrtResultWithOutLink"); if (System.IO.File.Exists(StlPath + ".stl")) { System.IO.File.Delete(StlPath + ".stl"); } NewPart.Selection.Clear(); NewPart.Part.Update(); CATIA.DisplayFileAlerts = false; NewPart.ExportData(StlPath, "stl"); NewPart.Close(); CATIA.DisplayFileAlerts = true; object[] Vec = new object[3]; oSel.Clear(); Reference Ref1 = SelectPoint("Selecione o conjunto de pontos fixos. Esc para sair."); oSel.Clear(); if (Ref1 == null) Environment.Exit(0); oSpa.GetMeasurable(Ref1).GetPoint(Vec); FixedPoints.Add(new double[] { (double)Vec[0], (double)Vec[1], (double)Vec[2] }); do { Ref1 = SelectPoint("Selecione o conjunto de pontos fixos (" + FixedPoints.Count + " selecionados). Esc para terminar."); oSel.Clear(); if (Ref1 == null) break; oSpa.GetMeasurable(Ref1).GetPoint(Vec); FixedPoints.Add(new double[] { (double)Vec[0], (double)Vec[1], (double)Vec[2] }); } while (true); if(FixedPoints.Count==0) Environment.Exit(0); oSel.Clear(); oPartDoc.Part.Update(); System.Windows.Forms.Application.DoEvents(); System.Threading.Thread.Sleep(500); Vec = new object[9]; Reference Ref2 = SelectPlane("Selecione qual o plano do planificado. Esc para terminar."); oSel.Clear(); oSpa.GetMeasurable(Ref2).GetPlane(Vec); oPlane = new double[] { (double)Vec[0], (double)Vec[1], (double)Vec[2], (double)Vec[3], (double)Vec[4], (double)Vec[5], (double)Vec[6], (double)Vec[7], (double)Vec[8] }; return StlPath + ".stl"; }
public void TestGetSnapshot() { Selection<object> test = new Selection<object>(); CollectionAssert.IsEmpty(test.GetSnapshot()); test.Add("a"); object[] snapshot = test.GetSnapshot(); Assert.AreEqual(snapshot, new object[] { "a" }); test.Add("b"); snapshot = test.GetSnapshot(); Assert.AreEqual(snapshot, new object[] { "a", "b" }); }
/// <summary> /// Selects the object that this check relates to. /// </summary> internal override void Select() { // If the label either has no attributes, or it is inside a polygon that has // more than one label, select the enclosing polygon. Selection ss = new Selection(); CheckType types = Types; if ((types & CheckType.NoAttributes)!=0 || (types & CheckType.MultiLabel)!=0) { Polygon pol = m_Label.Container; if (pol!=null) ss.Add(pol); } // Select the label too ss.Add(m_Label); EditingController.Current.SetSelection(ss); // Leave the focus with the view (to allow label deletion). EditingController.Current.ActiveDisplay.MapPanel.Focus(); }
public void TestGetSnapshotGeneric() { Selection<object> test = new Selection<object>(); CollectionAssert.IsEmpty(test.GetSnapshot()); test.Add("a"); test.Add(this); Assert.AreEqual(test.GetSnapshot<object>(), new object[] { "a", this }); Assert.AreEqual(test.GetSnapshot<string>(), new string[] { "a" }); }
/// <summary> /// Selects the object that this check relates to. /// </summary> internal override void Select() { Selection ss = new Selection(m_Divider.Line, null); // If the divider has the same polygon on both sides, select // the polygon as well. if ((Types & CheckType.Bridge)!=0 && m_Divider.Left!=null) ss.Add(m_Divider.Left); EditingController.Current.SetSelection(ss); EditingController.Current.ActiveDisplay.MapPanel.Focus(); }
public static Selection SelectTiles(Map thisMap, Selection selection, int left, int top, int width, int height) { var result = new Selection(); result.AddRange(selection); for (int x = left; x < left + width; x++) for (int y = top; y < top + height; y++) { Tile t = thisMap.GetTileAcrossWrap(x, y); if (t != null && !selection.ContainsTile(t)) result.Add(t.GetCoordinate()); } return result; }