Esempio n. 1
0
        /// <summary>
        /// Shows the OpenWith dialog for the specified files.
        /// </summary>
        public static void OpenFilesWith(string[] fileNames)
        {
            if (fileNames.Length == 0)
            {
                return;
            }

            List <DisplayBindingDescriptor> codons = DisplayBindingService.GetCodonsPerFileName(fileNames[0]).ToList();

            for (int i = 1; i < fileNames.Length; i++)
            {
                var codonsForThisFile = DisplayBindingService.GetCodonsPerFileName(fileNames[i]);
                codons.RemoveAll(c => !codonsForThisFile.Contains(c));
            }
            if (codons.Count == 0)
            {
                return;
            }

            int defaultCodonIndex = codons.IndexOf(DisplayBindingService.GetDefaultCodonPerFileName(fileNames[0]));

            if (defaultCodonIndex < 0)
            {
                defaultCodonIndex = 0;
            }
            //using (OpenWithDialog dlg = new OpenWithDialog(codons, defaultCodonIndex, Path.GetExtension(fileNames[0]))) {
            //    if (dlg.ShowDialog(WorkbenchSingleton.MainWin32Window) == DialogResult.OK) {
            //        foreach (string fileName in fileNames) {
            //            FileUtility.ObservedLoad(new FileService.LoadFileWrapper(dlg.SelectedBinding.Binding, true).Invoke, fileName);
            //        }
            //    }
            //}
        }
Esempio n. 2
0
        /// <summary>
        /// Shows the OpenWith dialog for the specified file.
        /// </summary>
        static void OpenWith(string fileName)
        {
            var codons            = DisplayBindingService.GetCodonsPerFileName(fileName);
            int defaultCodonIndex = codons.IndexOf(DisplayBindingService.GetDefaultCodonPerFileName(fileName));

            using (OpenWithDialog dlg = new OpenWithDialog(codons, defaultCodonIndex, Path.GetExtension(fileName))) {
                if (dlg.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK)
                {
                    FileUtility.ObservedLoad(new FileService.LoadFileWrapper(dlg.SelectedBinding.Binding, true).Invoke, fileName);
                }
            }
        }