Exemple #1
0
        private void addToGroupButton_Click(object sender, EventArgs e)
        {
            // This can be null if the category was selected.
            var selectedPropertyDescriptor = propertyGrid.SelectedGridItem.PropertyDescriptor as ProxyPropertyDescriptor;

            if (selectedPropertyDescriptor == null)
            {
                return;
            }

            DashboardNodePropertyBase property = DashboardViewModel.GetProperty(selectedPropertyDescriptor.Proxy.PropertyId);

            ProxyPropertyDescriptor selectedGroupDescriptor = GetCurrentGroupDescriptor();
            DashboardPropertyGroup  groupProperty           =
                GroupedDashboardViewModel.GetProperty(selectedGroupDescriptor.Proxy.PropertyId);

            try
            {
                groupProperty.Add(property);

                SetPropertyGridButtonsEnabled(false);
                RefreshAll();

                m_mainForm.ProjectStateChanged(string.Format("Dashboard property {0} added to group: {1}",
                                                             property.DisplayName, groupProperty.DisplayName));
            }
            catch (InvalidOperationException)
            {
                errorText.Text = string.Format("Cannot add a {0} property to a {1} group",
                                               selectedPropertyDescriptor.Proxy.TypeName,
                                               selectedGroupDescriptor.Proxy.TypeName);
            }
        }
Exemple #2
0
        private void PreserveGroupValue(string propertyName, object target)
        {
            DashboardNodePropertyBase property = DashboardViewModel.GetProperty(target, propertyName);

            if (property == null)
            {
                return;
            }

            DashboardPropertyGroup group = property.Group;

            if (group == null)
            {
                return;
            }

            object valueOfGroupMembers = @group.GroupedProperties
                                         .Select(member => member.GenericProxy.Value)
                                         .FirstOrDefault(value => !value.Equals(property.GenericProxy.Value));

            if (valueOfGroupMembers == null)
            {
                return;
            }

            MyLog.WARNING.WriteLine("Trying to change a group property {0}. Value reverted to {1}.", propertyName,
                                    valueOfGroupMembers);
            property.GenericProxy.Value = valueOfGroupMembers;
        }
 public DashboardGroupNameDialog(PropertyGrid sourceGrid, DashboardPropertyGroup group, GroupDashboard dashboard)
 {
     m_sourceGrid = sourceGrid;
     m_group      = @group;
     m_dashboard  = dashboard;
     InitializeComponent();
     groupNameText.Text = group.PropertyName;
 }
        public void AddsPropertyToGroup()
        {
            var node = new Node();

            var property = GetDirectProperty(node);

            var group = new DashboardPropertyGroup("Foo");

            group.Add(property);

            Assert.Equal(group.PropertyName, property.Group.PropertyName);
            Assert.True(group.GroupedProperties.Contains(property));
        }
        public void RemovesPropertyFromGroup()
        {
            var node = new Node();

            var property = GetDirectProperty(node);

            var group = new DashboardPropertyGroup("Foo");

            group.Add(property);
            group.Remove(property);

            Assert.Null(property.Group);
            Assert.Empty(group.GroupedProperties);
        }
        public void GroupDescriptorHasCorrectType()
        {
            var node = new Node();

            var property = GetDirectProperty(node);

            var group = new DashboardPropertyGroup("Foo");

            group.Add(property);

            var proxy      = group.GenericProxy;
            var descriptor = new ProxyPropertyDescriptor(ref proxy, new Attribute[0]);

            Assert.Equal(descriptor.PropertyType, typeof(string));
        }
        public void ProxyIsTransient()
        {
            var node = new Node();
            var task = new Task();

            var property = GetDirectProperty(node);

            Assert.Equal(property.GenericProxy, property.GenericProxy);

            var property2 = new DashboardTaskProperty(task, node.GetType().GetProperty("Name", BindingFlags.Public | BindingFlags.Instance));

            Assert.Equal(property2.GenericProxy, property2.GenericProxy);

            var property3 = new DashboardPropertyGroup("Foo");

            Assert.Equal(property3.GenericProxy, property3.GenericProxy);
        }
        public void GroupProxyChangesValues()
        {
            const string testName = "TestName";

            var node  = new Node();
            var node2 = new Node();

            var property = GetDirectProperty(node);

            var property2 = GetDirectProperty(node2);

            var group = new DashboardPropertyGroup("Foo");

            group.Add(property);
            group.Add(property2);

            group.GenericProxy.Value = testName;

            Assert.Equal(testName, node.Name);
            Assert.Equal(testName, node2.Name);
            Assert.Equal(testName, group.GenericProxy.Value);
        }