Esempio n. 1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     while (lvStyles.SelectedItems.Count > 0)
     {
         Style s = lvStyles.SelectedItems[0].Tag as Style;
         FStyles.Remove(s);
         lvStyles.Items.Remove(lvStyles.SelectedItems[0]);
     }
 }
Esempio n. 2
0
        public void StyleCollection_Remove()
        {
            // Arrange
            var style = new Style("id");
            var list  = new StyleCollection();

            list.Add(style);

            // Act
            var value = list.Remove(style);

            // Assert
            Assert.AreEqual(0, list.Count);
            Assert.IsTrue(value);
        }
        public void OwnerTest()
        {
            Document doc = new Document();

            doc.ID = "First Document";

            //doc.Styles should be initialized with the document as it's owner
            StyleCollection col = doc.Styles;

            Assert.AreEqual(doc, col.Owner);

            //A non IPDFComponent entry - make sure there are not cast exceptions
            Style unowned = new Style();

            col.Add(unowned);

            //An IPDFComponent entry - so should have it's parent value set
            StylesDocument styleDoc = new StylesDocument();

            col.Add(styleDoc);

            //parent should automatically be set on the styleDoc from the parent.
            Assert.AreEqual(doc, styleDoc.Parent);

            //Changing the owner should pass through
            Document other = new Document();

            other.ID  = "Other Document";
            col.Owner = other;
            Assert.AreEqual(other, styleDoc.Parent);

            //removing the time should not set the owner.
            col.Remove(styleDoc);
            Assert.IsNull(styleDoc.Parent);

            //multiple hierarchy
            StylesDocument inner = new StylesDocument();

            styleDoc.Styles.Add(inner);
            doc.Styles.Add(styleDoc);
            Assert.AreEqual(inner.Parent, styleDoc);
            Assert.AreEqual(other, styleDoc.Parent);
        }