void CopyValue(string value) { if (listBox1.SelectedIndex == -1) { return; } ClipBoardItem cl = new ClipBoardItem(); if (value == "pos_") { cl.Type = ClipBoardItem.ClipboardType.Position; cl.X = Value[listBox1.SelectedIndex].X; cl.Y = Value[listBox1.SelectedIndex].Y; cl.Z = Value[listBox1.SelectedIndex].Z; } else if (value == "Arg") { cl.Type = ClipBoardItem.ClipboardType.IntArray; cl.Args = Value[listBox1.SelectedIndex].Args.ToArray(); } Form1.clipboard.Add(cl); if (Form1.clipboard.Count > 10) { Form1.clipboard.RemoveAt(0); } ClipBoardMenu_Paste.DropDownItems.Clear(); List <ToolStripMenuItem> Items = new List <ToolStripMenuItem>(); for (int i = 0; i < Form1.clipboard.Count; i++) { ToolStripMenuItem btn = new ToolStripMenuItem(); btn.Name = "ClipboardN" + i.ToString(); btn.Text = Form1.clipboard[i].ToString(); btn.Click += QuickClipboardItem_Click; Items.Add(btn); } Items.Reverse(); ClipBoardMenu_Paste.DropDownItems.AddRange(Items.ToArray()); }
void PasteValue(ClipBoardItem itm) { if (listBox1.SelectedIndex == -1) { return; } if (itm.Type == ClipBoardItem.ClipboardType.Position) { Value[listBox1.SelectedIndex].X = itm.X; Value[listBox1.SelectedIndex].Y = itm.Y; Value[listBox1.SelectedIndex].Z = itm.Z; } else if (itm.Type == ClipBoardItem.ClipboardType.IntArray) { Value[listBox1.SelectedIndex].Args = itm.Args.ToList(); } else { MessageBox.Show("You can't paste this here"); return; } propertyGrid1.Refresh(); }
void PasteValue(ClipBoardItem itm) { if (Value == null) { Value = new LevelObj(); } if (itm.Type == ClipBoardItem.ClipboardType.Position) { if (Value.Prop.ContainsKey("pos_x")) { ((Node)Value.Prop["pos_x"]).StringValue = itm.X.ToString(); } if (Value.Prop.ContainsKey("pos_y")) { ((Node)Value.Prop["pos_y"]).StringValue = itm.Y.ToString(); } if (Value.Prop.ContainsKey("pos_z")) { ((Node)Value.Prop["pos_z"]).StringValue = itm.Z.ToString(); } } else if (itm.Type == ClipBoardItem.ClipboardType.Rotation) { if (Value.Prop.ContainsKey("dir_x")) { ((Node)Value.Prop["dir_x"]).StringValue = itm.X.ToString(); } if (Value.Prop.ContainsKey("dir_y")) { ((Node)Value.Prop["dir_y"]).StringValue = itm.Y.ToString(); } if (Value.Prop.ContainsKey("dir_z")) { ((Node)Value.Prop["dir_z"]).StringValue = itm.Z.ToString(); } } else if (itm.Type == ClipBoardItem.ClipboardType.Scale) { if (Value.Prop.ContainsKey("scale_x")) { ((Node)Value.Prop["scale_x"]).StringValue = itm.X.ToString(); } if (Value.Prop.ContainsKey("scale_y")) { ((Node)Value.Prop["scale_y"]).StringValue = itm.Y.ToString(); } if (Value.Prop.ContainsKey("scale_z")) { ((Node)Value.Prop["scale_z"]).StringValue = itm.Z.ToString(); } } else if (itm.Type == ClipBoardItem.ClipboardType.IntArray) { if (Value.Prop.ContainsKey("Arg")) { Value.Prop["Arg"] = itm.Args; } else { Value.Prop.Add("Arg", itm.Args); } } else if (itm.Type == ClipBoardItem.ClipboardType.Rail) { if (Value.Prop.ContainsKey("Rail")) { Value.Prop["Rail"] = itm.Rail.Clone(); } else { Value.Prop.Add("Rail", itm.Rail.Clone()); } } else if (itm.Type == ClipBoardItem.ClipboardType.FullObject) { string name = itm.Objs[0].ToString(); if (name == "ObjectChildArea" || name == "SwitchKeepOnArea" || name == "SwitchOnArea") { if (!Value.Prop.ContainsKey("ChildrenArea")) { Value.Prop.Add("ChildrenArea", new C0List()); } ((C0List)Value.Prop["ChildrenArea"]).List.Add(itm.Objs[0].Clone()); } else { if (!Value.Prop.ContainsKey("GenerateChildren")) { Value.Prop.Add("GenerateChildren", new C0List()); } ((C0List)Value.Prop["GenerateChildren"]).List.Add(itm.Objs[0].Clone()); } } else if (itm.Type == ClipBoardItem.ClipboardType.ObjectArray) { foreach (LevelObj o in itm.Objs) { string name = o.ToString(); if (name == "ObjectChildArea" || name == "SwitchKeepOnArea" || name == "SwitchOnArea") { if (!Value.Prop.ContainsKey("ChildrenArea")) { Value.Prop.Add("ChildrenArea", new C0List()); } ((C0List)Value.Prop["ChildrenArea"]).List.Add(o.Clone()); } else { if (!Value.Prop.ContainsKey("GenerateChildren")) { Value.Prop.Add("GenerateChildren", new C0List()); } ((C0List)Value.Prop["GenerateChildren"]).List.Add(o.Clone()); } } } propertyGrid1.Refresh(); }
void CopyValue(string value) { ClipBoardItem cl = new ClipBoardItem(); if (value == "pos_" || value == "dir_" || value == "scale_") { if (value == "pos_") { cl.Type = ClipBoardItem.ClipboardType.Position; } else if (value == "dir_") { cl.Type = ClipBoardItem.ClipboardType.Rotation; } else { cl.Type = ClipBoardItem.ClipboardType.Scale; } if (Value.Prop.ContainsKey(value + "x") && Value.Prop.ContainsKey(value + "y") && Value.Prop.ContainsKey(value + "z")) { cl.X = Single.Parse(((Node)Value.Prop[value + "x"]).StringValue); cl.Y = Single.Parse(((Node)Value.Prop[value + "y"]).StringValue); cl.Z = Single.Parse(((Node)Value.Prop[value + "z"]).StringValue); } else { MessageBox.Show("You can't copy this value from this object"); } } else if (value == "Arg") { cl.Type = ClipBoardItem.ClipboardType.IntArray; if (Value.Prop.ContainsKey("Arg")) { cl.Args = (int[])((int[])Value.Prop["Arg"]).Clone(); //This looks strange but (int[])Value.Prop["Arg"] doesn't work } else { MessageBox.Show("You can't copy this value from this object"); } } else if (value == "Full") { cl.Type = ClipBoardItem.ClipboardType.FullObject; cl.Objs = new LevelObj[] { Value.Clone() }; } Form1.clipboard.Add(cl); if (Form1.clipboard.Count > 10) { Form1.clipboard.RemoveAt(0); } ClipBoardMenu_Paste.DropDownItems.Clear(); List <ToolStripMenuItem> Items = new List <ToolStripMenuItem>(); for (int i = 0; i < Form1.clipboard.Count; i++) { ToolStripMenuItem btn = new ToolStripMenuItem(); btn.Name = "ClipboardN" + i.ToString(); btn.Text = Form1.clipboard[i].ToString(); btn.Click += QuickClipboardItem_Click; Items.Add(btn); } Items.Reverse(); ClipBoardMenu_Paste.DropDownItems.AddRange(Items.ToArray()); }