private void Compelet()
        {
            Regex re = new Regex(@"\\bibliography\{(\w+)\}");

            Match  m    = re.Match(this.textEditor.Document.Text);
            string path = @"Z:\30\1\ref.bib";// m.Groups[1].Captures[0].ToString() + " .bib";

            //if (e.Text == @"\ref{")
            {
                // open code completion after the user has pressed dot:
                completionWindow = new CompletionWindow(textEditor.TextArea);
                // provide AvalonEdit with the data:
                IList <ICompletionData> data  = completionWindow.CompletionList.CompletionData;
                StringBuilder           entry = new StringBuilder();

                foreach (BibTex b in BibTex.Parse(path))
                {
                    MyCompletionData d = new MyCompletionData(b.UID);
                    //d.Name = "name";
                    //d.Description = "des";
                    //d.Content = "content";
                    data.Add(d);
                }
                completionWindow.Show();
                completionWindow.Closed += delegate
                {
                    completionWindow = null;
                };
            }
        }
Exemplo n.º 2
0
        private void populate(string s = "")
        {
            Regex reBiblio = new Regex(@"(?<!%)(?<=\\bibliography\{)([^\{]+)(?=\})", RegexOptions.IgnoreCase);
            Match m        = reBiblio.Match(Textdoc.txtEditor.Text);

            if (m.Success)
            {
                this.path = this.Textdoc.CurrentFileInfo.Directory + "\\" + m.Groups[1].Captures[0].Value.ToString() + ".bib";
            }

            this.listView1.Items.Clear();
            foreach (BibTex entry in BibTex.Parse(this.path))
            {
                if (entry.Text.Contains(s) || string.IsNullOrEmpty(s))
                {
                    ListViewItem item = new ListViewItem(new string[] { "", "", entry.UID, entry["author"], entry["title"], entry["journal"], entry.Text });
                    item.ToolTipText = entry.Text;
                    item.Tag         = entry.UID;
                    this.listView1.Items.Add(item);
                }
            }
        }
Exemplo n.º 3
0
        private void Compelet()
        {
            string path     = "";
            Regex  reBiblio = new Regex(@"(?<!%)(?<=\\bibliography\{)([^\{]+)(?=\})", RegexOptions.IgnoreCase);
            Match  m        = reBiblio.Match(txtEditor.Text);

            if (m.Success)
            {
                path = this.CurrentFileInfo.Directory + "\\" + m.Groups[1].Captures[0].Value.ToString() + ".bib";
            }
            if (!File.Exists(path))
            {
                return;
            }

            //if (e.Text == @"\ref{")
            //{
            // open code completion after the user has pressed dot:
            completionWindow = new CompletionWindow(txtEditor.TextArea);
            // provide AvalonEdit with the data:
            IList <ICompletionData> data  = completionWindow.CompletionList.CompletionData;
            StringBuilder           entry = new StringBuilder();

            foreach (BibTex b in BibTex.Parse(path))
            {
                MyCompletionData d = new MyCompletionData(b.UID);
                d.Data = b.Text;
                //d.Description = "des";
                //d.Content = "content";
                data.Add(d);
            }
            completionWindow.Show();
            completionWindow.Closed += delegate
            {
                completionWindow = null;
            };
            //}
        }
Exemplo n.º 4
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Total = _selectedItems.Length;

                foreach (XElement item in _selectedItems)
                {
                    //exit if the user cancels
                    if (_isCancelationPending == true)
                    {
                        return;
                    }

                    BibTex bibtex = BibTex.XmlToBibTex(item);
                    if (bibtex != null)
                    {
                        Books books = new Books();
                        books.Title         = bibtex.title;
                        books.FileFormat    = new FileFormat();
                        books.FileFormat.Id = _formatId;
                        books.Media         = new Media();
                        books.Media.Id      = _mediaId;
                        books.AddedDate     = DateTime.Now;

                        #region Publisher

                        bool isNew;
                        books.Publisher = PublisherServices.GetPublisher(bibtex.editor, out isNew, "App_Editor");
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddPublisher("App_Editor", books.Publisher);
                        }

                        #endregion
                        #region Artist

                        Artist artist = ArtistServices.Get(bibtex.author.Trim(), out isNew);
                        books.Artists.Add(artist);
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddArtist(artist, books);
                        }

                        #endregion
                        books.Description = bibtex.booktitle;
                        books.Isbn        = bibtex.isbn;

                        int pages;
                        if (int.TryParse(bibtex.pages, out pages))
                        {
                            books.NbrPages = pages;
                        }

                        int year;
                        if (int.TryParse(bibtex.year, out year))
                        {
                            books.ReleaseDate = new DateTime(year, 1, 1);
                        }

                        Books bExist = Dal.GetInstance.GetBooks(_mediaName, books.Title);
                        if (bExist == null)
                        {
                            Dal.GetInstance.AddBook(books);
                            _intAddedItem++;
                        }
                        else
                        {
                            _intNotAddedItem++;
                        }
                    }
                    Current++;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }