コード例 #1
0
ファイル: LinkItemsForm.cs プロジェクト: SteveDunn/oglr
        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
ファイル: CustomProperty.cs プロジェクト: SteveDunn/oglr
        public CustomProperty Clone()
        {
            var result = new CustomProperty(Name, Value, Type, Description);

            return(result);
        }
コード例 #4
0
ファイル: CustomProperty.cs プロジェクト: SteveDunn/oglr
        public CustomProperty Clone()
        {
            var result = new CustomProperty(Name, Value, Type, Description);

            return result;
        }