Example #1
0
		public void Initialize (EditSession session)
		{
			this.session = session;
			
			//if standard values are supported by the converter, then 
			//we list them in a combo
			if (session.Property.Converter.GetStandardValuesSupported (session))
			{
				store = new ListStore (typeof(string), typeof(object));

				//if converter doesn't allow nonstandard values, or can't convert from strings, don't have an entry
				if (session.Property.Converter.GetStandardValuesExclusive (session) || !session.Property.Converter.CanConvertFrom (session, typeof(string))) {
					combo = new ComboBox (store);
					var crt = new CellRendererText ();
					combo.PackStart (crt, true);
					combo.AddAttribute (crt, "text", 0);
				} else {
					combo = new ComboBoxEntry (store, 0);
					entry = ((ComboBoxEntry)combo).Entry;
					entry.HeightRequest = combo.SizeRequest ().Height;
				}

				PackStart (combo, true, true, 0);
				combo.Changed += TextChanged;
				
				//fill the list
				foreach (object stdValue in session.Property.Converter.GetStandardValues (session)) {
					store.AppendValues (session.Property.Converter.ConvertToString (session, stdValue), ObjectBox.Box (stdValue));
				}
				
				//a value of "--" gets rendered as a --, if typeconverter marked with UsesDashesForSeparator
				object[] atts = session.Property.Converter.GetType ()
					.GetCustomAttributes (typeof (StandardValuesSeparatorAttribute), true);
				if (atts.Length > 0) {
					string separator = ((StandardValuesSeparatorAttribute)atts[0]).Separator;
					combo.RowSeparatorFunc = (model, iter) => separator == ((string)model.GetValue (iter, 0));
				}
			}
			// no standard values, so just use an entry
			else {
				entry = new Entry ();
				PackStart (entry, true, true, 0);
			}

			//if we have an entry, fix it up a little
			if (entry != null) {
				entry.HasFrame = false;
				entry.Changed += TextChanged;
				entry.FocusOutEvent += FirePendingChangeEvent;
			}

			if (entry != null && ShouldShowDialogButton ()) {
				var button = new Button ("...");
				PackStart (button, false, false, 0);
				button.Clicked += ButtonClicked;
			}
			
			Spacing = 3;
			ShowAll ();
		}
		public void Initialize (EditSession session)
		{
			this.session = session;
			
			//if standard values are supported by the converter, then 
			//we list them in a combo
			if (session.Property.Converter.GetStandardValuesSupported (session))
			{
				ListStore store = new ListStore (typeof (string));
				ComboBoxEntry combo = new ComboBoxEntry (store, 0);
				PackStart (combo, true, true, 0);
				combo.Changed += TextChanged;
				entry = combo.Entry;
				entry.HeightRequest = combo.SizeRequest ().Height;
				
				//but if the converter doesn't allow nonstandard values, 
				// then we make the entry uneditable
				if (session.Property.Converter.GetStandardValuesExclusive (session)) {
					entry.IsEditable = false;
					entry.CanFocus = false;
				}
				
				//fill the list
				foreach (object stdValue in session.Property.Converter.GetStandardValues (session)) {
					store.AppendValues (session.Property.Converter.ConvertToString (session, stdValue));
				}
				
				//a value of "--" gets rendered as a --, if typeconverter marked with UsesDashesForSeparator
				object[] atts = session.Property.Converter.GetType ()
					.GetCustomAttributes (typeof (StandardValuesSeparatorAttribute), true);
				if (atts.Length > 0) {
					string separator = ((StandardValuesSeparatorAttribute)atts[0]).Separator;
					combo.RowSeparatorFunc = delegate (TreeModel model, TreeIter iter) {
						return separator == ((string) model.GetValue (iter, 0));
					};
				}
			}
			// no standard values, so just use an entry
			else {
				entry = new Entry ();
				PackStart (entry, true, true, 0);
			}
			
			//either way we have an entry to play with
			entry.HasFrame = false;
			entry.Activated += TextChanged;
			
			if (ShouldShowDialogButton ()) {
				Button button = new Button ("...");
				PackStart (button, false, false, 0);
				button.Clicked += ButtonClicked;
			}
			
			Spacing = 3;
			ShowAll ();
		}
		public void Initialize (EditSession session)
		{
			PropertyDescriptor prop = session.Property;
			
			if (!prop.PropertyType.IsEnum)
				throw new ApplicationException ("Flags editor does not support editing values of type " + prop.PropertyType);
			
			Spacing = 3;
			propType = prop.PropertyType;
			
			property = prop.Description;
			if (property == null || property.Length == 0)
				property = prop.Name;

			// For small enums, the editor is a list of checkboxes inside a frame
			// For large enums (>5), use a selector dialog.

			values = System.Enum.GetValues (prop.PropertyType);
			
			if (values.Length < 6) 
			{
				Gtk.VBox vbox = new Gtk.VBox (true, 3);

				flags = new Hashtable ();

				foreach (object value in values) {
					Gtk.CheckButton check = new Gtk.CheckButton (value.ToString ());
					check.TooltipText = value.ToString ();
					ulong uintVal = Convert.ToUInt64 (value);
					flags[check] = uintVal;
					flags[uintVal] = check;
					
					check.Toggled += FlagToggled;
					vbox.PackStart (check, false, false, 0);
				}

				Gtk.Frame frame = new Gtk.Frame ();
				frame.Add (vbox);
				frame.ShowAll ();
				PackStart (frame, true, true, 0);
			} 
			else 
			{
				flagsLabel = new Gtk.Entry ();
				flagsLabel.IsEditable = false;
				flagsLabel.HasFrame = false;
				flagsLabel.ShowAll ();
				PackStart (flagsLabel, true, true, 0);
				
				Gtk.Button but = new Gtk.Button ("...");
				but.Clicked += OnSelectFlags;
				but.ShowAll ();
				PackStart (but, false, false, 0);
			}
		}
Example #4
0
		public void Initialize (EditSession session)
		{
			propType = session.Property.PropertyType;
			
			double min, max;
			
			switch (Type.GetTypeCode (propType)) {
				case TypeCode.Int16:
					min = (double) Int16.MinValue;
					max = (double) Int16.MaxValue;
					break;
				case TypeCode.UInt16:
					min = (double) UInt16.MinValue;
					max = (double) UInt16.MaxValue;
					break;
				case TypeCode.Int32:
					min = (double) Int32.MinValue;
					max = (double) Int32.MaxValue;
					break;
				case TypeCode.UInt32:
					min = (double) UInt32.MinValue;
					max = (double) UInt32.MaxValue;
					break;
				case TypeCode.Int64:
					min = (double) Int64.MinValue;
					max = (double) Int64.MaxValue;
					break;
				case TypeCode.UInt64:
					min = (double) UInt64.MinValue;
					max = (double) UInt64.MaxValue;
					break;
				case TypeCode.Byte:
					min = (double) Byte.MinValue;
					max = (double) Byte.MaxValue;
					break;
				case TypeCode.SByte:
					min = (double) SByte.MinValue;
					max = (double) SByte.MaxValue;
					break;
				case TypeCode.Decimal:
					min = (double) Decimal.MinValue;
					max = (double) Decimal.MaxValue;
					break;
				default:
					throw new ApplicationException ("IntRange editor does not support editing values of type " + session.Property.PropertyType);
			}
			
			SetRange (min, max);
		}
Example #5
0
        public void Initialize(EditSession session)
        {
            propType = session.Property.PropertyType;

            double min, max;

            if (propType == typeof(double)) {
                min = Double.MinValue;
                max = Double.MaxValue;
            } else if (propType == typeof(float)) {
                min = float.MinValue;
                max = float.MaxValue;
            } else
                throw new ApplicationException (Catalog.GetString("FloatRange editor does not support editing values of type ") + propType);

            SetRange (min, max);

            Digits = 2;
        }
		public void Initialize (EditSession session)
		{
			PropertyDescriptor prop = session.Property;
			
			if (!prop.PropertyType.IsEnum)
				throw new ApplicationException ("Enumeration editor does not support editing values of type " + prop.PropertyType);
			
			values = System.Enum.GetValues (prop.PropertyType);
			Hashtable names = new Hashtable ();
			foreach (FieldInfo f in prop.PropertyType.GetFields ()) {
				DescriptionAttribute att = (DescriptionAttribute) Attribute.GetCustomAttribute (f, typeof(DescriptionAttribute));
				if (att != null)
					names [f.Name] = att.Description;
				else
					names [f.Name] = f.Name;
			}
				       
			
			ebox = new Gtk.EventBox ();
			ebox.Show ();
			PackStart (ebox, true, true, 0);

			combo = Gtk.ComboBoxEntry.NewText ();
			combo.Changed += combo_Changed;
			combo.Entry.IsEditable = false;
			combo.Entry.CanFocus = false;
			combo.Entry.HasFrame = false;
			combo.Entry.HeightRequest = combo.SizeRequest ().Height;
			combo.Show ();
			ebox.Add (combo);

			foreach (object value in values) {
				string str = prop.Converter.ConvertToString (value);
				if (names.Contains (str))
					str = (string) names [str];
				combo.AppendText (str);
			}
		}
 public void Initialize(EditSession session)
 {
     if (session.Property.PropertyType != typeof(char))
         throw new ApplicationException (Catalog.GetString("Char editor does not support editing values of type ") + session.Property.PropertyType);
 }
Example #8
0
        public void Initialize(EditSession session)
        {
            this.session = session;

            //if standard values are supported by the converter, then
            //we list them in a combo
            if (session.Property.Converter.GetStandardValuesSupported(session))
            {
                store = new ListStore(typeof(string), typeof(object));

                //if converter doesn't allow nonstandard values, or can't convert from strings, don't have an entry
                if (session.Property.Converter.GetStandardValuesExclusive(session) || !session.Property.Converter.CanConvertFrom(session, typeof(string)))
                {
                    combo = new ComboBox(store);
                    var crt = new CellRendererText();
                    combo.PackStart(crt, true);
                    combo.AddAttribute(crt, "text", 0);
                }
                else
                {
                    combo = new ComboBoxEntry(store, 0);
                    entry = ((ComboBoxEntry)combo).Entry;
                    entry.HeightRequest = combo.SizeRequest().Height;
                }

                PackStart(combo, true, true, 0);
                combo.Changed += TextChanged;

                //fill the list
                foreach (object stdValue in session.Property.Converter.GetStandardValues(session))
                {
                    store.AppendValues(session.Property.Converter.ConvertToString(session, stdValue), ObjectBox.Box(stdValue));
                }

                //a value of "--" gets rendered as a --, if typeconverter marked with UsesDashesForSeparator
                object[] atts = session.Property.Converter.GetType()
                                .GetCustomAttributes(typeof(StandardValuesSeparatorAttribute), true);
                if (atts.Length > 0)
                {
                    string separator = ((StandardValuesSeparatorAttribute)atts[0]).Separator;
                    combo.RowSeparatorFunc = (model, iter) => separator == ((string)model.GetValue(iter, 0));
                }
            }
            // no standard values, so just use an entry
            else
            {
                entry            = new Entry();
                entry.IsEditable = !session.Property.IsReadOnly;
                PackStart(entry, true, true, 0);
            }

            //if we have an entry, fix it up a little
            if (entry != null)
            {
                entry.HasFrame       = false;
                entry.Changed       += TextChanged;
                entry.FocusOutEvent += FirePendingChangeEvent;
                if (!entry.IsEditable)
                {
                    entry.ModifyText(StateType.Normal, entry.Style.Text(Gtk.StateType.Insensitive));
                }
            }

            if (entry != null && ShouldShowDialogButton() && entry.IsEditable)
            {
                var button = new Button("...");
                PackStart(button, false, false, 0);
                button.Clicked += ButtonClicked;
            }

            Spacing = 3;
            ShowAll();
        }
Example #9
0
 public void Fill(Player player, Pattern pattern, int radius, int depth = -1)
 {
     EditSession.Fill((BlockCoordinates)player.KnownPosition, pattern, new AirBlocksMask(player.Level), radius, depth);
 }
Example #10
0
        /// <summary>
        /// Commit the edits made to this instance since the last call
        /// to BeginEdit
        /// </summary>
        protected void EndEdit()
        {
            if (!this.IsEditing)
            {
                return;
            }

            #if SILVERLIGHT
            // Validate the instance itself (cross-field validation happens here)
            List<ValidationResult> validationResults = new List<ValidationResult>();
            ValidationUtilities.TryValidateObject(this, this.CreateValidationContext(), validationResults);

            // Replace all errors for this instance and notify our parent
            ValidationUtilities.ApplyValidationErrors(this, validationResults);
            this.NotifyParentMemberValidationChanged(null, validationResults);
            #else
            // Validate the instance itself (cross-field validation happens here)
            // TODO : The desktop version of the framework doesn't currently do
            // deep validation.
            Validator.ValidateObject(this, this.CreateValidationContext(), /*validateAllProperties*/ true);
            #endif
            this._editSession = null;
        }
Example #11
0
 /// <summary>
 /// Begin editing this instance
 /// </summary>
 protected void BeginEdit()
 {
     if (!this.IsEditing)
     {
         this._editSession = EditSession.Begin(this);
     }
 }
Example #12
0
        public void Line(Player player, int tileId, int tileData = 0, int thickness = 0, bool shell = false)
        {
            var pattern = new Pattern(tileId, tileData);

            EditSession.DrawLine(Selector, pattern, Selector.Position1, Selector.Position2, thickness, !shell);
        }
Example #13
0
		public void Initialize (EditSession session)
		{
			this.prop = session.Property;
			component = session.Instance;
			Entry.Destroyed += new EventHandler (entry_Changed);
			Entry.Activated += new EventHandler (entry_Activated);
		}
Example #14
0
        /// <summary>
        /// Commit the edits made to this entity since the last call
        /// to BeginEdit
        /// </summary>
        protected void EndEdit()
        {
            if (!this.IsEditing)
            {
                return;
            }

#if SILVERLIGHT
            // Validate the entity itself (cross-field validation happens here)
            List<ValidationResult> validationResults = new List<ValidationResult>();
            ValidationUtilities.TryValidateObject(this, this.CreateValidationContext(), validationResults);

            // Replace all errors for this entity
            ValidationUtilities.ApplyValidationErrors(this, validationResults);
#else
            // Validate the entity itself (cross-field validation happens here)
            // TODO : The desktop version of the framework doesn't currently do
            // deep validation.
            Validator.ValidateObject(this, this.CreateValidationContext(), /*validateAllProperties*/ true);
#endif
            // Close out the editing session, after capturing the set of modified properties
            // for notifications below.
            string[] modifiedProperties = this._editSession.ModifiedProperties.ToArray();
            this._editSession = null;

            this.UpdateRelatedAssociations(modifiedProperties);
        }
Example #15
0
        /// <summary>
        /// Cancel any edits made to this entity since the last call
        /// to BeginEdit
        /// </summary>
        protected void CancelEdit()
        {
            if (!this.IsEditing)
            {
                return;
            }

            // Cancel and close out the editing session, after capturing the set of modified properties
            // for notifications below.
            string[] modifiedProperties = this._editSession.ModifiedProperties.ToArray();
            this._editSession.Cancel();
            this._editSession = null;

            this.UpdateRelatedAssociations(modifiedProperties);
        }
Example #16
0
        public void Initialize(EditSession session)
        {
            propType = session.Property.PropertyType;
            var declarationParameter = ((ParticleParameterDescriptor)session.Property).DeclarationParameter;

            double min, max;

            switch (Type.GetTypeCode(propType))
            {
            case TypeCode.Int16:
                min = (double)Int16.MinValue;
                max = (double)Int16.MaxValue;
                break;

            case TypeCode.UInt16:
                min = (double)UInt16.MinValue;
                max = (double)UInt16.MaxValue;
                break;

            case TypeCode.Int32:
                min = (double)Int32.MinValue;
                max = (double)Int32.MaxValue;
                break;

            case TypeCode.UInt32:
                min = (double)UInt32.MinValue;
                max = (double)UInt32.MaxValue;
                break;

            case TypeCode.Int64:
                min = (double)Int64.MinValue;
                max = (double)Int64.MaxValue;
                break;

            case TypeCode.UInt64:
                min = (double)UInt64.MinValue;
                max = (double)UInt64.MaxValue;
                break;

            case TypeCode.Byte:
                min = (double)Byte.MinValue;
                max = (double)Byte.MaxValue;
                break;

            case TypeCode.SByte:
                min = (double)SByte.MinValue;
                max = (double)SByte.MaxValue;
                break;

            default:
                throw new ApplicationException(
                          "IntRange editor does not support editing values of type " + session.Property.PropertyType);
            }

            if (declarationParameter.MinValue != null && declarationParameter.MinValue.IsInt())
            {
                min = (double)Convert.ChangeType(declarationParameter.MinValue.Get <int>(), typeof(double));
            }

            if (declarationParameter.MaxValue != null && declarationParameter.MaxValue.IsInt())
            {
                max = (double)Convert.ChangeType(declarationParameter.MaxValue.Get <int>(), typeof(double));
            }

            if (declarationParameter.ValueStep != null && declarationParameter.ValueStep.IsInt())
            {
                int step = declarationParameter.ValueStep.Get <int>();
                SetIncrements(step, step);
            }

            SetRange(min, max);
        }
Example #17
0
        public void Paste(Player player, bool skipAir = false, bool selectAfter = true, bool pastAtOrigin = false)
        {
            try
            {
                RegionSelector selector = RegionSelector.GetSelector(player);

                Clipboard clipboard = selector.Clipboard;
                if (clipboard == null)
                {
                    player.SendMessage("Nothing in clipboard");
                    return;
                }

                Vector3 to = pastAtOrigin ? clipboard.Origin : (BlockCoordinates)player.KnownPosition;

                var rotateY = clipboard.Transform;

                var clipOffset = clipboard.GetMin() - clipboard.Origin;
                var realTo     = to + Vector3.Transform(clipOffset, rotateY);
                var max        = realTo + Vector3.Transform(clipboard.GetMax() - clipboard.GetMin(), rotateY);

                var blocks = clipboard.GetBuffer();
                foreach (Block block in blocks)
                {
                    if (skipAir && block is Air)
                    {
                        continue;
                    }

                    if (rotateY != Matrix4x4.Identity)
                    {
                        Vector3 vec = Vector3.Transform(block.Coordinates - clipboard.Origin, rotateY);
                        block.Coordinates = vec + to;
                    }
                    else
                    {
                        //Vector3 vec = (block.Coordinates - clipboard.Origin);
                        Vector3 vec = new Vector3(
                            block.Coordinates.X - clipboard.Origin.X + to.X,
                            block.Coordinates.Y - clipboard.Origin.Y + to.Y,
                            block.Coordinates.Z - clipboard.Origin.Z + to.Z);

                        block.Coordinates = vec;
                    }

                    EditSession.SetBlock(block);
                }

                if (selectAfter)
                {
                    selector.Select(realTo, max);
                }

                //Task.Run(() =>
                //{
                //	SkyLightCalculations.Calculate(player.Level);
                //	player.CleanCache();
                //	player.ForcedSendChunks(() =>
                //	{
                //		player.SendMessage("Calculated skylights and resent chunks.");
                //	});
                //});
            }
            catch (Exception e)
            {
                Log.Error("Paste", e);
            }
        }
Example #18
0
        public void Center(Player player, int tileId = 1, int tileData = 0)
        {
            var pattern = new Pattern(tileId, tileData);

            EditSession.Center(Selector, pattern);
        }
Example #19
0
 public void Replace(Player player, Mask mask, Pattern pattern)
 {
     EditSession.ReplaceBlocks(Selector, mask, pattern);
 }
Example #20
0
        public void Set(Player player, int tileId, int tileData = 0)
        {
            var pattern = new Pattern(tileId, tileData);

            EditSession.SetBlocks(Selector, pattern);
        }
Example #21
0
 public void Naturalize(Player player)
 {
     UndoRecorder.CheckForDuplicates = false;
     EditSession.Naturalize(player, Selector);
 }
 public void Initialize(EditSession session)
 {
 }
Example #23
0
 /// <summary>
 /// Resets internal entity state. For example, when the entity is 
 /// being attached (or reattached) to a set.
 /// </summary>
 internal void Reset()
 {
     this._originalValues = null;
     this._editSession = null;
     this._trackChanges = false;
     this.CustomMethodInvocation = null;
     if (this._validationErrors != null)
     {
         this._validationErrors.Clear();
     }
     this.EntityConflict = null;
     this.EntitySet = null;
     this._lastSet = null;
     this.EntityState = EntityState.Detached;
     this._hasChildChanges = false;
 }
Example #24
0
 public void Set(Player player, Pattern pattern)
 {
     EditSession.SetBlocks(Selector, pattern);
 }
Example #25
0
        /// <summary>
        /// Accept the current changes to this <see cref="Entity"/> applying the proper
        /// state transitions. If this <see cref="Entity"/> has compositional associations,
        /// any changes made to those associations or the child entities themselves will also
        /// be accepted. 
        /// </summary>
        protected void AcceptChanges()
        {
            if (this.EntityState == EntityState.Unmodified ||
                this.EntityState == EntityState.Detached)
            {
                // if we're detached or have no changes, noop after
                // closing any in progress edit session
                this._editSession = null;
                return;
            }

            EntitySet entitySet = this.LastSet;

            // Accept any child changes. Note, we must accept child changes before setting our own
            // state to Unmodified. This avoids a situation where we get notifications from child
            // entities that cause our state to flip back to Modified.
            if (entitySet != null)
            {
                // accept any child changes
                entitySet.EntityContainer.CompleteChildChanges(this, true);
            }

            if (this.EntityState == EntityState.New)
            {
                this.EntityState = EntityState.Unmodified;
                if (entitySet != null)
                {
                    entitySet.AddToCache(this);

                    // currently associations do not include New entities when loaded
                    // unless those entities have been explicitly added to the collection.
                    // Therefore, once the entity transitions from New to Unmodified, we need
                    // to process association updates.
                    if (this.IsEditing)
                    {
                        // only update if we're editing, in which case the updates
                        // have been deferred
                        entitySet.UpdateRelatedAssociations(this, "EntityState");
                    }
                }
                this.StartTracking();
            }
            else if (this.EntityState == EntityState.Modified)
            {
                this.EntityState = EntityState.Unmodified;
                this._originalValues = null;
            }
            else if (this.EntityState == EntityState.Deleted)
            {
                this.StopTracking();
                if (entitySet != null)
                {
                    entitySet.RemoveFromCache(this);
                }
                // move back to the default state
                this.EntityState = EntityState.Detached;
            }

            if (entitySet != null)
            {
                // remove from the interesting entities set
                entitySet.TrackAsInteresting(this, false);
            }

            // need to end any in progress edit session
            this._editSession = null;

            this.CustomMethodInvocation = null;
            if (this._validationErrors != null)
            {
                this._validationErrors.Clear();
            }
            this.EntityConflict = null;
            this.IsInferred = false;
            this._hasChildChanges = false;
            Debug.Assert(!this.HasChanges, "Entity.HasChanges should be false");
        }
Example #26
0
        /// <summary>
        /// Revert all property changes made to this entity back to their original values. This method
        /// does not revert <see cref="EntitySet"/> Add/Remove operations, so if this <see cref="Entity"/>
        /// is New or Deleted, this method does nothing. This method also reverts any pending custom
        /// method invocations on the entity. If this <see cref="Entity"/> has compositional associations,
        /// any changes made to those associations or the child entities themselves will be reverted.
        /// </summary>
        protected void RejectChanges()
        {
            if (this.EntityState == EntityState.Unmodified ||
                this.EntityState == EntityState.Detached)
            {
                // if we're detached or have no changes, noop after
                // closing any in progress edit session
                this._editSession = null;
                return;
            }

            EntitySet entitySet = this.LastSet;

            // Reject any child changes. Note, we must reject child changes before setting our own
            // state to Unmodified. This avoids a situation where we get notifications from child
            // entities that cause our state to flip back to Modified.
            if (entitySet != null)
            {
                entitySet.EntityContainer.CompleteChildChanges(this, false);
            }

            if (this._entityState == EntityState.Modified || this.Parent != null)
            {
                if (entitySet != null)
                {
                    // undo any compositional child updates by undoing
                    // the appropriate set operation
                    if (this.Parent != null)
                    {
                        if (this.EntityState == EntityState.Deleted)
                        {
                            entitySet.Add(this);
                        }
                        else if (this.EntityState == EntityState.New)
                        {
                            entitySet.Remove(this);
                            this.EntityState = EntityState.Detached;
                        }
                    }
                }

                if (this._originalValues != null)
                {
                    this.ApplyState(this._originalValues);
                    this._originalValues = null;
                }

                if (entitySet != null && this.EntityState == EntityState.Modified)
                {
                    this.EntityState = EntityState.Unmodified;
                    entitySet.TrackAsInteresting(this, false);
                }
            }

            // need to end any in progress edit session
            this._editSession = null;

            // Reseting custom method invocation needs to be outside here 
            // since invocation could be combined with other operations
            // which result in a non-Modified state
            this.CustomMethodInvocation = null;

            // Empty out the error collections
            if (this._validationErrors != null)
            {
                this._validationErrors.Clear();
            }
            this.EntityConflict = null;
            this._hasChildChanges = false;
            Debug.Assert(!this.HasChanges, "Entity.HasChanges should be false");
        }
#pragma warning restore 67

        public void StartTracking(EditSession editSession)
        {
            throw new NotImplementedException();
        }
 public void Initialize(EditSession session)
 {
 }
Example #29
0
		public void Initialize (EditSession session)
		{
			if (session.Property.PropertyType != typeof(System.Drawing.Color))
				throw new ApplicationException ("Color editor does not support editing values of type " + session.Property.PropertyType);
		}
Example #30
0
#pragma warning restore 67

        public void StartTracking(EditSession editSession)
        {
            throw new NotImplementedException();
        }
Example #31
0
        /// <summary>
        /// Cancel any edits made to this instance since the last call
        /// to BeginEdit
        /// </summary>
        protected void CancelEdit()
        {
            if (!this.IsEditing)
            {
                return;
            }

            this._editSession.Cancel();
            this._editSession = null;
        }
Example #32
0
        public void Initialize(EditSession session)
        {
            this.session = session;

            //if standard values are supported by the converter, then
            //we list them in a combo
            if (session.Inspector.Converter.GetStandardValuesSupported(session))
            {
                ListStore     store = new ListStore(typeof(string));
                ComboBoxEntry combo = new ComboBoxEntry(store, 0);
                PackStart(combo, true, true, 0);
                combo.Changed      += TextChanged;
                entry               = combo.Entry;
                entry.HeightRequest = combo.SizeRequest().Height;

                //but if the converter doesn't allow nonstandard values,
                // then we make the entry uneditable
                if (session.Inspector.Converter.GetStandardValuesExclusive(session))
                {
                    entry.IsEditable = false;
                    entry.CanFocus   = false;
                }

                //fill the list
                foreach (object stdValue in session.Inspector.Converter.GetStandardValues(session))
                {
                    store.AppendValues(session.Inspector.Converter.ConvertToString(session, stdValue));
                }

                //a value of "--" gets rendered as a --, if typeconverter marked with UsesDashesForSeparator
                object[] atts = session.Inspector.Converter.GetType()
                                .GetCustomAttributes(typeof(StandardValuesSeparatorAttribute), true);
                if (atts.Length > 0)
                {
                    string separator = ((StandardValuesSeparatorAttribute)atts[0]).Separator;
                    combo.RowSeparatorFunc = delegate(TreeModel model, TreeIter iter) {
                        return(separator == ((string)model.GetValue(iter, 0)));
                    };
                }
            }
            // no standard values, so just use an entry
            else
            {
                entry = new Entry();
                PackStart(entry, true, true, 0);
            }

            //either way we have an entry to play with
            entry.HasFrame   = false;
            entry.Activated += TextChanged;

            if (ShouldShowDialogButton())
            {
                Button button = new Button("...");
                PackStart(button, false, false, 0);
                button.Clicked += ButtonClicked;
            }

            Spacing = 3;
            ShowAll();
        }
Example #33
0
		public void Initialize (EditSession session)
		{
			if (session.Property.PropertyType != typeof(bool))
				throw new ApplicationException ("Boolean editor does not support editing values of type " + session.Property.PropertyType);
		}
Example #34
0
        public void Initialize(EditSession session)
        {
            PropertyDescriptor prop = session.Property;

            if (!prop.PropertyType.IsEnum)
            {
                throw new ApplicationException("Flags editor does not support editing values of type " + prop.PropertyType);
            }

            Spacing  = FlagsEditorCell.CheckSpacing;
            propType = prop.PropertyType;

            property = prop.Description;
            if (property == null || property.Length == 0)
            {
                property = prop.Name;
            }

            // For small enums, the editor is a list of checkboxes inside a frame
            // For large enums (>5), use a selector dialog.

            values = System.Enum.GetValues(prop.PropertyType);

            if (values.Length < FlagsEditorCell.MaxCheckCount)
            {
                Gtk.VBox vbox = new Gtk.VBox(true, FlagsEditorCell.CheckSpacing);

                flags = new Hashtable();

                foreach (object value in values)
                {
                    ulong           uintVal = Convert.ToUInt64(value);
                    Gtk.CheckButton check   = new BooleanEditor();
                    if (uintVal == 0)
                    {
                        check.Active = true;                         // default for None is always enabled
                    }
                    check.Label       = value.ToString();
                    check.TooltipText = value.ToString();
                    flags[check]      = uintVal;
                    flags[uintVal]    = check;

                    check.Toggled += FlagToggled;
                    vbox.PackStart(check, false, false, 3);
                }

                Gtk.Frame frame = new Gtk.Frame();
                frame.Add(vbox);
                frame.ShowAll();
                PackStart(frame, true, true, 0);
            }
            else
            {
                flagsLabel            = new Gtk.Entry();
                flagsLabel.IsEditable = false;
                flagsLabel.HasFrame   = false;
                flagsLabel.ShowAll();
                PackStart(flagsLabel, true, true, 0);

                Gtk.Button but = new Gtk.Button("...");
                but.Clicked += OnSelectFlags;
                but.ShowAll();
                PackStart(but, false, false, 0);
            }
        }