示例#1
0
 protected virtual void CreateMissingAspectGettersAndPutters()
 {
     for (int i = 0; i < base.Columns.Count; i++)
     {
         AspectGetterDelegate delegate2 = null;
         AspectPutterDelegate delegate3 = null;
         OLVColumn            column    = this.GetColumn(i);
         if ((column.AspectGetter == null) && !string.IsNullOrEmpty(column.AspectName))
         {
             if (delegate2 == null)
             {
                 delegate2 = delegate(object row) {
                     DataRowView view = row as DataRowView;
                     if (view != null)
                     {
                         return(view[column.AspectName]);
                     }
                     return(column.GetAspectByName(row));
                 };
             }
             column.AspectGetter = delegate2;
         }
         if ((column.IsEditable && (column.AspectPutter == null)) && !string.IsNullOrEmpty(column.AspectName))
         {
             if (delegate3 == null)
             {
                 delegate3 = delegate(object row, object newValue) {
                     DataRowView view = row as DataRowView;
                     if (view != null)
                     {
                         view[column.AspectName] = newValue;
                     }
                     else
                     {
                         column.PutAspectByName(row, newValue);
                     }
                 };
             }
             column.AspectPutter = delegate3;
         }
     }
 }
示例#2
0
        private void olv_CellEditFinishing(object sender, CellEditEventArgs e)
        {
            AspectPutterDelegate delegate2  = null;
            AspectPutterDelegate delegate3  = null;
            AspectPutterDelegate delegate4  = null;
            AspectPutterDelegate delegate5  = null;
            AspectPutterDelegate delegate6  = null;
            AspectPutterDelegate delegate7  = null;
            AspectPutterDelegate delegate8  = null;
            AspectPutterDelegate delegate9  = null;
            AspectPutterDelegate delegate10 = null;
            AspectPutterDelegate delegate11 = null;
            AspectPutterDelegate delegate12 = null;
            AspectPutterDelegate delegate13 = null;

            switch (e.Column.Index)
            {
            case 0:
                if (delegate2 == null)
                {
                    delegate2 = delegate(object x, object newValue) {
                        if (x is AtlasObject)
                        {
                            ((AtlasObject)x).Container1 = (string)newValue;
                            this.DataChanged            = true;
                        }
                    };
                }
                this.CSCont1.AspectPutter = delegate2;
                break;

            case 1:
                if (delegate3 == null)
                {
                    delegate3 = delegate(object x, object newValue) {
                        if (x is AtlasObject)
                        {
                            ((AtlasObject)x).Container2 = (string)newValue;
                            this.DataChanged            = true;
                        }
                    };
                }
                this.CSCont2.AspectPutter = delegate3;
                break;

            case 2:
                if (delegate4 == null)
                {
                    delegate4 = delegate(object x, object newValue) {
                        if ((x is AtlasObject) && (e.Column == this.CX1))
                        {
                            ((AtlasObject)x).X1 = Convert.ToSingle(newValue);
                            EditedFile.setPixelUnits(this.imageHeight);
                            this.DataChanged = true;
                        }
                    };
                }
                this.CX1.AspectPutter = delegate4;
                break;

            case 3:
                if (delegate5 == null)
                {
                    delegate5 = delegate(object x, object newValue) {
                        if ((x is AtlasObject) && (e.Column == this.CY1))
                        {
                            ((AtlasObject)x).Y1 = Convert.ToSingle(newValue);
                            EditedFile.setPixelUnits(this.imageHeight);
                            this.DataChanged = true;
                        }
                    };
                }
                this.CY1.AspectPutter = delegate5;
                break;

            case 4:
                if (delegate6 == null)
                {
                    delegate6 = delegate(object x, object newValue) {
                        if ((x is AtlasObject) && (e.Column == this.CX2))
                        {
                            ((AtlasObject)x).X2 = Convert.ToSingle(newValue);
                            EditedFile.setPixelUnits(this.imageHeight);
                            this.DataChanged = true;
                        }
                    };
                }
                this.CX2.AspectPutter = delegate6;
                break;

            case 5:
                if (delegate7 == null)
                {
                    delegate7 = delegate(object x, object newValue) {
                        if ((x is AtlasObject) && (e.Column == this.CY2))
                        {
                            ((AtlasObject)x).Y2 = Convert.ToSingle(newValue);
                            EditedFile.setPixelUnits(this.imageHeight);
                            this.DataChanged = true;
                        }
                    };
                }
                this.CY2.AspectPutter = delegate7;
                break;

            case 6:
                if (delegate8 == null)
                {
                    delegate8 = delegate(object x, object newValue) {
                        if ((x is AtlasObject) && (e.Column == this.CX3))
                        {
                            ((AtlasObject)x).X3 = Convert.ToSingle(newValue);
                            this.DataChanged    = true;
                        }
                    };
                }
                this.CX3.AspectPutter = delegate8;
                break;

            case 7:
                if (delegate9 == null)
                {
                    delegate9 = delegate(object x, object newValue) {
                        if ((x is AtlasObject) && (e.Column == this.CY3))
                        {
                            ((AtlasObject)x).Y3 = Convert.ToSingle(newValue);
                            this.DataChanged    = true;
                        }
                    };
                }
                this.CY3.AspectPutter = delegate9;
                break;

            case 8:
                if (delegate10 == null)
                {
                    delegate10 = delegate(object x, object newValue) {
                        if ((x is AtlasObject) && (e.Column == this.CX1P))
                        {
                            ((AtlasObject)x).PX1 = Convert.ToSingle(newValue);
                            ((AtlasObject)x).X1  = ((AtlasObject)x).PX1 / this.imageHeight;
                            this.DataChanged     = true;
                        }
                    };
                }
                this.CX1P.AspectPutter = delegate10;
                break;

            case 9:
                if (delegate11 == null)
                {
                    delegate11 = delegate(object x, object newValue) {
                        if ((x is AtlasObject) && (e.Column == this.CY1P))
                        {
                            ((AtlasObject)x).PY1 = Convert.ToSingle(newValue);
                            ((AtlasObject)x).Y1  = ((AtlasObject)x).PY1 / this.imageHeight;
                            this.DataChanged     = true;
                        }
                    };
                }
                this.CY1P.AspectPutter = delegate11;
                break;

            case 10:
                if (delegate12 == null)
                {
                    delegate12 = delegate(object x, object newValue) {
                        if ((x is AtlasObject) && (e.Column == this.CX2P))
                        {
                            ((AtlasObject)x).PX2 = Convert.ToSingle(newValue);
                            ((AtlasObject)x).X2  = ((AtlasObject)x).PX2 / this.imageHeight;
                            this.DataChanged     = true;
                        }
                    };
                }
                this.CX2P.AspectPutter = delegate12;
                break;

            case 11:
                if (delegate13 == null)
                {
                    delegate13 = delegate(object x, object newValue) {
                        if ((x is AtlasObject) && (e.Column == this.CY2P))
                        {
                            ((AtlasObject)x).PY2 = Convert.ToSingle(newValue);
                            ((AtlasObject)x).Y2  = ((AtlasObject)x).PY2 / this.imageHeight;
                            this.DataChanged     = true;
                        }
                    };
                }
                this.CY2P.AspectPutter = delegate13;
                break;
            }
            this.Refresh();
        }