public void Load(string json) { blockSpace.Clear(); BlockDeserializer ds = new BlockDeserializer(); BlockSpace bspace = ds.LoadBlockSpace(json, blockSpace, blockSpace.GetSystemMethods(), (proc) => DefineNewProcFromFile(proc, "My blocks")); blockSpace.AddDummyEvents(); ResetBlockSpace(); }
internal void AddTool(BlockSpace blockSpace, ToolPrototype spec) { AddNewTool(blockSpace, spec); LayoutTools(currentCategory); if (currentCategory == spec.category) { UpdateBitmap(currentCategory, tabWidth, tabHeight); } }
internal void Detach(BlockSpace blockSpace) { if (Parent is InvokationBlock) { InvokationBlock ib = Parent as InvokationBlock; ib.SetArg(Index, blockSpace.Default(ib.ArgTypes[Index])); } else if (Parent is BlockStack) { throw new InvalidOperationException(); } }
internal void Detach(BlockSpace blockSpace) { if (Parent is InvokationBlock) { InvokationBlock ib = Parent as InvokationBlock; ib.SetArg(Index, blockSpace.Default(ib.ArgTypes[Index])); } else if(Parent is BlockStack) { throw new InvalidOperationException(); } }
private void AddNewTool(BlockSpace blockSpace, ToolPrototype spec) { string[] parts = spec.tool.Split("|".ToCharArray()); //string fileName = Path.Combine(filePrefix, parts[0]) + ".bmp"; string funcName = parts[1]; // Bitmap tbBmp = (Bitmap)Bitmap.FromFile(fileName); Bitmap tbBmp = dummyFactory.ViewFromBlock(blockSpace.makeNewBlock(funcName, spec.defaultArgs)) .Assemble(); //tbBmp.MakeTransparent(tbBmp.GetPixel(0, 0)); tools.Add(new ToolSpec(tbBmp, funcName, spec.category, spec.defaultArgs)); categories.Add(spec.category); }
private TopLevelScript ToTopLevelScript(JToken scriptJson, BlockSpace owner) { Point location; IBlock block; int x = int.Parse((string)scriptJson["location"][0]); int y = int.Parse((string)scriptJson["location"][1]); location = new Point(x, y); block = ToBlock(scriptJson["code"]); TopLevelScript ret = new TopLevelScript(location, block, owner); return(ret); }
public BlockViewFactory(Graphics textMetrics, Font textFont, BlockSpace blockSpace, Dictionary<IBlock, IBlockView> blockViews, Action modified) { this.modified = modified; this.textMetrics = textMetrics; this.textFont = textFont; boldFont = new Font(textFont, FontStyle.Bold); this.blockSpace = blockSpace; this.blockViews = blockViews; InitImageParts(); }
public BlockViewFactory(Graphics textMetrics, Font textFont, BlockSpace blockSpace, Dictionary <IBlock, IBlockView> blockViews, Action modified) { this.modified = modified; this.textMetrics = textMetrics; this.textFont = textFont; boldFont = new Font(textFont, FontStyle.Bold); this.blockSpace = blockSpace; this.blockViews = blockViews; InitImageParts(); }
public void Init(IEnumerable <ToolPrototype> toolSpecs, string filePrefix, string initialCategory, BlockSpace blockSpace) { this.currentCategory = initialCategory; this.toolSpecs = toolSpecs; this.filePrefix = filePrefix; tools.Clear(); dummyFactory = new BlockViewFactory(textMetrics, textFont, blockSpace, new Dictionary <IBlock, IBlockView>(), delegate() { }); foreach (ToolPrototype spec in toolSpecs) { AddNewTool(blockSpace, spec); } }
internal BlockSpace LoadBlockSpace(string json, BlockSpace blockSpace, Dictionary<string, BlockInfo> systemBlocks, Action<ProcDefBlock> handleDefineNewProc) { BlockSpace ret = blockSpace; this.blockSpace = blockSpace; this.handleDefineNewProc = handleDefineNewProc; JArray o = JArray.Parse(json); for (int i = 0; i < o.Count; ++i) { JToken scriptJson = o[i]; TopLevelScript script = ToTopLevelScript(scriptJson, ret); ret.AddScript(script); } return ret; }
public BlockController(Graphics textMetrics, Font textFont, Size canvasSize, Func<TextBox> textBoxMaker) { this.Modified += delegate(object sender) { }; blockSpace = new BlockSpace(); blockSpace.OnTopLevelAdded += new TopLevelEvent(blockSpace_OnTopLevelAdded); blockSpace.OnTopLevelDeleted += new TopLevelEvent(blockSpace_OnTopLevelDeleted); blockSpace.OnTopLevelMoved += new TopLevelEvent(blockSpace_OnTopLevelMoved); palette = new Palette(new Size(canvasSize.Width - 20, 60), textMetrics, textFont); palette.Modified += new PaletteModifiedEvent(palette_Modified); canvasView = new CanvasView(textMetrics, canvasSize, allViews, DropRegions, textFont, palette); this.canvasSize = canvasSize; state = CanvasState.Ready; viewFactory = new BlockViewFactory(textMetrics, textFont, blockSpace, blockViews, ()=>Modified(this)); this.textBoxMaker = textBoxMaker; }
public BlockController(Graphics textMetrics, Font textFont, Size canvasSize, Func <TextBox> textBoxMaker) { this.Modified += delegate(object sender) { }; blockSpace = new BlockSpace(); blockSpace.OnTopLevelAdded += new TopLevelEvent(blockSpace_OnTopLevelAdded); blockSpace.OnTopLevelDeleted += new TopLevelEvent(blockSpace_OnTopLevelDeleted); blockSpace.OnTopLevelMoved += new TopLevelEvent(blockSpace_OnTopLevelMoved); palette = new Palette(new Size(canvasSize.Width - 20, 60), textMetrics, textFont); palette.Modified += new PaletteModifiedEvent(palette_Modified); canvasView = new CanvasView(textMetrics, canvasSize, allViews, DropRegions, textFont, palette); this.canvasSize = canvasSize; state = CanvasState.Ready; viewFactory = new BlockViewFactory(textMetrics, textFont, blockSpace, blockViews, () => Modified(this)); this.textBoxMaker = textBoxMaker; }
internal BlockSpace LoadBlockSpace(string json, BlockSpace blockSpace, Dictionary <string, BlockInfo> systemBlocks, Action <ProcDefBlock> handleDefineNewProc) { BlockSpace ret = blockSpace; this.blockSpace = blockSpace; this.handleDefineNewProc = handleDefineNewProc; JArray o = JArray.Parse(json); for (int i = 0; i < o.Count; ++i) { JToken scriptJson = o[i]; TopLevelScript script = ToTopLevelScript(scriptJson, ret); ret.AddScript(script); } return(ret); }
public TopLevelScript(Point Location, IBlock Block, BlockSpace owner) { this._Location = Location; this.Block = Block; this.owner = owner; }
internal void AddTool(BlockSpace blockSpace, ToolPrototype spec) { AddNewTool(blockSpace, spec); LayoutTools(currentCategory); if (currentCategory == spec.category) UpdateBitmap(currentCategory, tabWidth, tabHeight); }
internal void ResetBlockSpace(BlockSpace blockSpace) { this.blockSpace = blockSpace; }
public void Init(IEnumerable<ToolPrototype> toolSpecs, string filePrefix, string initialCategory, BlockSpace blockSpace) { this.currentCategory = initialCategory; this.toolSpecs = toolSpecs; this.filePrefix = filePrefix; tools.Clear(); dummyFactory = new BlockViewFactory(textMetrics, textFont, blockSpace, new Dictionary<IBlock, IBlockView>(), delegate() { }); foreach (ToolPrototype spec in toolSpecs) { AddNewTool(blockSpace, spec); } }
private TopLevelScript ToTopLevelScript(JToken scriptJson, BlockSpace owner) { Point location; IBlock block; int x = int.Parse((string)scriptJson["location"][0]); int y = int.Parse((string)scriptJson["location"][1]); location = new Point(x, y); block = ToBlock(scriptJson["code"]); TopLevelScript ret = new TopLevelScript(location, block, owner); return ret; }