Пример #1
0
 public static void Init(XElement inputXml)
 {
     if (inputXml != null)
     {
         if (GuiTimeout._instance == null)
         {
             GuiTimeout._instance = new GuiTimeout();
         }
         GuiTimeout._instance.LoadXml(inputXml);
     }
 }
Пример #2
0
        private void LoadXml(XElement SourceXml)
        {
            XElement x;
            TsPage   currPage = null;
            TsPage   prevPage = null;

            IEnumerable <XElement> pagesXml;

            if (SourceXml != null)
            {
                this._debug    = XmlHandler.GetBoolFromXAttribute(SourceXml, "Debug", this._debug);
                this._livedata = XmlHandler.GetBoolFromXAttribute(SourceXml, "LiveData", this._livedata);

                //Set show grid lines after pages and columns have been created.
                x = SourceXml.Element("ShowGridLines");
                if ((x != null) && (this._prodmode == false))
                {
                    this.ShowGridLines = true;
                }

                x = SourceXml.Element("UseTouchDefaults");
                if (x != null)
                {
                    this.UseTouchDefaults = true;
                }

                //turn hardware eval on or off
                x = SourceXml.Element("HardwareEval");
                if (x != null)
                {
                    this._hardwareevaluator = new HardwareEvaluator();
                }

                //start layout import
                this.TsMainWindow = new TsMainWindow(this.ParentWindow, SourceXml);

                this._buttons = new TsButtons();
                this._buttons.LoadXml(SourceXml.Element("Buttons"));

                PageDefaults pagedef = new PageDefaults();

                x = SourceXml.Element("Heading");
                if (x != null)
                {
                    pagedef.PageHeader = new TsPageHeader(this.TsMainWindow, x);
                }
                else
                {
                    pagedef.PageHeader = new TsPageHeader();
                }

                x = SourceXml.Element("LeftPane");
                if (x != null)
                {
                    pagedef.LeftPane = new TsPane(x);
                }
                else
                {
                    pagedef.LeftPane = new TsPane();
                }

                x = SourceXml.Element("RightPane");
                if (x != null)
                {
                    pagedef.RightPane = new TsPane(x);
                }
                else
                {
                    pagedef.RightPane = new TsPane();
                }

                pagedef.Buttons    = this._buttons;
                pagedef.MainWindow = this.TsMainWindow;


                this.TsMainWindow.LoadXml(SourceXml);
                GuiTimeout.Init(SourceXml.Element("Timeout"));

                foreach (XElement xauth in SourceXml.Elements("Authentication"))
                {
                    this._authlibrary.AddAuthenticator(AuthenticationFactory.GetAuthenticator(xauth));
                }

                //now read in the options and add to a dictionary for later use
                pagesXml = SourceXml.Elements("Page");
                if (pagesXml != null)
                {
                    //Debug.WriteLine("pagesXml not null");
                    foreach (XElement xPage in pagesXml)
                    {
                        #region
                        //Debug.WriteLine("creating new page");
                        if (currPage != null)
                        {
                            //record the last page as the prevPage
                            prevPage = currPage;
                            currPage = new TsPage(this.TsMainWindow, xPage, pagedef);
                        }
                        else
                        {
                            currPage         = new TsPage(this.TsMainWindow, xPage, pagedef);
                            currPage.IsFirst = true;
                        }

                        //create the new page and assign the next page/prev page links
                        currPage.PreviousPage = prevPage;
                        if (prevPage != null)
                        {
                            prevPage.NextPage = currPage;
                        }

                        this._pages.Add(currPage);
                        currPage.Page.Loaded += this.OnWindowLoaded;
                        #endregion
                    }

                    //currPage.IsLast = true;
                }

                x = SourceXml.Element("NoUI");
                if (x != null)
                {
                    this._nouicontainer = new NoUIContainer(x);
                }
            }

            LoggerFacade.Info("Config load finished");
            this.ConfigLoadFinished?.Invoke(this, null);
        }