public void LoadXml(String xmlFile, Boolean refLoad = false)
        {
            _filePath = xmlFile;
            if (_filePath.LastIndexOf("/") >= 0)
            {
                _filePath = _filePath.Replace("\\", "/");
                XmlLayoutCollection.NowLoadingPath = _filePath.Substring(0, _filePath.LastIndexOf("/"));
                XmlLayoutCollection.PathSeperator  = "/";
            }
            else if (_filePath.LastIndexOf("\\") >= 0)
            {
                _filePath = _filePath.Replace("/", "\\");
                XmlLayoutCollection.NowLoadingPath = _filePath.Substring(0, _filePath.LastIndexOf("\\"));
                XmlLayoutCollection.PathSeperator  = "\\";
            }


            XmlNode rootNode = XmlGetter.RootNode(out _xDoc, _filePath);//"./ComponentSchemas/LayoutCollectionSchema.xsd", XmlSchemaValidation);
            //try
            {
                LoadXml(_xDoc, rootNode);
            }
            //catch (Exception e)
            {
                //    throw new Exception(e.Message + ":" + xmlFile);
            }
        }
Пример #2
0
        public void LoadXml(String xmlFile, Boolean refLoad = false)
        {
            if (XmlLayoutCollection.NowLoadingPath.Length > 0)
            {
                _filePath = XmlLayoutCollection.NowLoadingPath + XmlLayoutCollection.PathSeperator + xmlFile;
            }
            else
            {
                _filePath = xmlFile;
            }

            XmlNode xNode = XmlGetter.RootNode(out _xDoc, _filePath, null, XmlScenarioTable_E_XmlSchemaValidation);

            /*
             * _xDoc = new XmlDocument();
             * _xDoc.PreserveWhitespace = false;
             * _xDoc.Schemas = new System.Xml.Schema.XmlSchemaSet();
             * XmlSchema schema = XmlSchema.Read(File.OpenRead("./ComponentSchemas/LabelSchema.xsd"), XmlScenarioTable_E_XmlSchemaValidation);
             * _xDoc.Schemas.Add(schema);
             *
             * _xDoc.Load(xmlFile);
             *
             *
             * xNode = _xDoc.SelectSingleNode("//Label");
             */
            try
            {
                LoadXml(_xDoc, xNode, refLoad);
            }
            catch (Exception e)
            {
                MessageBox.Show("IXmlComponentBase.LoadXml1:" + e.Message + ":" + xmlFile);
            }
        }
Пример #3
0
        public void LoadXml(String xmlFile, bool refLoad = false)
        {
            if (XmlLayoutCollection.NowLoadingPath.Length > 0)
            {
                _filePath = XmlLayoutCollection.NowLoadingPath + XmlLayoutCollection.PathSeperator + xmlFile;
            }
            else
            {
                _filePath = xmlFile;
            }

            //DataSet dt = new DataSet();
            //dt.ReadXmlSchema(Properties.Resources.TableSchema);
            //dt.ReadXml(xmlFile); //schema를 불러와서 체크하기 위하여..

            /*
             * XmlDocument xDoc;
             *
             * xDoc = new XmlDocument();
             * xDoc.PreserveWhitespace = false;
             * xDoc.Schemas = new System.Xml.Schema.XmlSchemaSet();
             *
             *
             * XmlSchema schema = XmlSchema.Read(File.OpenRead("./ComponentSchemas/TableSchema.xsd"), XmlScenarioTable_E_XmlSchemaValidation);
             *
             * xDoc.Schemas.Add(schema);
             * xDoc.Load(xmlFile);
             * LoadXml( xDoc.SelectSingleNode("//Table") );
             */
            XmlNode root = XmlGetter.RootNode(out _xDoc, _filePath, "./ComponentSchemas/ScenarioTableSchema.xsd", XmlScenarioTable_E_XmlSchemaValidation);

            LoadXml(_xDoc, root, refLoad);
        }
Пример #4
0
        public void LoadXml(String xmlFile, Boolean refLoad = false)
        {
            XmlLayoutCollection.PathSeperator = "\\";

            if (xmlFile.Equals(_filePath))
            {
                throw new Exception("같은 시나리오를 재귀적으로 Ref했습니다. 시나리오파일명:" + _filePath);
            }
            _filePath = xmlFile.Replace("/", "\\");
            
            string fileDir = _filePath.Substring(0, _filePath.LastIndexOf("\\"));
            string fileName = _filePath.Substring(_filePath.LastIndexOf("\\") + 1);
            _name = fileName.Substring(0, fileName.LastIndexOf(".")); //xml을 뺌..

            _baseDir = fileDir;

            NowLoadingFile = xmlFile;
            //_filePath = _filePath.Replace("\\", "/").Replace(Directory.GetCurrentDirectory().Replace("\\", "/"), "");

            XmlNode rootNode = XmlGetter.RootNode(out _xDoc,_filePath, ".\\ComponentSchemas\\LayoutCollectionSchema.xsd", XmlSchemaValidation);
            //try
            {
                LoadXml(_xDoc, rootNode);
            }
            //catch (Exception e)
            {
                //    throw new Exception(e.Message + ":" + xmlFile);
            }
        }
Пример #5
0
        XmlDocument _xDoc;  public void LoadXml(String xmlFile, bool refLoad = false)
        {
            if (XmlLayoutCollection.NowLoadingPath.Length > 0)
            {
                _filePath = XmlLayoutCollection.NowLoadingPath + XmlLayoutCollection.PathSeperator + xmlFile;
            }
            else
            {
                _filePath = xmlFile;
            }
            XmlNode rootNode = XmlGetter.RootNode(out _xDoc, _filePath, "./ComponentSchemas/TabSchema.xsd", XmlSchemaValidation);

            try
            {
                LoadXml(_xDoc, rootNode, refLoad);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message + ":" + _filePath);
            }
        }
Пример #6
0
        XmlDocument _xDoc;  public void LoadXml(String xmlFile, Boolean refLoad = false)
        {
            if (XmlScenario.NowLoadingPath.Length > 0)
            {
                _filePath = XmlScenario.NowLoadingPath + XmlScenario.PathSeperator + xmlFile;
            }
            else
            {
                _filePath = xmlFile;
            }

            XmlNode xNode = XmlGetter.RootNode(out _xDoc, _filePath, null, XmlSchemaValidation);

            try
            {
                LoadXml(_xDoc, xNode, refLoad);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + ":" + xmlFile);
            }
        }
Пример #7
0
        public void LoadXml(String xmlFile, Boolean refLoad = false)
        {
            if (XmlLayoutCollection.NowLoadingPath.Length > 0)
            {
                _filePath = XmlLayoutCollection.NowLoadingPath + XmlLayoutCollection.PathSeperator + xmlFile;
            }
            else
            {
                _filePath = xmlFile;
            }

            XmlNode xNode = XmlGetter.RootNode(out _xDoc, _filePath, null, XmlSchemaValidation);

            try
            {
                LoadXml(_xDoc, xNode, refLoad);
            }
            catch (Exception e)
            {
                MessageBox.Show("XmlItemCondition.LoadXml:" + e.Message + ":" + xmlFile);
            }
        }
Пример #8
0
        public XmlNode LoadXml(String xmlFile, Boolean refLoad = false)
        {
            //DataSet dt = new DataSet();
            //dt.ReadXmlSchema(Properties.Resources.TableSchema);
            //dt.ReadXml(xmlFile); //schema를 불러와서 체크하기 위하여..
            if (XmlLayoutCollection.NowLoadingPath.Length > 0)
            {
                _filePath = XmlLayoutCollection.NowLoadingPath + XmlLayoutCollection.PathSeperator + xmlFile;
            }
            else
            {
                _filePath = xmlFile;
            }

            XmlNode xNode = XmlGetter.RootNode(out _xDoc, _filePath, "./ComponentSchemas/Rules/GlobalTypeRuleSchema.xsd", XmlSchemaValidation);

            /*
             * _xDoc = new XmlDocument();
             * _xDoc.PreserveWhitespace = false;
             * _xDoc.Schemas = new System.Xml.Schema.XmlSchemaSet();
             * XmlSchema schema = XmlSchema.Read(File.OpenRead("./ComponentSchemas/LabelSchema.xsd"), XmlScenarioTable_E_XmlSchemaValidation);
             * _xDoc.Schemas.Add(schema);
             *
             * _xDoc.Load(xmlFile);
             *
             *
             * xNode = _xDoc.SelectSingleNode("//Label");
             */
            try
            {
                LoadXml(_xDoc, xNode, refLoad);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message + ":" + xmlFile);
            }
            return(xNode);
        }
Пример #9
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, bool refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }


            string refPath  = XmlGetter.Attribute(rootNode, "Ref");
            bool   refExist = refPath.Length > 0;

            XmlNode comNode;

            if (refExist)
            {
                if (XmlLayoutCollection.NowLoadingPath.Length > 0)
                {
                    refPath = XmlLayoutCollection.NowLoadingPath + XmlLayoutCollection.PathSeperator + refPath;
                }

                comNode   = XmlGetter.RootNode(out _xDoc, refPath, null, XmlSchemaValidation);
                _filePath = refPath;
            }
            else
            {
                if (rootNode.ChildNodes.Count == 0)
                {
                    throw new Exception("Component 태그의 정의가 완전하지 않습니다. Ref로 xml파일을 불러오거나 직접 내부에 정의해야 합니다.\r\n name:" + XmlGetter.Attribute(rootNode, "Name"));
                }

                comNode = rootNode.ChildNodes[0];
            }
            string nameText;

            nameText = XmlGetter.Attribute(rootNode, "Name");

            XmlControlHandler.LoadInterface(this, rootNode, xDoc);


            Control control = XmlControlHandler.AddControl(nameText, xDoc, comNode, _panel, _idList, _namespace);;

            _realComponent = control;
            NowLoading     = control as IXmlComponent;
            //if (txt.Length > 0) control.Name = txt;
            if (XmlGetter.Attribute(rootNode, "Margin").Length > 0)
            {
                control.Margin = ValueParser.Padding(XmlGetter.Attribute(rootNode, "Margin"));
            }
            if (XmlGetter.Attribute(rootNode, "Padding").Length > 0)
            {
                control.Padding = ValueParser.Padding(XmlGetter.Attribute(rootNode, "Padding"));
            }
            if (XmlGetter.Attribute(rootNode, "Enabled").Length > 0)
            {
                control.Enabled = (XmlGetter.Attribute(rootNode, "Enabled").Equals("false") == false);
            }



            String hgt = XmlGetter.Attribute(rootNode, "Height");

            if (hgt.Length != 0)
            {
                control.Height = int.Parse(hgt);
            }
            String wid = XmlGetter.Attribute(rootNode, "Width");

            if (wid.Length != 0)
            {
                control.Width = int.Parse(wid);
            }

            if (_panel is FlowLayoutPanel)
            {
            }
            else if (_panel is Panel)
            {
                String x        = XmlGetter.Attribute(rootNode, "X");
                Point  location = new Point();
                if (x.Length != 0)
                {
                    location.X = int.Parse(x);
                }
                String y = XmlGetter.Attribute(rootNode, "Y");
                if (y.Length != 0)
                {
                    location.Y = int.Parse(y);
                }
                control.Location = location;
            }
        }
Пример #10
0
        public void LoadTemplates()
        {
            //_commonTemplateDir = Directory.GetCurrentDirectory() + "\\" + _commonTemplateDir;

            /*
             * if (Directory.Exists(_commonTemplateDir) == false) Directory.CreateDirectory(_commonTemplateDir);
             *
             * _projectPath = Directory.GetCurrentDirectory() + "\\" + _projectBase + "\\" + projectName;
             * _scenarioDir = _projectPath + "\\Scenarios";
             */
            String[] subTemplates = Directory.GetDirectories(_commonTemplateDir);
            for (int si = 0; si < subTemplates.Length; si++)
            {
                String subName = subTemplates[si].Substring(subTemplates[si].LastIndexOf("\\") + 1);

                //Cmds.Add(subName);
                //Dictionary<string, XmlTemplate> cmds = Cmds[subName] = new Dictionary<string, XmlTemplate>();
                Dictionary <String, String> icons = Icons[subName] = new Dictionary <string, String>();

                String templateBaseIconPath = Path.GetFullPath((_commonTemplateDir + "\\" + subName + ".png").Replace("/", "\\"));

                if (File.Exists(templateBaseIconPath))
                {
                    TemplateBaseIcons[subName] = templateBaseIconPath;                                   // new BitmapImage(new Uri(templateBaseIconPath));
                }
                String[] filePath = Directory.GetFiles(subTemplates[si]);

                for (int i = 0; i < filePath.Length; i++)
                {
                    //Con_Peer peer = new Con_Peer(peerPaths[i]);
                    String fileName = filePath[i].Substring(filePath[i].LastIndexOf("\\") + 1);

                    string ext  = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower(); //확장자..
                    String name = fileName.Substring(0, fileName.LastIndexOf("."));            // 확장자를 뗌..
                    //String absName = name;// subName + "." + name;

                    if (ext.Equals("xml"))
                    {
                        XmlDocument xDoc;
                        XmlNode     rootNode = XmlGetter.RootNode(out xDoc, filePath[i]);
                        if (rootNode.Name.ToLower().Equals("packet"))
                        {
                            _templatesPath[name] = filePath[i].Replace("/", "\\");

                            XmlTemplate template = new XmlTemplate(name);
                            template.LoadXml(_templatesPath[name]);

                            _totalTemplates.Add(name, template);
                            if (icons.ContainsKey(name)) //icon이 이전에 설정되었으면
                            {
                                template.ImagePath = icons[name];
                            }
                            else
                            {
                                icons[name] = null; //key를 사용할 것이므로 일단 null이라도 넣어서 방을 만든다.
                            }
                            //cmds.Add(name, template);
                        }
                        else if (rootNode.Name.ToLower().Equals("packetgroup"))
                        {
                        }
                    }
                    else if (ext.Equals("png") || ext.Equals("jpg") || ext.Equals("gif") || ext.Equals("jpeg"))
                    {
                        String fullPath = Path.GetFullPath(filePath[i].Replace("/", "\\"));

                        //BitmapImage img = new BitmapImage(new Uri(fullPath));
                        //icons.Add(name, img);
                        icons[name] = fullPath;                         //path일단 저장
                        if (_totalTemplates.ContainsKey(name))          //template이 먼저 추가되면
                        {
                            _totalTemplates[name].ImagePath = fullPath; //이미지 설정
                        }
                    }
                }
            }

            /*
             * String[] templatePath = Directory.GetFiles(_commonTemplateDir+"\\IOCMD");
             * for (int i = 0; i < templatePath.Length; i++)
             * {
             *  //Con_Peer peer = new Con_Peer(peerPaths[i]);
             *  String name = templatePath[i].Substring(templatePath[i].LastIndexOf("\\") + 1);
             *  name = name.Substring(0, name.LastIndexOf("."));// .xml을 떼어줌..
             *  _templatesPath[name] = templatePath[i].Replace("/", "\\");
             *  XmlTemplate template = new XmlTemplate();
             *  template.LoadXml(_templatesPath[name]);
             *  TOTALCMD.Add(name, template);
             *  IOCMD.Add(name, template);
             * }
             * templatePath = Directory.GetFiles(_commonTemplateDir + "\\LCMD");
             * for (int i = 0; i < templatePath.Length; i++)
             * {
             *  //Con_Peer peer = new Con_Peer(peerPaths[i]);
             *  String name = templatePath[i].Substring(templatePath[i].LastIndexOf("\\") + 1);
             *  name = name.Substring(0, name.LastIndexOf("."));// .xml을 떼어줌..
             *  _templatesPath[name] = templatePath[i].Replace("/", "\\");
             *  XmlTemplate template = new XmlTemplate();
             *  template.LoadXml(_templatesPath[name]);
             *  TOTALCMD.Add(name, template);
             *  LCMD.Add(name, template);
             * }
             * templatePath = Directory.GetFiles(_commonTemplateDir + "\\M1553CMD");
             * for (int i = 0; i < templatePath.Length; i++)
             * {
             *  //Con_Peer peer = new Con_Peer(peerPaths[i]);
             *  String name = templatePath[i].Substring(templatePath[i].LastIndexOf("\\") + 1);
             *  name = name.Substring(0, name.LastIndexOf("."));// .xml을 떼어줌..
             *  _templatesPath[name] = templatePath[i].Replace("/", "\\");
             *  XmlTemplate template = new XmlTemplate();
             *  template.LoadXml(_templatesPath[name]);
             *  TOTALCMD.Add(name, template);
             *  M1553CMD.Add(name, template);
             * }
             *
             *
             * templatePath = Directory.GetFiles(_projectPath + "/Templates");
             *
             * for (int i = 0; i < templatePath.Length; i++)
             * {
             *  //Con_Peer peer = new Con_Peer(peerPaths[i]);
             *  String name = templatePath[i].Substring(templatePath[i].LastIndexOf("\\") + 1);
             *  name = name.Substring(0, name.LastIndexOf("."));// .xml을 떼어줌..
             *  _templatesPath[name] = templatePath[i].Replace("/", "\\");
             *  //node.RelativeObject["peer"] = peer;
             *  //peer.SetName(name);
             *  //_activatedPeerNode = node;
             *
             *
             *  //_peersGroup[peer] = name;//마지막 읽은 group을 _activatedPeer에 배정한다.
             *  //peer.SetMsgList(name, new ConMsgList(name));
             * }
             */
        }