private void CreateSymbol(PaletteObj symbol, ListViewGroup group) { var item = Items.Add(symbol.Task.Symbol.Label, symbol.Image); item.Name = symbol.Task.Symbol.Name; item.Tag = symbol; item.Group = group; }
public void Add(PaletteObj symbol) { var group = Groups[symbol.Group]; if (group == null) { group = Groups.Add(symbol.Group, symbol.Group); SetGroupState(group, ListViewGroupState.Collapsible); } CreateSymbol(symbol, group); }
public void Add(PaletteObj symbol) { listView.Add(symbol); }
public override bool Equals(object obj) { PaletteObj plt = obj as PaletteObj; return(plt != null && plt.Name == Name && plt.Metadata == Metadata); }
public TagCompound BuildTag() { List <PaletteObj> palette = new List <PaletteObj>(); TagList blocks = new TagList("blocks", TagType.Compound); for (int x = 0; x < _width; x++) { for (int y = 0; y < _height; y++) { for (int z = 0; z < _length; z++) { BlockKey set = GetAt(x, y, z); PaletteObj plt = new PaletteObj() { Name = set.BlockName, Metadata = set.Metadata }; if (!palette.Contains(plt)) { palette.Add(plt); } int state = palette.IndexOf(plt); TagCompound blk = new TagCompound("") { new TagInt("state", state), new TagList("pos") { new TagInt(set.X), new TagInt(set.Y), new TagInt(set.Z) } }; if (set.NBT != null) { blk.Add("nbt", set.NBT); } blocks.Add(blk); } } } TagList paletteTag = new TagList("palette", TagType.Compound); for (int i = 0; i < palette.Count; i++) { paletteTag.Add(palette[i].BuildTag()); } TagList entities = new TagList("entities", TagType.Compound); foreach (TagCompound e in _entityList) { entities.Add(e); } TagList size = new TagList("size") { new TagInt(_width), new TagInt(_height), new TagInt(_length) }; TagCompound root = new TagCompound() { new TagInt("DataVersion", _dataVersion), new TagString("author", _author), paletteTag, blocks, entities, size }; return(root); }
/// <summary> /// Create a task, its symbol data and shape when a Palette symbol is dropped on the diagram /// </summary> /// <param name="symbolType"></param> /// <param name="datum"></param> public TaskObj CreateTask(PaletteObj symbolType, Point datum) { var symbolTask = symbolType.Task; if (symbolTask.ActivityName == "cleanup" && Model.Workflow.Tasks.Any(t => t.ActivityName == "cleanup")) { MessageBox.Show("No more than one Cleanup Start symbol permitted"); return(null); } ActivityObj activity = null; if (symbolTask.HasActivity()) { var json = RestClient.Get($"/activities/{symbolTask.ActivityName}/versions/{symbolTask.ActivityVersion}"); activity = JsonConvert.DeserializeObject <ActivityObj>(json); if (activity == null) { MessageBox.Show($"Missing activity - {symbolTask.ActivityName} {symbolTask.ActivityVersion}", "Database error"); return(null); } } var task = new TaskObj { TaskId = Guid.NewGuid().ToString().Substring(0, 8), ActivityName = symbolTask.ActivityName, ActivityVersion = symbolTask.ActivityVersion, Outflows = (from f in symbolTask.Outflows select new FlowObj { Name = f.Name }).ToArray(), Symbol = CloneSymbol(symbolTask.Symbol), FailOutflow = new FlowObj { Name = "Err" }, HiddenProperties = symbolTask.HiddenProperties }; if (activity != null) { task.Inputs = new InputCollection(activity.Inputs); if (task.Outflows.Length != 0) { task.Outputs = new OutputCollection(activity.Outputs); } } // Override or add inputs with data from palette symbol if (symbolTask.Inputs != null) { foreach (var input in symbolTask.Inputs) { task.Inputs[input.Key] = input.Value; } } // Override or add outputs with data from palette symbol if (symbolTask.Outputs != null) { foreach (var output in symbolTask.Outputs) { task.Outputs[output.Key] = output.Value; } } task.Symbol.Shape = Shape.Create(task.Symbol.Style, task, datum); if (symbolTask.HasFailOutflow()) { task.FailOutflow = new FlowObj { Name = "Err" }; } Model.Workflow.Tasks.Add(task); task.TaskChanged += UpdateGraphics; return(task); }