当前位置: 首页>>代码示例>>C#>>正文


C# Selection.Add方法代码示例

本文整理汇总了C#中Selection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Selection.Add方法的具体用法?C# Selection.Add怎么用?C# Selection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Selection的用法示例。

在下文中一共展示了Selection.Add方法的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestContains

 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"));
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:9,代码来源:TestSelection.cs


示例2: TestCount

 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);
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:9,代码来源:TestSelection.cs


示例3: TestIEnumerable

 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");
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:9,代码来源:TestSelection.cs


示例4: TestRemove

 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);
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:12,代码来源:TestSelection.cs


示例5: TestAdd

        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); });
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:16,代码来源:TestSelection.cs


示例6: GetSelectionFromComplexArray

		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;
		}
开发者ID:ramshteks,项目名称:csalgs-lib,代码行数:10,代码来源:Fourier.cs


示例7: GetSelectionFromRange

		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;
		}
开发者ID:ramshteks,项目名称:csalgs-lib,代码行数:14,代码来源:Polynomial.cs


示例8: TestChangeEvents

 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);
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:14,代码来源:TestSelection.cs


示例9: TestAsIEnumerable

 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);
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:9,代码来源:TestSelection.cs


示例10: TestGetSnapshotGeneric

 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" });
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:9,代码来源:TestSelection.cs


示例11: TestGetSnapshot

 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" });
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:11,代码来源:TestSelection.cs


示例12: TestGetLastSelected

 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);
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:10,代码来源:TestSelection.cs


示例13: generateSourceSelection

 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;
 }
开发者ID:ramshteks,项目名称:csalgs-lib,代码行数:9,代码来源:Form1.cs


示例14: TestIndexer

        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");
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:15,代码来源:TestSelection.cs


示例15: TestRemoveAt

 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); });
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:13,代码来源:TestSelection.cs


示例16: TestIndexOf

 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);
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:10,代码来源:TestSelection.cs


示例17: AddOrRemoveFromSelection

        void AddOrRemoveFromSelection(ISpatialObject so)
        {
            Selection sel = new Selection(this.SpatialSelection.Items);
            if (!sel.Remove(so))
                sel.Add(so);

            SetSelection(sel);
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:8,代码来源:EditingController.cs


示例18: Select

        /// <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();
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:25,代码来源:TextCheck.cs


示例19: TestCopyTo

 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" });
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:12,代码来源:TestSelection.cs


示例20: TestItemsChangedEvents

        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);
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:17,代码来源:TestSelection.cs


示例21: SelectTiles

 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;
 }
开发者ID:novice-rb,项目名称:civ-tools,代码行数:13,代码来源:Operations.cs


示例22: TestUniqueness

 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");
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:12,代码来源:TestSelection.cs


示例23: generateXYSourceSelection

 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;
 }
开发者ID:ramshteks,项目名称:csalgs-lib,代码行数:9,代码来源:Form1.cs


示例24: TestClear

 public void TestClear()
 {
     Selection<object> test = new Selection<object>();
     test.Add("a");
     test.Add("b");
     test.Clear();
     CollectionAssert.IsEmpty(test);
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:8,代码来源:TestSelection.cs


示例25: TestLastSelected

 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");
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:11,代码来源:TestSelection.cs


示例26: SaveSurfaceAndFixedPoints

        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";
        }
开发者ID:JGEsteves89,项目名称:BlankCalculator,代码行数:55,代码来源:CATInterop.cs


示例27: Select

        /// <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();
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:15,代码来源:DividerCheck.cs



注:本文中的Selection.Add方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。