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); } }
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; }
private static DashboardNodePropertyBase CheckDashboardProperty(MyProject project, Dashboard dashboard, int nodeId, string taskName, string propertyName) { var node = project.Network.GetChildNodeById(nodeId) as MyWorkingNode; Assert.NotNull(node); MyTask task = node.GetTaskByPropertyName(taskName); Assert.NotNull(task); DashboardNodePropertyBase property = dashboard.Get(task, propertyName); Assert.NotNull(property); return(property); }