Ejemplo n.º 1
0
		public DocumentController(MainController mainController, Document document)
		{
			this.mainController = mainController;
			this.document = document;

			documentProperties = (DocumentProperties) document.CustomDocumentProperties;

			var documentStyleTitle = GetDocumentStyleTitle();
			style = mainController.FindStyleByTitle(documentStyleTitle) ?? mainController.DefaultStyle;
		}
Ejemplo n.º 2
0
		public CiteProcRunner(StyleInfo style, GetDatabaseDelegate databaseProvider): this()
		{
			this.databaseProvider = databaseProvider;
			this.style = style;

			try
			{
				engine = Call(CreateEngineCommand, this.style.GetXml());                
				if (engine == null) throw new InvalidOperationException();
			}
			catch
			{
				throw new FailedToCreateCiteProcEngineForStyleException(style);
			}
		}
Ejemplo n.º 3
0
		public static StyleInfo LoadFromFile(string filename)
		{
			var styleFileInfo = new FileInfo(filename);

			var doc = new XmlDocument();
			var xmlNamespaceManager = new XmlNamespaceManager(doc.NameTable);
			xmlNamespaceManager.AddNamespace("x", StyleXmlNamespace);

			var styleInfo = new StyleInfo
						        {
						            FileInfo = styleFileInfo
						        };

			var node = doc.SelectSingleNode(TitleXPath, xmlNamespaceManager);
			styleInfo.Title = node == null ? string.Empty : node.InnerText;

			node = doc.SelectSingleNode(SummaryXPath, xmlNamespaceManager);
			styleInfo.Summary = node == null ? string.Empty : node.InnerText;

			return styleInfo;
		}
Ejemplo n.º 4
0
		public static List<StyleInfo> GetStylesInfo(string path = null)
		{
			try
			{
				var result = new List<StyleInfo>();

				var doc = new XmlDocument();
				var xmlNamespaceManager = new XmlNamespaceManager(doc.NameTable);
				xmlNamespaceManager.AddNamespace("x", StyleXmlNamespace);

				foreach (var styleFileInfo in GetStyleFiles(path))
				{
					try
					{
						doc.Load(styleFileInfo.FullName);

						var styleInfo = new StyleInfo
						                	{
						                		FileInfo = styleFileInfo
						                	};

						var node = doc.SelectSingleNode(TitleXPath, xmlNamespaceManager);
						styleInfo.Title = node == null ? string.Empty : node.InnerText;

						node = doc.SelectSingleNode(SummaryXPath, xmlNamespaceManager);
						styleInfo.Summary = node == null ? string.Empty : node.InnerText;

						result.Add(styleInfo);
					}
					catch {}
				}

				return result;
			}
			catch
			{
				return new List<StyleInfo>();
			}
		}
Ejemplo n.º 5
0
		public FailedToCreateCiteProcEngineForStyleException(StyleInfo style): base("A CiteProc engine could not be created from the style.")
		{
			this.style = style;
		}
Ejemplo n.º 6
0
 bool IsValidStyle(StyleInfo style)
 {
     return(styles.Contains(style));
 }
Ejemplo n.º 7
0
 bool IsValidStyle(StyleInfo style)
 {
     return styles.Contains(style);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Called when user changes style from dropdown list.
        /// </summary>
        /// <param name="newStyle"></param>
        public void TryChangeStyle(StyleInfo newStyle)
        {
            Debug.Assert(currentDocumentController != null);

            if (newStyle == null)
            {
                Process.Start(StyleHelper.FindMoreCitationStylesUrl);

                addinModule.SetSelectedStyle(currentDocumentController.Style);

                return;
            }

            if (IsValidStyle(newStyle))
            {
                currentDocumentController.Style = newStyle;

                DefaultStyle = newStyle;
            }

            addinModule.SetSelectedStyle(currentDocumentController.Style);
            addinModule.UpdateState(new SelectionManager(currentDocumentController));
        }
Ejemplo n.º 9
0
 public FailedToCreateCiteProcEngineForStyleException(StyleInfo style) : base("A CiteProc engine could not be created from the style.")
 {
     this.style = style;
 }
Ejemplo n.º 10
0
		public void SetSelectedStyle(StyleInfo style)
		{
			if (style == null)
			{
				rcbStyle.Text = StyleHelper.FindMoreCitationStyles.Title;
				ccbStyle.Text = StyleHelper.FindMoreCitationStyles.Title;

				return;
			}

			rcbStyle.Text = style.Title;
			ccbStyle.Text = style.Title;
		}
Ejemplo n.º 11
0
		ADXRibbonItem CreateRibbonItemForStyle(StyleInfo style)
		{
			return new ADXRibbonItem(components)
			       	{
			       		Caption = style.Title,
			       		ScreenTip = style.Title,
			       		SuperTip = style.Summary,
			       	};
		}