Exemple #1
0
        public Page4Html(UIServiceWpfApp app)
        {
            Debug.Assert(null != app);
            m_application = app;

            // m_clickHandler = (System.Windows.Forms.HtmlElementEventHandler)Delegate.CreateDelegate(typeof(System.Windows.Forms.HtmlElementEventHandler), this, "OnClicked");
            m_mouseDownHandler   = (System.Windows.Forms.HtmlElementEventHandler)Delegate.CreateDelegate(typeof(System.Windows.Forms.HtmlElementEventHandler), this, "OnLeftButtonDown");
            m_contextMenuHandler = (System.Windows.Forms.HtmlElementEventHandler)Delegate.CreateDelegate(typeof(System.Windows.Forms.HtmlElementEventHandler), this, "OnContextMenuShow");
            m_mouseUpHandler     = (System.Windows.Forms.HtmlElementEventHandler)Delegate.CreateDelegate(typeof(System.Windows.Forms.HtmlElementEventHandler), this, "OnLeftButtonUp");

            InitializeComponent();

            //setup handlers for creating screen element
            m_dicScreenElementCreator.Add(s_buttonValue, CreateButtonElement);
            m_dicScreenElementCreator.Add(s_countDownValue, CreateCountDownElement);
            m_dicScreenElementCreator.Add(s_textValue, CreateInputElement);
            m_dicScreenElementCreator.Add(s_passwordValue, CreateInputElement);
            m_dicScreenElementCreator.Add(s_textblockValue, CreateInputElement);
            m_dicScreenElementCreator.Add(s_selectValue, CreateSelectElement);
            m_dicScreenElementCreator.Add(s_listValue, CreateListElement);

            m_frontWebBrowser = htmlrender1;
//            m_backWebBrowser = htmlrender2;
            webbrowser1.Visibility = Visibility.Visible;
            //       webbrowser2.Visibility = Visibility.Hidden;
            //       m_curWebBrowser = m_frontWebBrowser;

            //setup event handlers
            m_frontWebBrowser.DocumentCompleted += OnDocumentCompleted;
            m_frontWebBrowser.Navigating        += OnNavigating;
            m_frontWebBrowser.Navigated         += OnNavigated;

            m_dataPropChangedHander = new Action <string>(OnPropertyChanged);

            //m_backWebBrowser.DocumentCompleted += OnDocumentCompleted;
            //m_backWebBrowser.Navigating += OnNavigating;
            //m_backWebBrowser.Navigated += OnNavigated;
        }
Exemple #2
0
        public Screen LoadScreen(string strName,
                                 UIServiceWpfApp argApp = null)
        {
            Debug.Assert(!string.IsNullOrEmpty(strName) && null != m_objDoc);

            LogProcessorService.Log.UIService.LogDebugFormat("Prepare for loading the screen with name [{0}]", strName);
            string strScr = string.Format(@"/{0}/{1}/{2}[@name='{3}']", UIServiceCfgDefines.s_WndNode, UIServiceCfgDefines.s_ScreensNode, UIServiceCfgDefines.s_ScreenNode, strName);
            //LogProcessorService.Log.UIService.LogDebugFormat("The xpath value is {0}", strScr);

            XmlNode objNode = m_objDoc.SelectSingleNode(strScr);

            if (null == objNode)
            {
                LogProcessorService.Log.UIService.LogWarnFormat("The screen [{0}] isn't exist", strName);
                return(null);
            }

            //
            string strUrl           = null;
            string strPath          = null;
            string strSite          = null;
            string subSite          = null;
            string needClearElement = null;
            bool   needCache        = true;
            //bool validationEnable = false;
            XmlAttribute objAttri = objNode.Attributes[UIServiceCfgDefines.s_UriAttri];

            if (null != objAttri)
            {
                strUrl = objAttri.Value;
                //LogProcessorService.Log.UIService.LogDebugFormat("The url of a page is {0}", strUrl);
            }
            else
            {
                throw new Exception("The url of a page must be exists");
            }

            bool bHtml = IsHtml(strUrl);
            bool bXaml = IsXaml(strUrl);

            if (!bHtml &&
                !bXaml)
            {
                return(null);
            }
            if (bHtml)
            {
                strUrl = strUrl.Replace(@"\", @"/");
            }

            objAttri = objNode.Attributes[UIServiceCfgDefines.s_SiteAttri];
            if (null != objAttri)
            {
                strSite = objAttri.Value;
            }
            objAttri = objNode.Attributes[UIServiceCfgDefines.s_subSiteAttri];
            if (null != objAttri)
            {
                subSite = objAttri.Value;
            }
            objAttri = objNode.Attributes[UIServiceCfgDefines.s_cacheAttri];
            if (null != objAttri &&
                !string.IsNullOrEmpty(objAttri.Value))
            {
                int temp = 0;
                if (int.TryParse(objAttri.Value, out temp))
                {
                    needCache = temp == 0 ? false : true;
                }
            }

            if (needCache)
            {
                objAttri = objNode.Attributes[UIServiceCfgDefines.s_needClearElementAttri];
                if (null != objAttri &&
                    !string.IsNullOrEmpty(objAttri.Value))
                {
                    needClearElement = objAttri.Value;
                }
            }
            //objAttri = objNode.Attributes[UIServiceCfgDefines.s_validationEnableAttri];
            //if ( null != objAttri &&
            //     !string.IsNullOrEmpty(objAttri.Value) )
            //{
            //    int temp = 0;
            //    if ( int.TryParse( objAttri.Value, out temp ) )
            //    {
            //        validationEnable = temp == 0 ? false : true;
            //    }
            //}
            //else
            //{
            //    strSite = SiteOfScreens;
            //}
            //LogProcessorService.Log.UIService.LogDebugFormat("The site of a page is {0}", strSite);

            //            objAttri = objNode.Attributes[s_PathAttri];
            //if ( null != objAttri )
            //{
            //    strPath = AppDomain.CurrentDomain.BaseDirectory + objAttri.Value;
            //}
            //else
            //{
            if (bHtml)
            {
                strPath = basePath4Html;
            }
            else if (bXaml)
            {
                strPath = basePath4Xaml;
            }
            string configPath = strPath;
            string dir        = string.Format(@"{0}{1}/", strPath, this.ResouceManager.CurrentUILanguage);
            Uri    uri        = new Uri(dir);

            if (uri.IsFile)
            {
                string localPath = uri.LocalPath;
                if (Directory.Exists(localPath))
                {
                    strPath = dir;
                }
            }
            //           }
            //LogProcessorService.Log.UIService.LogDebugFormat("The path of a page is {0}", strPath);

            Screen Scr = null;

            if (bHtml)
            {
                Scr = new htmlScreen()
                {
                    Name       = strName,
                    Path       = strPath,
                    Url        = strUrl,
                    Site       = strSite,
                    SubSite    = subSite,
                    NeedCache  = needCache,
                    ConfigPath = configPath
                };
            }
            else if (bXaml)
            {
                //Scr = new XamlScreen()
                //{
                //    Name = strName,
                //    Path = strPath,
                //    Url = strUrl,
                //    Site = strSite,
                //    SubSite = subSite,
                //    NeedCache = needCache,
                //    ConfigPath = configPath
                //};
            }
            Scr.App            = argApp;
            Scr.ResouceManager = this.ResouceManager;
            //Screen objScr = new Screen()
            //{
            //    Name = strName,
            //    Path = strPath,
            //    Url = strUrl,
            //    Site = strSite
            //};
            if (needCache &&
                !string.IsNullOrEmpty(needClearElement))
            {
                string[] arrElements = needClearElement.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in arrElements)
                {
                    Scr.AddNeedClearElement(item);
                }
            }

            //load storyboards of a screen.
            XmlNode storyboards = objNode.SelectSingleNode(UIServiceCfgDefines.s_storyboardsNode);

            if (null != storyboards)
            {
                LoadStoryboards(storyboards, Scr);
            }

            //load triggers of a screen
            XmlNode triggers = objNode.SelectSingleNode(UIServiceCfgDefines.s_TriggersNode);

            if (null != triggers)
            {
                LoadTriggers(triggers, Scr);
            }

            //load data template of a screen
            XmlNode templates = objNode.SelectSingleNode(UIServiceCfgDefines.s_templatesNode);

            if (null != templates)
            {
                LoadTemplates(templates, Scr);
            }

            //LogProcessorService.Log.UIService.LogInfoFormat("Success to load a screen with name [{0}] from a configuration file", strName);

            return(Scr);
        }