public void OnDrop(DropInfo dropInfo) { Point position = dropInfo.DropPosition; GraphicsVM gvm = dropInfo.Data as GraphicsVM; GraphicsBase graphics = GraphicsFactory.Create(position, gvm.Type); DrawableLayer.DrawVisual(graphics); }
public void Initialize() { this.GroupList = new ObservableCollection<GraphicsGroupVM>(); List<ToolboxGroup> groups; if (!JSONHelper.TryParseFile<List<ToolboxGroup>>(ToolboxJsonPath, out groups)) { logger.Error("加载工具箱分组失败"); return; } foreach (ToolboxGroup group in groups) { GraphicsGroupVM groupVM = new GraphicsGroupVM() { ID = group.ID, Name = group.Name, }; foreach (ToolboxItem toolboxItem in group.Items) { GraphicsVM gvm = new GraphicsVM() { ID = toolboxItem.ID, Name = toolboxItem.Name, IconURI = toolboxItem.Icon, Type = toolboxItem.Type }; groupVM.Items.Add(gvm); } this.GroupList.Add(groupVM); } this.ToolboxVM = new ToolboxViewModel(); }