Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Common initialization shared by the constructors.
        /// </summary>
        /// <param name="tssForm">The TSS form.</param>
        /// <param name="helpProvider">The help provider.</param>
        /// <param name="helpFileKey">The help file key.</param>
        /// <param name="styleSheet">The stylesheet.</param>
        /// ------------------------------------------------------------------------------------
        private void Initialize(ITsString tssForm, IHelpTopicProvider helpProvider, string helpFileKey,
                                IVwStylesheet styleSheet)
        {
            m_tssWf        = tssForm;
            m_helpProvider = helpProvider;
//			m_vss = styleSheet;
            if (m_helpProvider == null)
            {
                btnHelp.Enabled = false;
            }
            else
            {
                m_helpFileKey     = helpFileKey;
                this.helpProvider = new HelpProvider();
                this.helpProvider.HelpNamespace = FwDirectoryFinder.CodeDirectory + m_helpProvider.GetHelpString("UserHelpFile");
                this.helpProvider.SetHelpKeyword(this, m_helpProvider.GetHelpString(s_helpTopicKey));
                this.helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            }
            m_xv          = CreateSummaryView(m_rghvo, m_cache, styleSheet);
            m_xv.Dock     = DockStyle.Top;              // panel1 is docked to the bottom.
            m_xv.TabStop  = true;
            m_xv.TabIndex = 0;
            Controls.Add(m_xv);
            m_xv.Height = panel1.Location.Y - m_xv.Location.Y;
            m_xv.Width  = this.Width - 15;            // Changed from magic to more magic on 8/8/2014
            m_xv.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            m_xv.EditingHelper.DefaultCursor       = Cursors.Arrow;
            m_xv.EditingHelper.VwSelectionChanged += new EventHandler <VwSelectionArgs>(m_xv_VwSelectionChanged);
        }
 private void UpdateXml(string section)
 {
     if (!XmlView.Contains(section))
     {
         XmlView.Add(section);
     }
 }
Esempio n. 3
0
		public void NoNodeFound()
		{
			string xml = "<root>\r\n" +
				"\t<foo/>\r\n" +
				"</root>";
			XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//bar");
			Assert.AreEqual(0, nodes.Length);
		}
Esempio n. 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a view with a single LexEntry object.
        /// </summary>
        /// <param name="hvoEntry"></param>
        /// <param name="cache"></param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public static XmlView MakeSummaryView(int hvoEntry, FdoCache cache, IVwStylesheet styleSheet)
        {
            XmlView xv = new XmlView(hvoEntry, "publishStem", null, false);

            xv.LoadFlexLayouts = true;
            xv.Cache           = cache;
            xv.StyleSheet      = styleSheet;
            return(xv);
        }
Esempio n. 5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a view with a single LexEntry object.
        /// </summary>
        /// <param name="hvoEntry"></param>
        /// <param name="cache"></param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public static XmlView MakeSummaryView(int hvoEntry, FdoCache cache, IVwStylesheet styleSheet, Mediator mediator)
        {
            XmlView xv = new XmlView(hvoEntry, "publishStem", null, false);

            xv.Cache      = cache;
            xv.StyleSheet = styleSheet;
            xv.Mediator   = mediator;
            return(xv);
        }
Esempio n. 6
0
		public void ProcessingInstructionNode()
		{
			string xml = "<root><?test processinstruction='1.0'?></root>";
			XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//processing-instruction()");
			XPathNodeMatch node = nodes[0];
			Assert.AreEqual("test", node.Value);
			Assert.AreEqual("<?test processinstruction='1.0'?>", node.DisplayValue);
			Assert.AreEqual(0, node.LineNumber);
			Assert.AreEqual(8, node.LinePosition);
		}
        public override void FixtureInit()
        {
            XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();

            schemas.Add(SchemaCompletionData);
            XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, SchemaCompletionData, String.Empty);
            string xml = "<note xmlns='http://www.w3schools.com'></note>";

            schemaElement = (XmlSchemaElement)XmlView.GetSchemaObjectSelected(xml, xml.IndexOf("note xmlns"), provider);
        }
Esempio n. 8
0
        /// <summary>
        /// CamlQuery のインスタンスを作成します。
        /// </summary>
        /// <param name="setQueryParameters">クエリパラメータ設定メソッド</param>
        /// <param name="limit">取得するアイテム数の上限値</param>
        /// <param name="viewFields">取得するフィールド名</param>
        /// <returns>作成した CamlQuery を返します。</returns>
        public static CamlQuery CreateQuery(Action <XmlView> setQueryParameters, int limit, IEnumerable <string> viewFields)
        {
            var xml = new XmlView(limit, viewFields)
            {
                RecursiveAll = true,
            };

            setQueryParameters?.Invoke(xml);

            return(xml.CreateQuery());
        }
Esempio n. 9
0
		public void EmptyCommentNode()
		{
			string xml = "<!----><root/>";
			XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()");
			XPathNodeMatch node = nodes[0];
			Assert.AreEqual(1, nodes.Length);
			Assert.AreEqual(0, node.LineNumber);
			Assert.AreEqual(4, node.LinePosition);
			Assert.AreEqual(String.Empty, node.Value);
			Assert.AreEqual("<!---->", node.DisplayValue);
		}
Esempio n. 10
0
		public void TextNode()
		{
			string xml = "<root>\r\n" +
				"\t<foo>test</foo>\r\n" +
				"</root>";
			XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//foo/text()");
			XPathNodeMatch node = nodes[0];
			Assert.AreEqual(1, nodes.Length);
			Assert.AreEqual(1, node.LineNumber);
			Assert.AreEqual(6, node.LinePosition);
			Assert.AreEqual("test", node.Value);
			Assert.AreEqual("test", node.DisplayValue);
		}
Esempio n. 11
0
		public void AttributeNode()
		{
			string xml = "<root>\r\n" +
				"\t<foo Id='ab'></foo>\r\n" +
				"</root>";
			XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//foo/@Id");
			XPathNodeMatch node = nodes[0];
			Assert.AreEqual(1, nodes.Length);
			Assert.AreEqual(1, node.LineNumber);
			Assert.AreEqual(6, node.LinePosition);
			Assert.AreEqual("Id", node.Value);
			Assert.AreEqual("@Id", node.DisplayValue);
		}
Esempio n. 12
0
		public void NamespaceNode()
		{
			string xml = "<root xmlns='http://foo.com'/>";
			XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*");
			XPathNodeMatch node = nodes[0];
			XPathNodeMatch xmlNamespaceNode = nodes[1];
			Assert.AreEqual(2, nodes.Length);
			Assert.AreEqual(0, node.LineNumber);
			Assert.AreEqual(6, node.LinePosition);
			Assert.AreEqual("xmlns=\"http://foo.com\"", node.Value);
			Assert.AreEqual("xmlns=\"http://foo.com\"", node.DisplayValue);
			Assert.IsFalse(xmlNamespaceNode.HasLineInfo());
			Assert.AreEqual("xmlns:xml=\"http://www.w3.org/XML/1998/namespace\"", xmlNamespaceNode.Value);
		}
Esempio n. 13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a view with multiple LexEntry objects.
        /// </summary>
        /// <param name="rghvoEntries"></param>
        /// <param name="cache"></param>
        /// <param name="styleSheet"></param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private XmlView CreateSummaryView(List <int> rghvoEntries, FdoCache cache, IVwStylesheet styleSheet)
        {
            IVwVirtualHandler vh = DummyVirtualHandler.InstallDummyHandler(cache.VwCacheDaAccessor,
                                                                           "LexDb", "EntriesFound", (int)FieldType.kcptReferenceSequence);

            m_flidDummy = vh.Tag;
            cache.VwCacheDaAccessor.CacheVecProp(cache.LangProject.LexDbOAHvo, m_flidDummy,
                                                 rghvoEntries.ToArray(), rghvoEntries.Count);
            XmlView xv = new XmlView(cache.LangProject.LexDbOAHvo, "publishFound", null, false);

            xv.LoadFlexLayouts = true;
            xv.Cache           = cache;
            xv.StyleSheet      = styleSheet;
            return(xv);
        }
Esempio n. 14
0
		public void OneElementNode()
		{
			string xml = "<root>\r\n" +
				"\t<foo/>\r\n" +
				"</root>";
			XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//foo");
			XPathNodeMatch node = nodes[0];
			IXmlLineInfo lineInfo = node as IXmlLineInfo;
			Assert.AreEqual(1, nodes.Length);
			Assert.AreEqual(1, node.LineNumber);
			Assert.AreEqual(2, node.LinePosition);
			Assert.AreEqual("foo", node.Value);
			Assert.AreEqual("<foo/>", node.DisplayValue);
			Assert.AreEqual(XPathNodeType.Element, node.NodeType);
			Assert.IsNotNull(lineInfo);
		}
Esempio n. 15
0
        public override void FixtureInit()
        {
            XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();

            schemas.Add(SchemaCompletionData);
            XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());

            schemas.Add(xsdSchemaCompletionData);
            XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty);

            string xml   = GetSchema();
            int    index = xml.IndexOf("ref=\"dir\"");

            index           = xml.IndexOf("dir", index);
            schemaAttribute = (XmlSchemaAttribute)XmlView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a view with multiple LexEntry objects.
        /// </summary>
        /// <param name="rghvoEntries"></param>
        /// <param name="cache"></param>
        /// <param name="styleSheet"></param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        private XmlView CreateSummaryView(List <int> rghvoEntries, FdoCache cache, IVwStylesheet styleSheet)
        {
            // Make a decorator to publish the list of entries as a fake property of the LexDb.
            int kflidEntriesFound = 8999950;             // some arbitrary number not conflicting with real flids.
            var sda     = new ObjectListPublisher(cache.DomainDataByFlid as ISilDataAccessManaged, kflidEntriesFound);
            int hvoRoot = RootHvo;

            sda.CacheVecProp(hvoRoot, rghvoEntries.ToArray());
            // The name of this property must match the property used by the publishFound layout.
            sda.SetOwningPropInfo(LexDbTags.kflidClass, "LexDb", "EntriesFound");

            // Make an XmlView which displays that object using the specified layout.
            XmlView xv = new XmlView(hvoRoot, "publishFound", null, false, sda);

            xv.Cache      = cache;
            xv.Mediator   = m_mediator;
            xv.StyleSheet = styleSheet;
            return(xv);
        }
Esempio n. 17
0
		public void ElementWithNamespacePrefix()
		{
			string xml = "<f:root xmlns:f='http://foo.com'>\r\n" +
				"\t<f:foo></f:foo>\r\n" +
				"</f:root>";
			List<XmlNamespace> namespaces = new List<XmlNamespace>();
			namespaces.Add(new XmlNamespace("fo", "http://foo.com"));
			ReadOnlyCollection<XmlNamespace> readOnlyNamespaces = new ReadOnlyCollection<XmlNamespace>(namespaces);
			XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//fo:foo", readOnlyNamespaces);
			XPathNodeMatch node = nodes[0];
			IXmlLineInfo lineInfo = node as IXmlLineInfo;
			Assert.AreEqual(1, nodes.Length);
			Assert.AreEqual(1, node.LineNumber);
			Assert.AreEqual(2, node.LinePosition);
			Assert.AreEqual("f:foo", node.Value);
			Assert.AreEqual("<f:foo>", node.DisplayValue);
			Assert.AreEqual(XPathNodeType.Element, node.NodeType);
			Assert.IsNotNull(lineInfo);
		}
Esempio n. 18
0
 public void StringPropIsMarked()
 {
     using (var view = new XmlView(m_hvoLexDb, "root", null, true, m_sda))
     {
         var vc = new XmlVc(null, "root", true, view, null, m_sda);
         vc.IdentifySource = true;
         vc.SetCache(Cache);
         vc.m_layouts  = m_layouts;
         vc.DataAccess = m_sda;
         var testEnv = new MockEnv()
         {
             DataAccess = m_sda, OpenObject = m_hvoLexDb
         };
         vc.Display(testEnv, m_hvoLexDb, XmlVc.kRootFragId);
         VerifySourceIdentified(testEnv.EventHistory, m_hvoKick, kflidEntry_Form, m_wsVern, "Entry:basic:Headword:HeadwordL");
         VerifyLabel(testEnv.EventHistory, m_hvoKick, kflidEntry_Form, m_wsVern, 1, ")", "Entry:basic:Headword:HeadwordL");
         VerifyLabel(testEnv.EventHistory, m_hvoKick, kflidEntry_Form, m_wsVern, -2, "head(", "Entry:basic:Headword:HeadwordL");
         VerifySourceIdentified(testEnv.EventHistory, m_hvoKick, kflidEntry_Summary, "Entry:basic:Summary:Sum.");
     }
 }
Esempio n. 19
0
        static void Main()
        {
            Tracer.Tracer.Start();

            Tracer.Tracer.BeginTrace();
            Tracer.Tracer.EndTrace();

            Tracer.Tracer.BeginTrace();
            Tracer.Tracer.BeginTrace();
            Tracer.Tracer.BeginTrace();

            Thread.Sleep(1000);

            var bgThread = new Thread(ThreadStart);
            bgThread.Start();

            OtherMethod();

            Mine();

            Tracer.Tracer.EndTrace();
            Tracer.Tracer.EndTrace();
            Tracer.Tracer.EndTrace();

            bgThread.Join();

            var wholeResult = Tracer.Tracer.Stop();
            View xmlView = new XmlView(wholeResult);
            Console.WriteLine("=============== XML Saving Start ===============\n");
            Console.WriteLine("Saved to file {0}",xmlView.Save());
            Console.WriteLine("\n=============== XML Saving Stop ================");

            View consoleView = new ConsoleView(wholeResult);
            Console.WriteLine("\n=============== Console Saving Start ===============");
            Console.WriteLine(consoleView.Save());
            Console.WriteLine("=============== Console Saving Stop ================");

            // Здесь должен находится код по форматированному выводу результатов.

            Console.ReadKey();
        }
Esempio n. 20
0
        private void AddConfigurableControls()
        {
            // Load the controls.

            // 1. Initialize the preview pane (lower pane)
            m_previewPane            = new XmlView(0, "publicationNew", false);
            m_previewPane.Cache      = m_cache;
            m_previewPane.StyleSheet = FontHeightAdjuster.StyleSheetFromPropertyTable(m_propertyTable);

            BasicPaneBarContainer pbc = new BasicPaneBarContainer();

            pbc.Init(m_mediator, m_propertyTable, m_previewPane);
            pbc.Dock         = DockStyle.Fill;
            pbc.PaneBar.Text = LexEdStrings.ksFindExampleSentenceDlgPreviewPaneTitle;
            panel2.Controls.Add(pbc);
            if (m_previewPane.RootBox == null)
            {
                m_previewPane.MakeRoot();
            }

            // 2. load the browse view. (upper pane)
            XmlNode xnBrowseViewControlParameters = this.BrowseViewControlParameters;

            // First create our Clerk, since we can't set it's OwningObject via the configuration/mediator/PropertyTable info.
            m_clerk = RecordClerkFactory.CreateClerk(m_mediator, m_propertyTable, xnBrowseViewControlParameters, true);
            m_clerk.OwningObject = m_owningSense;

            m_rbv = DynamicLoader.CreateObject(xnBrowseViewControlParameters.ParentNode.SelectSingleNode("dynamicloaderinfo")) as ConcOccurrenceBrowseView;
            m_rbv.Init(m_mediator, m_propertyTable, xnBrowseViewControlParameters, m_previewPane, m_clerk.VirtualListPublisher);
            m_rbv.CheckBoxChanged += m_rbv_CheckBoxChanged;
            // add it to our controls.
            BasicPaneBarContainer pbc1 = new BasicPaneBarContainer();

            pbc1.Init(m_mediator, m_propertyTable, m_rbv);
            pbc1.BorderStyle  = BorderStyle.FixedSingle;
            pbc1.Dock         = DockStyle.Fill;
            pbc1.PaneBar.Text = LexEdStrings.ksFindExampleSentenceDlgBrowseViewPaneTitle;
            panel1.Controls.Add(pbc1);

            CheckAddBtnEnabling();
        }
Esempio n. 21
0
        private void m_view_SelChanged(object sender, EventArgs e)
        {
            // Todo: create or update XmlView of selected word if any.
            using (LexEntryUi leui = GetSelWord())
            {
                bool fEnable = m_view.GotRangeSelection && leui != null;
                m_btnCopy.Enabled   = fEnable;
                m_btnInsert.Enabled = fEnable;
                m_btnLookup.Enabled = fEnable;

                if (leui == null)
                {
                    return;
                }
                if (m_detailView == null)
                {
                    // Give the detailView the bottom 1/3 of the available height.
                    this.SuspendLayout();
                    int totalHeight = m_view.Height;
                    m_view.Height       = totalHeight * 2 / 3;
                    m_detailView        = MakeSummaryView(leui.Object.Hvo, m_cache, m_styleSheet, m_mediator);
                    m_detailView.Left   = m_view.Left;
                    m_detailView.Width  = m_view.Width;
                    m_detailView.Top    = m_view.Bottom + 5;
                    m_detailView.Height = totalHeight / 3;
                    m_detailView.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
                    m_detailView.EditingHelper.DefaultCursor = Cursors.Arrow;
                    this.Controls.Add(m_detailView);
                    this.ResumeLayout();
                    // JohnT: I'm not sure why this is needed here and not
                    // elsewhere, but without it, the root box somehow never
                    // receives an OnSizeChanged call and never actually
                    // constructs.
                    m_detailView.RootBox.Reconstruct();
                }
                else
                {
                    m_detailView.RootObjectHvo = leui.Object.Hvo;
                }
            }
        }
        public void OneNodeMarked()
        {
            string xml = "<root><foo/></root>";

            XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//root");

            IDocument doc = MockDocument.Create();

            doc.TextContent = xml;
            MarkerStrategy markerStrategy = new MarkerStrategy(doc);

            XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);

            List <TextMarker> markers = new List <TextMarker>();

            foreach (TextMarker marker in markerStrategy.TextMarker)
            {
                markers.Add(marker);
            }

            // Remove markers.
            XPathNodeTextMarker.RemoveMarkers(markerStrategy);
            List <TextMarker> markersAfterRemove = new List <TextMarker>();

            foreach (TextMarker markerAfterRemove in markerStrategy.TextMarker)
            {
                markers.Add(markerAfterRemove);
            }

            XPathNodeTextMarker xpathNodeTextMarker = (XPathNodeTextMarker)markers[0];

            Assert.AreEqual(1, markers.Count);
            Assert.AreEqual(1, xpathNodeTextMarker.Offset);
            Assert.AreEqual(4, xpathNodeTextMarker.Length);
            Assert.AreEqual(TextMarkerType.SolidBlock, xpathNodeTextMarker.TextMarkerType);
            Assert.AreEqual(0, markersAfterRemove.Count);
            Assert.AreEqual(XPathNodeTextMarker.MarkerBackColor, xpathNodeTextMarker.Color);
        }
        public void SetUp()
        {
            MockOpenedFile openedFile = new MockOpenedFile("test.xml");
            XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();

            xmlView = new XmlView(new DefaultTextEditorProperties(), schemas);
            xmlView.SetPrimaryFileUnitTestMode(openedFile);
            view = new XmlTreeView(xmlView, null, null);
            treeViewContainer = (XmlTreeViewContainerControl)view.Control;
            treeView          = treeViewContainer.TreeView;
            clipboardHandler  = view as IClipboardHandler;

            xmlView.XmlEditor.Text = "<html><body><p></p></body></html>";
            openedFile.SwitchToView(view);

            htmlTreeNode = treeView.Nodes[0] as XmlElementTreeNode;
            htmlTreeNode.PerformInitialization();
            bodyTreeNode = htmlTreeNode.Nodes[0] as XmlElementTreeNode;
            bodyTreeNode.PerformInitialization();
            paragraphTreeNode = bodyTreeNode.Nodes[0] as XmlElementTreeNode;

            treeView.SelectedNode = null;
        }
        public void NamespaceQuery()
        {
            string xml = "<?xml version='1.0'?>\r\n" +
                         "<Xml1></Xml1>";

            XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*");

            IDocument doc = MockDocument.Create();

            doc.TextContent = xml;
            MarkerStrategy markerStrategy = new MarkerStrategy(doc);

            XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);

            List <TextMarker> markers = new List <TextMarker>();

            foreach (TextMarker marker in markerStrategy.TextMarker)
            {
                markers.Add(marker);
            }
            Assert.AreEqual(0, markers.Count);
            Assert.AreEqual(1, nodes.Length);
        }
        public void EmptyCommentNode()
        {
            string xml = "<!----><root/>";

            XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()");

            IDocument doc = MockDocument.Create();

            doc.TextContent = xml;
            MarkerStrategy markerStrategy = new MarkerStrategy(doc);

            XPathNodeTextMarker.AddMarkers(markerStrategy, nodes);

            List <TextMarker> markers = new List <TextMarker>();

            foreach (TextMarker marker in markerStrategy.TextMarker)
            {
                markers.Add(marker);
            }

            Assert.AreEqual(0, markers.Count);
            Assert.AreEqual(1, nodes.Length);
        }
Esempio n. 26
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
                if (m_view != null && !Controls.Contains(m_view))
                {
                    m_view.Dispose();
                }
                if (m_detailView != null && !Controls.Contains(m_detailView))
                {
                    m_detailView.Dispose();
                }
            }
            m_sel        = null;
            m_cache      = null;
            m_view       = null;
            m_detailView = null;
            if (m_cdaTemp != null)
            {
                m_cdaTemp.ClearAllData();
                Marshal.ReleaseComObject(m_cdaTemp);
                m_cdaTemp = null;
            }

            base.Dispose(disposing);
        }
Esempio n. 27
0
 internal void Init(Mediator mediator, XmlNode xnBrowseViewControlParameters, XmlView pubView)
 {
     m_previewPane = pubView;
     base.Init(mediator, xnBrowseViewControlParameters);
 }
Esempio n. 28
0
		private void SetupSecondaryView ()
		{
			xmlView = new XmlView(generator,this);
			SecondaryViewContents.Add(xmlView);
			preview = new ReportPreview(loader,this);
			SecondaryViewContents.Add(preview);
			reportViewer = new ReportViewerSecondaryView(loader,this);
			SecondaryViewContents.Add(reportViewer);
			
			var p = new WPFReportPreview(loader,this);
			SecondaryViewContents.Add(p);
			
		}
        public String Index(String date, String timezone, double latitude, double longitude, double elevation, String timeformat, String format, String mode)
        {
            //if any of the parameters are empty then return a error saying parameters are missing
            if (date == "")
            {
                Console.WriteLine("date is missing, using todays date");
            }
            if (latitude == 0.0)
            {
                return("Error: latitude is a required parameter");
            }
            if (longitude == 0.0)
            {
                return("Error: longitude is a required parameter");
            }
            //check if the timezone is valid
            try
            {
                ITimeZone timeZone = new WindowsTimeZone(timezone);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Time zone is invalid returning error " + ex.Message);
                return("The time zone you have submitted is not valid. Time zones should be formatted like America/New_York");
            }

            //create a general try catch to prevent major errors
            try
            {
                //create a model to pass to the zmanimService
                ZmanimModel model = new ZmanimModel();
                //store the controller params in the model
                model.latitude   = latitude;
                model.longitude  = longitude;
                model.elevation  = elevation;
                model.mode       = mode;
                model.timeformat = timeformat;
                model.timezone   = timezone;
                //check if the date is parsable, if its not then set the model date to null
                DateTime theDate;
                if (DateTime.TryParse(date, out theDate))
                {
                    model.date = theDate;
                }
                else
                {
                    model.date = null;
                }
                //now pass the model to the zmanim service
                ZmanimService service = new ZmanimService(model);
                //make sure format is instantiated, if its not then instantiate it
                if (format == null)
                {
                    format = "json";
                }
                //pass the model to the view and return the view
                //choose the view based on the format parameter
                if (format.ToLower() == "xml")
                {
                    XmlView view = new XmlView(model);
                    return(view.getView());
                }
                else
                { //use json as the default format
                    JsonView view = new JsonView(model);
                    return(view.getView());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error:" + ex.Message);
                //return a error message
                return("There was a error generating the zmanim, please ensure all of your input parameters are correct and try again later");
            }
        }
Esempio n. 30
0
        private ISilDataAccess m_decoratedSda; // typically a ConcSda, understands the segment property of the fake HVO.

        internal void Init(Mediator mediator, PropertyTable propertyTable, XmlNode xnBrowseViewControlParameters, XmlView pubView, ISilDataAccess sda)
        {
            m_previewPane  = pubView;
            m_decoratedSda = sda;
            base.Init(mediator, propertyTable, xnBrowseViewControlParameters);
        }
		private void SetupSecondaryView ()
		{
			Console.WriteLine("SetupSecondaryView ()");
			
			xmlView = new XmlView(generator,this);
			SecondaryViewContents.Add(xmlView);
			
			reportPreview = new ReportPreview(loader,this);
			SecondaryViewContents.Add(reportPreview);
			
			reportViewer = new ReportViewerSecondaryView(loader,this);
			SecondaryViewContents.Add(reportViewer);
			
//			var wpfViewer = new WPFReportPreview(loader,this);
//			SecondaryViewContents.Add(wpfViewer);
			
//			testView = new TestWPFReportPreview(loader,this);
//			SecondaryViewContents.Add(testView);
			
		}
        private void loadViews()
        {
            XmlNodeList views = viewsXml.SelectNodes("/views/view");
              foreach (XmlElement viewEl in views)
              {
            int id = Convert.ToInt32(viewEl.GetAttribute("id"));
            XmlView view = new XmlView(id);

            XmlElement descriptionEl = (XmlElement)viewEl.SelectSingleNode("description");
            if (descriptionEl != null)
              view.Description = descriptionEl.InnerText;

            Views.Add(view);
            XmlNodeList loops = viewEl.SelectNodes("loop");
            foreach (XmlElement loopEl in loops)
            {
              XmlLoop loop = new XmlLoop();
              view.Loops.Add(loop);
              XmlNodeList cels = loopEl.SelectNodes("cel");
              foreach (XmlElement celEl in cels)
              {
            int width = Convert.ToInt32(celEl.GetAttribute("width"));
            int height = Convert.ToInt32(celEl.GetAttribute("height"));
            XmlCel cel = new XmlCel(width, height);
            loop.Add(cel);
              }
            }
              }
        }