static public void Initialize_CodeCompletion_TextEnter(this TemplateEditor editor) { // this is our code-completion helper editor.Editor.TextArea.TextEntering += editor.textEditor_TextArea_TextEntering; // this particular little method is for code completion and is not used editor.Editor.TextArea.TextEntered += editor.textEditor_TextArea_TextEntered; }
public void Edit(string typeName) { var type = this.GetType(typeName); var template = type.Dispatcher.Invoke(() => type.Template); var domain = template.Dispatcher.Invoke(() => template.Domain); var authentication = this.CommandContext.GetAuthentication(this); var contains = domain == null ? false : domain.Dispatcher.Invoke(() => domain.Users.Contains(authentication.ID)); template.Dispatcher.Invoke(() => { if (contains == false) { template.BeginEdit(authentication); } }); try { if (TemplateEditor.Edit(template, authentication) == true) { template = null; } } finally { if (template != null) { template.Dispatcher.Invoke(() => template.CancelEdit(authentication)); } } }
public async Task EditAsync([CommandCompletion(nameof(GetTypeNamesAsync))] string typeName) { var type = await this.GetTypeAsync(typeName); var template = type.Dispatcher.Invoke(() => type.Template); var domain = template.Dispatcher.Invoke(() => template.Domain); var authentication = this.CommandContext.GetAuthentication(this); var contains = domain != null && await domain.Members.ContainsAsync(authentication.ID); if (contains == false) { await template.BeginEditAsync(authentication); } try { if (await TemplateEditor.EditAsync(template, authentication) == true) { template = null; } } finally { if (template != null) { await template.CancelEditAsync(authentication); } } }
public async Task EditTemplateAsync([CommandCompletion(nameof(GetTableNamesAsync))] string tableName) { var authentication = this.CommandContext.GetAuthentication(this); var table = await this.GetTableAsync(tableName); var template = table.Dispatcher.Invoke(() => table.Template); var domain = template.Dispatcher.Invoke(() => template.Domain); var contains = domain != null && await domain.Members.ContainsAsync(authentication.ID); if (contains == false) { await template.BeginEditAsync(authentication); } if (await TemplateEditor.EditColumnsAsync(template, authentication) == false) { await template.CancelEditAsync(authentication); } else { try { await template.EndEditAsync(authentication); } catch { await template.CancelEditAsync(authentication); throw; } } }
// as to be visible to the extension static public void TextChangedEventHandler(this TemplateEditor editor, object sender, EventArgs e) { if (editor.FoldingUpdateTimer.IsEnabled) { editor.FoldingUpdateTimer.Stop(); } editor.FoldingUpdateTimer.Start(); }
private void SaveDocumentTab(TabPage tabPage) { TemplateEditor editor = (TemplateEditor)tabPage.Controls[0]; editor.Save(); tabPage.Text = Path.GetFileName(editor.Template.XsltHintPath); }
private void Editor_TextChanged(object sender, EventArgs e) { TemplateEditor editor = (TemplateEditor)sender; TabPage tabPage = (TabPage)editor.Parent; _unsavedChanges = true; tabPage.Text = Path.GetFileName(editor.Template.XsltHintPath) + "*"; UpdateTitle(); }
public bool Template([FromUri] int templateId, TemplateInfo template) { var viewEditor = new TemplateEditor(SxcContext, templateId, UserInfo, PortalSettings); viewEditor.EnsureUserMayEditTemplate(); viewEditor.Code = template.Code; return(true); }
static public void InitEntering1(this TemplateEditor editor) { try { if (editor.FoldingStrategy != null) { editor.FoldingStrategy.UpdateFoldings(editor.FoldingManager, editor.Editor.Document); } } catch (Exception) { } }
static void Init() { if (instance == null) { instance = CreateInstance <TemplateEditor> (); EditorWindow editorWindow = GetWindow <TemplateEditor> (); editorWindow.autoRepaintOnSceneChange = true; editorWindow.Show(); TemplateEditor.instance.BeginEdit(); } }
/// <summary> /// <para>Initialize Code-Completion</para> /// <para></para> /// </summary> /// <param name="editor"></param> /// <param name="config"></param> static public void InitializeControl(this TemplateEditor editor, UITemplateManager config) { editor.Factory = config; editor.avalonTextEditor.InputBindings.Add(new KeyBinding(ApplicationCommands.Save, Key.S, ModifierKeys.Control)); editor.avalonTextEditor.CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, config.sTemplates.TemplateFromUIHandler, config.sTemplates.TemplateFromUIHandlerCan)); // editor.Initialize_CodeCompletion_TextEnter(); editor.InitEntering2(); editor.avalonTextEditor.TextChanged += editor.TextChangedEventHandler; // editor.FoldingUpdateTimer.Interval = TimeSpan.FromMilliseconds(900); editor.FoldingUpdateTimer.Tick += editor.foldingUpdateTimer_Tick; editor.FoldingUpdateTimer.Start(); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { try { DataTemplate dataTemplate = null; var editor = TemplateEditor.GetEditor(container); // clearing the Tag property which in this case is used // to track the template returned in edit mode. editor.Tag = null; var dataContext = ((FrameworkElement)((ContentPresenter)container).Parent).DataContext; if (dataContext != null) { var dI = ((Infragistics.Windows.DataPresenter.DataRecord)((FrameworkElement)((ContentPresenter)container).Parent).DataContext).DataItem; if (dI is Models.DealVisualBase dataItem) { if (item != null) { switch (dataItem.IdCross) { case 1: dataTemplate = editor.FindResource("ctvFormatDecimal2Qta1") as DataTemplate; break; case 2: dataTemplate = editor.FindResource("ctvFormatDecimal4Qta1") as DataTemplate; break; } } if (dataTemplate != null) { return(dataTemplate); } } } return(base.SelectTemplate(item, container)); } catch (Exception ex) { return(base.SelectTemplate(item, container)); } }
static public void InitEntering2(this TemplateEditor editor) { if (editor.Editor.SyntaxHighlighting == null) { editor.FoldingStrategy = null; } else { switch (editor.Editor.SyntaxHighlighting.Name) { case "XML": editor.FoldingStrategy = new XmlFoldingStrategy(); editor.Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); break; case "C#": case "CSS": case "C++": case "PHP": case "Java": editor.Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(editor.Editor.Options); editor.FoldingStrategy = new CSharpPragmaRegionFoldingStrategy(); break; default: editor.Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy(); editor.FoldingStrategy = null; break; } } if (editor.FoldingStrategy != null) { if (editor.FoldingManager == null) { editor.FoldingManager = FoldingManager.Install(editor.Editor.TextArea); } editor.FoldingStrategy.UpdateFoldings(editor.FoldingManager, editor.Editor.Document); } else { if (editor.FoldingManager != null) { FoldingManager.Uninstall(editor.FoldingManager); editor.FoldingManager = null; } } }
private void projectTreeview_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { using (new Wait()) { if (e.Node is TemplateTreeNode) { TemplateTreeNode node = (TemplateTreeNode)e.Node; if (TemplateTabPages.ContainsKey(node.Template)) { documentsTabControl.SelectedTab = TemplateTabPages[node.Template]; } else { TabPage tabPage = new TabPage(Path.GetFileName(node.Template.XsltHintPath)); TemplateEditor editor = null; try { editor = new TemplateEditor(node.Template); } catch (Exception ex) { MessageBox.Show("An error occurred while loading the template: " + ex.Message, "Template Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } editor.Dock = DockStyle.Fill; editor.TextChanged += new EventHandler(Editor_TextChanged); tabPage.Controls.Add(editor); documentsTabControl.TabPages.Add(tabPage); documentsTabControl.SelectedTab = tabPage; documentsTabControl.Visible = true; TemplateTabPages.Add(node.Template, tabPage); } } } }
public TemplateInfo Template(int templateId) { var viewEditor = new TemplateEditor(SxcContext, templateId, UserInfo, PortalSettings); viewEditor.EnsureUserMayEditTemplate(); var templ = viewEditor.Template; var t = new TemplateInfo(); t.Type = templ.Type; t.FileName = templ.Path; t.Code = viewEditor.Code; t.Name = templ.Name; t.HasList = templ.UseForList; t.HasApp = App.Name != "Content"; t.AppId = App.AppId; t.TypeContent = templ.ContentTypeStaticName; t.TypeContentPresentation = templ.PresentationTypeStaticName; t.TypeList = templ.ListContentTypeStaticName; t.TypeListPresentation = templ.ListPresentationTypeStaticName; return(t); }
private bool CloseDocumentTab(TabPage tabPage) { TemplateEditor editor = (TemplateEditor)tabPage.Controls[0]; if (editor.UnsavedChanges) { DialogResult result = MessageBox.Show("The file \"{0}\" has unsaved changes. Would you like to save this file before closing it?".FormatString(editor.Template.XsltAbsolutePath), "Save Changes?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { editor.Save(); } else if (result == DialogResult.Cancel) { return(false); } } TemplateTabPages.Remove(editor.Template); documentsTabControl.TabPages.Remove(tabPage); documentsTabControl.Visible = (documentsTabControl.TabPages.Count > 0); return(true); }
public void EditTemplate(string tableName) { var authentication = this.CommandContext.GetAuthentication(this); var table = this.GetTable(tableName); var template = table.Dispatcher.Invoke(() => table.Template); var domain = template.Dispatcher.Invoke(() => template.Domain); var contains = domain == null ? false : domain.Dispatcher.Invoke(() => domain.Users.Contains(authentication.ID)); template.Dispatcher.Invoke(() => { if (contains == false) { template.BeginEdit(authentication); } }); if (TemplateEditor.EditColumns(template, authentication) == false) { template.Dispatcher.Invoke(() => template.CancelEdit(authentication)); } else { template.Dispatcher.Invoke(() => { try { template.EndEdit(authentication); } catch { template.CancelEdit(authentication); throw; } }); } }
public object PerformMdiFunction(IMyGenContent sender, string function, params object[] args) { if (function.Equals("getstaticdbroot", StringComparison.CurrentCultureIgnoreCase)) { return(MetaDataBrowser.StaticMyMetaObj); } if (function.Equals("showoledbdialog", StringComparison.CurrentCultureIgnoreCase) && args.Length == 1) { return(BrowseOleDbConnectionString(args[0].ToString())); } if (function.Equals("executionqueuestart", StringComparison.CurrentCultureIgnoreCase)) { toolStripStatusQueue.Visible = true; timerImgAnimate.Start(); } else if (function.Equals("executionqueueupdate", StringComparison.CurrentCultureIgnoreCase)) { if (ZeusProcessManager.ProcessCount == 0) { timerImgAnimate.Stop(); toolStripStatusQueue.Visible = false; } else if (ZeusProcessManager.ProcessCount > 0) { toolStripStatusQueue.Visible = true; timerImgAnimate.Start(); } } else if (function.Equals("showerrordetail", StringComparison.CurrentCultureIgnoreCase) && args.Length >= 1) { if (args[0] is List <IMyGenError> ) { List <IMyGenError> errors = args[0] as List <IMyGenError>; ErrorDetailDockContent.Update(errors[0]); if (ErrorDetailDockContent.IsHidden) { ErrorDetailDockContent.Show(MainDockPanel); } else { ErrorDetailDockContent.Activate(); } } } else if (function.Equals("navigatetotemplateerror", StringComparison.CurrentCultureIgnoreCase) && args.Length >= 1) { if (args[0] is IMyGenError) { IMyGenError error = args[0] as IMyGenError; TemplateEditor edit = null; if (string.IsNullOrEmpty(error.SourceFile)) { //it's a new unsaved template bool isopen = IsDocumentOpen(error.TemplateIdentifier); if (isopen) { edit = FindDocument(error.TemplateIdentifier) as TemplateEditor; edit.Activate(); } } else { FileInfo file = new FileInfo(error.TemplateFileName); if (file.Exists) { bool isopen = IsDocumentOpen(file.FullName); if (!isopen) { edit = new TemplateEditor(this); edit.FileOpen(file.FullName); } else { edit = FindDocument(file.FullName) as TemplateEditor; if (edit != null) { edit.Activate(); } } } } if (edit != null) { edit.NavigateTo(error); } } } else if (function.Equals("getmymetadbdriver", StringComparison.CurrentCultureIgnoreCase)) { return(DefaultSettings.Instance.DbDriver); } else if (function.Equals("getmymetaconnection", StringComparison.CurrentCultureIgnoreCase)) { return(DefaultSettings.Instance.ConnectionString); } else if (function.Equals("openfile", StringComparison.CurrentCultureIgnoreCase) && args.Length == 1) { if (args[0] is List <FileInfo> ) { List <FileInfo> files = args[0] as List <FileInfo>; foreach (FileInfo fi in files) { Zeus.WindowsTools.LaunchFile(fi.FullName); } } else if (args[0] is FileInfo) { FileInfo file = args[0] as FileInfo; Zeus.WindowsTools.LaunchFile(file.FullName); } else if (args[0] is String) { Zeus.WindowsTools.LaunchFile(args[0].ToString()); } } return(null); }
static public void foldingUpdateTimer_Tick(this TemplateEditor editor, object sender, EventArgs e) { editor.FoldingUpdateTimer.Stop(); editor.InitEntering1(); }