Exemplo n.º 1
0
        private void buttonAddAttribute_Click(object sender, EventArgs e)
        {
            SolidEdgeFramework.AttributeSets attributeSets = null;
            SolidEdgeFramework.AttributeSet attributeSet = null;
            SolidEdgeFramework.Attribute attribute = null;

            var dialog = new AddAttributeDialog();
            
            if (dialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                var setName = dialog.SetName;
                var attributeName = dialog.AttributeName;
                var attributevalue = dialog.AttributeValue;

                dynamic selectSetItem = lvAttributes.Tag;

                attributeSets = selectSetItem.AttributeSets;
                
                try
                {
                    attributeSet = attributeSets.Item(setName);
                }
                catch
                {
                    attributeSet = attributeSets.Add(setName);
                }

                attribute = attributeSet.Add(attributeName, SolidEdgeFramework.AttributeTypeConstants.seStringUnicode);
                attribute.Value = attributevalue;
            }

            UpdateListView();
        }
Exemplo n.º 2
0
        private void buttonRemoveAttribute_Click(object sender, EventArgs e)
        {
            SolidEdgeFramework.AttributeSets attributeSets = null;
            SolidEdgeFramework.AttributeSet attributeSet = null;

            List<ListViewItem> itemsToDelete = new List<ListViewItem>();

            foreach (ListViewItem item in lvAttributes.SelectedItems)
            {
                if (item.Selected)
                {
                    itemsToDelete.Add(item);
                }
            }

            dynamic selectSetItem = lvAttributes.Tag;

            foreach (var item in itemsToDelete)
            {
                var setName = item.Text;
                var attributeName = item.SubItems[1].Text;

                attributeSets = selectSetItem.AttributeSets;
                attributeSet = attributeSets.Item(setName);
                attributeSet.Remove(attributeName);

                if (attributeSet.Count == 0)
                {
                    attributeSets.Remove(attributeSet.SetName);
                }

                lvAttributes.Items.Remove(item);
            }
        }
Exemplo n.º 3
0
        private void UpdateListView()
        {
            SolidEdgeFramework.AttributeSets attributeSets = null;
            SolidEdgeFramework.AttributeSet attributeSet = null;
            SolidEdgeFramework.Attribute attribute = null;

            lvAttributes.Items.Clear();
            buttonAddAttribute.Enabled = false;
            buttonRemoveAttribute.Enabled = false;

            if (lvAttributes.Tag != null)
            {
                buttonAddAttribute.Enabled = true;

                dynamic selectSetItem = lvAttributes.Tag;
                attributeSets = selectSetItem.AttributeSets;

                for (int i = 1; i <= attributeSets.Count; i++)
                {
                    attributeSet = attributeSets.Item(i);

                    for (int j = 1; j <= attributeSet.Count; j++)
                    {
                        var lvItem = new ListViewItem();

                        attribute = attributeSet.Item(j);
                        lvItem.Text = attributeSet.SetName;
                        lvItem.SubItems.Add(attribute.Name);
                        lvItem.SubItems.Add(attribute.Value.ToString());
                        lvItem.SubItems.Add(attribute.Value.GetType().FullName);

                        lvAttributes.Items.Add(lvItem);
                    }
                }
            }
        }