Beispiel #1
0
 public void itemBag_GetValue(object sender, PropertySpecEventArgs e)
 {
     if (listViewItem.SelectedItems != null && listViewItem.SelectedItems.Count>0)
     {
         ListViewItem item = listViewItem.SelectedItems[0];
         e.Value = ((DataRow)item.Tag)[e.Property.Name];
     }
 }
Beispiel #2
0
        public void itemBag_SetValue(object sender, PropertySpecEventArgs e)
        {
            if (listViewItem.SelectedItems != null && listViewItem.SelectedItems.Count>0)
            {
                ListViewItem item = listViewItem.SelectedItems[0];
                //
                DataRow row = (DataRow)item.Tag;

                // little hack since the typconverter seems to be skipped if the mousewheel is used to select a value from propertygrid
                if (!row[e.Property.Name].GetType().IsAssignableFrom(e.Value.GetType()) && e.Property.ConverterTypeName!=null) {
                    TypeConverter conv =(TypeConverter) Activator.CreateInstance(Assembly.GetCallingAssembly().GetType(e.Property.ConverterTypeName));

                    Type destinationType = row.Table.Columns[e.Property.Name].DataType;

                    e.Value = conv.ConvertTo(e.Value,destinationType);
                }
                // little hackend

                row[e.Property.Name] = e.Value;
            }
        }
Beispiel #3
0
 void areaBag_GetValue(object sender, PropertySpecEventArgs e)
 {
     if (DB.areaBinding.Current != null)
     {
         DataRowView rowView = ((DataRowView)DB.areaBinding.Current);
         if (rowView.Row.RowState == DataRowState.Detached)
         {
             e.Value = null;
             return;
         }
         switch (e.Property.Name)
         {
             case "Width":
                 e.Value = rowView[DB.COL_AREA_Z];
                 break;
             case "Height":
                 e.Value = rowView[DB.COL_AREA_R];
                 break;
             default:
                 e.Value = rowView[e.Property.Name];
                 break;
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// This member overrides PropertyBag.OnGetValue.
 /// </summary>
 protected override void OnGetValue(PropertySpecEventArgs e)
 {
     e.Value = propValues[e.Property.Name];
     base.OnGetValue(e);
 }
        void questPartBag_SetValue(object sender, PropertySpecEventArgs e)
        {
            if (QuestPartRow!=null)
            {
                DataRow row = QuestPartRow.Row;

                // little hack since the typconverter seems to be skipped if the mousewheel is used to select a value from propertygrid
                if (!row[e.Property.Name].GetType().IsAssignableFrom(e.Value.GetType()))
                {
                    TypeConverter conv = (TypeConverter)Activator.CreateInstance(Assembly.GetCallingAssembly().GetType(e.Property.ConverterTypeName));

                    Type destinationType = row.Table.Columns[e.Property.Name].DataType;

                    e.Value = conv.ConvertTo(e.Value, destinationType);
                }
                // little hackend

                if (e.Property.Name == DB.COL_QUESTPART_CATEGORY)
                {
                    string categoryString = (string)e.Value;

                    if (!categoryString.EndsWith(";"))
                        categoryString += ";";
                    row[e.Property.Name] = categoryString;

                    string[] categories = categoryString.Split(';');
                    foreach (string category in categories)
                    {
                        DB.AddQuestPartCategory(category);
                    }
                }
                else
                {
                    row[e.Property.Name] = e.Value;
                }
                // update objectname if name changed
                /*if (e.Property.Name == DB.COL_NPC_NAME)
                {
                    row[DB.COL_NPC_OBJECTNAME] = Utils.ConvertToObjectName((String)e.Value);
                }*/

            }
        }
 void questPartBag_GetValue(object sender, PropertySpecEventArgs e)
 {
     if (QuestPartRow!=null)
     {
         e.Value = QuestPartRow.Row[e.Property.Name];
     }
 }
Beispiel #7
0
 /// <summary>
 /// This member overrides PropertyBag.OnSetValue.
 /// </summary>
 protected override void OnSetValue(PropertySpecEventArgs e)
 {
     propValues[e.Property.Name] = e.Value;
     base.OnSetValue(e);
 }
Beispiel #8
0
 /// <summary>
 /// This member overrides PropertyBag.OnGetValue.
 /// </summary>
 protected override void OnGetValue(PropertySpecEventArgs e)
 {
     e.Value = propValues[e.Property.Name];
     base.OnGetValue(e);
 }
 void locationBag_GetValue(object sender, PropertySpecEventArgs e)
 {
     if (DB.locationBinding.Current != null)
     {
         DataRowView rowView = ((DataRowView)DB.locationBinding.Current);
         switch (e.Property.Name)
         {
             default:
                 e.Value = rowView[e.Property.Name];
                 break;
         }
     }
 }
Beispiel #10
0
            public override object GetValue(object component)
            {
                // Have the property bag raise an event to get the current value
                // of the property.

                PropertySpecEventArgs e = new PropertySpecEventArgs(item, null);
                bag.OnGetValue(e);
                return e.Value;
            }
Beispiel #11
0
        public void npcBag_SetValue(object sender, PropertySpecEventArgs e)
        {
            if (listViewNPC.SelectedItems != null && listViewNPC.SelectedItems.Count>0)
            {
                ListViewItem item = listViewNPC.SelectedItems[0];

                DataRow row = (DataRow)item.Tag;

                // little hack since the typconverter seems to be skipped if the mousewheel is used to select a value from propertygrid
                if (!row[e.Property.Name].GetType().IsAssignableFrom(e.Value.GetType()))
                {
                    TypeConverter conv = (TypeConverter)Activator.CreateInstance(Assembly.GetCallingAssembly().GetType(e.Property.ConverterTypeName));

                    Type destinationType = row.Table.Columns[e.Property.Name].DataType;

                    e.Value = conv.ConvertTo(e.Value, destinationType);
                }
                // little hackend

                row[e.Property.Name] = e.Value;
                // update objectname if name changed
                if (e.Property.Name == DB.COL_NPC_NAME)
                {
                    row[DB.COL_NPC_OBJECTNAME] = Utils.ConvertToObjectName((String)e.Value);
                }
            }
        }
Beispiel #12
0
        void areaBag_SetValue(object sender, PropertySpecEventArgs e)
        {
            if (DB.areaBinding.Current != null)
            {
                DataRowView rowView = ((DataRowView)DB.areaBinding.Current);
                if (rowView.Row.RowState == DataRowState.Detached)
                {
                    return;
                }

                switch (e.Property.Name)
                {
                    case "Name":
                        rowView[e.Property.Name] = e.Value;
                        rowView[DB.COL_AREA_OBJECTNAME] = Utils.ConvertToObjectName((string)e.Value);
                        break;
                    case "Width":
                        rowView[DB.COL_AREA_Z] = e.Value;
                        break;
                    case "Height":
                        rowView[DB.COL_AREA_R] = e.Value;
                        break;
                    default:

                        // little hack since the typconverter seems to be skipped if the mousewheel is used to select a value from propertygrid
                        if (!DB.AreaTable.Columns[e.Property.Name].DataType.IsAssignableFrom(e.Value.GetType()))
                        {
                            TypeConverter conv = (TypeConverter)Activator.CreateInstance(Assembly.GetCallingAssembly().GetType(e.Property.ConverterTypeName));
                            e.Value = conv.ConvertTo(e.Value, DB.AreaTable.Columns[e.Property.Name].DataType);
                        }

                        rowView[e.Property.Name] = e.Value;
                        break;
                }
                if ("AreaType".Equals(e.Property.Name))
                {
                    if (Const.AREA_SQUARE.Equals(e.Value))
                        propertyGridArea.SelectedObject = areaSquareBag;
                    else
                        propertyGridArea.SelectedObject = areaCircleBag;
                }

                propertyGridArea.Refresh();
                dataGridArea.Refresh();
            }
        }
Beispiel #13
0
        void locationBag_SetValue(object sender, PropertySpecEventArgs e)
        {
            if (DB.locationBinding.Current != null)
            {
                DataRowView rowView;
                switch (e.Property.Name)
                {
                    case "Name":
                        rowView = ((DataRowView)DB.locationBinding.Current);

                        rowView[DB.COL_LOCATION_OBJECTNAME] = Utils.ConvertToObjectName((string)e.Value);

                        ((DataRowView)DB.locationBinding.Current)[e.Property.Name] = e.Value;
                        break;
                    default:

                        // little hack since the typconverter seems to be skipped if the mousewheel is used to select a value from propertygrid
                        if (!DB.LocationTable.Columns[e.Property.Name].DataType.IsAssignableFrom(e.Value.GetType()))
                        {
                            TypeConverter conv = (TypeConverter)Activator.CreateInstance(Assembly.GetCallingAssembly().GetType(e.Property.ConverterTypeName));
                            e.Value = conv.ConvertTo(e.Value, DB.LocationTable.Columns[e.Property.Name].DataType);
                        }

                        ((DataRowView)DB.locationBinding.Current)[e.Property.Name] = e.Value;
                        break;
                }
                propertyGridLocation.Refresh();
                dataGridViewLocation.Refresh();
            }
        }
Beispiel #14
0
 /// <summary>
 /// This member overrides PropertyBag.OnSetValue.
 /// </summary>
 protected override void OnSetValue(PropertySpecEventArgs e)
 {
     propValues[e.Property.Name] = e.Value;
     base.OnSetValue(e);
 }
Beispiel #15
0
 void bag_GetValue(object sender, PropertySpecEventArgs e)
 {
     e.Value = m_propetyTable[e.Property.Name];
 }
Beispiel #16
0
 /// <summary>
 /// Raises the SetValue event.
 /// </summary>
 /// <param name="e">A PropertySpecEventArgs that contains the event data.</param>
 protected virtual void OnSetValue(PropertySpecEventArgs e)
 {
     if(SetValue != null)
         SetValue(this, e);
 }
Beispiel #17
0
        void bag_SetValue(object sender, PropertySpecEventArgs e)
        {
            if ( (e.Property.Attributes[0]  as ReadOnlyAttribute).IsReadOnly)
            return;

             m_isChangableTable.Remove(e.Property.Name);
             m_isChangableTable.Add(e.Property.Name, true);
             m_propetyTable.Remove(e.Property.Name);
             m_propetyTable.Add(e.Property.Name, e.Value);
        }
Beispiel #18
0
            public override void SetValue(object component, object value)
            {
                // Have the property bag raise an event to set the current value
                // of the property.

                PropertySpecEventArgs e = new PropertySpecEventArgs(item, value);
                bag.OnSetValue(e);
            }
Beispiel #19
0
            public override void SetValue(object component, object value)
            {
                PropertySpecEventArgs e = new PropertySpecEventArgs(item, value);

                bag.OnSetValue(e);
            }