//PdfOverlay pdfOverlay1; public Form1() { //make sure that double to string is converted with decimal point (not comma!) System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US"); (GlobalUI.UI as GlobalUIWinForms).MainForm = this; TheVM = new MainWindowVM<TextEditorDocumentWrapper>(TheCompiler.Instance); InitializeComponent(); if (DesignMode) return; TextEditorDocumentWrapper.TheOneAndOnly = txtCode; // The order should be exactly the same as that in the OverlayToolType enum!!! ToolButtons = new List<ToolStripButton> { cmdMove, cmdNode, cmdEdge, cmdPath, cmdSmoothCurve, cmdBezier, cmdRectangle, cmdEllipse, cmdGrid, cmdArc, cmdArcEdit }; ToolPaneButtons = new List<ToolStripButton> { cmdSnippets, cmdFiles, cmdDynPreamble }; SetupComponents(); SetupBindings(); GlobalUI.UI.OnRecentFileEvent += (s, e) => { if (e.IsInsert) MyMRU.Insert(e.FileName); else MyMRU.Remove(e.FileName); }; MyMRU.OnFileOpen += (s, e) => TheVM.Open(e.FileName, ModifierKeys.HasFlag(Keys.Control)); TheVM.CreateNewFile(false); }
//public static List<TexOutputParser.TexError> TexErrors = new List<TexOutputParser.TexError>(); // public static System.Collections.ObjectModel.ObservableCollection<TexOutputParser.TexError> TexErrors = new System.Collections.ObjectModel.ObservableCollection<TexOutputParser.TexError>(); // public FileSystemWatcher fileWatcher = new FileSystemWatcher(); public MainWindow() { this.DataContext = TheVM = new ViewModels.MainWindowVM<AvalonDocumentWrapper>(TheCompiler.Instance); InitializeComponent(); // register GlobalUI events GlobalUIWPF GlobUI = (GlobalUIWPF)GlobalUI.UI; GlobUI.OnGlobalStatus += (s, e) => AddStatusLine(e.StatusLine, e.IsError); GlobUI.OnExportCompile += (s, e) => ExportCompiler.ExportCompileDialog.Export(e.Code, e.File); GlobUI.OnRecentFileEvent += (s, e) => { if (e.IsInsert) recentFileList.InsertFile(e.FileName); else recentFileList.RemoveFile(e.FileName); }; GlobUI.MessageBoxOwner = this; // Register events with the global compiler TheCompiler.Instance.OnCompileEvent += TexCompiler_OnCompileEvent; TheCompiler.Instance.OnTexOutput += TexCompiler_OnTexOutput; //make sure that double to string is converted with decimal point (not comma!) System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US"); // set up command bindings CommandBindings.Add(TheVM.GetNewCommandBinding()); CommandBindings.Add(TheVM.GetOpenCommandBinding()); CommandBindings.Add(TheVM.GetSaveCommandBinding()); CommandBindings.Add(TheVM.GetSaveAsCommandBinding()); //ICSharpCode.AvalonEdit.Document.TextDocument doc; doc. CommandBinding CommentCommandBinding = new CommandBinding(CommentCommand, CommentCommandHandler, AlwaysTrue); CommandBinding UnCommentCommandBinding = new CommandBinding(UnCommentCommand, UnCommentCommandHandler, AlwaysTrue); // CommandBinding FindNextCommandBinding = new CommandBinding(FindNextCommand, FindNextCommandHandler, AlwaysTrue); // CommandBinding FindPreviousCommandBinding = new CommandBinding(FindPreviousCommand, FindPreviousCommandHandler, AlwaysTrue); // CommandBinding ShowCodeCompletionsCommandBinding = new CommandBinding(ShowCodeCompletionsCommand, ShowCodeCompletionsCommandHandler, AlwaysTrue); // CommandBinding CompileCommandBinding = new CommandBinding(CompileCommand, CompileCommandHandler, AlwaysTrue); // CommandBinding SavePdfCommandBinding = new CommandBinding(SavePdfCommand, SavePdfHandler, AlwaysTrue); // CommandBinding SavePdfAsCommandBinding = new CommandBinding(SavePdfAsCommand, SavePdfAsHandler, AlwaysTrue); CommandBinding ShowPdfCommandBinding = new CommandBinding(ShowPdfCommand, ShowPdfHandler, AlwaysTrue); // CommandBinding ExportFileCommandBinding = new CommandBinding(ExportFileCommand, ExportFileHandler, AlwaysTrue); CommandBinding OpenPgfManualBinding = new CommandBinding(OpenPgfManualCommand, OpenPgfManualHandler, AlwaysTrue); pdfOverlay1.Rasterizer = rasterControl1.TheModel; // EnsureFindDialogExists(); TikzToBMPFactory.Instance.JobNumberChanged += TikzToBmpFactory_JobNumberChanged; // set up find/replace dialog FindReplaceManager.CurrentEditor = new FindReplace.TextEditorAdapter(txtCode); FindReplaceManager.ShowSearchIn = false; FindReplaceManager.OwnerWindow = this; CommandBindings.Add(FindReplaceManager.FindBinding); CommandBindings.Add(FindReplaceManager.ReplaceBinding); CommandBindings.Add(FindReplaceManager.FindNextBinding); updateChecker.Status += (s, e) => AddStatusLine(e.Description, e.HasFailed); updateChecker.Success += new EventHandler<TESharedComponents.UpdateChecker.SuccessEventArgs>(updateChecker_Success); recentFileList = RecentFileList; recentFileList.UseXmlPersister(System.IO.Path.Combine(Helper.GetAppdataPath(), "RecentFileList.xml")); //recentFileList.UseXmlPersister(); // AsyncParser.DoWork += new System.ComponentModel.DoWorkEventHandler(AsyncParser_DoWork); // AsyncParser.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(AsyncParser_RunWorkerCompleted); //fileWatcher.NotifyFilter = NotifyFilters.LastWrite; // fileWatcher.Changed += new FileSystemEventHandler(fileWatcher_Changed); this.KeyDown += new KeyEventHandler(MainWindow_KeyDown); // manually bind dynamic preamble DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(DynPreamble.DynPreambleView.PreambleProperty, typeof(DynPreamble.DynPreambleView) ); if (dpd != null) { dpd.AddValueChanged(preambleView, delegate { if (TheVM != null) TheVM.DynamicPreamble = preambleView.Preamble; }); } if (TheVM != null) TheVM.DynamicPreamble = preambleView.Preamble; // bind lstError to TexErrors (make sure that TexErrors is suitable object for data binding!) //lstErrors.ItemsSource = TexErrors; //lstErrors.Items.GroupDescriptions.Add(new System.ComponentModel.GroupDescription()) //lstErrors.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("severity", System.ComponentModel.ListSortDirection.Ascending)); // in the constructor: // txtCode.TextArea.TextEntering += textEditor_TextArea_TextEntering; // txtCode.TextArea.TextEntered += textEditor_TextArea_TextEntered; /* ofd.CheckFileExists = true; ofd.ValidateNames = true; ofd.Filter = "Tex Files|*.tex"+"|All Files|*.*"; sfd.Filter = "Tex Files|*.tex"+"|All Files|*.*"; sfd.OverwritePrompt = true; sfd.ValidateNames = true; * */ txtStatus.Document.Blocks.Clear(); RecentFileList.MenuClick += (s, e) => TheVM.Open(e.Filepath, Keyboard.Modifiers.HasFlag(ModifierKeys.Control)); //cmbGrid.SelectedIndex = 4; }