public DAGroupProperties(ServerNode serverNode, DAGroupNode groupNode)
		{
			this.serverNode = serverNode;
            this.groupNode = groupNode;
			InitializeComponent();

            properties.Name = groupNode != null ? groupNode.Name : string.Empty;

			_propertyGrid.IsReadOnly = false;
			_propertyGrid.SelectedObject = properties;
            _acceptButton.Content = groupNode != null ? "OK" : "Create";

            if (groupNode != null)
            {
                groupNode.GetPropertiesAsync((task, args) =>
                {
                    if (args.Result != null)
                    {
                        var groupProperties = (GroupProperties)args.Result;
                        Mapper.Map(groupProperties, properties);
                        properties.PropertiesChanged();
                    }
                });                
            }
		}
        public DAGroupProperties(ServerNode serverNode, DAGroupNode groupNode)
        {
            this.serverNode = serverNode;
            this.groupNode  = groupNode;
            InitializeComponent();

            properties.Name = groupNode != null ? groupNode.Name : string.Empty;

            _propertyGrid.IsReadOnly     = false;
            _propertyGrid.SelectedObject = properties;
            _acceptButton.Content        = groupNode != null ? "OK" : "Create";

            if (groupNode != null)
            {
                groupNode.GetPropertiesAsync((task, args) =>
                {
                    if (args.Result != null)
                    {
                        var groupProperties = (GroupProperties)args.Result;
                        Mapper.Map(groupProperties, properties);
                        properties.PropertiesChanged();
                    }
                });
            }
        }
        public AddOrRemoveDAGroupItemResults(DAGroupNode.AddRemoveResult result)
		{
			InitializeComponent();

            var addedItems = new List<DAGroupItem>(result.ToAdd.Length);
            for (var i = 0; i < result.AddResult.Length; i++)
            {
                if (result.AddResult[i].Error != 0)
                {
                    addedItems.Add(new DAGroupItem
                    {
                        Name = result.ToAdd[i].ItemId,
                        Error = result.AddResult[i].Error,
                    });
                }
            }
            _itemToAddList.ItemsSource = addedItems;

            var removedItems = new List<DAGroupItem>(result.ToRemove.Count);
            for (var i = 0; i < result.RemoveResult.Length; i++)
            {
                if (result.RemoveResult[i] != 0)
                {
                    result.ToRemove[i].Error = result.RemoveResult[i];
                    removedItems.Add(result.ToRemove[i]);
                }
            }
            _itemToRemoveList.ItemsSource = removedItems;
        }
        public AddOrRemoveDAGroupItems(DAGroupNode groupNode)
        {
            this.groupNode = groupNode;
            InitializeComponent();

            groupNode.GetItemsFlatAsync((task, args) =>
            {
                var result = (string[])args.Result;
                items      = new ObservableCollection <DAGroupItem>(result.Select(x => new DAGroupItem
                {
                    Name     = x,
                    Selected = groupNode.Items.Any(y => y.Name == x)
                }));
                _itemList.ItemsSource = items;
            });
        }
        public AddOrRemoveDAGroupItems(DAGroupNode groupNode)
		{
            this.groupNode = groupNode;
			InitializeComponent();

            groupNode.GetItemsFlatAsync((task, args) =>
            {
                var result = (string[])args.Result;
                items = new ObservableCollection<DAGroupItem>(result.Select(x =>new DAGroupItem
                {
                    Name = x,
                    Selected = groupNode.Items.Any(y => y.Name == x)
                }));
                _itemList.ItemsSource = items;
            });
		}