Пример #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Updates the preview of exported text.
        /// </summary>
        private void Export()
        {
            TextExporterFactory exporterFactory = new TextExporterFactory(editor.HighlightingStyleRegistry);

            switch (exporterComboBox.SelectedIndex)
            {
            case 0:
                exportEditor.Document.SetText(editor.Document.CurrentSnapshot.Export(exporterFactory.CreateRtf()));
                break;

            case 1:
                exportEditor.Document.SetText(editor.Document.CurrentSnapshot.Export(exporterFactory.CreateHtmlClassBased()));
                break;

            case 2:
                exportEditor.Document.SetText(editor.Document.CurrentSnapshot.Export(exporterFactory.CreateHtmlInline()));
                break;

            case 3:
                exportEditor.Document.SetText(editor.Document.CurrentSnapshot.Export(exporterFactory.CreateHtmlInlineFragment()));
                break;
            }

            if (exporterComboBox.SelectedIndex == 0)
            {
                exportEditor.Document.Language = SyntaxLanguage.PlainText;
                this.LoadRtf(exportEditor.Document.CurrentSnapshot.Text);
            }
            else
            {
                exportEditor.Document.Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("Html.langdef");
                this.LoadRtf("No RTF preview available since this is an HTML export.");
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a new No Change editor, which displays the text in the NewGenFile of the file passed to it.
        /// </summary>
        /// <param name="textFileInfo">The text file to display.</param>
        public ucNoChangeEditor(FileInformation <string> textFileInfo)
        {
            InitializeComponent();

            if (textFileInfo == null)
            {
                throw new InvalidOperationException("Cannot initialise the NoChangeEditor with a null TextFileInformation object.");
            }

            //if (textFileInfo.CurrentDiffResult.DiffType != TypeOfDiff.ExactCopy)
            //{
            //    throw new Exception("This control is only inteneded to be used for files no changes.");
            //}
            IProjectFile <string> file = textFileInfo.MergedFileExists ? textFileInfo.MergedFile : textFileInfo.UserFile;

            if (file == null || file.HasContents == false)
            {
                if (textFileInfo.NewGenFile == null || textFileInfo.NewGenFile.HasContents == false)
                {
                    throw new InvalidOperationException("The user and newly generated file do not exist, so the control has nothing to display.");
                }
                file = textFileInfo.NewGenFile;
            }


            syntaxEditor.Text = file.GetContents();

            syntaxEditor.Document.Language = SyntaxEditorHelper.GetSyntaxLanguageFromFileName(textFileInfo.RelativeFilePath);
            warningLabel.MaximumSize       = new System.Drawing.Size(Size.Width, 0);
            warningLabel.Text = "";
        }
Пример #3
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes an instance of the <c>MainControl</c> class.
        /// </summary>
        public MainControl()
        {
            InitializeComponent();

            // Load the most basic version of the Simple language
            editor.Document.Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("Simple-Advanced.langdef");
        }
Пример #4
0
        /// <summary>
        /// Loads a language definition from a file.
        /// </summary>
        /// <param name="filename">The filename.</param>
        private void LoadLanguageDefinitionFromFile(string filename)
        {
            if (String.IsNullOrEmpty(filename))
            {
                // Show a file open dialog
                OpenFileDialog dialog = new OpenFileDialog();
                if (!BrowserInteropHelper.IsBrowserHosted)
                {
                    dialog.CheckFileExists = true;
                }
                dialog.Multiselect = false;
                dialog.Filter      = "Language definition files (*.langdef)|*.langdef|All files (*.*)|*.*";
                if (dialog.ShowDialog() != true)
                {
                    return;
                }

                // Open a language definition
                using (Stream stream = dialog.OpenFile()) {
                    // Read the file
                    SyntaxLanguageDefinitionSerializer serializer = new SyntaxLanguageDefinitionSerializer();
                    this.LoadLanguage(serializer.LoadFromStream(stream));
                }
            }
            else
            {
                // Load an embedded resource .langdef file
                this.LoadLanguage(SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream(filename));
            }
        }
Пример #5
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes an instance of the <c>MainControl</c> class.
        /// </summary>
        public MainControl()
        {
            InitializeComponent();

            // Load a language from a language definition
            editor.Document.Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("JavaScript.langdef");
        }
Пример #6
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes an instance of the <c>MainControl</c> class.
        /// </summary>
        public MainControl()
        {
            InitializeComponent();

            // Load a language from a language definition
            cSharpEditor.Document.Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("CSharp.langdef");

            // For the HTML text box that uses the Web Languages Add-on, the following code is needed:

            //
            // NOTE: Make sure that you've read through the add-on language's 'Getting Started' topic
            //   since it tells you how to set up an ambient parse request dispatcher within your
            //   application OnStartup code, and add related cleanup in your application OnExit code.
            //   These steps are essential to having the add-on perform well.
            //

            // Register the schema resolver service with the XML language (needed to support IntelliPrompt for HTML)
            XmlSchemaResolver resolver = new XmlSchemaResolver();

            resolver.DefaultNamespace = "http://www.w3.org/1999/xhtml";
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(SyntaxEditorHelper.XmlSchemasPath + "Xhtml.xsd")) {
                resolver.AddSchemaFromStream(stream);
            }
            // Xml.xsd is also required for Xhtml.xsd
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(SyntaxEditorHelper.XmlSchemasPath + "Xml.xsd")) {
                resolver.AddSchemaFromStream(stream);
            }
            xmlEditor.Document.Language.RegisterXmlSchemaResolver(resolver);
        }
Пример #7
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>JavascriptSyntaxLanguage</c> class.
        /// </summary>
        public JavascriptSyntaxLanguage() : base("Javascript")
        {
            // Initialize this language from a language definition
            SyntaxEditorHelper.InitializeLanguageFromResourceStream(this, "JavaScript.langdef");

            //
            // NOTE: Make sure that you've set up an ambient parse request dispatcher for your application
            //   (see documentation on 'Parse Requests and Dispatchers') so that this parser is called in
            //   a worker thread as the editor is updated
            //

            // Register a parser that will construct a complete range-based outlining source for the document
            //   within a worker thread after any text change... for this sample, the outlining source is returned
            //   as the parser's result to the ICodeDocument.ParseData property, where it is retrieved by
            //   the outliner below... note that if we were doing more advanced parsing
            //   by constructing an AST of the document, we'd want to use the AST result to construct the
            //   range-based outlining source instead
            this.RegisterService <IParser>(new JavascriptOutliningParser());

            // Register an outliner, which tells the document's outlining manager that
            //   this language supports automatic outlining, and helps drive outlining updates
            this.RegisterService <IOutliner>(new JavascriptOutliner());

            // Register a built-in service that automatically provides quick info tips
            //   when hovering over collapsed outlining nodes
            this.RegisterService(new CollapsedRegionQuickInfoProvider());
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>CollapsedRegionSyntaxLanguage</c> class.
        /// </summary>
        public CollapsedRegionSyntaxLanguage() : base("CollapsedRegion")
        {
            // Initialize this language from a language definition
            SyntaxEditorHelper.InitializeLanguageFromResourceStream(this, "CSharp.langdef");

            // Register a tagger provider on the language as a service that can create CollapsedRegionTag objects
            this.RegisterService(new CodeDocumentTaggerProvider <CollapsedRegionTagger>(typeof(CollapsedRegionTagger)));
        }
Пример #9
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>CustomSyntaxLanguage</c> class.
        /// </summary>
        public CustomSyntaxLanguage() : base("CustomDecorator")
        {
            // Initialize this language from a language definition
            SyntaxEditorHelper.InitializeLanguageFromResourceStream(this, "CSharp.langdef");

            // Register a tagger provider on the language as a service that can create CustomTag objects
            this.RegisterService(new TextViewTaggerProvider <WordHighlightTagger>(typeof(WordHighlightTagger)));
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>CustomSyntaxLanguage</c> class.
        /// </summary>
        public CustomSyntaxLanguage() : base("CustomDecorator")
        {
            // Initialize this language from a language definition
            SyntaxEditorHelper.InitializeLanguageFromResourceStream(this, "CSharp.langdef");

            // Register a provider service that can create the custom adornment manager
            this.RegisterService(new AdornmentManagerProvider <AlternatingRowsAdornmentManager>(typeof(AlternatingRowsAdornmentManager)));
        }
Пример #11
0
        private static Color deletedMarkerColour = Color.Red;                     // Color.FromArgb(230, 176, 165); // Red

        public static SyntaxLanguage GetSyntaxLanguageForFileInformation(IFileInformation fi)
        {
            if (fi.TemplateLanguage.HasValue)
            {
                return(SyntaxEditorHelper.GetDynamicLanguage(fi.TemplateLanguage.Value));
            }

            return(SyntaxEditorHelper.GetDynamicLanguage(TemplateContentLanguage.PlainText));
        }
Пример #12
0
        public FormCodeInput()
        {
            InitializeComponent();

            SyntaxEditorHelper.SetupEditorTemplateAndScriptLanguages(syntaxEditor1, TemplateContentLanguage.CSharp, SyntaxEditorHelper.ScriptLanguageTypes.CSharp);
            ActiproSoftware.SyntaxEditor.KeyPressTrigger t = new ActiproSoftware.SyntaxEditor.KeyPressTrigger("MemberListTrigger2", true, '#');
            t.ValidLexicalStates.Add(syntaxEditor1.Document.Language.DefaultLexicalState);
            syntaxEditor1.Document.Language.Triggers.Add(t);
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>ColorPreviewSyntaxLanguage</c> class.
        /// </summary>
        public ColorPreviewSyntaxLanguage() : base("ColorPreview")
        {
            // Initialize this language from a language definition
            SyntaxEditorHelper.InitializeLanguageFromResourceStream(this, "Css.langdef");

            // Register a tagger provider on the language as a service that can create ColorPreviewTag objects
            this.RegisterService(new CodeDocumentTaggerProvider <ColorPreviewTagger>(typeof(ColorPreviewTagger)));

            // Register a provider service that can create the custom adornment manager
            this.RegisterService(new AdornmentManagerProvider <ColorPreviewAdornmentManager>(typeof(ColorPreviewAdornmentManager)));
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>IntraTextNoteSyntaxLanguage</c> class.
        /// </summary>
        public IntraTextNoteSyntaxLanguage() : base("IntraTextNote")
        {
            // Initialize this language from a language definition
            SyntaxEditorHelper.InitializeLanguageFromResourceStream(this, "CSharp.langdef");

            // Register a provider service that can create the custom adornment manager
            this.RegisterService(new AdornmentManagerProvider <IntraTextNoteAdornmentManager>(typeof(IntraTextNoteAdornmentManager)));

            // Register a tagger provider on the language as a service that can create IntraTextNoteTag objects
            this.RegisterService(new CodeDocumentTaggerProvider <IntraTextNoteTagger>(typeof(IntraTextNoteTagger)));
        }
Пример #15
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>SimpleSyntaxLanguage</c> class.
        /// </summary>
        public SimpleSyntaxLanguage() : base("Simple")
        {
            // Initialize the language using the lexer and token tagger in the .langdef file
            SyntaxEditorHelper.InitializeLanguageFromResourceStream(this, "Simple-Basic.langdef");

            //
            // NOTE: Make sure that you've set up an ambient parse request dispatcher for your application
            //   (see documentation on 'Parse Requests and Dispatchers') so that this parser is called in
            //   a worker thread as the editor is updated
            //
            this.RegisterParser(new SimpleParser());
        }
Пример #16
0
        public void Reset(IProjectFile <string> file, TemplateContentLanguage language)
        {
            if (file.HasContents == false)
            {
                throw new ArgumentException("file must have contents");
            }

            this.file   = file;
            editor.Text = file.GetContents();
            editor.Document.Language = SyntaxEditorHelper.GetDynamicLanguage(language);
            errorTreeList.LicenseKey = "F962CEC7-CD8F-4911-A9E9-CAB39962FC1F";
            Reparse();
        }
Пример #17
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>JavascriptSyntaxLanguage</c> class.
        /// </summary>
        public JavascriptSyntaxLanguage() : base("Javascript")
        {
            // Initialize this language from a language definition
            SyntaxEditorHelper.InitializeLanguageFromResourceStream(this, "JavaScript.langdef");

            // Register an outliner, which tells the document's outlining manager that
            //   this language supports automatic outlining, and helps drive outlining updates
            this.RegisterService <IOutliner>(new TokenOutliner <JavascriptOutliningSource>());

            // Register a built-in service that automatically provides quick info tips
            //   when hovering over collapsed outlining nodes
            this.RegisterService(new CollapsedRegionQuickInfoProvider());
        }
Пример #18
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>CollapsedRegionSyntaxLanguage</c> class.
        /// </summary>
        public CollapsedRegionSyntaxLanguage() : base("CollapsedRegion")
        {
            // Initialize this language from a language definition
            SyntaxEditorHelper.InitializeLanguageFromResourceStream(this, "CSharp.langdef");

            // Register a provider service that can create the custom adornment manager
            this.RegisterService(new AdornmentManagerProvider <CollapsedRegionAdornmentManager>(typeof(CollapsedRegionAdornmentManager)));

            // Register a tagger provider on the language as a service that can create CollapsedRegionTag objects
            this.RegisterService(new CodeDocumentTaggerProvider <CollapsedRegionTagger>(typeof(CollapsedRegionTagger)));

            // Register a quick info provider for collapsed regions
            this.RegisterService(new CollapsedRegionQuickInfoProvider());
        }
Пример #19
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes an instance of the <c>MainControl</c> class.
        /// </summary>
        public MainControl()
        {
            InitializeComponent();

            // Load the EBNF language
            ebnfEditor.Document.Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("Ebnf.langdef");

            // Show the EBNF
            ILLParser parser = editor.Document.Language.GetParser() as ILLParser;

            if (parser != null)
            {
                ebnfEditor.Document.SetText(parser.Grammar.ToEbnfString());
            }
        }
Пример #20
0
        public QueryModel()
        {
            ModelUrl = "/query";
            ApplicationModel.Current.Server.Value.RawUrl = null;

            queryDocument = new EditorDocument()
            {
                Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("RavenQuery.langdef")
            };

            ExceptionLine   = -1;
            ExceptionColumn = -1;

            CollectionSource = new QueryDocumentsCollectionSource();
            Observable.FromEventPattern <QueryStatisticsUpdatedEventArgs>(h => CollectionSource.QueryStatisticsUpdated += h,
                                                                          h => CollectionSource.QueryStatisticsUpdated -= h)
            .SampleResponsive(TimeSpan.FromSeconds(0.5))
            .TakeUntil(Unloaded)
            .ObserveOnDispatcher()
            .Subscribe(e =>
            {
                QueryTime = e.EventArgs.QueryTime;
                Results   = e.EventArgs.Statistics;
            });
            Observable.FromEventPattern <QueryErrorEventArgs>(h => CollectionSource.QueryError += h,
                                                              h => CollectionSource.QueryError -= h)
            .ObserveOnDispatcher()
            .Subscribe(e => HandleQueryError(e.EventArgs.Exception));

            DocumentsResult = new DocumentsModel(CollectionSource)
            {
                Header = "Results",
                DocumentNavigatorFactory = (id, index) => DocumentNavigator.Create(id, index, IndexName, CollectionSource.TemplateQuery),
            };

            QueryErrorMessage = new Observable <string>();
            IsErrorVisible    = new Observable <bool>();

            SortBy = new BindableCollection <StringRef>(x => x.Value);
            SortBy.CollectionChanged += HandleSortByChanged;
            SortByOptions             = new BindableCollection <string>(x => x);
            Suggestions    = new BindableCollection <FieldAndTerm>(x => x.Field);
            DynamicOptions = new BindableCollection <string>(x => x)
            {
                "AllDocs"
            };
        }
Пример #21
0
        private void Populate()
        {
            for (int i = 0; i < frmFunctionWizard.CurrentFunction.Parameters.Count; i++)
            {
                ParamInfo param = frmFunctionWizard.CurrentFunction.Parameters[i];
                var       item  = new ListViewItem(new string[] { param.Name, Utility.GetDemangledGenericTypeName(param.DataType, Project.Instance.Namespaces) });
                item.Tag = param.DataType;
                lstParameters.Items.Add(item);
            }
            ddlReturnType.Items.Clear();
            ddlReturnType.Text = "";
            ddlReturnType.Items.Clear();

            if (frmFunctionWizard.CurrentFunction.IsTemplateFunction)
            {
                var outputLanguages = (TemplateContentLanguage[])Enum.GetValues(typeof(TemplateContentLanguage));

                foreach (TemplateContentLanguage outputLanguage in outputLanguages)
                {
                    ddlReturnType.Items.Add(SyntaxEditorHelper.LanguageNameFromEnum(outputLanguage));
                }
                ddlReturnType.DropDownStyle = ComboBoxStyle.DropDownList;
            }
            else
            {
                switch (frmFunctionWizard.CurrentFunction.ScriptLanguage)
                {
                case SyntaxEditorHelper.ScriptLanguageTypes.CSharp:
                    ddlReturnType.Items.AddRange(new[] { "double", "float", "int", "string", "void" });
                    break;

                case SyntaxEditorHelper.ScriptLanguageTypes.VbNet:
                    ddlReturnType.Items.AddRange(new[] { "Double", "Float", "Int", "String", "Void" });
                    break;

                default:
                    throw new NotImplementedException("Script language type not handled yet: " + frmFunctionWizard.CurrentFunction.ScriptLanguage.ToString());
                }
                ddlReturnType.DropDownStyle = ComboBoxStyle.DropDown;
            }
            string returnType = frmFunctionWizard.CurrentFunction.ReturnType != null ? frmFunctionWizard.CurrentFunction.ReturnType.Name : "void";

            ddlReturnType.Text = frmFunctionWizard.CurrentFunction.IsTemplateFunction ? frmFunctionWizard.CurrentFunction.TemplateReturnLanguage : returnType;
        }
Пример #22
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes an instance of the <c>MainControl</c> class.
        /// </summary>
        public MainControl()
        {
            InitializeComponent();

            // Load a language from a language definition
            editor.Document.Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("JavaScript.langdef");

            // Register a code snippet provider that has several snippets available
            ICodeSnippetFolder snippetFolder = SyntaxEditorHelper.LoadSampleJavascriptCodeSnippetsFromResources();

            editor.Document.Language.RegisterService(new CodeSnippetProvider()
            {
                RootFolder = snippetFolder
            });

            // Ensure all classification types and related styles have been registered
            //   since classification types are used for code snippet field display
            new DisplayItemClassificationTypeProvider().RegisterAll();
        }
Пример #23
0
 static PatchModel()
 {
     JsonLanguage    = new JsonSyntaxLanguageExtended();
     JScriptLanguage = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("JScript.langdef");
     QueryLanguage   = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("RavenQuery.langdef");
 }
Пример #24
0
 static SmugglerTaskSectionModel()
 {
     JScriptLanguage = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("JScript.langdef");
 }
Пример #25
0
 static ReportingModel()
 {
     QueryLanguage = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("RavenQuery.langdef");
 }
Пример #26
0
 static SqlReplicationSettingsSectionModel()
 {
     JScriptLanguage = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("JScript.langdef");
 }
Пример #27
0
		public void PopulateFunctionList()
		{
			try
			{
				superTooltip1 = new SuperTooltip();
				superTooltip1.BeforeTooltipDisplay += superTooltip1_BeforeTooltipDisplay;
				List<string> specialFunctions = Project.Instance.InternalFunctionNames;

				treeFunctions.BeginUpdate();
				treeFunctions.Nodes.Clear();

				foreach (string category in Project.Instance.FunctionCategories)
				{
					RemoveTabsOfDeletedFunctions();
					var categoryNode = new Node();
					categoryNode.Text = " " + (string.IsNullOrEmpty(category) ? "General" : category);
					bool categoryAdded = false;

					foreach (FunctionInfo function in Project.Instance.Functions)
					{
						if (function.Category != category || specialFunctions.BinarySearch(function.Name) >= 0)
						{
							continue;
						}
						if (function.IsExtensionMethod)
							continue;
						if (!categoryAdded)
						{
							categoryNode.Style = treeFunctions.Styles["elementStyleGroup"];
							treeFunctions.Nodes.Add(categoryNode);
							categoryAdded = true;
						}
						var functionNode = new Node { Text = function.Name, Tag = function };

						if (!function.IsTemplateFunction)
						{
							functionNode.Image = imageListFunctions.Images[0];
						}
						else
						{
							switch (SyntaxEditorHelper.LanguageEnumFromName(function.TemplateReturnLanguage))
							{
								case TemplateContentLanguage.CSharp:
									functionNode.Image = imageListFunctions.Images[3];
									break;
								case TemplateContentLanguage.VbDotNet:
									functionNode.Image = imageListFunctions.Images[5];
									break;
								case TemplateContentLanguage.Sql:
									functionNode.Image = imageListFunctions.Images[0];
									break;
								case TemplateContentLanguage.Html:
									functionNode.Image = imageListFunctions.Images[4];
									break;
								case TemplateContentLanguage.Css:
									functionNode.Image = imageListFunctions.Images[2];
									break;
								case TemplateContentLanguage.IniFile:
									functionNode.Image = imageListFunctions.Images[0];
									break;
								case TemplateContentLanguage.JScript:
									functionNode.Image = imageListFunctions.Images[0];
									break;
								case TemplateContentLanguage.Python:
									functionNode.Image = imageListFunctions.Images[0];
									break;
								case TemplateContentLanguage.VbScript:
									functionNode.Image = imageListFunctions.Images[5];
									break;
								case TemplateContentLanguage.Xml:
									functionNode.Image = imageListFunctions.Images[6];
									break;
								case TemplateContentLanguage.PlainText:
									functionNode.Image = imageListFunctions.Images[0];
									break;
								default:
									functionNode.Image = imageListFunctions.Images[0];
									//throw new Exception("This function return type not handled yet in CreateDirectiveXmlToCSharpLanguage: " + function.ReturnType);
									break;
							}
						}
						//toolTipForNavBar.SetToolTip(functionNode, string.Format("({1}) {0}", function.Name, function.ReturnType));
						var sti = new SuperTooltipInfo(function.Name, "", function.Description, functionNode.Image, null, eTooltipColor.Office2003);
						superTooltip1.SetSuperTooltip(functionNode, sti);
						categoryNode.Nodes.Add(functionNode);
					}
				}
				foreach (Node node in treeFunctions.Nodes)
				{
					node.ExpandAll();
					node.Expand();
				}
			}
			finally
			{
				treeFunctions.EndUpdate();
			}
		}
Пример #28
0
		private TabItem CreateNewFunctionTabPage(FunctionInfo function, bool allowEdit)
		{
			TabItem newPage = new TabItem();
			TabControlPanel panel = new TabControlPanel();
			panel.TabItem = newPage;
			panel.Dock = DockStyle.Fill;
			newPage.AttachedControl = panel;
			newPage.Text = function.Name;
			newPage.ImageIndex = 0;
			newPage.Tag = function;
			newPage.CloseButtonVisible = true;
			ucFunction funcPanel = new ucFunction();
			funcPanel.Dock = DockStyle.Fill;
			funcPanel.AllowEdit = allowEdit;
			newPage.AttachedControl.Controls.Add(funcPanel);
			funcPanel.FunctionName = function.Name;
			funcPanel.CurrentFunction = function;
			//funcPanel.DefaultValueFunction = defaultValueFunction;
			funcPanel.Populate();

			switch (SyntaxEditorHelper.GetScriptingLanguage(function.ScriptLanguage))
			{
				case TemplateContentLanguage.CSharp:
					newPage.ImageIndex = 3;
					break;
				case TemplateContentLanguage.VbDotNet:
					newPage.ImageIndex = 5;
					break;
				case TemplateContentLanguage.Sql:
					newPage.ImageIndex = 0;
					break;
				case TemplateContentLanguage.Html:
					newPage.ImageIndex = 4;
					break;
				case TemplateContentLanguage.Css:
					newPage.ImageIndex = 2;
					break;
				case TemplateContentLanguage.IniFile:
					newPage.ImageIndex = 0;
					break;
				case TemplateContentLanguage.JScript:
					newPage.ImageIndex = 0;
					break;
				case TemplateContentLanguage.Python:
					newPage.ImageIndex = 0;
					break;
				case TemplateContentLanguage.VbScript:
					newPage.ImageIndex = 5;
					break;
				case TemplateContentLanguage.Xml:
					newPage.ImageIndex = 6;
					break;
				case TemplateContentLanguage.PlainText:
					newPage.ImageIndex = 0;
					break;
				default:
					throw new Exception("This function return type not handled yet in ShowFunction: " +
										funcPanel.ReturnType);
			}

			return newPage;
		}
Пример #29
0
        /// <summary>
        /// Loads a language definition.
        /// </summary>
        /// <param name="languageKey">The key that identifies the language.</param>
        private void LoadLanguage(string languageKey)
        {
            // Clear errors and document outline
            errorListView.ItemsSource = null;
            astOutputEditor.Document.SetText("(Language may not have AST building features)");

            switch (languageKey)
            {
            case "Assembly":
                this.LoadLanguageDefinitionFromFile("Assembly.langdef");
                break;

            case "Batch file":
                this.LoadLanguageDefinitionFromFile("BatchFile.langdef");
                break;

            case "C":
                this.LoadLanguageDefinitionFromFile("C.langdef");
                break;

            case "C#":
                this.LoadLanguageDefinitionFromFile("CSharp.langdef");
                editor.Document.Language.RegisterLineCommenter(new LineBasedLineCommenter()
                {
                    StartDelimiter = "//"
                });
                break;

            case "C# (in .NET Languages Add-on)": {
                // .NET Languages Add-on C# language
                var language = new ActiproSoftware.Text.Languages.CSharp.Implementation.CSharpSyntaxLanguage();
                language.RegisterService <ActiproSoftware.Text.Languages.DotNet.Reflection.IProjectAssembly>(cSharpProjectAssembly);
                this.LoadLanguage(language);

                // Register a code snippet provider that has several snippets available
                ICodeSnippetFolder snippetFolder = SyntaxEditorHelper.LoadSampleCSharpCodeSnippetsFromResources();
                editor.Document.Language.RegisterService(new ActiproSoftware.Text.Languages.CSharp.Implementation.CSharpCodeSnippetProvider()
                    {
                        RootFolder = snippetFolder
                    });
                break;
            }

            case "C++":
                this.LoadLanguageDefinitionFromFile("Cpp.langdef");
                break;

            case "CSS":
                this.LoadLanguageDefinitionFromFile("Css.langdef");
                break;

            case "Custom...":
                this.LoadLanguageDefinitionFromFile(null);
                break;

            case "HTML":
                this.LoadLanguageDefinitionFromFile("Html.langdef");
                editor.Document.Language.RegisterLineCommenter(new RangeLineCommenter()
                {
                    StartDelimiter = "<!--", EndDelimiter = "-->"
                });
                break;

            case "INI file":
                this.LoadLanguageDefinitionFromFile("IniFile.langdef");
                break;

            case "Java":
                this.LoadLanguageDefinitionFromFile("Java.langdef");
                editor.Document.Language.RegisterLineCommenter(new LineBasedLineCommenter()
                {
                    StartDelimiter = "//"
                });
                break;

            case "JavaScript":
                this.LoadLanguageDefinitionFromFile("JavaScript.langdef");
                editor.Document.Language.RegisterLineCommenter(new LineBasedLineCommenter()
                {
                    StartDelimiter = "//"
                });
                break;

            case "JavaScript (in Web Languages Add-on)":
                // Web Languages Add-on JavaScript language
                this.LoadLanguage(new ActiproSoftware.Text.Languages.JavaScript.Implementation.JavaScriptSyntaxLanguage());
                break;

            case "JSON (in Web Languages Add-on)":
                // Web Languages Add-on JSON language
                this.LoadLanguage(new ActiproSoftware.Text.Languages.JavaScript.Implementation.JsonSyntaxLanguage());
                break;

            case "Lua":
                this.LoadLanguageDefinitionFromFile("Lua.langdef");
                break;

            case "Markdown":
                this.LoadLanguageDefinitionFromFile("Markdown.langdef");
                break;

            case "MSIL":
                this.LoadLanguageDefinitionFromFile("Msil.langdef");
                break;

            case "Pascal":
                this.LoadLanguageDefinitionFromFile("Pascal.langdef");
                break;

            case "Perl":
                this.LoadLanguageDefinitionFromFile("Perl.langdef");
                break;

            case "PHP":
                this.LoadLanguageDefinitionFromFile("Php.langdef");
                break;

            case "PowerShell":
                this.LoadLanguageDefinitionFromFile("PowerShell.langdef");
                break;

            case "Python":
                this.LoadLanguageDefinitionFromFile("Python.langdef");
                break;

            case "Python v2.x (in Python Language Add-on)":
                // Python Language Add-on Python language
                this.LoadLanguage(new ActiproSoftware.Text.Languages.Python.Implementation.PythonSyntaxLanguage(ActiproSoftware.Text.Languages.Python.PythonVersion.Version2));
                break;

            case "Python v3.x (in Python Language Add-on)":
                // Python Language Add-on Python language
                this.LoadLanguage(new ActiproSoftware.Text.Languages.Python.Implementation.PythonSyntaxLanguage(ActiproSoftware.Text.Languages.Python.PythonVersion.Version3));
                break;

            case "RTF":
                this.LoadLanguageDefinitionFromFile("Rtf.langdef");
                break;

            case "Ruby":
                this.LoadLanguageDefinitionFromFile("Ruby.langdef");
                break;

            case "SQL":
                this.LoadLanguageDefinitionFromFile("Sql.langdef");
                break;

            case "VB":
                this.LoadLanguageDefinitionFromFile("VB.langdef");
                editor.Document.Language.RegisterLineCommenter(new LineBasedLineCommenter()
                {
                    StartDelimiter = "'"
                });
                break;

            case "VB (in .NET Languages Add-on)": {
                // .NET Languages Add-on VB language
                var language = new ActiproSoftware.Text.Languages.VB.Implementation.VBSyntaxLanguage();
                language.RegisterService <ActiproSoftware.Text.Languages.DotNet.Reflection.IProjectAssembly>(vbProjectAssembly);
                this.LoadLanguage(language);

                // Register a code snippet provider that has several snippets available
                ICodeSnippetFolder snippetFolder = SyntaxEditorHelper.LoadSampleVBCodeSnippetsFromResources();
                editor.Document.Language.RegisterService(new ActiproSoftware.Text.Languages.VB.Implementation.VBCodeSnippetProvider()
                    {
                        RootFolder = snippetFolder
                    });
                break;
            }

            case "VBScript":
                this.LoadLanguageDefinitionFromFile("VBScript.langdef");
                break;

            case "XAML":
                this.LoadLanguageDefinitionFromFile("Xaml.langdef");
                editor.Document.Language.RegisterLineCommenter(new RangeLineCommenter()
                {
                    StartDelimiter = "<!--", EndDelimiter = "-->"
                });
                break;

            case "XML":
                this.LoadLanguageDefinitionFromFile("Xml.langdef");
                editor.Document.Language.RegisterLineCommenter(new RangeLineCommenter()
                {
                    StartDelimiter = "<!--", EndDelimiter = "-->"
                });
                break;

            case "XML (in Web Languages Add-on)":
                // Web Languages Add-on XML language
                this.LoadLanguage(new ActiproSoftware.Text.Languages.Xml.Implementation.XmlSyntaxLanguage());
                break;

            default:
                // Plain text
                this.LoadLanguage(SyntaxLanguage.PlainText);
                break;
            }
        }
Пример #30
0
        public QueryModel()
        {
            ModelUrl = "/query";
            ApplicationModel.Current.Server.Value.RawUrl = null;
            SelectedTransformer = new Observable <string> {
                Value = "None"
            };
            SelectedTransformer.PropertyChanged += (sender, args) => Requery();

            ApplicationModel.DatabaseCommands.GetTransformersAsync(0, 256).ContinueOnSuccessInTheUIThread(transformers =>
            {
                Transformers = new List <string> {
                    "None"
                };
                Transformers.AddRange(transformers.Select(definition => definition.Name));

                OnPropertyChanged(() => Transformers);
            });

            queryDocument = new EditorDocument
            {
                Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("RavenQuery.langdef")
            };

            ExceptionLine   = -1;
            ExceptionColumn = -1;

            CollectionSource = new QueryDocumentsCollectionSource();
            Observable.FromEventPattern <QueryStatisticsUpdatedEventArgs>(h => CollectionSource.QueryStatisticsUpdated += h,
                                                                          h => CollectionSource.QueryStatisticsUpdated -= h)
            .SampleResponsive(TimeSpan.FromSeconds(0.5))
            .TakeUntil(Unloaded)
            .ObserveOnDispatcher()
            .Subscribe(e =>
            {
                QueryTime = e.EventArgs.QueryTime;
                Results   = e.EventArgs.Statistics;
            });
            Observable.FromEventPattern <QueryErrorEventArgs>(h => CollectionSource.QueryError += h,
                                                              h => CollectionSource.QueryError -= h)
            .ObserveOnDispatcher()
            .Subscribe(e => HandleQueryError(e.EventArgs.Exception));

            DocumentsResult = new DocumentsModel(CollectionSource)
            {
                Header = "Results",
                DocumentNavigatorFactory = (id, index) => DocumentNavigator.Create(id, index, IndexName, CollectionSource.TemplateQuery),
            };

            QueryErrorMessage = new Observable <string>();
            IsErrorVisible    = new Observable <bool>();

            SortBy = new BindableCollection <StringRef>(x => x.Value);
            SortBy.CollectionChanged += HandleSortByChanged;
            SortByOptions             = new BindableCollection <string>(x => x);
            Suggestions    = new BindableCollection <FieldAndTerm>(x => x.Field);
            DynamicOptions = new BindableCollection <string>(x => x)
            {
                "AllDocs"
            };
            AvailableIndexes = new BindableCollection <string>(x => x);

            SpatialQuery = new SpatialQueryModel {
                IndexName = indexName
            };
        }