Exemplo n.º 1
0
        void buttonOkClick(object sender, EventArgs e)
        {
            //todo: move to an action
            if (uiFirstItemCustomPropertyNameTextBox.Text=="")
            {
                MessageBox.Show(
                    @"Please specify a name for the Custom Property that is to be added to the first Item!",
                    @"Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error ) ;

                return;
            }

            if (uiLinkSecondItemToFirstCheckbox.Checked && uiSecondItemCustomPropertyNameTextBox.Text==string.Empty)
            {
                MessageBox.Show(
                    @"Please specify a name for the Custom Property that is to be added to the second Item!",
                    @"Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error ) ;

                return;
            }

            var model = ObjectFactory.GetInstance<IModel>() ;

            IEnumerable<ITreeItem> selectedEditors = model.Level.SelectedEditors.ToList(  ) ;

            ITreeItem firstSelectedItem = selectedEditors.First() ;

            CustomProperties customPropertiesForFirstItem = firstSelectedItem.ItemProperties.CustomProperties ;

            if (customPropertiesForFirstItem.ContainsKey(uiFirstItemCustomPropertyNameTextBox.Text))
            {
                MessageBox.Show(
                    "The first Item ({0}) already has a Custom Property named \"{1}\". Please use another name.".FormatWith(firstSelectedItem.ItemProperties.Name, uiFirstItemCustomPropertyNameTextBox.Text),
                    @"Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error ) ;

                return;
            }

            var customProperty = new CustomProperty
                {
                    Name = uiFirstItemCustomPropertyNameTextBox.Text,
                    Type = typeof( ItemEditor )
                } ;

            ITreeItem secondSelectItem = selectedEditors.ElementAt( 1 ) ;

            customProperty.Value = secondSelectItem;

            customPropertiesForFirstItem.Add(customProperty.Name, customProperty);

            if (uiLinkSecondItemToFirstCheckbox.Checked)
            {
                CustomProperties customPropertiesForSecondItem = secondSelectItem.ItemProperties.CustomProperties ;

                if (customPropertiesForSecondItem.ContainsKey(uiSecondItemCustomPropertyNameTextBox.Text))
                {
                    MessageBox.Show(
                        "The second Item ({0}) already has a Custom Property named \"{1}\". Please use another name!".FormatWith(secondSelectItem.ItemProperties.Name, uiSecondItemCustomPropertyNameTextBox.Text),
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information ) ;

                    customPropertiesForFirstItem.Remove(customProperty.Name);

                    return;
                }

                customProperty = new CustomProperty
                    {
                        Name = uiSecondItemCustomPropertyNameTextBox.Text,
                        Type = typeof( ItemEditor ),
                        Value = firstSelectedItem
                    } ;

                customPropertiesForSecondItem.Add(customProperty.Name, customProperty);
            }

            Hide();
        }
Exemplo n.º 2
0
        public void AddCustomProperty( ITreeItem treeItem, CustomProperty newCustomProperty )
        {
            treeItem.ItemProperties.CustomProperties.Add( newCustomProperty.Name, newCustomProperty ) ;

            tryFire( ( ) => ItemChanged, treeItem ) ;
        }
Exemplo n.º 3
0
        public CustomProperty Clone()
        {
            var result = new CustomProperty(Name, Value, Type, Description);

            return(result);
        }
Exemplo n.º 4
0
        public CustomProperty Clone()
        {
            var result = new CustomProperty(Name, Value, Type, Description);

            return result;
        }