source: EcnlProtoTool/trunk/webapp/webmrbc/Blockly.cs@ 321

Last change on this file since 321 was 321, checked in by coas-nagasima, 7 years ago

文字コードを設定

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csharp;charset=UTF-8
File size: 73.8 KB
Line 
1/**
2 * @license
3 * Visual Blocks Editor
4 *
5 * Copyright 2012 Google Inc.
6 * https://developers.google.com/blockly/
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20using System;
21using System.Collections.Generic;
22using Bridge;
23using Bridge.Html5;
24
25namespace WebMrbc
26{
27 /**
28 * @fileoverview Core JavaScript library for Blockly.
29 * @author fraser@google.com (Neil Fraser)
30 */
31 [External, Name("Blockly")]
32 public partial class Blockly
33 {
34 [Name(false)]
35 public static Xml Xml;
36 [Name(false)]
37 public static Events Events;
38 [Name(false)]
39 public static Procedures Procedures;
40 [Name(false)]
41 public static Variables Variables;
42 [Name(false)]
43 public static Names Names;
44
45 /// <summary>
46 /// Number of pixels the mouse must move before a drag starts.
47 /// </summary>
48 [Name(false)]
49 public static int DRAG_RADIUS = 5;
50
51 /// <summary>
52 /// Maximum misalignment between connections for them to snap together.
53 /// </summary>
54 [Name(false)]
55 public static int SNAP_RADIUS = 20;
56
57 /// <summary>
58 /// Delay in ms between trigger and bumping unconnected block out of alignment.
59 /// </summary>
60 [Name(false)]
61 public static int BUMP_DELAY = 250;
62
63 /// <summary>
64 /// Number of characters to truncate a collapsed block to.
65 /// </summary>
66 [Name(false)]
67 public static int COLLAPSE_CHARS = 30;
68
69 /// <summary>
70 /// Length in ms for a touch to become a long press.
71 /// </summary>
72 [Name(false)]
73 public static int LONGPRESS = 750;
74
75 /// <summary>
76 /// Prevent a sound from playing if another sound preceded it within this many
77 /// miliseconds.
78 /// </summary>
79 [Name(false)]
80 public static int SOUND_LIMIT = 100;
81
82 /// <summary>
83 /// The richness of block colours, regardless of the hue.
84 /// Must be in the range of 0 (inclusive) to 1 (exclusive).
85 /// </summary>
86 [Name(false)]
87 public static double HSV_SATURATION = 0.45;
88
89 /// <summary>
90 /// The intensity of block colours, regardless of the hue.
91 /// Must be in the range of 0 (inclusive) to 1 (exclusive).
92 /// </summary>
93 [Name(false)]
94 public static double HSV_VALUE = 0.65;
95
96 /// <summary>
97 /// Sprited icons and images.
98 /// </summary>
99 [Name(false)]
100 public static object SPRITE = new {
101 width = 96,
102 height = 124,
103 url = "sprites.png"
104 };
105
106 /// <summary>
107 /// Required name space for SVG elements.
108 /// </summary>
109 [Name(false)]
110 public static readonly string SVG_NS = "http://www.w3.org/2000/svg";
111
112 /// <summary>
113 /// Required name space for HTML elements.
114 /// </summary>
115 [Name(false)]
116 public static readonly string HTML_NS = "http://www.w3.org/1999/xhtml";
117
118 /// <summary>
119 /// ENUM for a right-facing value input. E.g. 'set item to' or 'return'.
120 /// </summary>
121 [Name(false)]
122 public static int INPUT_VALUE = 1;
123
124 /// <summary>
125 /// ENUM for a left-facing value output. E.g. 'random fraction'.
126 /// </summary>
127 [Name(false)]
128 public static int OUTPUT_VALUE = 2;
129
130 /// <summary>
131 /// ENUM for a down-facing block stack. E.g. 'if-do' or 'else'.
132 /// </summary>
133 [Name(false)]
134 public static int NEXT_STATEMENT = 3;
135
136 /// <summary>
137 /// ENUM for an up-facing block stack. E.g. 'break out of loop'.
138 /// </summary>
139 [Name(false)]
140 public static int PREVIOUS_STATEMENT = 4;
141
142 /// <summary>
143 /// ENUM for an dummy input. Used to add field(s) with no input.
144 /// </summary>
145 [Name(false)]
146 public static int DUMMY_INPUT = 5;
147
148 /// <summary>
149 /// ENUM for left alignment.
150 /// </summary>
151 [Name(false)]
152 public static int ALIGN_LEFT = -1;
153
154 /// <summary>
155 /// ENUM for centre alignment.
156 /// </summary>
157 [Name(false)]
158 public static int ALIGN_CENTRE = 0;
159
160 /// <summary>
161 /// ENUM for right alignment.
162 /// </summary>
163 [Name(false)]
164 public static int ALIGN_RIGHT = 1;
165
166 /// <summary>
167 /// ENUM for no drag operation.
168 /// </summary>
169 [Name(false)]
170 public static int DRAG_NONE = 0;
171
172 /// <summary>
173 /// ENUM for inside the sticky DRAG_RADIUS.
174 /// </summary>
175 [Name(false)]
176 public static int DRAG_STICKY = 1;
177
178 /// <summary>
179 /// ENUM for inside the non-sticky DRAG_RADIUS, for differentiating between
180 /// clicks and drags.
181 /// </summary>
182 [Name(false)]
183 public static int DRAG_BEGIN = 1;
184
185 /// <summary>
186 /// ENUM for freely draggable (outside the DRAG_RADIUS, if one applies).
187 /// </summary>
188 [Name(false)]
189 public static int DRAG_FREE = 2;
190
191 /// <summary>
192 /// Lookup table for determining the opposite type of a connection.
193 /// </summary>
194 [Name(false)]
195 public static int[] OPPOSITE_TYPE = {
196 0,
197 OUTPUT_VALUE,
198 INPUT_VALUE,
199 PREVIOUS_STATEMENT,
200 NEXT_STATEMENT
201 };
202
203 /// <summary>
204 /// ENUM for toolbox and flyout at top of screen.
205 /// </summary>
206 [Name(false)]
207 public static int TOOLBOX_AT_TOP = 0;
208
209 /// <summary>
210 /// ENUM for toolbox and flyout at bottom of screen.
211 /// </summary>
212 [Name(false)]
213 public static int TOOLBOX_AT_BOTTOM = 1;
214
215 /// <summary>
216 /// ENUM for toolbox and flyout at left of screen.
217 /// </summary>
218 [Name(false)]
219 public static int TOOLBOX_AT_LEFT = 2;
220
221 /// <summary>
222 /// ENUM for toolbox and flyout at right of screen.
223 /// </summary>
224 [Name(false)]
225 public static int TOOLBOX_AT_RIGHT = 3;
226
227 /// <summary>
228 /// The main workspace most recently used.
229 /// Set by Blockly.WorkspaceSvg.prototype.markFocused
230 /// </summary>
231 public static WorkspaceSvg mainWorkspace;
232
233 /// <summary>
234 /// Currently selected block.
235 /// </summary>
236 public static Block selected;
237
238 [Name(false)]
239 public static Blocks Blocks;
240
241 /// <summary>
242 /// Register a callback function associated with a given key, for clicks on
243 /// buttons and labels in the flyout.
244 /// For instance, a button specified by the XML
245 /// <button text="create variable" callbackKey="CREATE_VARIABLE"></button>
246 /// should be matched by a call to
247 /// registerButtonCallback("CREATE_VARIABLE", yourCallbackFunction).
248 /// </summary>
249 /// <param name="key">The name to use to look up this function.</param>
250 /// <param name="func">The function to call when the
251 /// given button is clicked.</param>
252 internal static void registerButtonCallback(string key, Action<FlyoutButton> func)
253 {
254 throw new NotImplementedException();
255 }
256
257 /// <summary>
258 /// Convert a hue (HSV model) into an RGB hex triplet.
259 /// </summary>
260 /// <param name="hue">Hue on a colour wheel (0-360).</param>
261 /// <returns>RGB code, e.g. '#5ba65b'.</returns>
262 public static string hueToRgb(int hue)
263 {
264 throw new NotImplementedException();
265 }
266
267 /// <summary>
268 /// Returns the dimensions of the specified SVG image.
269 /// </summary>
270 /// <param name="svg">SVG image.</param>
271 /// <returns>Contains width and height properties.</returns>
272 public static goog.math.Size svgSize(Element svg)
273 {
274 throw new NotImplementedException();
275 }
276
277 /// <summary>
278 /// Size the workspace when the contents change. This also updates
279 /// scrollbars accordingly.
280 /// </summary>
281 /// <param name="workspace"></param>
282 public static void resizeSvgContents(WorkspaceSvg workspace)
283 {
284 throw new NotImplementedException();
285 }
286
287 /// <summary>
288 /// Size the SVG image to completely fill its container. Call this when the view
289 /// actually changes sizes (e.g. on a window resize/device orientation change).
290 /// See Blockly.resizeSvgContents to resize the workspace when the contents
291 /// change (e.g. when a block is added or removed).
292 /// Record the height/width of the SVG image.
293 /// </summary>
294 /// <param name="workspace">Any workspace in the SVG.</param>
295 public static void svgResize(WorkspaceSvg workspace)
296 {
297 throw new NotImplementedException();
298 }
299
300 /// <summary>
301 /// Close tooltips, context menus, dropdown selections, etc.
302 /// </summary>
303 /// <param name="opt_allowToolbox">If true, don't close the toolbox.</param>
304 public static void hideChaff(bool opt_allowToolbox = false)
305 {
306 throw new NotImplementedException();
307 }
308
309 /// <summary>
310 /// When something in Blockly's workspace changes, call a function.
311 /// </summary>
312 /// <param name="func">Function to call.</param>
313 /// <returns>Opaque data that can be passed to removeChangeListener.</returns>
314 public static Action<Abstract> addChangeListener(Action<Abstract> func)
315 {
316 // Backwards compatability from before there could be multiple workspaces.
317 App.WriteLine("Deprecated call to Blockly.addChangeListener, " +
318 "use workspace.addChangeListener instead.");
319 return getMainWorkspace().addChangeListener(func);
320 }
321
322 /// <summary>
323 /// Returns the main workspace. Returns the last used main workspace (based on
324 /// focus). Try not to use this function, particularly if there are multiple
325 /// Blockly instances on a page.
326 /// </summary>
327 /// <returns>The main workspace.</returns>
328 public static WorkspaceSvg getMainWorkspace()
329 {
330 return mainWorkspace;
331 }
332
333 /// <summary>
334 /// Wrapper to window.alert() that app developers may override to
335 /// provide alternatives to the modal browser window.
336 /// </summary>
337 /// <param name="message">The message to display to the user.</param>
338 /// <param name="opt_callback">The callback when the alert is dismissed.</param>
339 internal static void alert(string message, Action opt_callback = null)
340 {
341 throw new NotImplementedException();
342 }
343
344 /// <summary>
345 /// Wrapper to window.prompt() that app developers may override to provide
346 /// alternatives to the modal browser window. Built-in browser prompts are
347 /// often used for better text input experience on mobile device. We strongly
348 /// recommend testing mobile when overriding this.
349 /// </summary>
350 /// <param name="message">The message to display to the user.</param>
351 /// <param name="defaultValue">The value to initialize the prompt with.</param>
352 /// <param name="callback">The callback for handling user reponse.</param>
353 internal static void prompt(string message, string defaultValue, Action<string> callback)
354 {
355 throw new NotImplementedException();
356 }
357
358 /// <summary>
359 /// Inject a Blockly editor into the specified container element (usually a div).
360 /// </summary>
361 /// <param name="container">Containing element, or its ID, or a CSS selector.</param>
362 /// <param name="opt_options">opt_options Optional dictionary of options.</param>
363 /// <returns>Newly created main workspace.</returns>
364 public static WorkspaceSvg inject(Union<string, Element> container, object opt_options = null)
365 {
366 throw new NotImplementedException();
367 }
368
369 /// <summary>
370 /// Modify the block tree on the existing toolbox.
371 /// </summary>
372 /// <param name="tree">DOM tree of blocks, or text representation of same.</param>
373 public static void updateToolbox(Union<Node, string> tree)
374 {
375 throw new NotImplementedException();
376 }
377
378 /// <summary>
379 /// Don't do anything for this event, just halt propagation.
380 /// </summary>
381 /// <param name="e">An event.</param>
382 public static void noEvent(Event e)
383 {
384 // This event has been handled. No need to bubble up to the document.
385 e.PreventDefault();
386 e.StopPropagation();
387 }
388
389 /// <summary>
390 /// Helper method for creating SVG elements.
391 /// </summary>
392 /// <param name="name">Element's tag name.</param>
393 /// <param name="attrs">Dictionary of attribute names and values.</param>
394 /// <param name="parent">Optional parent on which to append the element.</param>
395 /// <param name="opt_workspace">Optional workspace for access to context (scale...).</param>
396 /// <returns>Newly created SVG element.</returns>
397 public static Element createSvgElement(string name, object attrs, Element parent, Workspace opt_workspace)
398 {
399 throw new NotImplementedException();
400 }
401
402 /// <summary>
403 /// Is this event a right-click?
404 /// </summary>
405 /// <param name="e">Mouse event.</param>
406 /// <returns>True if right-click.</returns>
407 public static bool isRightButton(Event e)
408 {
409 throw new NotImplementedException();
410 }
411
412 /// <summary>
413 /// Return the converted coordinates of the given mouse event.
414 /// The origin (0,0) is the top-left corner of the Blockly svg.
415 /// </summary>
416 /// <param name="e">Mouse event.</param>
417 /// <param name="svg">SVG element.</param>
418 /// <param name="matrix">Inverted screen CTM to use.</param>
419 /// <returns>Object with .x and .y properties.</returns>
420 public static goog.math.Coordinate mouseToSvg(Event e, Element svg, SVGMatrix matrix)
421 {
422 throw new NotImplementedException();
423 }
424
425 /// <summary>
426 /// Given an array of strings, return the length of the shortest one.
427 /// </summary>
428 /// <param name="array">Array of strings.</param>
429 /// <returns>Length of shortest string.</returns>
430 public static int shortestStringLength(string[] array)
431 {
432 throw new NotImplementedException();
433 }
434
435 /// <summary>
436 /// Given an array of strings, return the length of the common prefix.
437 /// Words may not be split. Any space after a word is included in the length.
438 /// </summary>
439 /// <param name="array">Array of strings.</param>
440 /// <param name="opt_shortest">Length of shortest string.</param>
441 /// <returns>Length of common prefix.</returns>
442 public static int commonWordPrefix(string[] array, int opt_shortest = 0)
443 {
444 throw new NotImplementedException();
445 }
446
447 /// <summary>
448 /// Given an array of strings, return the length of the common suffix.
449 /// Words may not be split. Any space after a word is included in the length.
450 /// </summary>
451 /// <param name="array">Array of strings.</param>
452 /// <param name="opt_shortest">Length of shortest string.</param>
453 /// <returns>Length of common suffix.</returns>
454 public static int commonWordSuffix(string[] array, int opt_shortest = 0)
455 {
456 throw new NotImplementedException();
457 }
458
459 /// <summary>
460 /// Is the given string a number (includes negative and decimals).
461 /// </summary>
462 /// <param name="str">Input string.</param>
463 /// <returns>True if number, false otherwise.</returns>
464 public static bool isNumber(string str)
465 {
466 throw new NotImplementedException();
467 }
468
469 /// <summary>
470 /// Parse a string with any number of interpolation tokens (%1, %2, ...).
471 /// '%' characters may be self-escaped (%%).
472 /// </summary>
473 /// <param name="message">Text containing interpolation tokens.</param>
474 /// <returns>Array of strings and numbers.</returns>
475 public static Union<string, int> tokenizeInterpolation(string message)
476 {
477 throw new NotImplementedException();
478 }
479
480 /// <summary>
481 /// Generate a unique ID. This should be globally unique.
482 /// 87 characters ^ 20 length > 128 bits (better than a UUID).
483 /// </summary>
484 /// <returns>A globally unique ID string.</returns>
485 public static string genUid()
486 {
487 throw new NotImplementedException();
488 }
489
490 /// <summary>
491 /// Wrap text to the specified width.
492 /// </summary>
493 /// <param name="text">Text to wrap.</param>
494 /// <param name="wrap">Width to wrap each line.</param>
495 /// <returns></returns>
496 public static string wrap(string text, int wrap)
497 {
498 throw new NotImplementedException();
499 }
500 }
501
502 [External, Name("Blockly.Xml")]
503 public class Xml
504 {
505 /// <summary>
506 /// Encode a block tree as XML.
507 /// </summary>
508 /// <param name="workspace">workspace The workspace containing blocks.</param>
509 /// <returns>XML document.</returns>
510 public Element workspaceToDom(Workspace workspace)
511 {
512 throw new NotImplementedException();
513 }
514
515 /// <summary>
516 /// Encode a block subtree as XML with XY coordinates.
517 /// </summary>
518 /// <param name="block">The root block to encode.</param>
519 /// <returns>Tree of XML elements.</returns>
520 public Element blockToDomWithXY(Block block)
521 {
522 throw new NotImplementedException();
523 }
524
525 /// <summary>
526 /// Encode a block subtree as XML.
527 /// </summary>
528 /// <param name="block">The root block to encode.</param>
529 /// <returns>Tree of XML elements.</returns>
530 public Element blockToDom(Block block)
531 {
532 throw new NotImplementedException();
533 }
534
535 /// <summary>
536 /// Converts a DOM structure into plain text.
537 /// Currently the text format is fairly ugly: all one line with no whitespace.
538 /// </summary>
539 /// <param name="dom">A tree of XML elements.</param>
540 /// <returns>Text representation.</returns>
541 public string domToText(Element dom)
542 {
543 throw new NotImplementedException();
544 }
545
546 /// <summary>
547 /// Converts a DOM structure into properly indented text.
548 /// </summary>
549 /// <param name="dom">A tree of XML elements.</param>
550 /// <returns>Text representation.</returns>
551 public string domToPrettyText(Element dom)
552 {
553 throw new NotImplementedException();
554 }
555
556 /// <summary>
557 /// Converts plain text into a DOM structure.
558 /// Throws an error if XML doesn't parse.
559 /// </summary>
560 /// <param name="text">Text representation.</param>
561 /// <returns>A tree of XML elements.</returns>
562 public Element textToDom(string text)
563 {
564 throw new NotImplementedException();
565 }
566
567 /// <summary>
568 /// Decode an XML DOM and create blocks on the workspace.
569 /// </summary>
570 /// <param name="xml">XML DOM.</param>
571 /// <param name="workspace">The workspace.</param>
572 public void domToWorkspace(Element xml, Workspace workspace)
573 {
574 throw new NotImplementedException();
575 }
576
577 /// <summary>
578 /// Decode an XML block tag and create a block (and possibly sub blocks) on the
579 /// workspace.
580 /// </summary>
581 /// <param name="xmlBlock">XML block element.</param>
582 /// <param name="workspace">The workspace.</param>
583 /// <returns>The root block created.</returns>
584 public Block domToBlock(Element xmlBlock, Workspace workspace)
585 {
586 throw new NotImplementedException();
587 }
588
589 /// <summary>
590 /// Remove any 'next' block (statements in a stack).
591 /// </summary>
592 /// <param name="xmlBlock">XML block element.</param>
593 public void deleteNext(Element xmlBlock)
594 {
595 throw new NotImplementedException();
596 }
597 }
598
599 /**
600 * @fileoverview Object representing a workspace.
601 * @author fraser@google.com (Neil Fraser)
602 */
603 [External, Name("Blockly.Workspace")]
604 public class Workspace
605 {
606 public string id;
607 public Options options;
608 public bool RTL;
609 public bool horizontalLayout;
610 public int toolboxPosition;
611 public bool isFlyout;
612
613 /// <summary>
614 /// A list of all of the named variables in the workspace, including variables
615 /// that are not currently in use.
616 /// </summary>
617 public string[] variableList;
618
619 /// <summary>
620 /// Workspaces may be headless.
621 /// True if visible. False if headless.
622 /// </summary>
623 public bool rendered;
624
625 /// <summary>
626 /// Maximum number of undo events in stack.
627 /// 0 to turn off undo, Infinity for unlimited.
628 /// </summary>
629 public int MAX_UNDO = 1024;
630
631 /// <summary>
632 /// Class for a workspace. This is a data structure that contains blocks.
633 /// There is no UI, and can be created headlessly.
634 /// </summary>
635 /// <param name="opt_options">Dictionary of options.</param>
636 public Workspace(Options opt_options = null)
637 {
638 options = opt_options;
639 }
640
641 /// <summary>
642 /// Dispose of this workspace.
643 /// Unlink from all DOM elements to prevent memory leaks.
644 /// </summary>
645 public void dispose()
646 {
647
648 }
649
650 /// <summary>
651 /// Angle away from the horizontal to sweep for blocks. Order of execution is
652 /// generally top to bottom, but a small angle changes the scan to give a bit of
653 /// a left to right bias (reversed in RTL). Units are in degrees.
654 /// See: http://tvtropes.org/pmwiki/pmwiki.php/Main/DiagonalBilling.
655 /// </summary>
656 public int SCAN_ANGLE = 3;
657
658 /// <summary>
659 /// Add a block to the list of top blocks.
660 /// </summary>
661 /// <param name="block">Block to remove.</param>
662 public void addTopBlock(Block block)
663 {
664 throw new NotImplementedException();
665 }
666
667 /// <summary>
668 /// Remove a block from the list of top blocks.
669 /// </summary>
670 /// <param name="block">Block to remove.</param>
671 public void removeTopBlock(Block block)
672 {
673 throw new NotImplementedException();
674 }
675
676 /// <summary>
677 /// Finds the top-level blocks and returns them. Blocks are optionally sorted
678 /// by position; top to bottom (with slight LTR or RTL bias).
679 /// </summary>
680 /// <param name="ordered">Sort the list if true.</param>
681 /// <returns>The top-level block objects.</returns>
682 public Block[] getTopBlocks(bool ordered)
683 {
684 throw new NotImplementedException();
685 }
686
687 /// <summary>
688 /// Find all blocks in workspace. No particular order.
689 /// </summary>
690 /// <returns></returns>
691 public Block[] getAllBlocks()
692 {
693 throw new NotImplementedException();
694 }
695
696 /// <summary>
697 /// Dispose of all blocks in workspace.
698 /// </summary>
699 public void clear()
700 {
701 throw new NotImplementedException();
702 }
703
704 /// <summary>
705 /// Returns the horizontal offset of the workspace.
706 /// Intended for LTR/RTL compatibility in XML.
707 /// Not relevant for a headless workspace.
708 /// </summary>
709 /// <returns>Width.</returns>
710 public int getWidth()
711 {
712 throw new NotImplementedException();
713 }
714
715
716 /// <summary>
717 /// Obtain a newly created block.
718 /// </summary>
719 /// <param name="prototypeName">Name of the language object containing
720 /// type-specific functions for this block.</param>
721 /// <param name="opt_id">Optional ID. Use this ID if provided, otherwise
722 /// create a new id.</param>
723 /// <returns>The created block.</returns>
724 public Block newBlock(string prototypeName, string opt_id = null)
725 {
726 throw new NotImplementedException();
727 }
728
729 /// <summary>
730 /// The number of blocks that may be added to the workspace before reaching
731 /// the maxBlocks.
732 /// </summary>
733 /// <returns></returns>
734 public int remainingCapacity()
735 {
736 throw new NotImplementedException();
737 }
738
739 /// <summary>
740 /// Undo or redo the previous action.
741 /// </summary>
742 /// <param name="redo">False if undo, true if redo.</param>
743 public void undo(bool redo)
744 {
745 throw new NotImplementedException();
746 }
747
748 /// <summary>
749 /// Clear the undo/redo stacks.
750 /// </summary>
751 public void clearUndo()
752 {
753 throw new NotImplementedException();
754 }
755
756 /// <summary>
757 /// When something in this workspace changes, call a function.
758 /// </summary>
759 /// <param name="func">Function to call.</param>
760 /// <returns>Function that can be passed to
761 /// removeChangeListener.</returns>
762 public Action<Abstract> addChangeListener(Action<Abstract> func)
763 {
764 throw new NotImplementedException();
765 }
766
767 /// <summary>
768 /// Stop listening for this workspace's changes.
769 /// </summary>
770 /// <param name="func">Function to stop calling.</param>
771 public void removeChangeListener(Action<Abstract> func)
772 {
773 throw new NotImplementedException();
774 }
775
776 /// <summary>
777 /// Fire a change event.
778 /// </summary>
779 /// <param name="event">Event to fire.</param>
780 public void fireChangeListener(Abstract @event)
781 {
782 throw new NotImplementedException();
783 }
784
785 /// <summary>
786 /// Find the block on this workspace with the specified ID.
787 /// </summary>
788 /// <param name="id">ID of block to find.</param>
789 /// <returns>The sought after block or null if not found.</returns>
790 public Block getBlockById(string id)
791 {
792 throw new NotImplementedException();
793 }
794
795 /// <summary>
796 /// Find the workspace with the specified ID.
797 /// </summary>
798 /// <param name="id">ID of workspace to find.</param>
799 /// <returns>The sought after workspace or null if not found.</returns>
800 public Workspace getById(string id)
801 {
802 throw new NotImplementedException();
803 }
804
805 /**
806 * Create a variable with the given name.
807 * TODO: #468
808 * @param {string} name The new variable's name.
809 */
810 public void createVariable(string newText)
811 {
812 throw new NotImplementedException();
813 }
814
815 /// <summary>
816 /// Check whether a variable exists with the given name. The check is
817 /// case-insensitive.
818 /// </summary>
819 /// <param name="name">The name to check for.</param>
820 /// <returns>The index of the name in the variable list, or -1 if it is
821 /// not present.</returns>
822 internal int variableIndexOf(string name)
823 {
824 throw new NotImplementedException();
825 }
826 }
827
828 [External, Name("Blockly.WorkspaceSvg")]
829 public class WorkspaceSvg : Workspace
830 {
831 public WorkspaceSvg(Options options)
832 : base(options)
833 {
834 }
835
836 public Metrics getMetrics()
837 {
838 throw new NotImplementedException();
839 }
840
841 public void setMetrics(Metrics metrics)
842 {
843 throw new NotImplementedException();
844 }
845
846 /// <summary>
847 /// Getter for the inverted screen CTM.
848 /// </summary>
849 /// <returns>The matrix to use in mouseToSvg</returns>
850 public SVGMatrix getInverseScreenCTM()
851 {
852 throw new NotImplementedException();
853 }
854
855 /// <summary>
856 /// Update the inverted screen CTM.
857 /// </summary>
858 public void updateInverseScreenCTM()
859 {
860 throw new NotImplementedException();
861 }
862
863 /// <summary>
864 /// Save resize handler data so we can delete it later in dispose.
865 /// </summary>
866 /// <param name="handler">Data that can be passed to unbindEvent_.</param>
867 public void setResizeHandlerWrapper(Action handler)
868 {
869 throw new NotImplementedException();
870 }
871
872 /// <summary>
873 /// Create the workspace DOM elements.
874 /// </summary>
875 /// <param name="opt_backgroundClass">opt_backgroundClass Either 'blocklyMainBackground' or
876 /// 'blocklyMutatorBackground'.</param>
877 /// <returns>The workspace's SVG group.</returns>
878 public Element createDom(string opt_backgroundClass = null)
879 {
880 throw new NotImplementedException();
881 }
882
883 /// <summary>
884 /// Dispose of this workspace.
885 /// Unlink from all DOM elements to prevent memory leaks.
886 /// </summary>
887 public new void dispose()
888 {
889 throw new NotImplementedException();
890 }
891
892 /// <summary>
893 /// Obtain a newly created block.
894 /// </summary>
895 /// <param name="prototypeName">Name of the language object containing
896 /// type-specific functions for this block.</param>
897 /// <param name="opt_id">Optional ID. Use this ID if provided, otherwise
898 /// create a new id.</param>
899 /// <returns>The created block.</returns>
900 public new BlockSvg newBlock(string prototypeName, string opt_id = null)
901 {
902 throw new NotImplementedException();
903 }
904
905 /// <summary>
906 /// Resize the parts of the workspace that change when the workspace
907 /// contents (e.g. block positions) change. This will also scroll the
908 /// workspace contents if needed.
909 /// </summary>
910 public void resizeContents()
911 {
912 throw new NotImplementedException();
913 }
914
915 /// <summary>
916 /// Resize and reposition all of the workspace chrome (toolbox,
917 /// trash, scrollbars etc.)
918 /// This should be called when something changes that
919 /// requires recalculating dimensions and positions of the
920 /// trash, zoom, toolbox, etc. (e.g.window resize).
921 /// </summary>
922 public void resize()
923 {
924 throw new NotImplementedException();
925 }
926
927 /// <summary>
928 /// Get the SVG element that forms the drawing surface.
929 /// </summary>
930 /// <returns>SVG element.</returns>
931 public Element getCanvas()
932 {
933 throw new NotImplementedException();
934 }
935
936 /// <summary>
937 /// Get the SVG element that forms the bubble surface.
938 /// </summary>
939 /// <returns>SVG element.</returns>
940 public Element getBubbleCanvas()
941 {
942 throw new NotImplementedException();
943 }
944
945 /// <summary>
946 /// Get the SVG element that contains this workspace.
947 /// </summary>
948 /// <returns>SVG element.</returns>
949 public Element getParentSvg()
950 {
951 throw new NotImplementedException();
952 }
953
954 /// <summary>
955 /// Translate this workspace to new coordinates.
956 /// </summary>
957 /// <param name="x">Horizontal translation.</param>
958 /// <param name="y">Vertical translation.</param>
959 public void translate(int x, int y)
960 {
961 throw new NotImplementedException();
962 }
963
964 /// <summary>
965 /// Returns the horizontal offset of the workspace.
966 /// Intended for LTR/RTL compatibility in XML.
967 /// </summary>
968 /// <returns>Width.</returns>
969 public new int getWidth()
970 {
971 throw new NotImplementedException();
972 }
973
974 /// <summary>
975 /// Toggles the visibility of the workspace.
976 /// Currently only intended for main workspace.
977 /// </summary>
978 /// <param name="isVisible">True if workspace should be visible.</param>
979 public void setVisible(bool isVisible)
980 {
981 throw new NotImplementedException();
982 }
983
984 /// <summary>
985 /// Render all blocks in workspace.
986 /// </summary>
987 public void render()
988 {
989 throw new NotImplementedException();
990 }
991
992 /// <summary>
993 /// Turn the visual trace functionality on or off.
994 /// </summary>
995 /// <param name="armed">True if the trace should be on.</param>
996 public void traceOn(bool armed)
997 {
998 throw new NotImplementedException();
999 }
1000
1001 /// <summary>
1002 /// Highlight a block in the workspace.
1003 /// </summary>
1004 /// <param name="id">ID of block to find.</param>
1005 public void highlightBlock(string id)
1006 {
1007 throw new NotImplementedException();
1008 }
1009
1010 /// <summary>
1011 /// Paste the provided block onto the workspace.
1012 /// </summary>
1013 /// <param name="xmlBlock">XML block element.</param>
1014 public void paste(Element xmlBlock)
1015 {
1016 throw new NotImplementedException();
1017 }
1018
1019 /// <summary>
1020 /// Make a list of all the delete areas for this workspace.
1021 /// </summary>
1022 public void recordDeleteAreas()
1023 {
1024 throw new NotImplementedException();
1025 }
1026
1027 /// <summary>
1028 /// Is the mouse event over a delete area (toolbox or non-closing flyout)?
1029 /// Opens or closes the trashcan and sets the cursor as a side effect.
1030 /// </summary>
1031 /// <param name="e">Mouse move event.</param>
1032 /// <returns></returns>
1033 public bool isDeleteArea(Event e)
1034 {
1035 throw new NotImplementedException();
1036 }
1037
1038 /// <summary>
1039 /// Start tracking a drag of an object on this workspace.
1040 /// </summary>
1041 /// <param name="e">Mouse down event.</param>
1042 /// <param name="xy">Starting location of object.</param>
1043 public void startDrag(Event e, goog.math.Coordinate xy)
1044 {
1045 throw new NotImplementedException();
1046 }
1047
1048 /// <summary>
1049 /// Track a drag of an object on this workspace.
1050 /// </summary>
1051 /// <param name="e">Mouse move event.</param>
1052 /// <returns>New location of object.</returns>
1053 public goog.math.Coordinate moveDrag(Event e)
1054 {
1055 throw new NotImplementedException();
1056 }
1057
1058 /// <summary>
1059 /// Is the user currently dragging a block or scrolling the flyout/workspace?
1060 /// </summary>
1061 /// <returns>True if currently dragging or scrolling.</returns>
1062 public bool isDragging()
1063 {
1064 throw new NotImplementedException();
1065 }
1066
1067 /// <summary>
1068 /// Calculate the bounding box for the blocks on the workspace.
1069 /// </summary>
1070 /// <returns>Contains the position and size of the bounding box
1071 /// containing the blocks on the workspace.
1072 /// {x: 0, y: 0, width: 0, height: 0}</returns>
1073 public object getBlocksBoundingBox()
1074 {
1075 throw new NotImplementedException();
1076 }
1077
1078 /// <summary>
1079 /// Play a named sound at specified volume. If volume is not specified,
1080 /// use full volume (1).
1081 /// </summary>
1082 /// <param name="name">Name of sound.</param>
1083 /// <param name="opt_volume">Volume of sound (0-1).</param>
1084 public void playAudio(string name, double opt_volume = 1)
1085 {
1086 throw new NotImplementedException();
1087 }
1088
1089 /// <summary>
1090 /// Modify the block tree on the existing toolbox.
1091 /// </summary>
1092 /// <param name="tree">DOM tree of blocks, or text representation of same.</param>
1093 public void updateToolbox(Union<Node, string> tree)
1094 {
1095 throw new NotImplementedException();
1096 }
1097
1098 /// <summary>
1099 /// Mark this workspace as the currently focused main workspace.
1100 /// </summary>
1101 public void markFocused()
1102 {
1103 throw new NotImplementedException();
1104 }
1105
1106 /// <summary>
1107 /// Zooming the blocks centered in (x, y) coordinate with zooming in or out.
1108 /// </summary>
1109 /// <param name="x">X coordinate of center.</param>
1110 /// <param name="y">Y coordinate of center.</param>
1111 /// <param name="type">Type of zooming (-1 zooming out and 1 zooming in).</param>
1112 public void zoom(double x, double y, double type)
1113 {
1114 throw new NotImplementedException();
1115 }
1116
1117 /// <summary>
1118 /// Zooming the blocks centered in the center of view with zooming in or out.
1119 /// </summary>
1120 /// <param name="type"></param>
1121 public void zoomCenter(double type)
1122 {
1123 throw new NotImplementedException();
1124 }
1125
1126 /// <summary>
1127 /// Zoom the blocks to fit in the workspace if possible.
1128 /// </summary>
1129 public void zoomToFit()
1130 {
1131 throw new NotImplementedException();
1132 }
1133
1134 /// <summary>
1135 /// Center the workspace.
1136 /// </summary>
1137 public void scrollCenter()
1138 {
1139 throw new NotImplementedException();
1140 }
1141
1142 /// <summary>
1143 /// Set the workspace's zoom factor.
1144 /// </summary>
1145 /// <param name="newScale">Zoom factor.</param>
1146 public void setScale(double newScale)
1147 {
1148 throw new NotImplementedException();
1149 }
1150 }
1151
1152 [External, Name("Blockly.Metrics")]
1153 public class Metrics
1154 {
1155 ///<summary>Height of the visible rectangle</summary>
1156 public double viewHeight;
1157 ///<summary>Width of the visible rectangle</summary>
1158 public double viewWidth;
1159 ///<summary>Height of the contents</summary>
1160 public double contentHeight;
1161 ///<summary>Width of the contents</summary>
1162 public double contentWidth;
1163 ///<summary>Offset of top edge of visible rectangle from parent</summary>
1164 public double viewTop;
1165 ///<summary>Offset of the top-most content from the y=0 coordinate</summary>
1166 public double contentTop;
1167 ///<summary>Top-edge of view</summary>
1168 public double absoluteTop;
1169 ///<summary>Offset of the left edge of visible rectangle from parent</summary>
1170 public double viewLeft;
1171 ///<summary>Offset of the left-most content from the x=0 coordinate</summary>
1172 public double contentLeft;
1173 ///<summary>Left-edge of view</summary>
1174 public double absoluteLeft;
1175 }
1176
1177 [External, Name("Blockly.Events")]
1178 public class Events
1179 {
1180 public const string CREATE = "create";
1181 public const string DELETE = "delete";
1182 public const string CHANGE = "change";
1183 public const string MOVE = "move";
1184 public const string UI = "ui";
1185
1186 internal string group_ = "";
1187 public bool recordUndo = false;
1188
1189 internal string[] getDescendantIds_(Block block)
1190 {
1191 throw new NotImplementedException();
1192 }
1193
1194 internal void enable()
1195 {
1196 throw new NotImplementedException();
1197 }
1198
1199 internal void disable()
1200 {
1201 throw new NotImplementedException();
1202 }
1203
1204 internal void setGroup(string group)
1205 {
1206 throw new NotImplementedException();
1207 }
1208
1209 internal void fire(Abstract ev)
1210 {
1211 throw new NotImplementedException();
1212 }
1213 }
1214
1215 [External, Name("Blockly.Events.Abstract")]
1216 public class Abstract
1217 {
1218 /// <summary>
1219 /// One of Blockly.Events.CREATE, Blockly.Events.DELETE, Blockly.Events.CHANGE, Blockly.Events.MOVE, Blockly.Events.UI.
1220 /// </summary>
1221 internal string type;
1222
1223 /// <summary>
1224 /// UUID of workspace. The workspace can be found with Workspace.getById(event.workspaceId)
1225 /// </summary>
1226 internal string workspaceId;
1227
1228 /// <summary>
1229 /// UUID of block. The block can be found with workspace.getBlockById(event.blockId)
1230 /// </summary>
1231 internal string blockId;
1232
1233 /// <summary>
1234 /// UUID of group. Some events are part of an indivisible group, such as inserting a statement in a stack.
1235 /// </summary>
1236 internal string group;
1237
1238 internal bool recordUndo;
1239
1240 public Abstract(Block block, string type)
1241 {
1242 this.type = type;
1243 if (block != null) {
1244 blockId = block.id;
1245 workspaceId = block.workspace.id;
1246 }
1247 group = Blockly.Events.group_;
1248 recordUndo = Blockly.Events.recordUndo;
1249 }
1250 }
1251
1252 [External, Name("Blockly.Events.Create")]
1253 public class Create : Abstract
1254 {
1255 /// <summary>
1256 /// An XML tree defining the new block and any connected child blocks.
1257 /// </summary>
1258 internal Element xml;
1259
1260 /// <summary>
1261 /// An array containing the UUIDs of the new block and any connected child blocks.
1262 /// </summary>
1263 internal string[] ids;
1264
1265 /// <summary>
1266 /// Class for a block creation event.
1267 /// </summary>
1268 /// <param name="block">The created block. Null for a blank event.</param>
1269 public Create(Block block)
1270 : base(block, Events.CHANGE)
1271 {
1272 if (block == null) {
1273 return; // Blank event to be populated by fromJson.
1274 }
1275 xml = Blockly.Xml.blockToDomWithXY(block);
1276 ids = Blockly.Events.getDescendantIds_(block);
1277 }
1278 }
1279
1280 [External, Name("Blockly.Events.Delete")]
1281 public class Delete : Abstract
1282 {
1283 /// <summary>
1284 /// An XML tree defining the deleted block and any connected child blocks.
1285 /// </summary>
1286 internal object oldXml;
1287
1288 /// <summary>
1289 /// An array containing the UUIDs of the deleted block and any connected child blocks.
1290 /// </summary>
1291 internal string[] ids;
1292
1293 /// <summary>
1294 /// Class for a block deletion event.
1295 /// </summary>
1296 /// <param name="block">The deleted block. Null for a blank event.</param>
1297 public Delete(Block block)
1298 : base(block, Events.DELETE)
1299 {
1300 if (block == null) {
1301 return; // Blank event to be populated by fromJson.
1302 }
1303 if (block.getParent() != null) {
1304 throw new Exception("Connected blocks cannot be deleted.");
1305 }
1306 oldXml = Blockly.Xml.blockToDomWithXY(block);
1307 ids = Blockly.Events.getDescendantIds_(block);
1308 }
1309 }
1310
1311 [External, Name("Blockly.Events.Change")]
1312 public class Change : Abstract
1313 {
1314 /// <summary>
1315 /// One of 'field', 'comment', 'collapsed', 'disabled', 'inline', 'mutate'
1316 /// </summary>
1317 internal string element;
1318
1319 /// <summary>
1320 /// Name of the field if this is a change to a field.
1321 /// </summary>
1322 internal string name;
1323
1324 /// <summary>
1325 /// Original value.
1326 /// </summary>
1327 internal object oldValue;
1328
1329 /// <summary>
1330 /// Changed value.
1331 /// </summary>
1332 internal object newValue;
1333
1334 /// <summary>
1335 /// Class for a block change event.
1336 /// </summary>
1337 /// <param name="block">The changed block. Null for a blank event.</param>
1338 /// <param name="element">One of 'field', 'comment', 'disabled', etc.</param>
1339 /// <param name="name">Name of input or field affected, or null.</param>
1340 /// <param name="oldValue">Previous value of element.</param>
1341 /// <param name="newValue">New value of element.</param>
1342 public Change(Block block, string element, string name, string oldValue, string newValue)
1343 : base(block, Events.CHANGE)
1344 {
1345 if (block == null) {
1346 return; // Blank event to be populated by fromJson.
1347 }
1348 this.element = element;
1349 this.name = name;
1350 this.oldValue = oldValue;
1351 this.newValue = newValue;
1352 }
1353 }
1354
1355 [External, Name("Blockly.Events.Move")]
1356 public class Move : Abstract
1357 {
1358 /// <summary>
1359 /// UUID of old parent block. Undefined if it was a top level block.
1360 /// </summary>
1361 internal string oldParentId;
1362
1363 /// <summary>
1364 /// Name of input on old parent. Undefined if it was a top level block or parent's next block.
1365 /// </summary>
1366 internal string oldInputName;
1367
1368 /// <summary>
1369 /// X and Y coordinates if it was a top level block. Undefined if it had a parent.
1370 /// </summary>
1371 internal object oldCoordinate;
1372
1373 /// <summary>
1374 /// UUID of new parent block. Undefined if it is a top level block.
1375 /// </summary>
1376 internal string newParentId;
1377
1378 /// <summary>
1379 /// Name of input on new parent. Undefined if it is a top level block or parent's next block.
1380 /// </summary>
1381 internal string newInputName;
1382
1383 /// <summary>
1384 /// X and Y coordinates if it is a top level block. Undefined if it has a parent.
1385 /// </summary>
1386 internal object newCoordinate;
1387
1388 /// <summary>
1389 /// Class for a block move event. Created before the move.
1390 /// </summary>
1391 /// <param name="block">The moved block. Null for a blank event.</param>
1392 public Move(Block block)
1393 : base(block, Events.MOVE)
1394 {
1395 if (block == null) {
1396 return; // Blank event to be populated by fromJson.
1397 }
1398 var location = this.currentLocation_();
1399 this.oldParentId = location.parentId;
1400 this.oldInputName = location.inputName;
1401 this.oldCoordinate = location.coordinate;
1402 }
1403
1404 /**
1405 * Record the block's new location. Called after the move.
1406 */
1407 public void recordNew()
1408 {
1409 var location = this.currentLocation_();
1410 this.newParentId = location.parentId;
1411 this.newInputName = location.inputName;
1412 this.newCoordinate = location.coordinate;
1413 }
1414
1415 class Location
1416 {
1417 public string parentId;
1418 public string inputName;
1419 public object coordinate;
1420
1421 public Location(string parentId, string inputName, object coordinate)
1422 {
1423 this.parentId = parentId;
1424 this.inputName = inputName;
1425 this.coordinate = coordinate;
1426 }
1427 }
1428
1429 /**
1430 * Returns the parentId and input if the block is connected,
1431 * or the XY location if disconnected.
1432 * @return {!Object} Collection of location info.
1433 * @private
1434 */
1435 private Location currentLocation_()
1436 {
1437 throw new NotImplementedException();
1438 }
1439 }
1440
1441 [External, Name("Blockly.Events.Ui")]
1442 public class Ui : Abstract
1443 {
1444 /// <summary>
1445 /// One of 'selected', 'category', 'click', 'commentOpen', 'mutatorOpen', 'warningOpen'
1446 /// </summary>
1447 internal string element;
1448
1449 /// <summary>
1450 /// Original value.
1451 /// </summary>
1452 internal object oldValue;
1453
1454 /// <summary>
1455 /// Changed value.
1456 /// </summary>
1457 internal object newValue;
1458
1459 /// <summary>
1460 /// Class for a UI event.
1461 /// </summary>
1462 /// <param name="block">The affected block.</param>
1463 /// <param name="element">One of 'selected', 'comment', 'mutator', etc.</param>
1464 /// <param name="oldValue">Previous value of element.</param>
1465 /// <param name="newValue">New value of element.</param>
1466 public Ui(Block block, string element, string oldValue, string newValue)
1467 : base(block, Events.UI)
1468 {
1469 this.element = element;
1470 this.oldValue = oldValue;
1471 this.newValue = newValue;
1472 }
1473 }
1474
1475 [External, Name("Blockly.Options")]
1476 public class Options
1477 {
1478 public Node languageTree;
1479 public bool oneBasedIndex;
1480 public Workspace parentWorkspace;
1481 public bool comments;
1482 }
1483
1484 [External, Name("Blockly.BlockSvg")]
1485 public class BlockSvg : Block
1486 {
1487 [Name(false)]
1488 public int TAB_HEIGHT = 20;
1489
1490 public BlockSvg(string type) : base(type)
1491 {
1492 }
1493 }
1494
1495 [External, Name("Blockly.Comment")]
1496 public class Comment : Block
1497 {
1498 public Comment(string type) : base(type)
1499 {
1500 }
1501 }
1502
1503 [External, Name("Blockly.Input")]
1504 public class Input
1505 {
1506 public int type;
1507 public string name;
1508 public Block block;
1509 public Connection connection;
1510 public Field[] fieldRow;
1511
1512 /// <summary>
1513 /// Class for an input with an optional field.
1514 /// </summary>
1515 /// <param name="type">The type of the input.</param>
1516 /// <param name="name">Language-neutral identifier which may used to find this
1517 /// input again.</param>
1518 /// <param name="block">The block containing this input.</param>
1519 /// <param name="connection">Optional connection for this input.</param>
1520 public Input(int type, string name, Block block, Connection connection)
1521 {
1522 this.type = type;
1523 this.name = name;
1524 this.block = block;
1525 this.connection = connection;
1526 }
1527
1528 /// <summary>
1529 /// Add an item to the end of the input's field row.
1530 /// </summary>
1531 /// <param name="field">Something to add as a field.</param>
1532 /// <param name="opt_name">Language-neutral identifier which may used to find
1533 /// this field again.Should be unique to the host block.</param>
1534 /// <returns>The input being append to (to allow chaining).</returns>
1535 public Input appendField(Union<string, Field> field, string opt_name = null)
1536 {
1537 throw new NotImplementedException();
1538 }
1539
1540 /// <summary>
1541 /// Add an item to the end of the input's field row.
1542 /// </summary>
1543 /// <param name="field">Something to add as a field.</param>
1544 /// <param name="opt_name">Language-neutral identifier which may used to find
1545 /// this field again.Should be unique to the host block.</param>
1546 /// <returns>The input being append to (to allow chaining).</returns>
1547 public Input appendTitle(Union<string, Field> field, string opt_name = null)
1548 {
1549 throw new NotImplementedException();
1550 }
1551
1552 /// <summary>
1553 /// Remove a field from this input.
1554 /// </summary>
1555 /// <param name="name">The name of the field.</param>
1556 public void removeField(string name)
1557 {
1558 throw new NotImplementedException();
1559 }
1560
1561 /// <summary>
1562 /// Gets whether this input is visible or not.
1563 /// </summary>
1564 /// <returns>True if visible.</returns>
1565 public bool isVisible()
1566 {
1567 throw new NotImplementedException();
1568 }
1569
1570 /// <summary>
1571 /// Sets whether this input is visible or not.
1572 /// Used to collapse/uncollapse a block.
1573 /// </summary>
1574 /// <param name="visible">True if visible.</param>
1575 /// <returns>List of blocks to render.</returns>
1576 public Block[] setVisible(bool visible)
1577 {
1578 throw new NotImplementedException();
1579 }
1580
1581 /// <summary>
1582 /// Change a connection's compatibility.
1583 /// </summary>
1584 /// <param name="check">Compatible value type or
1585 /// list of value types.Null if all types are compatible.</param>
1586 /// <returns>The input being modified (to allow chaining).</returns>
1587 public Input setCheck(Union<string, string[]> check)
1588 {
1589 throw new NotImplementedException();
1590 }
1591
1592 /// <summary>
1593 /// Change the alignment of the connection's field(s).
1594 /// </summary>
1595 /// <param name="align">align One of Blockly.ALIGN_LEFT, ALIGN_CENTRE, ALIGN_RIGHT.
1596 /// In RTL mode directions are reversed, and ALIGN_RIGHT aligns to the left.</param>
1597 /// <returns>The input being modified (to allow chaining).</returns>
1598 public Input setAlign(double align)
1599 {
1600 throw new NotImplementedException();
1601 }
1602
1603 /// <summary>
1604 /// Initialize the fields on this input.
1605 /// </summary>
1606 public void init()
1607 {
1608 throw new NotImplementedException();
1609 }
1610
1611 /// <summary>
1612 /// Sever all links to this input.
1613 /// </summary>
1614 public void dispose()
1615 {
1616 throw new NotImplementedException();
1617 }
1618 }
1619
1620 [External, Name("Blockly.Icon")]
1621 public class Icon
1622 {
1623 public Icon(Block block)
1624 {
1625 }
1626 }
1627
1628 [External, Name("Blockly.Mutator")]
1629 public class Mutator : Icon
1630 {
1631 public Workspace workspace_;
1632
1633 public Mutator(string[] quarkNames)
1634 : base(null)
1635 {
1636 }
1637
1638 /// <summary>
1639 /// Reconnect an block to a mutated input.
1640 /// </summary>
1641 /// <param name="connectionChild">Connection on child block.</param>
1642 /// <param name="block">Parent block.</param>
1643 /// <param name="inputName">Name of input on parent block.</param>
1644 /// <returns>True iff a reconnection was made, false otherwise.</returns>
1645 internal static bool reconnect(Connection connectionChild, Block block, string inputName)
1646 {
1647 throw new NotImplementedException();
1648 }
1649
1650 internal bool isVisible()
1651 {
1652 throw new NotImplementedException();
1653 }
1654 }
1655
1656 [External, Name("Blockly.Connection")]
1657 public class Connection
1658 {
1659 public Connection targetConnection;
1660
1661 public Connection(Block source, int type)
1662 {
1663 }
1664
1665 public void connect(Connection previousConnection)
1666 {
1667 throw new NotImplementedException();
1668 }
1669
1670 public void disconnect()
1671 {
1672 throw new NotImplementedException();
1673 }
1674
1675 public Block targetBlock()
1676 {
1677 throw new NotImplementedException();
1678 }
1679
1680 public bool checkType_(Connection connection)
1681 {
1682 throw new NotImplementedException();
1683 }
1684
1685 public Connection setCheck(object check)
1686 {
1687 throw new NotImplementedException();
1688 }
1689
1690 internal Block getSourceBlock()
1691 {
1692 throw new NotImplementedException();
1693 }
1694 }
1695
1696 [External, Name("Blockly.RenderedConnection")]
1697 public class RenderedConnection : Connection
1698 {
1699 public RenderedConnection(Block source, int type)
1700 : base(source, type)
1701 {
1702 }
1703 }
1704
1705 [External, Name("Blockly.Field")]
1706 public class Field
1707 {
1708 public goog.math.Size size_;
1709 public string text_;
1710 public Block sourceBlock_;
1711
1712 /// <summary>
1713 /// Abstract class for an editable field.
1714 /// </summary>
1715 /// <param name="text">The initial content of the field.</param>
1716 /// <param name="opt_validator">An optional function that is called
1717 /// to validate any constraints on what the user entered. Takes the new
1718 /// text as an argument and returns either the accepted text, a replacement
1719 /// text, or null to abort the change.</param>
1720 public Field(string text, Func<string, object> opt_validator = null)
1721 {
1722 size_ = new goog.math.Size(0, 25);
1723 setValue(text);
1724 setValidator(opt_validator);
1725 }
1726
1727 /// <summary>
1728 /// Name of field. Unique within each block.
1729 /// Static labels are usually unnamed.
1730 /// </summary>
1731 public string name;
1732
1733 /// <summary>
1734 /// Maximum characters of text to display before adding an ellipsis.
1735 /// </summary>
1736 public int maxDisplayLength;
1737
1738 /// <summary>
1739 /// Non-breaking space.
1740 /// </summary>
1741 [Name(false)]
1742 public const string NBSP = "\u00A0";
1743
1744 /// <summary>
1745 /// Editable fields are saved by the XML renderer, non-editable fields are not.
1746 /// </summary>
1747 [Name(false)]
1748 public bool EDITABLE = true;
1749
1750 /// <summary>
1751 /// Attach this field to a block.
1752 /// </summary>
1753 /// <param name="block">The block containing this field.</param>
1754 public void setSourceBlock(Block block)
1755 {
1756 throw new NotImplementedException();
1757 }
1758
1759 /// <summary>
1760 /// Install this field on a block.
1761 /// </summary>
1762 public virtual void init()
1763 {
1764 throw new NotImplementedException();
1765 }
1766
1767 /// <summary>
1768 /// Dispose of all DOM objects belonging to this editable field.
1769 /// </summary>
1770 public virtual void dispose()
1771 {
1772 throw new NotImplementedException();
1773 }
1774
1775 /// <summary>
1776 /// Add or remove the UI indicating if this field is editable or not.
1777 /// </summary>
1778 public void updateEditable()
1779 {
1780 throw new NotImplementedException();
1781 }
1782
1783 /// <summary>
1784 /// Gets whether this editable field is visible or not.
1785 /// </summary>
1786 /// <returns>True if visible.</returns>
1787 public bool isVisible()
1788 {
1789 throw new NotImplementedException();
1790 }
1791
1792 /// <summary>
1793 /// Sets whether this editable field is visible or not.
1794 /// </summary>
1795 /// <param name="visible">True if visible.</param>
1796 public void setVisible(bool visible)
1797 {
1798 throw new NotImplementedException();
1799 }
1800
1801 /// <summary>
1802 /// Sets a new validation function for editable fields.
1803 /// </summary>
1804 /// <param name="handler">New validation function, or null.</param>
1805 public virtual void setValidator(Func<string, object> handler)
1806 {
1807 throw new NotImplementedException();
1808 }
1809
1810 /// <summary>
1811 /// Gets the validation function for editable fields.
1812 /// </summary>
1813 /// <returns>Validation function, or null.</returns>
1814 public Func<string, string> getValidator()
1815 {
1816 throw new NotImplementedException();
1817 }
1818
1819 /// <summary>
1820 /// Gets the group element for this editable field.
1821 /// Used for measuring the size and for positioning.
1822 /// </summary>
1823 /// <returns>The group element.</returns>
1824 public virtual Element getSvgRoot()
1825 {
1826 throw new NotImplementedException();
1827 }
1828
1829 /// <summary>
1830 /// Start caching field widths. Every call to this function MUST also call
1831 /// stopCache. Caches must not survive between execution threads.
1832 /// </summary>
1833 public void startCache()
1834 {
1835 throw new NotImplementedException();
1836 }
1837
1838 /// <summary>
1839 /// Stop caching field widths. Unless caching was already on when the
1840 /// corresponding call to startCache was made.
1841 /// </summary>
1842 public void stopCache()
1843 {
1844 throw new NotImplementedException();
1845 }
1846
1847 /// <summary>
1848 /// Returns the height and width of the field.
1849 /// </summary>
1850 /// <returns>Height and width.</returns>
1851 public goog.math.Size getSize()
1852 {
1853 throw new NotImplementedException();
1854 }
1855
1856 /// <summary>
1857 /// Get the text from this field.
1858 /// </summary>
1859 /// <returns>Current text.</returns>
1860 public virtual string getText()
1861 {
1862 throw new NotImplementedException();
1863 }
1864
1865 /// <summary>
1866 /// Set the text in this field. Trigger a rerender of the source block.
1867 /// </summary>
1868 /// <param name="text">New text.</param>
1869 public virtual void setText(string text)
1870 {
1871 throw new NotImplementedException();
1872 }
1873
1874 /// <summary>
1875 /// By default there is no difference between the human-readable text and
1876 /// the language-neutral values. Subclasses (such as dropdown) may define this.
1877 /// </summary>
1878 /// <returns>Current text.</returns>
1879 public virtual string getValue()
1880 {
1881 throw new NotImplementedException();
1882 }
1883
1884 /// <summary>
1885 /// By default there is no difference between the human-readable text and
1886 /// the language-neutral values. Subclasses (such as dropdown) may define this.
1887 /// </summary>
1888 /// <param name="newText">New text.</param>
1889 public virtual void setValue(string newText)
1890 {
1891 throw new NotImplementedException();
1892 }
1893
1894 /// <summary>
1895 /// Change the tooltip text for this field.
1896 /// </summary>
1897 /// <param name="newTip">newTip Text for tooltip or a parent element to
1898 /// link to for its tooltip.</param>
1899 public virtual void setTooltip(Union<string, Element> newTip)
1900 {
1901 throw new NotImplementedException();
1902 }
1903 }
1904
1905 [External, Name("Blockly.FieldLabel")]
1906 public class FieldLabel : Field
1907 {
1908 /// <summary>
1909 /// Class for a non-editable field.
1910 /// </summary>
1911 /// <param name="text">The initial content of the field.</param>
1912 /// <param name="opt_class">Optional CSS class for the field's text.</param>
1913 public FieldLabel(string text, string opt_class = null)
1914 : base(text)
1915 {
1916 }
1917
1918 /// <summary>
1919 /// Install this text on a block.
1920 /// </summary>
1921 public override void init()
1922 {
1923 base.init();
1924 }
1925
1926 /// <summary>
1927 /// Dispose of all DOM objects belonging to this text.
1928 /// </summary>
1929 public override void dispose()
1930 {
1931 base.dispose();
1932 }
1933
1934 /// <summary>
1935 /// Gets the group element for this field.
1936 /// Used for measuring the size and for positioning.
1937 /// </summary>
1938 /// <returns></returns>
1939 public override Element getSvgRoot()
1940 {
1941 return base.getSvgRoot();
1942 }
1943
1944 /// <summary>
1945 /// Change the tooltip text for this field.
1946 /// </summary>
1947 /// <param name="newTip">Text for tooltip or a parent element to
1948 /// link to for its tooltip.</param>
1949 public override void setTooltip(Union<string, Element> newTip)
1950 {
1951 base.setTooltip(newTip);
1952 }
1953 }
1954
1955 [External, Name("Blockly.FieldCheckbox")]
1956 public class FieldCheckbox : Field
1957 {
1958 /// <summary>
1959 /// Class for a checkbox field.
1960 /// </summary>
1961 /// <param name="state">The initial state of the field ('TRUE' or 'FALSE').</param>
1962 /// <param name="opt_validator">A function that is executed when a new
1963 /// option is selected. Its sole argument is the new checkbox state. If
1964 /// it returns a value, this becomes the new checkbox state, unless the
1965 /// value is null, in which case the change is aborted.</param>
1966 public FieldCheckbox(string state, Func<string, object> opt_validator = null)
1967 : base("", opt_validator)
1968 {
1969 }
1970
1971 /// <summary>
1972 /// Character for the checkmark.
1973 /// </summary>
1974 public string CHECK_CHAR = "\u2713";
1975
1976 /// <summary>
1977 /// Mouse cursor style when over the hotspot that initiates editability.
1978 /// </summary>
1979 public string CURSOR = "default";
1980
1981 /// <summary>
1982 /// Install this checkbox on a block.
1983 /// </summary>
1984 public override void init()
1985 {
1986 base.init();
1987 }
1988
1989 /// <summary>
1990 /// Return 'TRUE' if the checkbox is checked, 'FALSE' otherwise.
1991 /// </summary>
1992 /// <returns>Current state.</returns>
1993 public override string getValue()
1994 {
1995 return base.getValue();
1996 }
1997
1998 /// <summary>
1999 /// Set the checkbox to be checked if strBool is 'TRUE', unchecks otherwise.
2000 /// </summary>
2001 /// <param name="strBool">New state.</param>
2002 public override void setValue(string strBool)
2003 {
2004 base.setValue(strBool);
2005 }
2006 }
2007
2008 [External, Name("Blockly.FieldDropdown")]
2009 public class FieldDropdown : Field
2010 {
2011 /// <summary>
2012 /// Class for an editable dropdown field.
2013 /// </summary>
2014 /// <param name="menuGenerator">An array of
2015 /// options for a dropdown list, or a function which generates these options.</param>
2016 /// <param name="opt_validator">A function that is executed when a new
2017 /// option is selected, with the newly selected value as its sole argument.
2018 /// If it returns a value, that value (which must be one of the options) will
2019 /// become selected in place of the newly selected option, unless the return
2020 /// value is null, in which case the change is aborted.
2021 /// </param>
2022 public FieldDropdown(Union<string[][], Func<string[][]>> menuGenerator, Func<string, object> opt_validator = null)
2023 : base(menuGenerator.As<string[][]>()[0][1], opt_validator)
2024 {
2025 }
2026
2027 /// <summary>
2028 /// Horizontal distance that a checkmark ovehangs the dropdown.
2029 /// </summary>
2030 public int CHECKMARK_OVERHANG = 25;
2031
2032 /// <summary>
2033 /// Android can't (in 2014) display "▾", so use "▼" instead.
2034 /// </summary>
2035 public string ARROW_CHAR = "\u25BE";
2036
2037 /// <summary>
2038 /// Mouse cursor style when over the hotspot that initiates the editor.
2039 /// </summary>
2040 public string CURSOR = "default";
2041
2042 /// <summary>
2043 /// Install this dropdown on a block.
2044 /// </summary>
2045 public override void init()
2046 {
2047 base.init();
2048 }
2049
2050 /// <summary>
2051 /// Get the language-neutral value from this dropdown menu.
2052 /// </summary>
2053 /// <returns>Current text.</returns>
2054 public override string getValue()
2055 {
2056 return base.getValue();
2057 }
2058
2059 /// <summary>
2060 /// Set the language-neutral value for this dropdown menu.
2061 /// </summary>
2062 /// <param name="newText">New value to set.</param>
2063 public override void setValue(string newText)
2064 {
2065 base.setValue(newText);
2066 }
2067
2068 /// <summary>
2069 /// Set the text in this field. Trigger a rerender of the source block.
2070 /// </summary>
2071 /// <param name="text">New text.</param>
2072 public override void setText(string text)
2073 {
2074 base.setText(text);
2075 }
2076
2077 /// <summary>
2078 /// Close the dropdown menu if this input is being deleted.
2079 /// </summary>
2080 public override void dispose()
2081 {
2082 base.dispose();
2083 }
2084 }
2085
2086 [External, Name("Blockly.FieldTextInput")]
2087 public class FieldTextInput : Field
2088 {
2089 public Action<string> onFinishEditing_;
2090
2091 /// <summary>
2092 /// Class for an editable text field.
2093 /// </summary>
2094 /// <param name="text">The initial content of the field.</param>
2095 /// <param name="opt_validator">An optional function that is called
2096 /// to validate any constraints on what the user entered. Takes the new
2097 /// text as an argument and returns either the accepted text, a replacement
2098 /// text, or null to abort the change.</param>
2099 public FieldTextInput(string text, Func<string, object> opt_validator = null)
2100 : base(text, opt_validator)
2101 {
2102 }
2103
2104 /// <summary>
2105 /// Point size of text. Should match blocklyText's font-size in CSS.
2106 /// </summary>
2107 public int FONTSIZE = 11;
2108
2109 /// <summary>
2110 /// Mouse cursor style when over the hotspot that initiates the editor.
2111 /// </summary>
2112 public string CURSOR = "text";
2113
2114 /// <summary>
2115 /// Close the input widget if this input is being deleted.
2116 /// </summary>
2117 public override void dispose()
2118 {
2119 base.dispose();
2120 }
2121
2122 /// <summary>
2123 /// Set the text in this field.
2124 /// </summary>
2125 /// <param name="text">New text.</param>
2126 public override void setValue(string text)
2127 {
2128 base.setValue(text);
2129 }
2130
2131 /// <summary>
2132 /// Set whether this field is spellchecked by the browser.
2133 /// </summary>
2134 /// <param name="check">True if checked.</param>
2135 public void setSpellcheck(bool check)
2136 {
2137 throw new NotImplementedException();
2138 }
2139
2140 /// <summary>
2141 /// Ensure that only a number may be entered.
2142 /// </summary>
2143 /// <param name="text">The user's text.</param>
2144 /// <returns>A string representing a valid number, or null if invalid.</returns>
2145 public virtual string numberValidator(string text)
2146 {
2147 throw new NotImplementedException();
2148 }
2149
2150 /// <summary>
2151 /// Ensure that only a nonnegative integer may be entered.
2152 /// </summary>
2153 /// <param name="test">The user's text.</param>
2154 /// <returns>A string representing a valid int, or null if invalid.</returns>
2155 public string nonnegativeIntegerValidator(string test)
2156 {
2157 throw new NotImplementedException();
2158 }
2159 }
2160
2161 [External, Name("Blockly.FieldDate")]
2162 public class FieldDate : Field
2163 {
2164 /// <summary>
2165 /// Class for a date input field.
2166 /// </summary>
2167 /// <param name="date">The initial date.</param>
2168 /// <param name="opt_validator">A function that is executed when a new
2169 /// date is selected. Its sole argument is the new date value. Its
2170 /// return value becomes the selected date, unless it is undefined, in
2171 /// which case the new date stands, or it is null, in which case the change
2172 /// is aborted.</param>
2173 public FieldDate(string date, Func<string, object> opt_validator = null)
2174 : base(date, opt_validator)
2175 {
2176 }
2177
2178 /// <summary>
2179 /// Mouse cursor style when over the hotspot that initiates the editor.
2180 /// </summary>
2181 public string CURSOR = "text";
2182
2183 /// <summary>
2184 /// Close the colour picker if this input is being deleted.
2185 /// </summary>
2186 public override void dispose()
2187 {
2188 base.dispose();
2189 }
2190
2191 /// <summary>
2192 /// Return the current date.
2193 /// </summary>
2194 /// <returns>Current date.</returns>
2195 public override string getValue()
2196 {
2197 return base.getValue();
2198 }
2199
2200 /// <summary>
2201 /// Set the date.
2202 /// </summary>
2203 /// <param name="newText">The new date.</param>
2204 public override void setValue(string newText)
2205 {
2206 base.setValue(newText);
2207 }
2208
2209 /// <summary>
2210 /// CSS for date picker. See css.js for use.
2211 /// </summary>
2212 public string[] CSS = new string[0];
2213 }
2214
2215 [External, Name("Blockly.FieldColour")]
2216 public class FieldColour : Field
2217 {
2218 /// <summary>
2219 /// Class for a colour input field.
2220 /// </summary>
2221 /// <param name="colour">The initial colour in '#rrggbb' format.</param>
2222 /// <param name="opt_validator">A function that is executed when a new
2223 /// colour is selected. Its sole argument is the new colour value. Its
2224 /// return value becomes the selected colour, unless it is undefined, in
2225 /// which case the new colour stands, or it is null, in which case the change
2226 /// is aborted.</param>
2227 public FieldColour(string colour, Func<string, object> opt_validator = null)
2228 : base(colour, opt_validator)
2229 {
2230 }
2231
2232 /// <summary>
2233 /// Install this field on a block.
2234 /// </summary>
2235 public override void init()
2236 {
2237 base.init();
2238 }
2239
2240 /// <summary>
2241 /// Mouse cursor style when over the hotspot that initiates the editor.
2242 /// </summary>
2243 public string CURSOR = "default";
2244
2245 /// <summary>
2246 /// Close the colour picker if this input is being deleted.
2247 /// </summary>
2248 public override void dispose()
2249 {
2250 base.dispose();
2251 }
2252
2253 /// <summary>
2254 /// Return the current colour.
2255 /// </summary>
2256 /// <returns>Current colour in '#rrggbb' format.</returns>
2257 public override string getValue()
2258 {
2259 return base.getValue();
2260 }
2261
2262 /// <summary>
2263 /// Set the colour.
2264 /// </summary>
2265 /// <param name="colour">The new colour in '#rrggbb' format.</param>
2266 public override void setValue(string colour)
2267 {
2268 base.setValue(colour);
2269 }
2270
2271 /// <summary>
2272 /// Get the text from this field. Used when the block is collapsed.
2273 /// </summary>
2274 /// <returns>Current text.</returns>
2275 public override string getText()
2276 {
2277 return base.getText();
2278 }
2279
2280 /// <summary>
2281 /// An array of colour strings for the palette.
2282 /// See bottom of this page for the default:
2283 /// http://docs.closure-library.googlecode.com/git/closure_goog_ui_colorpicker.js.source.html
2284 /// </summary>
2285 public string[] COLOURS = new string[0];
2286
2287 /// <summary>
2288 /// Set a custom colour grid for this field.
2289 /// </summary>
2290 /// <param name="colours">Array of colours for this block,
2291 /// or null to use default (FieldColour.COLOURS).</param>
2292 /// <returns>Returns itself (for method chaining).</returns>
2293 public FieldColour setColours(string[] colours)
2294 {
2295 throw new NotImplementedException();
2296 }
2297
2298 /// <summary>
2299 /// Set a custom grid size for this field.
2300 /// </summary>
2301 /// <param name="columns">Number of columns for this block,
2302 /// or 0 to use default (FieldColour.COLUMNS).</param>
2303 /// <returns>Returns itself (for method chaining).</returns>
2304 public FieldColour setColumns(int columns)
2305 {
2306 throw new NotImplementedException();
2307 }
2308 }
2309
2310 [External, Name("Blockly.FieldNumber")]
2311 public class FieldNumber : FieldTextInput
2312 {
2313 /// <summary>
2314 /// Class for an editable number field.
2315 /// </summary>
2316 /// <param name="value">The initial content of the field.</param>
2317 /// <param name="opt_min">Minimum value.</param>
2318 /// <param name="opt_max">Maximum value.</param>
2319 /// <param name="opt_precision">Precision for value.</param>
2320 /// <param name="opt_validator">An optional function that is called
2321 /// to validate any constraints on what the user entered. Takes the new
2322 /// text as an argument and returns either the accepted text, a replacement
2323 /// text, or null to abort the change.</param>
2324 public FieldNumber(string value, Union<string, int> opt_min,
2325 Union<string, int> opt_max, Union<string, int> opt_precision,
2326 Func<string, object> opt_validator = null)
2327 : base(value, opt_validator)
2328 {
2329 }
2330
2331 /// <summary>
2332 /// Set the maximum, minimum and precision constraints on this field.
2333 /// Any of these properties may be undefiend or NaN to be disabled.
2334 /// Setting precision (usually a power of 10) enforces a minimum step between
2335 /// values. That is, the user's value will rounded to the closest multiple of
2336 /// precision. The least significant digit place is inferred from the precision.
2337 /// Integers values can be enforces by choosing an integer precision.
2338 /// </summary>
2339 /// <param name="min">Minimum value.</param>
2340 /// <param name="max">Maximum value.</param>
2341 /// <param name="precision">Precision for value.</param>
2342 public void setConstraints(Union<string, int> min, Union<string, int> max,
2343 Union<string, int> precision)
2344 {
2345 throw new NotImplementedException();
2346 }
2347
2348 /// <summary>
2349 /// Sets a new change handler for number field.
2350 /// </summary>
2351 /// <param name="handler">New change handler, or null.</param>
2352 public override void setValidator(Func<string, object> handler)
2353 {
2354 base.setValidator(handler);
2355 }
2356
2357 /// <summary>
2358 /// Ensure that only a number in the correct range may be entered.
2359 /// </summary>
2360 /// <param name="text">The user's text.</param>
2361 /// <returns>A string representing a valid number, or null if invalid.</returns>
2362 public override string numberValidator(string text)
2363 {
2364 return base.numberValidator(text);
2365 }
2366 }
2367
2368 [External, Name("Blockly.FieldAngle")]
2369 public class FieldAngle : FieldTextInput
2370 {
2371 /// <summary>
2372 /// Class for an editable angle field.
2373 /// </summary>
2374 /// <param name="text">The initial content of the field.</param>
2375 /// <param name="opt_validator">An optional function that is called
2376 /// to validate any constraints on what the user entered. Takes the new
2377 /// text as an argument and returns the accepted text or null to abort
2378 /// the change.</param>
2379 public FieldAngle(string text, Func<string, object> opt_validator = null)
2380 : base(text, opt_validator)
2381 {
2382 }
2383
2384 /// <summary>
2385 /// Sets a new change handler for angle field.
2386 /// </summary>
2387 /// <param name="handler">New change handler, or null.</param>
2388 public override void setValidator(Func<string, object> handler)
2389 {
2390 base.setValidator(handler);
2391 }
2392
2393 /// <summary>
2394 /// Round angles to the nearest 15 degrees when using mouse.
2395 /// Set to 0 to disable rounding.
2396 /// </summary>
2397 public int ROUND = 15;
2398
2399 /// <summary>
2400 /// Half the width of protractor image.
2401 /// </summary>
2402 public static int HALF = 100 / 2;
2403
2404 /// <summary>
2405 /// Angle increases clockwise (true) or counterclockwise (false).
2406 /// </summary>
2407 public bool CLOCKWISE = false;
2408
2409 /// <summary>
2410 /// Offset the location of 0 degrees (and all angles) by a constant.
2411 /// Usually either 0 (0 = right) or 90 (0 = up).
2412 /// </summary>
2413 public int OFFSET = 0;
2414
2415 /// <summary>
2416 /// Maximum allowed angle before wrapping.
2417 /// Usually either 360 (for 0 to 359.9) or 180 (for -179.9 to 180).
2418 /// </summary>
2419 public int WRAP = 360;
2420
2421 /// <summary>
2422 /// Radius of protractor circle. Slightly smaller than protractor size since
2423 /// otherwise SVG crops off half the border at the edges.
2424 /// </summary>
2425 public int RADIUS = HALF - 1;
2426
2427 /// <summary>
2428 /// Set the angle to match the mouse's position.
2429 /// </summary>
2430 /// <param name="e">Mouse move event.</param>
2431 public void onMouseMove(Event e)
2432 {
2433 throw new NotImplementedException();
2434 }
2435
2436 /// <summary>
2437 /// Insert a degree symbol.
2438 /// </summary>
2439 /// <param name="text">New text.</param>
2440 public override void setText(string text)
2441 {
2442 base.setText(text);
2443 }
2444
2445 /// <summary>
2446 /// Ensure that only an angle may be entered.
2447 /// </summary>
2448 /// <param name="text">The user's text.</param>
2449 /// <returns>A string representing a valid angle, or null if invalid.</returns>
2450 public string angleValidator(string text)
2451 {
2452 throw new NotImplementedException();
2453 }
2454 }
2455
2456 [External, Name("Blockly.FieldImage")]
2457 public class FieldImage : Field
2458 {
2459 /// <summary>
2460 /// Class for an image.
2461 /// </summary>
2462 /// <param name="src">The URL of the image.</param>
2463 /// <param name="width">Width of the image.</param>
2464 /// <param name="height">Height of the image.</param>
2465 /// <param name="opt_alt">Optional alt text for when block is collapsed.</param>
2466 public FieldImage(string src, int width, int height, string opt_alt = "")
2467 : base(src)
2468 {
2469 }
2470
2471 /// <summary>
2472 /// Install this image on a block.
2473 /// </summary>
2474 public override void init()
2475 {
2476 base.init();
2477 }
2478
2479 /// <summary>
2480 /// Dispose of all DOM objects belonging to this text.
2481 /// </summary>
2482 public override void dispose()
2483 {
2484 base.dispose();
2485 }
2486
2487 /// <summary>
2488 /// Change the tooltip text for this field.
2489 /// </summary>
2490 /// <param name="newTip">Text for tooltip or a parent element to
2491 /// link to for its tooltip.</param>
2492 public override void setTooltip(Union<string, Element> newTip)
2493 {
2494 base.setTooltip(newTip);
2495 }
2496
2497 /// <summary>
2498 /// Get the source URL of this image.
2499 /// </summary>
2500 /// <returns>Current text.</returns>
2501 public override string getValue()
2502 {
2503 return base.getValue();
2504 }
2505
2506 /// <summary>
2507 /// Set the source URL of this image.
2508 /// </summary>
2509 /// <param name="newText">New source.</param>
2510 public override void setValue(string newText)
2511 {
2512 base.setValue(newText);
2513 }
2514
2515 /// <summary>
2516 /// Set the alt text of this image.
2517 /// </summary>
2518 /// <param name="alt">New alt text.</param>
2519 public override void setText(string alt)
2520 {
2521 base.setText(alt);
2522 }
2523 }
2524
2525 [External, Name("Blockly.FieldVariable")]
2526 public class FieldVariable : Field
2527 {
2528 /// <summary>
2529 /// Class for a variable's dropdown field.
2530 /// </summary>
2531 /// <param name="varname">The default name for the variable. If null,
2532 /// a unique variable name will be generated.</param>
2533 /// <param name="opt_validator">A function that is executed when a new
2534 /// option is selected. Its sole argument is the new option value.</param>
2535 public FieldVariable(string varname, Func<string, object> opt_validator = null)
2536 : base(varname, opt_validator)
2537 {
2538 }
2539
2540 /// <summary>
2541 /// Sets a new change handler for angle field.
2542 /// </summary>
2543 /// <param name="handler">New change handler, or null.</param>
2544 public override void setValidator(Func<string, object> handler)
2545 {
2546 base.setValidator(handler);
2547 }
2548
2549 /// <summary>
2550 /// Install this dropdown on a block.
2551 /// </summary>
2552 public override void init()
2553 {
2554 base.init();
2555 }
2556
2557 /// <summary>
2558 /// Get the variable's name (use a variableDB to convert into a real name).
2559 /// Unline a regular dropdown, variables are literal and have no neutral value.
2560 /// </summary>
2561 /// <returns>Current text.</returns>
2562 public override string getValue()
2563 {
2564 return base.getValue();
2565 }
2566
2567 /// <summary>
2568 /// Set the variable name.
2569 /// </summary>
2570 /// <param name="newValue">New text.</param>
2571 public override void setValue(string newValue)
2572 {
2573 base.setValue(newValue);
2574 }
2575
2576 /// <summary>
2577 /// Return a sorted list of variable names for variable dropdown menus.
2578 /// Include a special option at the end for creating a new variable name.
2579 /// </summary>
2580 /// <returns>Array of variable names.</returns>
2581 public string[] dropdownCreate()
2582 {
2583 throw new NotImplementedException();
2584 }
2585
2586 /// <summary>
2587 /// Event handler for a change in variable name.
2588 /// Special case the 'New variable...' and 'Rename variable...' options.
2589 /// In both of these special cases, prompt the user for a new name.
2590 /// </summary>
2591 /// <param name="text">The selected dropdown menu option.</param>
2592 /// <returns>An acceptable new variable name, or null if
2593 /// change is to be either aborted (cancel button) or has been already
2594 /// handled (rename), or undefined if an existing variable was chosen.</returns>
2595 public string dropdownChange(string text)
2596 {
2597 throw new NotImplementedException();
2598 }
2599 }
2600
2601 [External, Name("Blockly.Rectangle")]
2602 public class Rectangle
2603 {
2604 public goog.math.Coordinate topLeft;
2605 public goog.math.Coordinate bottomRight;
2606 }
2607
2608 [External, Name("Blockly.ContextMenu")]
2609 public class ContextMenu
2610 {
2611 public static Action callbackFactory(Block block, Element xml)
2612 {
2613 throw new NotImplementedException();
2614 }
2615 }
2616
2617 [External, Name("Blockly.FlyoutButton")]
2618 public class FlyoutButton
2619 {
2620 internal Workspace getTargetWorkspace()
2621 {
2622 throw new NotImplementedException();
2623 }
2624 }
2625
2626 /// <summary>
2627 /// Allow for switching between one and zero based indexing for lists and text,
2628 /// one based by default.
2629 /// </summary>
2630 [External, Name("Blockly.Blocks")]
2631 public class Blocks
2632 {
2633 public bool ONE_BASED_INDEXING = true;
2634 }
2635}
2636
2637/// <summary>
2638/// Google's common JavaScript library
2639/// https://developers.google.com/closure/library/
2640/// </summary>
2641[External]
2642public static class goog
2643{
2644 public static string getMsg(string str, object opt_values)
2645 {
2646 throw new NotImplementedException();
2647 }
2648
2649 public static class dom
2650 {
2651 public static Element createDom(string v, object o = null, Union<string, Element> t = null)
2652 {
2653 throw new NotImplementedException();
2654 }
2655 }
2656
2657 public static class math
2658 {
2659 public class Size
2660 {
2661 public double width;
2662 public double height;
2663
2664 public Size(double width, double hieght)
2665 {
2666 this.width = width;
2667 this.height = hieght;
2668 }
2669 }
2670
2671 public class Coordinate
2672 {
2673 public double x;
2674 public double y;
2675 }
2676 }
2677
2678 public static class @string
2679 {
2680 public class CaseInsensitiveCompare : IComparer<string>
2681 {
2682 public int Compare(string x, string y)
2683 {
2684 return x.ToLower().CompareTo(y.ToLower());
2685 }
2686 }
2687
2688 public static CaseInsensitiveCompare caseInsensitiveCompare = new CaseInsensitiveCompare();
2689 }
2690
2691 public static class array
2692 {
2693 internal static bool equals(Array a, Array b)
2694 {
2695 throw new NotImplementedException();
2696 }
2697 }
2698
2699 public static class asserts
2700 {
2701 internal static void assert(bool cond, string format, params string[] args)
2702 {
2703 if (!cond) throw new NotImplementedException();
2704 }
2705
2706 internal static void assertArray(object array, string format, params string[] args)
2707 {
2708 assert(array is Array, format, args);
2709 }
2710
2711 internal static void assertFunction(object func, string format, params string[] args)
2712 {
2713 assert(func is System.Reflection.MethodInfo, format, args);
2714 }
2715
2716 internal static void assertString(object str, string format, params string[] args)
2717 {
2718 assert(str is String, format, args);
2719 }
2720
2721 internal static void fail(string format, params string[] args)
2722 {
2723 throw new NotImplementedException();
2724 }
2725 }
2726}
Note: See TracBrowser for help on using the repository browser.