当前位置: 首页>>代码示例>>C#>>正文


C# DashboardHelper.CreateFromXml方法代码示例

本文整理汇总了C#中DashboardHelper.CreateFromXml方法的典型用法代码示例。如果您正苦于以下问题:C# DashboardHelper.CreateFromXml方法的具体用法?C# DashboardHelper.CreateFromXml怎么用?C# DashboardHelper.CreateFromXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DashboardHelper的用法示例。


在下文中一共展示了DashboardHelper.CreateFromXml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateFromXml

        private void CreateFromXml(string fileName)
        {
            gadgetXmlElement = null;
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(fileName);

            foreach (System.Xml.XmlElement element in doc.DocumentElement.ChildNodes)
            {
                if (element.Name.ToLower().Equals("dashboardhelper"))
                {
                    DashboardHelper helper = new DashboardHelper();
                    helper.NotificationEvent += new NotificationEventHandler(dashboardHelper_NotificationEvent);
                    helper.IsAutoClosing = this.IsGeneratingHTMLFromCommandLine;

                    foreach (System.Xml.XmlElement child in element.ChildNodes)
                    {
                        // Check to see if PRJ file exists and if not, prompt the user that this is the case; then offer to select a new PRJ file.
                        if (child.Name.Equals("projectPath") && !string.IsNullOrEmpty(child.InnerText))
                        {
                            FileInfo fiProject = new FileInfo(child.InnerText);
                            FileInfo fiCanvas = new FileInfo(fileName);
                            string projectPath = child.InnerText;

                            if (File.Exists(fiCanvas.Directory + "\\" + fiProject.Name))
                            {
                                projectPath = fiCanvas.Directory + "\\" + fiProject.Name;
                                child.InnerText = projectPath;
                            }
                            else if (!System.IO.File.Exists(child.InnerText))
                            {
                                string message = string.Format(DashboardSharedStrings.ERROR_PROJECT_NOT_FOUND_FOR_CANVAS, child.InnerText);
                                Epi.Windows.MsgBox.ShowError(message);

                                System.Windows.Forms.OpenFileDialog projectDialog = new System.Windows.Forms.OpenFileDialog();
                                projectDialog.Filter = "Epi Info 7 Project File|*.prj";

                                System.Windows.Forms.DialogResult projectDialogResult = projectDialog.ShowDialog();

                                if (projectDialogResult == System.Windows.Forms.DialogResult.OK)
                                {
                                    child.InnerText = projectDialog.FileName;
                                }
                                else
                                {
                                    return;
                                }
                            }
                        }
                        else if (child.Name.Equals("connectionString") && !string.IsNullOrEmpty(child.InnerText))
                        {
                            string connStr;

                            try
                            {
                                connStr = Configuration.Decrypt(child.InnerText);
                            }
                            catch (System.Security.Cryptography.CryptographicException)
                            {
                                Epi.Windows.MsgBox.ShowError(DashboardSharedStrings.ERROR_CANNOT_DECRYPT);
                                return;
                            }

                            if (connStr.ToLower().StartsWith("provider=microsoft.ace") || connStr.ToLower().StartsWith("provider=microsoft.jet.oledb"))
                            {
                                string filePath = string.Empty;

                                int indexOf = connStr.IndexOf("Data Source=");

                                if (indexOf >= 0)
                                {
                                    indexOf += 12;
                                    filePath = connStr.Substring(indexOf, connStr.Length - indexOf);

                                    bool isTextFile = filePath.ToLower().Contains("text;");

                                    if (filePath.ToLower().Contains("extended properties"))
                                    {
                                        indexOf = filePath.IndexOf(';');
                                        if (indexOf >= 0)
                                        {
                                            filePath = filePath.Substring(0, indexOf);
                                        }
                                    }
                                    filePath = filePath.TrimStart('\"');
                                    filePath = filePath.TrimEnd('\"');

                                    FileInfo fiDataSource = new FileInfo(filePath);
                                    FileInfo fiCanvas = new FileInfo(fileName);
                                    string dsPath = filePath;

                                    if (File.Exists(fiCanvas.Directory + "\\" + fiDataSource.Name))
                                    {
                                        dsPath = fiCanvas.Directory + "\\" + fiDataSource.Name;
                                        child.InnerText = Configuration.Encrypt(dsPath);
                                    }
                                    else if (!System.IO.File.Exists(dsPath) && !isTextFile)
                                    {
                                        string message = string.Format(DashboardSharedStrings.ERROR_CANVAS_DATA_SOURCE_NOT_FOUND, dsPath);
                                        Epi.Windows.MsgBox.ShowError(message);
                                        return;
//.........这里部分代码省略.........
开发者ID:NALSS,项目名称:epiinfo-82474,代码行数:101,代码来源:DashboardControl.xaml.cs

示例2: OpenMap

        public void OpenMap(string filePath)
        {
            ClearGraphics();
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(filePath);
            Stack<System.Xml.XmlElement> elementStack = new Stack<System.Xml.XmlElement>();

            foreach (System.Xml.XmlElement element in doc.DocumentElement.ChildNodes)
            {
                elementStack.Push(element);
            }
            while (elementStack.Count > 0)
            {
                System.Xml.XmlElement element = elementStack.Pop();
                if (element.Name.Equals("referenceLayer"))
                {
                    ILayerProperties layerProperties = (ILayerProperties)Activator.CreateInstance(Type.GetType(element.Attributes["layerType"].Value), new object[] { myMap });
                    layerProperties.MakeReadOnly();
                    layerProperties.CreateFromXml(element);
                    layerList.AddListItem(layerProperties, 0);
                }
                if (element.Name.Equals("graphicsLayer"))
                {
                    ILayerProperties layerProperties = (ILayerProperties)Activator.CreateInstance(Type.GetType(element.Attributes["layerType"].Value), new object[] { myMap, new MapPoint(double.Parse(element.Attributes["locationX"].Value), double.Parse(element.Attributes["locationY"].Value)) });
                    layerProperties.MakeReadOnly();
                    layerProperties.CreateFromXml(element);
                    layerList.AddListItem(layerProperties, 0);
                }
                if (element.Name.Equals("dataLayer"))
                {
                    DashboardHelper helper = new DashboardHelper();
                    string dataLayerConn = string.Empty;
                    string dataLayerTable = string.Empty;

                    foreach (System.Xml.XmlElement child in element.ChildNodes)
                    {
                        if (child.Name.Equals("dashboardHelper"))
                        {
                            helper.CreateFromXml(child);
                            helper.PopulateDataSet();
                        }
                    }

                    ILayerProperties layerProperties = (ILayerProperties)Activator.CreateInstance(Type.GetType(element.Attributes["layerType"].Value), new object[] { myMap, helper, this });
                    layerProperties.MakeReadOnly();
                    layerProperties.FilterRequested += new EventHandler(ILayerProperties_FilterRequested);
                    layerProperties.MapGenerated += new EventHandler(ILayerProperties_MapGenerated);
                    layerProperties.CreateFromXml(element);
                    layerList.AddListItem(layerProperties, 0);
                }
            }
            if (doc.DocumentElement.Attributes.Count > 0)
            {
                string baseMapType = doc.DocumentElement.Attributes["baseMapType"].Value;
                if (baseMapType.Equals("street"))
                {
                    ToggleStreet();
                }
                else if (baseMapType.Equals("satellite"))
                {
                    ToggleSatellite();
                }
                else
                {
                    ToggleBlank();
                }
            }
        }
开发者ID:NALSS,项目名称:epiinfo-82474,代码行数:68,代码来源:StandaloneMapControl.xaml.cs

示例3: CreateFromXml

        private void CreateFromXml(string fileName)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(fileName);

            bool isLegacyCanvas = false;
            if (doc.InnerXml.Contains("EpiDashboard."))
            {
                isLegacyCanvas = true;
                doc.InnerXml = doc.InnerXml.Replace("EpiDashboard.", "Epi.WPF.Dashboard.");
            }

            foreach (System.Xml.XmlElement element in doc.DocumentElement.ChildNodes)
            {
                if (element.Name.ToLower().Equals("dashboardhelper"))
                {
                    DashboardHelper helper = new DashboardHelper();
                    helper.NotificationEvent += new NotificationEventHandler(dashboardHelper_NotificationEvent);

                    foreach (System.Xml.XmlElement child in element.ChildNodes)
                    {
                        // Check to see if PRJ file exists and if not, prompt the user that this is the case; then offer to select a new PRJ file.
                        if (child.Name.Equals("projectPath") && !string.IsNullOrEmpty(child.InnerText))
                        {
                            FileInfo fiProject = new FileInfo(child.InnerText);
                            FileInfo fiCanvas = new FileInfo(fileName);
                            string projectPath = child.InnerText;

                            if (File.Exists(fiCanvas.Directory + "\\" + fiProject.Name))
                            {
                                projectPath = fiCanvas.Directory + "\\" + fiProject.Name;
                                child.InnerText = projectPath;
                            }
                            else if (!System.IO.File.Exists(child.InnerText))
                            {
                                string message = string.Format(DashboardSharedStrings.ERROR_PROJECT_NOT_FOUND_FOR_CANVAS, child.InnerText);
                                Epi.WPF.Dashboard.Dialogs.MsgBox.ShowError(message);

                                System.Windows.Forms.OpenFileDialog projectDialog = new System.Windows.Forms.OpenFileDialog();
                                projectDialog.Filter = "Epi Info 7 Project File|*.prj";

                                System.Windows.Forms.DialogResult projectDialogResult = projectDialog.ShowDialog();

                                if (projectDialogResult == System.Windows.Forms.DialogResult.OK)
                                {
                                    child.InnerText = projectDialog.FileName;
                                }
                                else
                                {
                                    return;
                                }
                            }
                        }
                        else if (child.Name.Equals("connectionString") && !string.IsNullOrEmpty(child.InnerText))
                        {
                            string connStr;

                            try
                            {
                                connStr = Configuration.Decrypt(child.InnerText);
                            }
                            catch (System.Security.Cryptography.CryptographicException)
                            {
                                Epi.WPF.Dashboard.Dialogs.MsgBox.ShowError(DashboardSharedStrings.ERROR_CANNOT_DECRYPT);
                                return;
                            }

                            if (connStr.ToLower().StartsWith("provider=microsoft.ace") || connStr.ToLower().StartsWith("provider=microsoft.jet.oledb"))
                            {
                                string filePath = string.Empty;

                                int indexOf = connStr.IndexOf("Data Source=");

                                if (indexOf >= 0)
                                {
                                    indexOf += 12;
                                    filePath = connStr.Substring(indexOf, connStr.Length - indexOf);

                                    if (filePath.ToLower().Contains("extended properties"))
                                    {
                                        indexOf = filePath.IndexOf(';');
                                        if (indexOf >= 0)
                                        {
                                            filePath = filePath.Substring(0, indexOf);
                                        }
                                    }
                                    filePath = filePath.TrimStart('\"');
                                    filePath = filePath.TrimEnd('\"');

                                    FileInfo fiDataSource = new FileInfo(filePath);
                                    FileInfo fiCanvas = new FileInfo(fileName);
                                    string dsPath = filePath;

                                    if (File.Exists(fiCanvas.Directory + "\\" + fiDataSource.Name))
                                    {
                                        dsPath = fiCanvas.Directory + "\\" + fiDataSource.Name;
                                        child.InnerText = Configuration.Encrypt(dsPath);
                                    }
                                    else if (!System.IO.File.Exists(dsPath))
                                    {
//.........这里部分代码省略.........
开发者ID:NALSS,项目名称:epiinfo-82474,代码行数:101,代码来源:DashboardControl.xaml.cs


注:本文中的DashboardHelper.CreateFromXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。