public HitbaseControl AddControlFromStream(int parentControlID, int controlIndex, byte[] objectStream, bool keepControlID) { BinaryFormatter bf = new BinaryFormatter(); MemoryStream mem = new MemoryStream(objectStream); HitbaseControl parentCtl = FindHitbaseControlFromID(parentControlID); HitbaseControl ctl = (HitbaseControl)bf.Deserialize(mem); PropertyInfo[] propInfo = ctl.GetType().GetProperties(); HitbaseControl newControl = Activator.CreateInstance(ctl.GetType(), this) as HitbaseControl; foreach (PropertyInfo pi in propInfo) { if (pi.CanWrite) { pi.SetValue(newControl, pi.GetValue(ctl, null), null); } } if (keepControlID) { PropertyInfo piControlID = ctl.GetType().GetProperty("ControlID"); newControl.SetControlID((int)piControlID.GetValue(ctl, null)); } AddHitbaseControl(parentCtl, controlIndex, newControl); mem.Close(); return(newControl); }
public void ChangeProperty(HitbaseControl ctl, string property, object value) { //TODO_WPF!!!!!!!!!!!!!undoEngine.BeginUndoStep(StringTable.PropertyChanged); PropertyInfo propInfo = ctl.GetType().GetProperty(property); //TODO_WPF!!!!!!!!!!!!!undoEngine.AddPropertyChange(ctl.ControlID, property, propInfo.GetValue(ctl, null)); propInfo.SetValue(ctl, value, null); //TODO_WPF!!!!!!!!!!!!!undoEngine.EndUndoStep(); }