예제 #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();
        }
예제 #2
0
파일: Model.cs 프로젝트: SteveDunn/oglr
        public void AddCustomProperty( ITreeItem treeItem, CustomProperty newCustomProperty )
        {
            treeItem.ItemProperties.CustomProperties.Add( newCustomProperty.Name, newCustomProperty ) ;

            tryFire( ( ) => ItemChanged, treeItem ) ;
        }
예제 #3
0
        public CustomProperty Clone()
        {
            var result = new CustomProperty(Name, Value, Type, Description);

            return(result);
        }
예제 #4
0
        public CustomProperty Clone()
        {
            var result = new CustomProperty(Name, Value, Type, Description);

            return result;
        }