Esempio n. 1
0
        public void CreateFromTemplate(TemplateNode node, int dropOnNodePosition)
        {
            string templatePath = GetTemplatePath(node);
            _fieldDrop = true;

            _dropOnNodePosition = dropOnNodePosition;

            _templateLevel = GetTemplateLevel(node);
            CreateFromTemplate(templatePath);
        }
Esempio n. 2
0
        public Size GetFieldFootprint(TemplateNode node)
        {
            Size size = new Size();
            string templatePath = GetTemplatePath(node);

            using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(templatePath))
            {
                while (reader.ReadToFollowing("FieldFootprint"))
                {
                    if (reader.MoveToFirstAttribute())
                    {
                        do
                        {
                            if (reader.Name == "Width") size.Width = int.Parse(reader.Value);
                            if (reader.Name == "Height") size.Height = int.Parse(reader.Value);
                        }
                        while (reader.MoveToNextAttribute());
                    }
                    break;
                }
            }

            return size;
        }
Esempio n. 3
0
        public void CreateFromTemplate(TemplateNode node, Point location)
        {
            string templatePath = GetTemplatePath(node);
            _fieldDrop = true;

            _fieldDropLocaton = location;

            _templateLevel = GetTemplateLevel(node);
            CreateFromTemplate(templatePath);
        }
Esempio n. 4
0
 public static string GetTemplatePath(TemplateNode node)
 {
     return GetTemplatePath((string)node.Tag);
 }
Esempio n. 5
0
 public static Enums.TemplateLevel GetTemplateLevel(TemplateNode node)
 {
     if (node.Tag is string)
     {
         return GetTemplateLevel(GetTemplatePath(node));
     }
     return Enums.TemplateLevel.Unknown;
 }
Esempio n. 6
0
        /// <summary>
        /// Recursive method that adds template nodes to the project explorer
        /// </summary>
        private void AddTemplateNodes(TreeNode parentNode, string path)
        {
            Configuration config = Configuration.GetNewInstance();
            string execPath = config.Directories.Templates;

            string[] templateNames = System.IO.Directory.GetFiles(path, "*.xml");
            string[] directoryNames = System.IO.Directory.GetDirectories(path);

            for (int i = 0; i < directoryNames.Length; i++)
            {
                string name = (string)directoryNames[i];
                name = name.Substring(name.LastIndexOf('\\'));
                name = name.TrimStart(new char[] { '\\' });

                if ((IsProjectLoaded && name != "SourceTables") ||
                    (IsProjectLoaded == false && name == "Projects") ||
                    (IsProjectLoaded == false && name == "Forms"))
                {

                    TemplateNode templateNode = new TemplateNode();
                    templateNode.Text = Path.GetFileNameWithoutExtension(directoryNames[i]);
                    templateNode.ImageIndex = 0;
                    templateNode.Tag = directoryNames[i];
                    templateNode.SelectedImageIndex = 0;
                    templateNode.Value = MetaFieldType.Group;

                    parentNode.Nodes.Add(templateNode);
                    AddTemplateNodes(templateNode, System.IO.Path.Combine(path, directoryNames[i]));
                }
            }

            for (int i = 0; i < templateNames.Length; i++)
            {
                TemplateNode templateNode = new TemplateNode();
                templateNode.Text = System.IO.Path.GetFileNameWithoutExtension(templateNames[i]);
                templateNode.Tag = templateNames[i].Replace(execPath, "");
                templateNode.ImageIndex = 6;
                templateNode.SelectedImageIndex = 6;
                templateNode.Value = MetaFieldType.Group;

                bool hasProjectName = true;

                if (IsProjectLoaded == false && parentNode.Text == "Forms")
                {
                    using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(templateNames[i]))
                    {
                        try
                        {
                            while (reader.ReadToFollowing("Template"))
                            {
                                string nameCandidate = reader.GetAttribute("Name");

                                if (string.IsNullOrEmpty(nameCandidate))
                                {
                                    hasProjectName = false;
                                }
                            }
                        }
                        catch
                        {
                            Logger.Log("Project Explorer - The template file [ " + reader.BaseURI + " ] cannot be read.");
                        }
                    }
                }

                if (hasProjectName)
                {
                    parentNode.Nodes.Add(templateNode);
                }
            }
        }
Esempio n. 7
0
        void projectTree_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (sender is TreeView)
            {
                Point point = new Point(e.X, e.Y);
                TreeNode node = ((TreeView)sender).GetNodeAt(point);

                if (node != null && node is PageNode)
                {
                    draggedPageNode = (PageNode)node;
                }
                if (node != null && node is TemplateNode)
                {
                    draggedTemplateNode = (TemplateNode)node;
                }
            }
        }