コード例 #1
0
        private Icon GetIconForDocument(IDocumentObject document)
        {
            Type docType = document.GetType();

            // Query factories for an Icon first
            foreach (var ext in DocumentFactoryManager.Instance.GetExtensions())
            {
                IDocumentFactory factory = GetFactory(ext.ExtensionType);
                Icon             ret     = factory.GetIconForDocument(document);
                if (ret != null)
                {
                    return(ret);
                }
            }

            // No extension icon, go for defaults
            if (document is NetGraphDocument)
            {
                return(Properties.Resources.NetGraphIcon);
            }
            else if (document is ParserDocument)
            {
                return(Properties.Resources.ParserComponent);
            }
            else if (document is AssemblyDocument)
            {
                return(Properties.Resources.Assembly_ProjectEntry);
            }
            else if (document is ScriptDocument)
            {
                ScriptDocument doc = (ScriptDocument)document;

                switch (doc.Container.Engine)
                {
                case "csharp": return(Properties.Resources.CSScriptIcon);

                case "python": return(Properties.Resources.PythonScriptIcon);

                case "visualbasic": return(Properties.Resources.VBScriptIcon);

                case "fsharp": return(Properties.Resources.CSScriptIcon);
                }

                return(Properties.Resources.ScriptIcon);
            }
            else if (document is NetServiceDocument)
            {
                return(Properties.Resources.Network_Map);
            }
            else if (document is TextDocument)
            {
                return(Properties.Resources.textdoc);
            }
            else if (document is TestDocument)
            {
                return(Properties.Resources.otheroptions);
            }

            return(Properties.Resources.UtilityText);
        }
コード例 #2
0
        private void listBox_ScriptFiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_lastScriptFile != null)
            {
                _lastScriptFile.TextBuffer = richTextBox_ScriptFile.Text.Replace("\n", "\r\n");
            }

            ScriptDocument file = ScriptFile.Scripts[listBox_ScriptFiles.SelectedIndex];

            richTextBox_ScriptFile.Select(0, 0);
            richTextBox_ScriptFile.ScrollToCaret();
            richTextBox_ScriptFile.Text = file.TextBuffer;
            _lastScriptFile             = file;

            _elements.Clear();
            listBox_ScriptMessages.Items.Clear();
            foreach (IScriptElement element in ScriptParser.Parse(file))
            {
                _elements.Add(element);
                if (element.GetType() == typeof(ScriptMessage))
                {
                    listBox_ScriptMessages.Items.Add(element);
                }
            }
        }
コード例 #3
0
        public JsCall(ScriptDocument sd, string function, JsList parameters)
            : base(sd)
        {
            Function = function;

            Parameters = parameters;

        }
コード例 #4
0
 public JsQuote(ScriptDocument sd, object text, bool doubleQuotes)
     : base(sd)
 {
     Text = text;
     DoubleQuotes = doubleQuotes;
     this.MultiLine = false;
     this.StartOnNewLine = false;
 }
コード例 #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="document">The script document</param>
 /// <param name="className">The class name</param>
 public ScriptNetworkLayerFactory(ScriptDocument document, string className)
 {
     Script      = document;
     ClassName   = className;
     Description = Properties.Resources.ScriptNetworkLayerFactory_Name;
     _config     = new Dictionary <string, object>();
     _desc       = new ScriptDynamicTypeDescriptor(this);
 }
コード例 #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="document">The script document</param>
        /// <param name="className">The class name</param>
        public ScriptDataEndpointFactory(ScriptDocument document, string className)
            : base(className, new ServerConfig())
        {
            ServerConfig config = Config as ServerConfig;

            config.SetFactory(this);
            Script    = document;
            ClassName = className;
        }
コード例 #7
0
        public ScriptOptionsForm(ScriptDocument document)
        {
            InitializeComponent();
            _document = document;

            checkBoxEnableDebug.Checked           = _document.Container.EnableDebug;
            dynamicConfigEditorControl.Properties = _document.Configuration.ToArray();

            LoadReferenceList(_document.Container.ReferencedNames);
        }
コード例 #8
0
        /// <summary>
        /// Saves the document at the given URI</summary>
        /// <param name="document">Document to save</param>
        /// <param name="uri">New document URI</param>
        public void Save(IDocument document, Uri uri)
        {
            ScriptDocument circuitDocument = (ScriptDocument)document;
            string         filePath        = uri.LocalPath;
            FileMode       fileMode        = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate;

            using (FileStream stream = new FileStream(filePath, fileMode))
            {
                var writer = new ScriptWriter(m_schemaLoader.TypeCollection);
                writer.Write(circuitDocument.DomNode, stream, uri);
            }
        }
コード例 #9
0
        private static string GetDocumentIconName(IDocumentObject document)
        {
            string iconName = document.DefaultName;

            if ((document is ScriptDocument) && !(document is ParserDocument))
            {
                ScriptDocument doc = (ScriptDocument)document;
                iconName = doc.Container.Engine;
            }

            return(iconName);
        }
コード例 #10
0
ファイル: ScriptBox.cs プロジェクト: alexisjojo/ktibiax
        /// <summary>
        /// Initializes a new instance of the <see cref="ScriptBox"/> class.
        /// </summary>
        public ScriptBox()
        {
            InitializeComponent();
            Document = new ScriptDocument();
            Document.Setup(this);

            scriptEditor1.ScrollBars = ScrollBars.Both;
            scriptEditor1.HighLightedLineColor = Color.WhiteSmoke;
            scriptEditor1.SupressAutoComplete = true;
            scriptEditor1.SupressInfoTips = true;
            scriptEditor1.AutoListAutoSelect = false;
        }
コード例 #11
0
 private void ReloadScript()
 {
     if ((_script == null) && (_uuid != Guid.Empty))
     {
         _script = (ScriptDocument)CANAPEProject.CurrentProject.GetDocumentByUuid(_uuid);
         if (_script == null)
         {
             _uuid     = Guid.Empty;
             ClassName = String.Empty;
         }
     }
 }
コード例 #12
0
		/// <remarks>
		/// Creates a new <see cref="IDocument"/> object. Only create
		/// <see cref="IDocument"/> with this method.
		/// </remarks>
		public IDocument CreateDocument() {
			ScriptDocument doc = new ScriptDocument();
			doc.TextBufferStrategy = new GapTextBufferStrategy();
			doc.FormattingStrategy = new ScriptFormattingStrategy();
			doc.LineManager = new LineManager(doc, null);
			doc.FoldingManager = new FoldingManager(doc, doc.LineManager);
			doc.FoldingManager.FoldingStrategy = null; //new ParserFoldingStrategy();
			doc.MarkerStrategy = new MarkerStrategy(doc);
			doc.BookmarkManager = new BookmarkManager(doc, doc.LineManager);
			doc.FunctionMarkerManager = new ScriptEntityManager();
			return doc;
		}
コード例 #13
0
ファイル: ParserDocumentControl.cs プロジェクト: wflk/canape
        private void createScriptDocumentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string script = _document.Script;

            if (script != null)
            {
                ScriptDocument doc = CANAPEProject.CurrentProject.CreateDocument <ScriptDocument>("csharp");

                doc.Script = script;

                DocumentControl.Show(doc);
            }
        }
コード例 #14
0
ファイル: NodeRichTextBox.cs プロジェクト: tyranid/canape
 private void ApplyScript_Click(ScriptDocument script)
 {
     try
     {
         ApplyStringConverter(ScriptUtils.GetInstance <IStringConverter>(script.Container) ?? new ScriptStringConverter(script));
     }
     catch (Exception ex)
     {
         MessageBox.Show(this,
                         ex.Message, CANAPE.Properties.Resources.MessageBox_ErrorString,
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #15
0
        PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
        {
            List <PropertyDescriptor>    descs = new List <PropertyDescriptor>();
            PropertyDescriptorCollection coll  = TypeDescriptor.GetProperties(_provider, attributes, true);

            foreach (PropertyDescriptor d in coll)
            {
                descs.Add(d);
            }

            ScriptDocument doc = _provider.Script;

            if (doc != null)
            {
                Dictionary <string, dynamic> config = new Dictionary <string, dynamic>(_provider.Config);

                _provider.Config.Clear();

                foreach (DynamicNodeConfigProperty p in doc.Configuration)
                {
                    // Copy across any valid properties
                    if (config.ContainsKey(p.Name) && p.CheckType(config[p.Name]))
                    {
                        _provider.Config[p.Name] = config[p.Name];
                    }
                    else
                    {
                        _provider.Config[p.Name] = p.DefaultValue;
                    }

                    List <Attribute> attrs = new List <Attribute>();
                    attrs.Add(new CategoryAttribute("Node Config"));

                    if (!String.IsNullOrWhiteSpace(p.Description))
                    {
                        attrs.Add(new DescriptionAttribute(p.Description));
                    }

                    if (typeof(IDocumentObject).IsAssignableFrom(p.PropertyType))
                    {
                        attrs.Add(new TypeConverterAttribute(typeof(DocumentChoiceConverter <>).MakeGenericType(p.PropertyType)));
                    }

                    DynamicNodePropertyDescriptor custom = new DynamicNodePropertyDescriptor(p, attrs.ToArray());
                    custom.PropertyChanged += new EventHandler(custom_PropertyChanged);
                    descs.Add(custom);
                }
            }

            return(new PropertyDescriptorCollection(descs.ToArray()));
        }
コード例 #16
0
        private void UpdateScriptFile()
        {
            if (listBox_ScriptFiles.SelectedIndex == -1)
            {
                return;
            }
            ScriptDocument script = ScriptFile.Scripts[listBox_ScriptFiles.SelectedIndex];

            script.TextBuffer = richTextBox_ScriptFile.Text.Replace("\n", "\r\n");

            _updatingScript = true;
            int messagePos = richTextBox_ScriptMessage.SelectionStart;
            int messageLen = richTextBox_ScriptMessage.SelectionLength;

            Win32.LockWindow(this.Handle);
            int scrollPos = Win32.GetScrollPos(richTextBox_ScriptFile.Handle, 1);
            int pos       = richTextBox_ScriptFile.SelectionStart;
            int len       = richTextBox_ScriptFile.SelectionLength;

            richTextBox_ScriptFile.Text            = script.TextBuffer;
            richTextBox_ScriptFile.SelectionStart  = pos;
            richTextBox_ScriptFile.SelectionLength = len;
            Win32.SetScrollPos(richTextBox_ScriptFile.Handle, 1, scrollPos, true);
            Win32.PostMessage(richTextBox_ScriptFile.Handle, 0x115, 4 + 0x10000 * scrollPos, 0);
            Win32.LockWindow(IntPtr.Zero);

            int lastIndex = listBox_ScriptMessages.SelectedIndex;

            _elements.Clear();
            listBox_ScriptMessages.Items.Clear();
            foreach (IScriptElement element in ScriptParser.Parse(script))
            {
                _elements.Add(element);
                if (element.GetType() == typeof(ScriptMessage))
                {
                    listBox_ScriptMessages.Items.Add(element);
                }
            }

            try
            {
                listBox_ScriptMessages.SelectedIndex      = lastIndex;
                richTextBox_ScriptMessage.SelectionStart  = messagePos;
                richTextBox_ScriptMessage.SelectionLength = messageLen;
            }
            catch (Exception e)
            {
            }
            _updatingScript = false;
        }
コード例 #17
0
        /// <summary>
        /// Notifies the client that its Control has been activated. Activation occurs when
        /// the Control gets focus, or a parent "host" Control gets focus.</summary>
        /// <param name="control">Client Control that was activated</param>
        /// <remarks>This method is only called by IControlHostService if the Control was previously
        /// registered for this IControlHostClient.</remarks>
        public void Activate(Control control)
        {
            AdaptableControl adaptableControl = (AdaptableControl)control;
            var context = adaptableControl.ContextAs <VisualScriptEditingContext>();

            m_contextRegistry.ActiveContext = context;

            ScriptDocument circuitDocument = context.As <ScriptDocument>();

            if (circuitDocument != null)
            {
                m_documentRegistry.ActiveDocument = circuitDocument;
            }
        }
コード例 #18
0
        private void scriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (SelectTemplateForm frm = new SelectScriptTemplateForm())
            {
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    CANAPETemplate template = frm.Template;

                    ScriptDocument document = CANAPEProject.CurrentProject.CreateDocument <ScriptDocument>(template.TypeName);

                    document.Script = template.GetText();

                    OnDisplayDocument(document);
                }
            }
        }
コード例 #19
0
        public EditorTabPage(ScriptDocument doc, Action <string> help_cb)
        {
            InitializeComponent();
            m_help_callback = help_cb;
            m_document_id   = doc.Id;

            //Set editor defaults
            this.ShowSpaces          = true;
            this.TabIndent           = 4;
            this.ShowTabs            = true;
            this.ConvertTabsToSpaces = true;
            this.SetHighlighting("Python");
            this.Dock             = System.Windows.Forms.DockStyle.Fill;
            this.IsIconBarVisible = true;

            if (!string.IsNullOrEmpty(doc.FullPath))
            {
                LoadFile(doc.FullPath, false, true);
            }
            else
            {
                this.Text = doc.SourceCode;
            }

            doc.SetDelegates(this.GetEditorText, this.SetEditorText, this.GetBreakPointLines);

            // test for custom colors
            ICSharpCode.TextEditor.Document.DefaultHighlightingStrategy strat = this.Document.HighlightingStrategy as ICSharpCode.TextEditor.Document.DefaultHighlightingStrategy;
            if (strat != null)
            {
                strat.SetColorFor("SpaceMarkers", new ICSharpCode.TextEditor.Document.HighlightColor(System.Drawing.Color.BurlyWood, true, false));
            }
            this.Document.FoldingManager.FoldingStrategy = new PythonFoldingStrategy();
            this.Document.FormattingStrategy             = new PythonFormattingStrategy();
            this.Document.FoldingManager.UpdateFoldings(null, null);

            // Wire up events for this TextEditor
            this.Document.LineCountChanged += new EventHandler <ICSharpCode.TextEditor.Document.LineCountChangeEventArgs>(Document_LineCountChanged);
            this.Document.DocumentChanged  += new ICSharpCode.TextEditor.Document.DocumentEventHandler(OnDocumentChanged);
            this.ActiveTextAreaControl.TextArea.IconBarMargin.MouseDown += new ICSharpCode.TextEditor.MarginMouseEventHandler(IconBarMargin_MouseDown);

            //this.ActiveTextAreaControl.TextArea.DoProcessDialogKey += new ICSharpCode.TextEditor.DialogKeyProcessor(TextArea_DoProcessDialogKey);

            this.ActiveTextAreaControl.TextArea.KeyEventHandler += TextAreaKeyEventHandler;
            this.Disposed += CloseCodeCompletionWindow;
            this.ActiveTextAreaControl.TextArea.IconBarMargin.Painted += new ICSharpCode.TextEditor.MarginPaintEventHandler(IconBarMargin_Painted);
        }
コード例 #20
0
        private void OnShowCurrentFileClick(object sender, EventArgs eventArgs)
        {
            if (listBox_ScriptFiles.SelectedIndex == -1)
            {
                return;
            }
            Enabled = false;
            ScriptDocument file = ScriptFile.Scripts[listBox_ScriptFiles.SelectedIndex];

            file.WriteToOriginalFile();
            if (file.BaseFile.GetType() == typeof(LZBFile))
            {
                LZBFile            lzbFile            = (LZBFile)file.BaseFile;
                ScriptViewerWindow scriptViewerWindow = new ScriptViewerWindow(lzbFile.DecompressedFile);
                scriptViewerWindow.Show();
            }
            Enabled = true;
        }
コード例 #21
0
        private void button_Apply_Click(object sender, EventArgs e)
        {
            IScriptElement element = (IScriptElement)listBox_ScriptMessages.SelectedItem;

            if (element.GetType() == typeof(ScriptMessage))
            {
                ScriptMessage message = (ScriptMessage)element;
                message.Content = richTextBox_ScriptMessage.Text.Replace("\n", "\r\n");
            }

            ScriptDocument script = (ScriptDocument)listBox_ScriptFiles.SelectedItem;

            ScriptParser.Parse(script, _elements);

            richTextBox_ScriptFile.Select(0, 0);
            richTextBox_ScriptFile.ScrollToCaret();
            richTextBox_ScriptFile.Text = script.TextBuffer;
        }
コード例 #22
0
        public void DecompressScripts()
        {
            if (ApplicationState.Instance.ProjectFile == null)
            {
                MessageBox.Show("Open a project file before decompressing!", "Project file not found!");
                return;
            }
            PSXImage modifiedImage = ApplicationState.Instance.ProjectFile.ModifiedImage;

            _scriptPKN = modifiedImage.PKNFiles.Find(pkn => pkn.Name == "SCRIPT");
            if (_scriptPKN == null)
            {
                return;
            }
            if (_scriptPKN.Files.Count == 0) //cheap fix for when pkn files dont save files
            {
                _scriptPKN.Unpack();
            }
            Enabled = false;

            ScriptFile = new ScriptFile();

            richTextBox_ScriptFile.Text = "";
            for (int i = 0; i < _scriptPKN.Files.Count; i++)
            {
                BaseFile baseFile = _scriptPKN.Files[i];
                if (baseFile.GetType() == typeof(LZBFile))
                {
                    LZBFile lzbFile = (LZBFile)baseFile;
                    lzbFile.Decompress();
                }
                ScriptDocument scriptFile = new ScriptDocument(baseFile);
                ScriptFile.Scripts.Add(scriptFile);
                progressBar_Progress.Value = (int)((double)i / _scriptPKN.Files.Count * 100);
            }
            listBox_ScriptFiles.Items.Clear();
            foreach (ScriptDocument scriptFile in ScriptFile.Scripts)
            {
                listBox_ScriptFiles.Items.Add(scriptFile);
            }

            progressBar_Progress.Value = 0;
            Enabled = true;
        }
コード例 #23
0
        public ScriptDocument NewDocument()
        {
            UITabPage        page   = new UITabPage("untitled.boo*");
            ScintillaControl editor = new ScintillaControl();

            editor.SmartIndentingEnabled = true;
            editor.Configuration         = config;
            editor.ConfigurationLanguage = "cpp";
            editor.Dock = DockStyle.Fill;

            ScriptDocument doc = new ScriptDocument(editor);

            openScripts.Add(doc);

            page.Controls.Add(editor);
            uiTab1.TabPages.Add(page);

            return(doc);
        }
コード例 #24
0
        // TODO: Fix this :)
        public ScriptDocumentControl(IDocumentObject document, bool forParserDocument)
        {
            _document = (ScriptDocument)document;
            _currText = _document.Script;

            InitializeComponent();

            Text = _document.Name;

            ScriptDocumentControlConfig config = _document.GetProperty <ScriptDocumentControlConfig>(DOCUMENT_CONFIG_NAME, false);

            UpdateConfig(config ?? DocumentControl.GetConfigItem <ScriptDocumentControlConfig>(GetConfigForEngine(_document.Container.Engine), true));

            LoadFile(_document.Script);

            _forParserDocument = forParserDocument;

            if (!forParserDocument)
            {
                if (this.ParentForm != null)
                {
                    this.ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);
                }
            }

            textEditorControl.ActiveTextAreaControl.Document.UndoStack.OperationPushed +=
                new OperationEventHandler(UndoStack_OperationPushed);
            textEditorControl.ActiveTextAreaControl.Document.UndoStack.ActionUndone += new EventHandler(UndoStack_ActionUndone);
            textEditorControl.ActiveTextAreaControl.Document.UndoStack.ActionRedone += new EventHandler(UndoStack_ActionUndone);

            if (GlobalControlConfig.ScriptEditorFont != null)
            {
                textEditorControl.Font = GlobalControlConfig.ScriptEditorFont;
            }

            if (forParserDocument)
            {
                toolStripButtonSave.Visible     = false;
                toolStripButtonOptions.Visible  = false;
                toolStripButtonOpenTest.Visible = false;
            }
        }
コード例 #25
0
ファイル: ConsoleControl.cs プロジェクト: wflk/canape
        private void execScript_Click(object sender, EventArgs e)
        {
            ScriptDocument doc = ((ToolStripItem)sender).Tag as ScriptDocument;

            StringBuilder builder = new StringBuilder();

            builder.Append("exec('");
            foreach (char c in doc.Container.Script)
            {
                if (c != '\r')
                {
                    builder.AppendFormat("\\x{0:X02}", (int)c);
                }
            }
            builder.Append("')");

            _input.Enqueue(builder.ToString());

            WriteOutputString("Executed: " + doc.Name);
        }
コード例 #26
0
        public void UpdateScriptMessage()
        {
            if (_changingMessageSelection)
            {
                return;
            }

            IScriptElement element = (IScriptElement)listBox_ScriptMessages.SelectedItem;

            if (element == null)
            {
                return;
            }
            if (element.GetType() == typeof(ScriptMessage))
            {
                ScriptMessage message = (ScriptMessage)element;
                message.Content = richTextBox_ScriptMessage.Text.Replace("\n", "\r\n");
                UpdatePreview(message);
            }

            ScriptDocument script = (ScriptDocument)listBox_ScriptFiles.SelectedItem;

            ScriptParser.Parse(script, _elements);

            _updatingMessage = true;

            Win32.LockWindow(this.Handle);
            int scrollPos = Win32.GetScrollPos(richTextBox_ScriptFile.Handle, 1);
            int pos       = richTextBox_ScriptFile.SelectionStart;
            int len       = richTextBox_ScriptFile.SelectionLength;

            richTextBox_ScriptFile.Text            = script.TextBuffer;
            richTextBox_ScriptFile.SelectionStart  = pos;
            richTextBox_ScriptFile.SelectionLength = len;
            Win32.SetScrollPos(richTextBox_ScriptFile.Handle, 1, scrollPos, true);
            Win32.PostMessage(richTextBox_ScriptFile.Handle, 0x115, 4 + 0x10000 * scrollPos, 0);
            Win32.LockWindow(IntPtr.Zero);

            _updatingMessage = false;
        }
コード例 #27
0
        public ScriptDocument Open(Uri uri)
        {
            DomNode node     = null;
            string  filePath = uri.LocalPath;

            if (!File.Exists(filePath))
            {
                Outputs.WriteLine(OutputMessageType.Error, "Failed to open source file {0}", filePath);
                return(null);
            }

            // read existing document using standard XML reader
            using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                ScriptReader reader = new ScriptReader(m_nodeDefinitionManager.NodeTypeManager);
                node = reader.Read(stream, uri);
            }

            ScriptDocument scriptDocument = null;

            if (node != null)
            {
                // now that the data is complete, initialize all other extensions to the Dom data
                node.InitializeExtensions();

                scriptDocument = node.Cast <ScriptDocument>();
                string      fileName    = Path.GetFileName(filePath);
                ControlInfo controlInfo = new ControlInfo(fileName, filePath, StandardControlGroup.Center);

                //Set IsDocument to true to prevent exception in command service if two files with the
                //  same name, but in different directories, are opened.
                controlInfo.IsDocument = true;

                scriptDocument.ControlInfo = controlInfo;
                scriptDocument.Uri         = uri;
            }

            return(scriptDocument);
        }
コード例 #28
0
        public void CompressScripts()
        {
            if (ApplicationState.Instance.ProjectFile == null)
            {
                MessageBox.Show("Open a project file before compressing!", "Project file not found!");
                return;
            }

            for (int i = 0; i < ScriptFile.Scripts.Count; i++)
            {
                ScriptDocument scriptFile = ScriptFile.Scripts[i];

                //Don't touch those file! - (can) Softlock the engine, and we dont need to modify gamelogic to that degree
                if (scriptFile.Name == "FLAG.TXT")
                {
                    continue;
                }

                //Enforce correct end of file as done by other conan files (prevents softlock on EOF)
                scriptFile.TextBuffer += "\r\n\r\n\r\n\r\n";

                scriptFile.WriteToOriginalFile();
                if (scriptFile.BaseFile.GetType() == typeof(LZBFile))
                {
                    LZBFile lzbFile = (LZBFile)scriptFile.BaseFile;
                    lzbFile.Compress(false);
                }
                Invoke((MethodInvoker) delegate
                {
                    progressBar_Progress.Value = (int)((double)i / ScriptFile.Scripts.Count * 100);
                });
            }

            Invoke((MethodInvoker) delegate
            {
                progressBar_Progress.Value = 0;
                Enabled = true;
            });
        }
コード例 #29
0
        /// <summary>
        /// Requests permission to close the client's Control.
        /// Allows user to save document before closing it.</summary>
        /// <param name="control">Client Control to be closed</param>
        /// <returns>True if the Control either can close or is already closed. False to cancel.</returns>
        /// <remarks>
        /// 1. This method is only called by IControlHostService if the Control was previously
        /// registered for this IControlHostClient.
        /// 2. If true is returned, the IControlHostService calls its own
        /// UnregisterControl. The IControlHostClient has to call RegisterControl again
        /// if it wants to re-register this Control.</remarks>
        public bool Close(Control control)
        {
            var adaptableControl = (AdaptableControl)control;

            bool           closed          = true;
            ScriptDocument circuitDocument = adaptableControl.ContextAs <ScriptDocument>();

            if (circuitDocument != null)
            {
                closed = m_documentService.Close(circuitDocument);
                if (closed)
                {
                    Close(circuitDocument);
                }
            }
            else
            {
                // We don't care if the control was already unregistered. 'closed' should be true.
                m_circuitControlRegistry.UnregisterControl(control);
            }
            return(closed);
        }
コード例 #30
0
        private void OnCompressClick(object sender, EventArgs eventArgs)
        {
            if (ScriptFile.Scripts.Count == 0)
            {
                MessageBox.Show("Decompress all first!");
                return;
            }
            if (listBox_ScriptFiles.SelectedIndex == -1)
            {
                return;
            }
            Enabled = false;
            ScriptDocument file = ScriptFile.Scripts[listBox_ScriptFiles.SelectedIndex];

            file.TextBuffer = richTextBox_ScriptFile.Text.Replace("\n", "\r\n");
            file.WriteToOriginalFile();
            if (file.BaseFile.GetType() == typeof(LZBFile))
            {
                LZBFile lzbFile = (LZBFile)file.BaseFile;
                lzbFile.Compress(false);
            }
            Enabled = true;
        }
コード例 #31
0
 public JsArray(ScriptDocument sd) : base(sd) { }
コード例 #32
0
        protected override bool SelectScript(ScriptDocument document, string className)
        {
            Server = new ScriptDataEndpointFactory(document, className);

            return(true);
        }
コード例 #33
0
        public JsQuote(ScriptDocument sd)
			: this(sd, null, false)
        {
        }
コード例 #34
0
		public JsComponent(ScriptDocument sd) : base(sd) { }
コード例 #35
0
 public JsObject(ScriptDocument sd, params object[] lines) : base(sd, lines) { }
コード例 #36
0
 public JsObject(ScriptDocument sd) : base(sd) { }
コード例 #37
0
		public JsScriptItem(ScriptDocument sd) : base(sd) { }
コード例 #38
0
 public JsBlock(ScriptDocument sd) : base(sd) { }
コード例 #39
0
 public ExtJsComponent(ScriptDocument sd, string className, string baseClass, string id)
     : base(sd, className, baseClass)
 {
 }
コード例 #40
0
        public ExtJsClass(ScriptDocument sd, string className, string baseClass)
			: base(sd)
        {
            ClassName = className;
            BaseClass = baseClass;
        }
コード例 #41
0
 public JsList(ScriptDocument sd) : base(sd) { }
コード例 #42
0
 public JsCall(ScriptDocument sd, string function, params object[] parameters)
     : base(sd)
 {
     Function = function;
     Parameters = Js.CreateList(parameters);
 }
コード例 #43
0
		public JsBuilder(ScriptDocument sd): base(sd) {}
コード例 #44
0
 protected virtual bool SelectScript(ScriptDocument document, string className)
 {
     // Do nothing
     return(true);
 }
コード例 #45
0
		public JsFunction(ScriptDocument sd, JsList parameters, ScriptLines commands)
			: this(sd, commands)
        {
            _Parameters = parameters;
        }
コード例 #46
0
 public JsObject(ScriptDocument sd, IEnumerable<object> lines) : base(sd, lines) { }
コード例 #47
0
        /// <summary>
        /// Opens or creates a document at the given URI.
        /// Creates and configures with control adapters D2dAdaptableControl to display subcircuit</summary>
        /// <param name="uri">Document URI</param>
        /// <returns>Document, or null if the document couldn't be opened or created</returns>
        public IDocument Open(Uri uri)
        {
            DomNode node     = null;
            string  filePath = uri.LocalPath;

            if (File.Exists(filePath))
            {
                // read existing document using standard XML reader
                using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    ScriptReader reader = new ScriptReader(m_nodeDefinitionManager.NodeTypeManager);
                    node = reader.Read(stream, uri);
                }
            }
            else
            {
                // create new document by creating a Dom node of the root type defined by the schema
                node = new DomNode(visualScriptDocumentType.Type, new ChildInfo("VScript", visualScriptDocumentType.Type));
                // create an empty root prototype folder
                node.SetChild(
                    visualScriptDocumentType.prototypeFolderChild,
                    new DomNode(prototypeFolderType.Type));
            }

            ScriptDocument circuitCircuitDocument = null;

            if (node != null)
            {
                // now that the data is complete, initialize all other extensions to the Dom data
                node.InitializeExtensions();

                AdaptableControl control = CreateNodeControl(node);
                control.AddHelp("https://github.com/SonyWWS/ATF/wiki/Adaptable-Controls".Localize());

                var viewingContext = node.Cast <ViewingContext>();
                viewingContext.Control = control;

                circuitCircuitDocument = node.Cast <ScriptDocument>();
                string      fileName    = Path.GetFileName(filePath);
                ControlInfo controlInfo = new ControlInfo(fileName, filePath, StandardControlGroup.Center);

                //Set IsDocument to true to prevent exception in command service if two files with the
                //  same name, but in different directories, are opened.
                controlInfo.IsDocument = true;

                circuitCircuitDocument.ControlInfo = controlInfo;
                circuitCircuitDocument.Uri         = uri;

                var editingContext = node.Cast <VisualScriptEditingContext>();
                editingContext.GetLocalBound       = GetLocalBound;
                editingContext.GetWorldOffset      = GetWorldOffset;
                editingContext.GetTitleHeight      = GetTitleHeight;
                editingContext.GetLabelHeight      = GetLabelHeight;
                editingContext.GetSubContentOffset = GetSubContentOffset;

                control.Context = editingContext;
                // Disabled
                //editingContext.SchemaLoader = m_schemaLoader; // schema needed for cut and paste between applications

                m_circuitControlRegistry.RegisterControl(node, control, controlInfo, this);

                // Set the zoom and translation to show the existing items (if any).
                var enumerableContext = editingContext.Cast <IEnumerableContext>();
                if (viewingContext.CanFrame(enumerableContext.Items))
                {
                    viewingContext.Frame(enumerableContext.Items);
                }
            }

            return(circuitCircuitDocument);
        }
コード例 #48
0
ファイル: NodeRichTextBox.cs プロジェクト: tyranid/canape
 public ScriptStringConverter(ScriptDocument document)
 {
     _document = document;
 }
コード例 #49
0
		public JsFunction(ScriptDocument sd, ScriptLines commands)
            : this(sd)
        {
            _Commands = commands;
        }
コード例 #50
0
		public JsScriptSet(ScriptDocument sd) : base(sd) { }
コード例 #51
0
 public JsFunction(ScriptDocument sd)
     :base(sd)
 {
 }
コード例 #52
0
 public JsProperty(ScriptDocument sd, string name, object value)
     :base(sd)
 {
     _Name = name;
     _Value = value;
 }
コード例 #53
0
        public JsQuote(ScriptDocument sd, object text)
			: this(sd, text, false)
        {
        }