/// <summary>
        /// Assigns the property value to the property of every source element.
        /// </summary>
        /// <param name="value">Property value to be assigned.</param>
        public override void SetPropertyValue(object value)
        {
            Double?valueD = null;

            // empty string values are treated as null...
            if (String.IsNullOrEmpty(value as string))
            {
                value = null;
            }
            if (String.IsNullOrWhiteSpace(value as string))
            {
                value = null;
            }

            try
            {
                if (value != null)
                {
                    valueD = Convert.ToDouble(value);
                }
            }
            catch
            {
                IMessageBoxService messageBox = this.GlobalServiceProvider.Resolve <IMessageBoxService>();
                messageBox.ShowError("Could not set new value: Conversion failed");
                return;
            }

            using (Transaction transaction = this.Store.TransactionManager.BeginTransaction("Update property value - " + this.PropertyName))
            {
                PropertyGridEditorViewModel.SetPropertyValues(this.Elements, this.PropertyName, valueD);
                transaction.Commit();
            }
        }
        /// <summary>
        /// Edit element executed.
        /// </summary>
        protected virtual void EditElementCommand_Executed()
        {
            // update the default values list first.
            this.UpdateDefaultValuesList();

            using (SelectElementViewModel vm = new SelectElementViewModel(this.ViewModelStore, this.DefaultValues))
            {
                vm.Title = "Select a role player";

                //if (this.Elements.Count == 1)
                //    vm.Title += " of type " + this.ViewModelStore.ElementTypeProvider.GetTypeDisplayName(this.Elements[0] as ModelElement);

                bool?result = this.GlobalServiceProvider.Resolve <IUIVisualizerService>().ShowDialog("SelectElementPopup", vm);
                if (result == true)
                {
                    try
                    {
                        using (Transaction transaction = this.Store.TransactionManager.BeginTransaction("Update role value - " + this.PropertyName))
                        {
                            PropertyGridEditorViewModel.SetPropertyValues(this.Elements, this.PropertyName, vm.SelectedElement);
                            transaction.Commit();
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Windows.MessageBox.Show("Error while adding: " + ex.Message);
                    }
                }
            }
            GC.Collect();
        }
Exemple #3
0
        /// <summary>
        /// Assigns the property value to the property of every source element.
        /// </summary>
        /// <param name="value">Property value to be assigned.</param>
        public override void SetPropertyValue(object value)
        {
            if (!this.IsFlags)
            {
                Enum eValue = value as Enum;
                if (value as string == NullElement)
                {
                    eValue = null;
                }

                using (Transaction transaction = this.Store.TransactionManager.BeginTransaction("Update property value - " + this.PropertyName))
                {
                    PropertyGridEditorViewModel.SetPropertyValues(this.Elements, this.PropertyName, eValue);
                    transaction.Commit();
                }
            }
            else
            {
                Enum eValue;

                string v = value as String;
                if (String.IsNullOrEmpty(v))
                {
                    eValue = null;
                }
                else
                {
                    string[] vals       = v.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                    string   parsedVals = "";

                    foreach (string literal in vals)
                    {
                        if (parsedVals != "")
                        {
                            parsedVals += ",";
                        }
                        parsedVals += literal.Trim();
                    }

                    eValue = (Enum)Enum.Parse(this.enumType, parsedVals);
                }

                using (Transaction transaction = this.Store.TransactionManager.BeginTransaction("Update property value - " + this.PropertyName))
                {
                    PropertyGridEditorViewModel.SetPropertyValues(this.Elements, this.PropertyName, eValue);
                    transaction.Commit();
                }
            }
        }
 /// <summary>
 /// Delete element executed.
 /// </summary>
 protected virtual void DeleteElementCommand_Executed()
 {
     try
     {
         using (Transaction transaction = this.Store.TransactionManager.BeginTransaction("Update role value - " + this.PropertyName))
         {
             PropertyGridEditorViewModel.SetPropertyValues(this.Elements, this.PropertyName, null);
             transaction.Commit();
         }
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show("Error while deleting: " + ex.Message);
     }
 }
Exemple #5
0
        /// <summary>
        /// Assigns the property value to the property of every source element.
        /// </summary>
        /// <param name="value">Property value to be assigned.</param>
        public override void SetPropertyValue(object value)
        {
            // empty string values are treated as null...
            if (String.IsNullOrEmpty(value as string))
            {
                value = null;
            }
            if (String.IsNullOrWhiteSpace(value as string))
            {
                value = null;
            }

            using (Transaction transaction = this.Store.TransactionManager.BeginTransaction("Update property value - " + this.PropertyName))
            {
                PropertyGridEditorViewModel.SetPropertyValues(this.Elements, this.PropertyName, value);
                transaction.Commit();
            }
        }
        /// <summary>
        /// Assigns the property value to the property of every source element.
        /// </summary>
        /// <param name="value">Property value to be assigned.</param>
        public override void SetPropertyValue(object value)
        {
            bool?bValue = null;

            if (value as string == TrueElement)
            {
                bValue = true;
            }
            else if (value as string == FalseElement)
            {
                bValue = false;
            }

            using (Transaction transaction = this.Store.TransactionManager.BeginTransaction("Update property value - " + this.PropertyName))
            {
                PropertyGridEditorViewModel.SetPropertyValues(this.Elements, this.PropertyName, bValue);
                transaction.Commit();
            }
        }