public ComponentRemovedUndoAction(DesignerReport report, ComponentEventArgs cea)
        {
            this.report   = report;
            oldComponent  = (Control)cea.Component;
            componentType = cea.Component.GetType();

            cx    = oldComponent.Location.X;
            cy    = oldComponent.Location.Y;
            width = oldComponent.Width;
            heigh = oldComponent.Height;
            if (oldComponent is System.Windows.Forms.Label)
            {
                strFormat = report.GetPropertyValue(oldComponent.Name, "Format");
            }
        }
示例#2
0
        public ComponentChangedUndoAction(DesignerReport report, ComponentChangedEventArgs ea)
        {
            this.report       = report;
            this.oldcomponent = ea.Component;

            if (this.oldcomponent is Control)
            {
                this.componentName = ((Control)oldcomponent).Name;
            }

            this.member   = ea.Member;
            this.PropName = ea.Member.Name;

            if (ea.Component is PictureBox && PropName == "Image")
            {
                PictureBox pictureBox = ea.Component as PictureBox;
                if (pictureBox != null)
                {
                    oldImagePath = report.GetPropertyValue(pictureBox.Name, "Image");
                }
            }

            fieldName   = staticfieldName;
            objName     = staticobjName;
            XmlPropName = staticXmlPropName;

            isCollection = ea.NewValue is IList;

            if (isCollection)
            {
                IList    oldCol   = (IList)ea.OldValue;
                IList    newCol   = (IList)ea.NewValue;
                object[] newArray = new object[newCol.Count];
                isComponentCollection = false;
                if (newCol.Count > 0)
                {
                    isComponentCollection = newCol[0] is IComponent;
                }

                if (oldCol != null)
                {
                    object[] oldArray = new object[oldCol.Count];
                    if (isComponentCollection)
                    {
                        int idx = 0;
                        foreach (IComponent cmp in oldCol)
                        {
                            oldArray[idx++] = cmp.Site.Name;
                        }
                    }
                    else
                    {
                        oldCol.CopyTo(oldArray, 0);
                    }
                    this.oldValue = oldArray;
                }

                if (isComponentCollection)
                {
                    int idx = 0;
                    foreach (IComponent cmp in newCol)
                    {
                        newArray[idx++] = cmp.Site.Name;
                    }
                }
                else
                {
                    newCol.CopyTo(newArray, 0);
                }

                this.newValue = newArray;
            }
            else
            {
                this.oldValue = ea.OldValue;
                this.newValue = ea.NewValue;
            }
        }
示例#3
0
        public void Undo()
        {
            //			if(oldValue == null) return;

            if (oldcomponent == null)
            {
                return;
            }

            object component = null;

            if (oldcomponent is Control && componentName != null)
            {
                component = report.GetControl(oldcomponent as Control, componentName);
                // report.DestroyComponent(oldcomponent as Control);
                //component = oldcomponent;
            }

            if (component == null)
            {
                component = oldcomponent;
            }

            report.OnComponentChanging(component, member);
            if (component is PictureBox && PropName == "Image" && oldImagePath != null)
            {
                PictureBox pictureBox = component as PictureBox;
                newImagePath = report.GetPropertyValue(pictureBox.Name, "Image");

                SetPictureBoxImage(component as PictureBox, oldImagePath);
                //report.Edit_Info("Name", pictureBox.Name, "Image", oldImagePath);
                return;
            }

            Type         t     = component.GetType();
            PropertyInfo pInfo = t.GetProperty(member.Name);

            try
            {
                pInfo.SetValue(component, oldValue, null);
                //control.Location = new Point(control.Location.X, base2.Top + control.垂直位置);
                //component.
                if (component is CustomControl)
                {
                    ((CustomControl)component).Cs.Remove();
                    BandBase base2 = report.FindBandPosY(((CustomControl)component).Location.Y);
                    ((CustomControl)component).Band = base2;
                    ((CustomControl)component).垂直位置 = ((CustomControl)component).Location.Y - ((CustomControl)component).Band.Top;
                }

                if (component is BandDesigner)
                {
                    report.CurrentBandControl = (BandDesigner)component;
                    report.CurrentBand        = (BandBase)((BandDesigner)component).Tag;

                    report.ArrangeAreaDesigner();
                    report.SetRulers();
                    report.ArrangeBands();
                    report.BandControlPaint(this, null);
                }


                WriteXmlProperty(component, oldValue);
            }
            catch {}
            report.OnComponentChanged(component, member, newValue, oldValue);
        }