private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (!(e.Node.Tag is DocumentPart))
            {
                return;
            }

            DocumentPart docPart = e.Node.Tag as DocumentPart;

            this.comboBoxRelType.Items.Clear();

            List <PartInfo> list = KnownPackageInfo.GetPartTypesForContentType(docPart.ContentType);

            if (list == null || list.Count == 0)
            {
                foreach (string relType in KnownPackageInfo.GetRelationshipTypes().Keys)
                {
                    this.comboBoxRelType.Items.Add(relType);
                }
                return;
            }

            foreach (PartInfo partInfo in list)
            {
                this.comboBoxRelType.Items.Add(partInfo.m_relType);
            }
            comboBoxRelType.Text = list[0].m_relType;
        }
        public NewExternalRelationshipDialog()
        {
            InitializeComponent();

            this.comboBox1.Items.Clear();
            foreach (string relType in KnownPackageInfo.GetRelationshipTypes().Keys)
            {
                this.comboBox1.Items.Add(relType);
            }
        }
Example #3
0
        public NewExternalRelationshipDialog(Microsoft.OpenXMLEditor.PackageEditorPane main)
        {
            InitializeComponent();

            this.comboBox1.Items.Clear();
            foreach (string relType in KnownPackageInfo.GetRelationshipTypes().Keys)
            {
                this.comboBox1.Items.Add(relType);
            }
        }
        private void NewInternalRelationshipDialog_Load(object sender, EventArgs e)
        {
            this.comboBoxRelType.Items.Clear();
            foreach (string relType in KnownPackageInfo.GetRelationshipTypes().Keys)
            {
                this.comboBoxRelType.Items.Add(relType);
            }

            this.comboBoxKind.Items.Clear();
            comboBoxKind.Items.Add(System.UriKind.Absolute);
            comboBoxKind.Items.Add(System.UriKind.Relative);
            comboBoxKind.SelectedItem = System.UriKind.Relative;
        }
        static void UpdateInstallablePackages()
        {
            EditorApplication.update -= UpdateInstallablePackages;

            if (s_SearchRequest == null || IsEditorInPlayMode() || s_CachedMDStoreInformation.hasAlreadyRequestedData)
            {
                return;
            }

            if (s_SearchRequest.IsCompleted && s_SearchRequest.Error != null)
            {
                Debug.LogError($"Error retrieving package information from Package Manager: {s_SearchRequest.Error.message}.");
                s_SearchRequest = null;
                return;
            }

            if (!s_SearchRequest.IsCompleted || s_SearchRequest.Result == null)
            {
                EditorApplication.update += UpdateInstallablePackages;
                return;
            }

            var installablePackages = new List <string>();
            var knownPackageInfos   = new List <KnownPackageInfo>();

            foreach (var package in s_SearchRequest.Result)
            {
                if (s_Packages.ContainsKey(package.name))
                {
                    var kpi = new KnownPackageInfo();
                    kpi.packageId = package.name;

                    kpi.verifiedVersion = package.versions.verified;
                    if (string.IsNullOrEmpty(kpi.verifiedVersion))
                    {
                        kpi.verifiedVersion = package.versions.latestCompatible;
                    }
                    knownPackageInfos.Add(kpi);
                    installablePackages.Add(package.name);
                }
            }

            s_CachedMDStoreInformation.knownPackageInfos       = knownPackageInfos.ToArray();
            s_CachedMDStoreInformation.installablePackages     = installablePackages.ToArray();
            s_CachedMDStoreInformation.hasAlreadyRequestedData = true;

            s_SearchRequest = null;

            StoreCachedMDStoreInformation();
        }
        static void UpdateInstallablePackages()
        {
            EditorApplication.update -= UpdateInstallablePackages;

            if (s_SearchRequest == null || IsEditorInPlayMode() || s_CachedMDStoreInformation.hasAlreadyRequestedData)
            {
                return;
            }

            if (!s_SearchRequest.IsCompleted)
            {
                EditorApplication.update += UpdateInstallablePackages;
                return;
            }

            var installablePackages = new List <string>();
            var knownPackageInfos   = new List <KnownPackageInfo>();

            foreach (var package in s_SearchRequest.Result)
            {
                if (s_Packages.ContainsKey(package.name))
                {
                    var kpi = new KnownPackageInfo();
                    kpi.packageId = package.name;

                    kpi.verifiedVersion = package.versions.verified;
                    if (string.IsNullOrEmpty(kpi.verifiedVersion) || kpi.verifiedVersion.StartsWith("1."))
                    {
                        kpi.verifiedVersion = package.versions.latest;
                    }
                    knownPackageInfos.Add(kpi);
                    installablePackages.Add(package.name);
                }
            }

            s_CachedMDStoreInformation.knownPackageInfos       = knownPackageInfos.ToArray();
            s_CachedMDStoreInformation.installablePackages     = installablePackages.ToArray();
            s_CachedMDStoreInformation.hasAlreadyRequestedData = true;

            s_SearchRequest = null;

            StoreCachedMDStoreInformation();
        }
Example #7
0
        public NewPartDialog(bool disableImport)
        {
            InitializeComponent();

            this.comboBoxContentType.Items.Clear();

            ContentTypeInfo[] types = KnownPackageInfo.GetContentTypes();
            foreach (ContentTypeInfo cti in types)
            {
                this.comboBoxContentType.Items.Add(cti.m_mime);
            }

            if (disableImport)
            {
                this.labelImport.Enabled             = false;
                this.textBoxExternalFilename.Enabled = false;
                this.buttonBrowse.Enabled            = false;
            }
        }
Example #8
0
        private void ButtonBrowse_Click(object sender, EventArgs e)
        {
            ArrayList imageTypes = new ArrayList
            {
                new string[] { "*.jpg;*.jpeg", "JPEG File Interchange Format" },
                new string[] { "*.gif", "Graphics Interchange Format" },
                new string[] { "*.png", "Portable Network Graphics" },
                new string[] { "*.bmp", "Windows Bitmap" },
                new string[] { "*.ico", "Windows Icon" },
                new string[] { "*.emf", "Windows Enhanced Metafile" },
                new string[] { "*.wmf", "Windows Metafile" },
                new string[] { "*.emz", "Compressed Windows Enhanced Metafile" },
                new string[] { "*.wmz", "Compressed Windows Metafile" },
                new string[] { "*.pcz", "Compressed Macintosh PICT" },
                new string[] { "*.tif;*.tiff", "Tag Image File Format" },
                new string[] { "*.xbm", "X Bitmap Graphic" },
                new string[] { "*.pcx", "PC Paintbrush Bitmap Graphic" }
            };

            string filter = "", allFilters = "";

            foreach (string[] imageType in imageTypes)
            {
                if (filter.Length > 0)
                {
                    filter += "|";
                }
                filter += imageType[1] + " (" + imageType[0] + ")|" + imageType[0];

                if (allFilters.Length > 0)
                {
                    allFilters += ";";
                }
                allFilters += imageType[0];
            }
            openFileDialog.Filter      = "All Files (*.*)|*.*|All Pictures (" + allFilters + ")|" + allFilters + "|" + filter;
            openFileDialog.FilterIndex = 2;
            if (openFileDialog.ShowDialog(this) != DialogResult.OK || string.IsNullOrEmpty(openFileDialog.FileName))
            {
                return;
            }

            textBoxExternalFilename.Text = openFileDialog.FileName;

            textBoxName.Text = System.IO.Path.GetFileName(textBoxExternalFilename.Text).ToLower();

            string ext = System.IO.Path.GetExtension(textBoxName.Text);

            if (ext == ".jpg")
            {
                ext = ".jpeg";
            }
            else if (ext == ".tif")
            {
                ext = ".tiff";
            }

            List <ContentTypeInfo> contentTypes = KnownPackageInfo.GetContentTypesForExt(ext);

            if (contentTypes != null && contentTypes.Count > 0)
            {
                comboBoxContentType.Text = contentTypes[0].m_mime;

                comboBoxCompression.SelectedItem = contentTypes[0].m_comp == Comp.CD ? System.IO.Packaging.CompressionOption.SuperFast : System.IO.Packaging.CompressionOption.NotCompressed;
            }
        }