public static void CopyFrom(this GameData To, GameData From, bool SkipNonSerialized = true) { Type targetType = To.GetType(); Type sourceType = From.GetType(); PropertyInfo[] sourceProps = sourceType.GetProperties(); foreach (var propInfo in sourceProps) { //filter the properties if (propInfo.GetCustomAttributes(typeof(NonSerializedAttribute), false).Length == 0 && SkipNonSerialized) continue; //Get the matching property from the target PropertyInfo toProp = (targetType == sourceType) ? propInfo : targetType.GetProperty(propInfo.Name); //If it exists and it's writeable if (toProp != null && toProp.CanWrite) { //Copy the value from the source to the target Object value = propInfo.GetValue(From, null); toProp.SetValue(To, value, null); } } }
public void SendResult(GameData.MailResult Result) { PacketOut Out = new PacketOut((byte)Opcodes.F_MAIL); Out.WriteByte(0x0F); Out.WriteUInt16((ushort)Result); GetPlayer().SendPacket(Out); }
public GameDataWrapper(GameData BaseObject = null) { data = BaseObject; if (data == null) data = new GameData(); }
void NewImage(Imageset imageset, GameData.Image image) { SettingDlg dlg = new SettingDlg("New image", image); if (dlg.ShowDialog() != DialogResult.OK) return; if (imageset.Contains(image.Name)) { MessageBox.Show(String.Format("The image '{0}' already exist!!", image.Name)); return; } imageset.Add(image); image.Imageset = imageset; ShowImageset(imageset); listView2.Items[listView2.Items.Count - 1].Selected = true; }
void ShowImage(GameData.Image image) { try { propertyGrid1.SelectedObject = image; propertyGrid1.Tag = image; if (panel1.BackgroundImage == null) return; Bitmap srcBitmap = new Bitmap(panel1.BackgroundImage); Rectangle rect = new Rectangle(image.X, image.Y, image.Width, image.Height); panel2.BackgroundImage = srcBitmap.Clone(rect, srcBitmap.PixelFormat); panel2.Size = panel2.BackgroundImage.Size; boundPanel.Visible = true; boundPanel.Location = new Point(image.X, image.Y); boundPanel.Size = new Size(image.Width, image.Height); } catch (Exception) { } }