Пример #1
0
 /// <summary>
 /// Handles the event of a new row being added
 /// </summary>
 /// <param name="sender">The object that notified of the event</param>
 /// <param name="e">Attached arguments regarding the event</param>
 private void NewRowHandler(object sender, DataTableNewRowEventArgs e)
 {
     if (ObjectInitialiser != null)
     {
         ObjectInitialiser.InitialiseDataRow(e.Row);
     }
 }
Пример #2
0
        public Game1()
        {
            camPos   = new Vector2();
            r        = new Random();
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            collisionManager      = new CollisionManager();
            spriteLoader          = new Sprite_Loader();
            objectInitialiser     = new ObjectInitialiser();
            stageManager          = new StageManager(new MenuManager(new Vector2(gameWidth / 2 - 10, gameHeight / 2)), new PlayerManager());

            //Graphics
            //int pix = graphics.PreferredBackBufferWidth; 800
            //int pix2 = graphics.PreferredBackBufferHeight; 480
            graphics.PreferredBackBufferWidth  = gameWidth;
            graphics.PreferredBackBufferHeight = gameHeight;
        }
Пример #3
0
        /// <summary>
        /// Handles the event of a row being added
        /// </summary>
        /// <param name="e">Attached arguments regarding the event</param>
        private void RowAdded(DataRowChangeEventArgs e)
        {
            try
            {
                _isBeingAdded = true;
                BusinessObject newBo;
                try
                {
                    DeregisterForBOEvents();
                    newBo = (BusinessObject)_collection.CreateBusinessObject();
                }
                finally
                {
                    RegisterForBOEvents();
                }

                if (ObjectInitialiser != null)
                {
                    try
                    {
                        DeregisterForBOEvents();
                        ObjectInitialiser.InitialiseObject(newBo);
                    }
                    finally
                    {
                        RegisterForBOEvents();
                    }
                }
                DataRow row = e.Row;
                try
                {
                    DeregisterForBOEvents();
                    // set all the values in the grid to the bo's current prop values (defaults)
                    // make sure the part entered to create the row is not changed.
                    row[IDColumnName] = newBo.ID.ObjectID;
                    foreach (UIGridColumn uiProperty in _uiGridProperties)
                    {
                        //If no value was typed into the grid then use the default value for the property if one exists.
                        if (DBNull.Value.Equals(row[uiProperty.PropertyName]))
                        {
                            var boMapper = new BOMapper(newBo);
                            var propertyValueToDisplay = boMapper.GetPropertyValueToDisplay(uiProperty.PropertyName);
                            if (propertyValueToDisplay != null)
                            {
                                _table.Columns[uiProperty.PropertyName].ReadOnly = false;
                                row[uiProperty.PropertyName] = propertyValueToDisplay;
                            }
                        }
                        else
                        {
                            ApplyRowCellValueToBOProperty(row, uiProperty, newBo);
                        }
                    }
                }
                finally
                {
                    RegisterForBOEvents();
                }
                string message;
                if (newBo.Status.IsValid(out message))
                {
                    newBo.Save();
                    row.AcceptChanges();
                }
                row.RowError = message;
                if (newBo.Status.IsNew)
                {
                    _addedRows.Add(row, newBo);
                }

                if (newBo.ID.ObjectID == Guid.Empty)
                {
                    throw new HabaneroDeveloperException
                              ("Serious error The objectID is Empty", "Serious error The objectID is Empty");
                }
                _isBeingAdded = false;
            }
            catch (Exception ex)
            {
                _isBeingAdded = false;
                if (e.Row != null)
                {
                    e.Row.RowError = ex.Message;
                }
                throw;
            }
        }