Ejemplo n.º 1
0
        protected void OnElementSelected(object controller, ElementEventArgs args)
        {
            ElementProperties                elementProperties   = null;
            IFlowSharpCodeEditorService      csCodeEditorService = ServiceManager.Get <IFlowSharpCodeEditorService>();
            IFlowSharpScintillaEditorService editorService       = ServiceManager.Get <IFlowSharpScintillaEditorService>();

            if (args.Element != null)
            {
                GraphicElement el = args.Element;
                System.Diagnostics.Trace.WriteLine("*** ON ELEMENT SELECTED " + el.Id.ToString());
                elementProperties = el.CreateProperties();

                if (!String.IsNullOrEmpty(csCodeEditorService.Filename))
                {
                    // Save last position.
                    int curpos = csCodeEditorService.GetPosition();
                    fileCaretPos[csCodeEditorService.Filename] = curpos;
                    System.Diagnostics.Trace.WriteLine("*** " + csCodeEditorService.Filename + " => SET CURRENT POS: " + curpos);
                }

                string code;
                el.Json.TryGetValue("Code", out code);
                csCodeEditorService.SetText("C#", code ?? String.Empty);

                string fn = el.Id.ToString();               // Use something that is unique for this shape's code.
                System.Diagnostics.Trace.WriteLine("*** " + fn + " => SET ID");
                csCodeEditorService.Filename = fn;

                // Set the last known position if we have one.
                int pos;

                if (fileCaretPos.TryGetValue(fn, out pos))
                {
                    System.Diagnostics.Trace.WriteLine("*** " + fn + " => SET PREVIOUS POS: " + pos);
                    csCodeEditorService.SetPosition(pos);
                }
                else
                {
                    // A newly seen document, set the caret to pos 0 so the editor doesn't retain
                    // the previous scrollbar location.
                    csCodeEditorService.SetPosition(0);
                }

                el.Json.TryGetValue("python", out code);
                editorService.SetText("python", code ?? String.Empty);
            }
            else
            {
                csCodeEditorService.SetText("C#", String.Empty);
                editorService.SetText("python", String.Empty);
            }
        }
Ejemplo n.º 2
0
        protected void OnElementSelected(object controller, ElementEventArgs args)
        {
            ElementProperties                elementProperties   = null;
            IFlowSharpCodeEditorService      csCodeEditorService = ServiceManager.Get <IFlowSharpCodeEditorService>();
            IFlowSharpScintillaEditorService editorService       = ServiceManager.Get <IFlowSharpScintillaEditorService>();

            if (args.Element != null)
            {
                GraphicElement el = args.Element;
                elementProperties = el.CreateProperties();

                string code;
                el.Json.TryGetValue("Code", out code);
                csCodeEditorService.SetText("C#", code ?? String.Empty);

                el.Json.TryGetValue("python", out code);
                editorService.SetText("python", code ?? String.Empty);
            }
            else
            {
                csCodeEditorService.SetText("C#", String.Empty);
                editorService.SetText("python", String.Empty);
            }
        }