private static DockContent GetMdiForm(System.Xml.XmlDocument doc, bool valid)
        {
            IXEditNetProfile prof = ProfileProvider.GetProfile(doc);

            UserControl userControl = null;

            if (prof != null)
            {
                userControl = prof.GetEditorRegion(doc);
            }

            if (userControl == null)
            {
                userControl = new XEditNetDefaultEditorRegion();
            }

            IXEditNetEditorRegion r = userControl as IXEditNetEditorRegion;

            if (r == null)
            {
                throw new InvalidOperationException("User control returned by profile does not implement " + typeof(IXEditNetEditorRegion));
            }

            if (prof != null && prof.Info.Stylesheet != null && prof.Info.Stylesheet.Length > 0)
            {
                r.Editor.SetStylesheet(prof.Info.Stylesheet);
            }

            r.Editor.Attach(doc, valid);
            XEditNetChildForm2 form = new XEditNetChildForm2(userControl);

            return(form);
        }
Example #2
0
        private void AddProfile(IXEditNetProfile xnp)
        {
            string groupName = xnp.Info.Group;
            string itemName  = xnp.Info.Name;

            TreeNodeCollection parentList = treeView1.Nodes;

            if (groupName != null)
            {
                bool found = false;
                foreach (TreeNode n in parentList)
                {
                    if (n.Text == groupName)
                    {
                        parentList = n.Nodes;
                        found      = true;
                    }
                }
                if (!found)
                {
                    TreeNode n = new TreeNode(groupName);
                    parentList.Add(n);
                    parentList = n.Nodes;
                }
            }
            TreeNode itemNode = parentList.Add(itemName);

            itemNode.Tag = xnp;
        }
        public RegisteredTypeProfile(ProfileInfo pi)
        {
            profileInfo = pi;

            if (pi.Profile != null)
            {
                profile = ProfileProvider.GetProfile(pi.Profile, null);
            }
        }
Example #4
0
        public static IXEditNetProfile GetProfile(string codebase, Uri baseUri)
        {
            string[] parts = codebase.Split('!');
            if (parts.Length == 0)
            {
                throw new ArgumentException("xeditnet-profile must refer to a class");
            }

            if (parts.Length > 2)
            {
                throw new ArgumentException("xeditnet-profile must be of the form [assembly]!classname");
            }

            // TODO: M: exception handling

            Assembly asm       = typeof(ProfileProvider).Assembly;
            string   className = parts[0];

            if (parts.Length > 1)
            {
                Uri uri = baseUri == null ? new Uri(parts[0]) : new Uri(baseUri, parts[0]);

                if (!File.Exists(uri.LocalPath))
                {
                    uri = new Uri(new Uri(asm.CodeBase), parts[0]);
                }

                asm = Assembly.LoadFrom(uri.LocalPath);
                if (asm == null)
                {
                    throw new ArgumentException("Failed to load assembly from " + uri.LocalPath);
                }

                className = parts[1];
            }

            object o = asm.CreateInstance(className);

            if (o == null)
            {
                throw new ArgumentException("Error loading class for specified profile");
            }

            IXEditNetProfile ret = o as IXEditNetProfile;

            if (ret == null)
            {
                throw new ArgumentException("Specified profile must refer to a class implementing IXEditNetProfile");
            }

            return(ret);
        }
Example #5
0
        private void ProfileSelected(object sender, Gui.Wizard.PageEventArgs e)
        {
            IXEditNetProfile tmp = null;

            if (treeView1.SelectedNode == null)
            {
                MessageBox.Show(this, "Please select a wizard to create a new document", "Select Profile", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            object o = treeView1.SelectedNode.Tag;

            if (o is IXEditNetProfile)
            {
                tmp = (IXEditNetProfile)o;
            }
            else if (o is ProfileInfo)
            {
                tmp = new RegisteredTypeProfile((ProfileInfo)o);
            }

            if (tmp != null && tmp == currentProfile)
            {
                return;                 // use previous wizard instance
            }
            currentProfile = tmp;
            if (currentProfile == null)
            {
                throw new InvalidOperationException("Tag for selected node is null!");
            }

            while (wizard1.Pages.Count > 1)
            {
                wizard1.Pages.RemoveAt(1);
            }

            wizardPlugin = currentProfile.GetCreateWizardPlugin();
            if (wizardPlugin == null)
            {
                OnWizardFinished(new EventArgs());
                return;
            }
            wizard1.Pages.AddRange(wizardPlugin.Pages);

            wizard1.PageIndex = 0;
            e.Page            = wizard1.Pages[1];
        }
Example #6
0
        private void LoadProfilesFromAssembly()
        {
            Assembly asm = typeof(NewFileDialog).Assembly;

            foreach (Type t in asm.GetTypes())
            {
                if (t.GetInterface(typeof(IXEditNetProfile).FullName) != null)
                {
                    try
                    {
                        IXEditNetProfile xnp = (IXEditNetProfile)t.Assembly.CreateInstance(t.FullName);
                        AddProfile(xnp);
                    }
                    catch (MissingMethodException)
                    {
                        // TODO: L: hack!
                    }
                }
            }
        }
Example #7
0
        private void ProfileSelected(object sender, Gui.Wizard.PageEventArgs e)
        {
            IXEditNetProfile tmp=null;

            if ( treeView1.SelectedNode == null )
            {
                MessageBox.Show(this, "Please select a wizard to create a new document", "Select Profile", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            object o=treeView1.SelectedNode.Tag;
            if ( o is IXEditNetProfile )
                tmp=(IXEditNetProfile) o;
            else if ( o is ProfileInfo )
                tmp=new RegisteredTypeProfile((ProfileInfo) o);

            if ( tmp != null && tmp == currentProfile )
                return; // use previous wizard instance

            currentProfile=tmp;
            if ( currentProfile == null )
                throw new InvalidOperationException("Tag for selected node is null!");

            while ( wizard1.Pages.Count > 1 )
                wizard1.Pages.RemoveAt(1);

            wizardPlugin=currentProfile.GetCreateWizardPlugin();
            if ( wizardPlugin == null )
            {
                OnWizardFinished(new EventArgs());
                return;
            }
            wizard1.Pages.AddRange(wizardPlugin.Pages);

            wizard1.PageIndex=0;
            e.Page=wizard1.Pages[1];
        }
Example #8
0
        private void AddProfile(IXEditNetProfile xnp)
        {
            string groupName=xnp.Info.Group;
            string itemName=xnp.Info.Name;

            TreeNodeCollection parentList=treeView1.Nodes;
            if ( groupName != null )
            {
                bool found=false;
                foreach ( TreeNode n in parentList )
                {
                    if ( n.Text == groupName )
                    {
                        parentList=n.Nodes;
                        found=true;
                    }
                }
                if ( !found )
                {
                    TreeNode n=new TreeNode(groupName);
                    parentList.Add(n);
                    parentList=n.Nodes;
                }
            }
            TreeNode itemNode=parentList.Add(itemName);
            itemNode.Tag=xnp;
        }