コード例 #1
0
ファイル: SetEditor.cs プロジェクト: rambotech/BOG.Weedkiller
        public bool PasteConfigFromClipboard()
        {
            bool result = false;

            try
            {
                WeedKillerConfigSet cs = ObjectXMLSerializer <WeedKillerConfigSet> .CreateObjectFormat(Clipboard.GetText());

                foreach (WeedKillerConfig c in cs.ConfigSet)
                {
                    c.Description = "Copy of " + c.Description;
                    ListViewItem i = new ListViewItem(c.Description);
                    i.Tag   = c;
                    i.Group = new ListViewGroup("Configuration Set");
                    this.lvwConfigSet.Items.Add(i);
                    AdjustListViewItemColor(this.lvwConfigSet.Items.Count - 1);
                }
                _Saved = false;
                AdjustControls();
                this.lvwConfigSet.Sort();
                result = true;
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message, "Can't paste from clipboard", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(result);
        }
コード例 #2
0
        public void Iteration_GetSet_OK()
        {
            Dictionary <string, string[]> IterationSets = new Dictionary <string, string[]>();

            IterationSets.Add("List", new string[] { "A", "B", "C" });
            IterationSets.Add("Numbers01", new string[] { "10", "9", "8", "7", "6", "5", "4", "3", "2", "1", "0" });
            IterationSets.Add("Numbers02", new string[] { "250", "255", "260", "265", "270", "275", "280" });

            Iteration iter = new Iteration();

            iter.AddListItems("List", new List <string>(IterationSets["List"]));
            iter.AddNumberRange("Numbers01", 10, -1, 0, Iteration.EndValueEval.Inclusive);
            iter.AddNumberSequence("Numbers02", 250, 5, 7);

            string serialized = ObjectXMLSerializer <Iteration> .CreateDocumentFormat(iter);

            Iteration iterCloned = ObjectXMLSerializer <Iteration> .CreateObjectFormat(serialized);

            Assert.AreEqual(iter.IterationItems.Count, iterCloned.IterationItems.Count, "Iteration item count mismatch");
            foreach (int key in iter.IterationItems.Keys)
            {
                Assert.AreEqual(
                    iter.IterationItems[key].Name,
                    iterCloned.IterationItems[key].Name,
                    "Iteration item name mismatch for key " + key.ToString());
                Assert.AreEqual(
                    iter.IterationItems[key].IterationValues.Count,
                    iterCloned.IterationItems[key].IterationValues.Count,
                    "Iteration item count mismatch for key " + key.ToString());
            }
            Assert.AreEqual(iter.TotalIterationCount, iterCloned.TotalIterationCount, "Total count mismatch");
        }