Exemplo n.º 1
0
        public ActionResult Install()
        {
            session.Log("installing perl file associations");
            FileAssociation.EnsureAssociationsSet(associations());

            session.Log("updating PATHEXT");
            var oldPathExt = Environment.GetEnvironmentVariable("PATHEXT", EnvironmentVariableTarget.Machine);
            var exts       = String.Join(";", oldPathExt.Split(';').Concat(PathExtensions).Distinct().ToArray());

            if (exts != oldPathExt)
            {
                Environment.SetEnvironmentVariable("PATHEXT", exts, EnvironmentVariableTarget.Machine);
            }

            session.Log("install cmd-prompt shortcut");
            ActionResult result = CmdPromptShortcut();

            if (result.Equals(ActionResult.Failure))
            {
                session.Log("Could not create Command Prompt shortcut");
                // Do not fail if we cannot create shortcut
                return(ActionResult.Success);
            }

            session.Log("Install Documentation link");
            DocumentationShortcut();

            return(ActionResult.Success);
        }
Exemplo n.º 2
0
        public EditFileAssociationControl(FileAssociation fileAssociation, UIApplication environment) : base(environment)
        {
            InitializeComponent();

            SetUpValues(fileAssociation);
            SetUpValueChangedHandlers();
        }
        public EditFileAssociationControl(FileAssociation fileAssociation)
        {
            InitializeComponent();

            SetUpValues(fileAssociation);
            SetUpValueChangedHandlers();
        }
Exemplo n.º 4
0
        private static void AddFileAssociations(this ApplicationManifest application, Project project)
        {
            Logger.Normal(Messages.Build_Process_FileAssociations);

            if (project.FileAssociations.Value is null)
            {
                Logger.Normal(Messages.Result_NoneFound, 1, 2);
                return;
            }

            foreach (var item  in project.FileAssociations.Value.Split(':'))
            {
                var elements        = item.Split(';');
                var fileAssociation = new FileAssociation
                {
                    Extension   = elements[0],
                    Description = elements[1],
                    ProgId      = elements[2],
                    DefaultIcon = elements[3]
                };
                Logger.Normal(fileAssociation.Extension, 1);
                application.FileAssociations.Add(fileAssociation);
                application.Add(project, Path.Combine(project.Source.Value, fileAssociation.DefaultIcon), fileAssociation.DefaultIcon, GlobKind.Files);
            }
            Logger.Normal();
        }
Exemplo n.º 5
0
        private static string RemoveFileAssociationProgIDInfo(FileAssociation fileAssociation, DefinitionIdentity subId, RegistryKey classesKey, string productName)
        {
            string str = null;

            using (RegistryKey key = classesKey.OpenSubKey(fileAssociation.ProgID, true))
            {
                if (key == null)
                {
                    return(null);
                }
                object obj2 = key.GetValue("AppId");
                if (!(obj2 is string))
                {
                    return(null);
                }
                string a = (string)obj2;
                if (!string.Equals(a, subId.ToString(), StringComparison.Ordinal))
                {
                    return(null);
                }
                str = (string)key.GetValue("Guid");
                try
                {
                    classesKey.DeleteSubKeyTree(fileAssociation.ProgID);
                }
                catch (ArgumentException exception)
                {
                    throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssocProgIdDeleteFailed"), new object[] { fileAssociation.ProgID, productName }), exception);
                }
            }
            return(str);
        }
Exemplo n.º 6
0
 private static void RemoveFileAssociationExtentionInfo(FileAssociation fileAssociation, DefinitionIdentity subId, RegistryKey classesKey, string productName)
 {
     using (RegistryKey key = classesKey.OpenSubKey(fileAssociation.Extension, true))
     {
         if (key != null)
         {
             object obj2 = key.GetValue("AppId");
             if (obj2 is string)
             {
                 string a = (string)obj2;
                 if (string.Equals(a, subId.ToString(), StringComparison.Ordinal))
                 {
                     try
                     {
                         classesKey.DeleteSubKeyTree(fileAssociation.Extension);
                     }
                     catch (ArgumentException exception)
                     {
                         throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssocExtDeleteFailed"), new object[] { fileAssociation.Extension, productName }), exception);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 private static bool CanAddFileAssociation(FileAssociation fileAssociation)
 {
     try
     {
         using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Classes"))
         {
             using (RegistryKey key2 = key.OpenSubKey(fileAssociation.Extension))
             {
                 using (RegistryKey key3 = key.OpenSubKey(fileAssociation.ProgID))
                 {
                     if ((key2 != null) || (key3 != null))
                     {
                         Logger.AddWarningInformation(string.Format(CultureInfo.CurrentUICulture, Resources.GetString("SkippedFileAssoc"), new object[] { fileAssociation.Extension }));
                         Logger.AddInternalState("File association for " + fileAssociation.Extension + " skipped, since another application is using it.");
                         return(false);
                     }
                 }
             }
         }
     }
     catch (SecurityException exception)
     {
         Logger.AddInternalState("Exception reading registry key : " + exception.StackTrace);
         Logger.AddInternalState("File association for " + fileAssociation.Extension + " skipped");
         return(false);
     }
     return(true);
 }
Exemplo n.º 8
0
 private static void RemoveFileAssociationExtentionInfo(FileAssociation fileAssociation, DefinitionIdentity subId, RegistryKey classesKey, string productName)
 {
     using (RegistryKey registryKey = classesKey.OpenSubKey(fileAssociation.Extension, true))
     {
         if (registryKey == null)
         {
             return;
         }
         object obj = registryKey.GetValue("AppId");
         if (!(obj is string))
         {
             return;
         }
         if (!string.Equals((string)obj, subId.ToString(), StringComparison.Ordinal))
         {
             return;
         }
         try
         {
             classesKey.DeleteSubKeyTree(fileAssociation.Extension);
         }
         catch (ArgumentException ex)
         {
             throw new DeploymentException(ExceptionTypes.InvalidARPEntry, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssocExtDeleteFailed"), new object[2]
             {
                 (object)fileAssociation.Extension,
                 (object)productName
             }), (Exception)ex);
         }
     }
 }
Exemplo n.º 9
0
        public Preferences()
        {
            InitializeComponent();
            askToChangeDefaultPassCheckBox.Checked = Settings.Default.askToChangeDefaultPass;
            switch ((DownloadBehaviour)Settings.Default.openAfterDownload)
            {
            case DownloadBehaviour.Ask:
                radioDownloadAsk.Checked = true;
                break;

            case DownloadBehaviour.Open:
                radioDownloadYes.Checked = true;
                break;

            case DownloadBehaviour.DoNothing:
                radioDownloadNo.Checked = true;
                break;
            }
            keepFileAssociationsCheckBox.Checked = Settings.Default.checkFileAssociations;
            isAssociated = FileAssociation.isAssociated(Program.extension, Program.executablePath);
            updateKeyCount();
            if (Program.enableInternetUpdates)
            {
                updatePrivacy();
                toolTip.SetToolTip(removeOEMcheckBox, Utils.wordWrap(maximumPrivacyTooltip, 65));
                toolTip.IsBalloon = true;
            }
            else
            {
                tabControl1.Controls.Remove(this.tabPage3);
            }

            editKeysCheckBox_CheckedChanged(null, null);
            allowApply = false;
        }
Exemplo n.º 10
0
 static void Main()
 {
     FileAssociation.AssociateMe(PROCESSOR_C_SHARP, "XWolf_TextProcessor", "Text processor");
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new Form1());
 }
Exemplo n.º 11
0
 private void associateExts(string dir)
 {
     if (!FileAssociation.IsAssociated(".mp3"))
     {
         FileAssociation.Associate(".mp3", "urMusik.mp3", ResolveExt(0), System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\icon.ico", dir + "\\urMusik.exe");
     }
     if (!FileAssociation.IsAssociated(".wav"))
     {
         FileAssociation.Associate(".wav", "urMusik.wav", ResolveExt(1), System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\icon.ico", dir + "\\urMusik.exe");
     }
     if (!FileAssociation.IsAssociated(".pcm"))
     {
         FileAssociation.Associate(".pcm", "urMusik.pcm", ResolveExt(2), System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\icon.ico", dir + "\\urMusik.exe");
     }
     if (!FileAssociation.IsAssociated(".aac"))
     {
         FileAssociation.Associate(".aac", "urMusik.aac", ResolveExt(3), System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\icon.ico", dir + "\\urMusik.exe");
     }
     if (!FileAssociation.IsAssociated(".m4a"))
     {
         FileAssociation.Associate(".m4a", "urMusik.m4a", ResolveExt(3), System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\icon.ico", dir + "\\urMusik.exe");
     }
     if (!FileAssociation.IsAssociated(".flac"))
     {
         FileAssociation.Associate(".flac", "urMusik.flac", ResolveExt(4), System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\icon.ico", dir + "\\urMusik.exe");
     }
 }
Exemplo n.º 12
0
        /// <summary>
        ///  Verifica a instalacao do programa
        /// </summary>
        private static void VerificaInstalacao()
        {
            string asmName  = Assembly.GetExecutingAssembly().Location;
            string location = Path.GetDirectoryName(asmName);

            Func <string, DirectoryInfo> criaDiretorio =
                new Func <string, DirectoryInfo>(s =>
                                                 (!Directory.Exists(Path.Combine(location, s))) ?
                                                 Directory.CreateDirectory(Path.Combine(location, s)) : null);


            criaDiretorio("History");
            criaDiretorio("Log");


            try
            {
                FileAssociation FA = new FileAssociation();
                FA.Extension   = "kbd";
                FA.ContentType = "application/kanbadaboard";
                FA.FullName    = "Quadro Kanban para Kanbada!";
                FA.ProperName  = "Kanbada! board";

                FA.AddCommand("open", string.Format("\"{0}\" -view \"%1\"", asmName));
                FA.IconPath = Path.Combine(location, @"Resources\kanbada.ico");
                FA.Create();
                // Remove the file type from the registry
                //FA.Remove();
            }
            catch
            {
                // Se de erro nao precisa notificar usuario;
            }
        }
Exemplo n.º 13
0
        private static void createFileAssociation()
        {
            var appPath = Assembly.GetExecutingAssembly().Location;

            FileAssociation.CreateFileAssociation(".srt", "Sub", "Subtitle File",
                                                  appPath
                                                  );
        }
    private Regex GetRegex(FileAssociation fileAssociation)
    {
      if (myCache.ContainsKey(fileAssociation.Pattern))
        return myCache[fileAssociation.Pattern];

      return new Regex(fileAssociation.Pattern,
        RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Singleline);
    }
        void UpdateNodeCellsForResult(TreeModelViewNode viewNode, FileAssociation fileAssociation)
        {
            viewNode.SetValue(myPatternTypeColumn, fileAssociation.PatternType);

            string docType = String.Format("{0}{1}", fileAssociation.DocType, fileAssociation.Enabled ? null : " (disabled)");

            viewNode.SetValue(myAssociationColumn, docType);
        }
Exemplo n.º 16
0
        public SettingsDlg(AlvSettings alvSettings, bool firstTimeShown)
        {
            log.Debug("Creating SettingsDlg form");

            InitializeComponent();
            this.settings   = alvSettings;
            this.totalCmd   = new TotalCmdIntegration();
            this.logBrowser = LogBrowserSettings.Instance;


            //Load values from filter entry
            this.showMarkersCheckBox.Checked                 = this.settings.MainFormUI.ShowMarkers;
            this.exitAppOnESCCheckBox.Checked                = this.settings.MainFormUI.ExitAppOnESC;
            this.autoScrollCheckBox.Checked                  = this.settings.MainFormUI.AutoScrollWhenAutoRefresh;
            this.autoScrollShowTwoItemsCheckBox.Checked      = this.settings.MainFormUI.AutoScrollShowTwoItems;
            this.autoRefreshPeriodEdit.Value                 = this.settings.MainFormUI.AutoRefreshPeriod;
            this.addOnlyBaseNameInRecentListCheckBox.Checked = this.settings.MainFormUI.AddOnlyBaseNameInRecentList;
            this.rememberFiltersEnabledCheckBox.Checked      = this.settings.MainFormUI.RememberFiltersEnabled;
            this.trimClassColumnFromLeftCheckBox.Checked     = this.settings.MainFormUI.TrimClassColumnFromLeft;
            this.showLogIconsCheckBox.Checked                = this.settings.MainFormUI.ShowLogIcons;

            this.extDiffPathEdit.Text       = settings.TextDiff.DiffPath;
            this.extDiffParametersEdit.Text = settings.TextDiff.DiffParameters;

            this.extTextEditPathEdit.Text       = settings.TextEditor.TextEditorPath;
            this.extTextEditParametersEdit.Text = settings.TextEditor.TextEditorParameteres;

            this.topLevelFolders.Text = this.logBrowser.TopLevelFolders;
            this.openAndExitOnDoubleClickCheckBox.Checked = this.logBrowser.ShowAndCloseOnDoubleClick;

            this.integrateWithTotalCmdCheckBox.Checked = this.totalCmd.IsLogViewerIntegrated;
            if (this.totalCmd.IsInstalled)
            {
                this.integrateWithTotalCmdCheckBox.Enabled = true;
                this.totalCmdStatusLabel.Text = "Total Commander is installed on this computer.";
            }
            else
            {
                this.integrateWithTotalCmdCheckBox.Enabled = false;
                this.totalCmdStatusLabel.Text = "Total Commander wasn't found on this computer.";
            }

            try
            {
                alvWasAssociated = FileAssociation.IsAssociated(".log", "AdvancedLogViewer");
                associateWithAlvCheckBox.Checked = alvWasAssociated || firstTimeShown;
            }
            catch
            {
                MessageBox.Show("Can't get information about associated application with LOG extension. Run ALV as Administrator.", "Administration rights required", MessageBoxButtons.OK, MessageBoxIcon.Error);
                associateWithAlvCheckBox.Enabled = false;
            }
            this.automaticUpdateEnabledCheckBox.Checked = this.settings.AutomaticUpdates.EnableAutomaticCheck;
            this.automaticUpdateCheckPeriodEdit.Value   = this.settings.AutomaticUpdates.CheckInterval;

            log.Debug("SettingsDlg form created");
        }
Exemplo n.º 17
0
        public void FileAssocTest()
        {
            FileAssociation assoc = new FileAssociation("sqlfoo");

            assoc.DisplayName = "SQL Script";
            assoc.ProperName  = "sqlfooscript";
            assoc.AddCommand("open", "C:\\River\\Orqa2\\Orqa\\bin\\debug\\orqa.exe %1");
            assoc.Create();
        }
Exemplo n.º 18
0
        private static void AddFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, Uri deploymentProviderUri)
        {
            if (!ShellExposure.CanAddFileAssociation(fileAssociation))
            {
                return;
            }
            string subkey = Guid.NewGuid().ToString("B");
            string str    = subId.ToString();

            using (RegistryKey subKey1 = Registry.CurrentUser.CreateSubKey("Software\\Classes"))
            {
                using (RegistryKey subKey2 = subKey1.CreateSubKey(fileAssociation.Extension))
                {
                    subKey2.SetValue((string)null, (object)fileAssociation.ProgID);
                    subKey2.SetValue("AppId", (object)str);
                    subKey2.SetValue("Guid", (object)subkey);
                    subKey2.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri);
                }
                using (RegistryKey subKey2 = subKey1.CreateSubKey(fileAssociation.ProgID))
                {
                    subKey2.SetValue((string)null, (object)fileAssociation.Description);
                    subKey2.SetValue("AppId", (object)str);
                    subKey2.SetValue("Guid", (object)subkey);
                    subKey2.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri);
                    using (RegistryKey subKey3 = subKey2.CreateSubKey("shell"))
                    {
                        subKey3.SetValue((string)null, (object)"open");
                        using (RegistryKey subKey4 = subKey3.CreateSubKey("open\\command"))
                        {
                            subKey4.SetValue((string)null, (object)("rundll32.exe dfshim.dll, ShOpenVerbExtension " + subkey + " %1"));
                            Logger.AddInternalState("File association created. Extension=" + fileAssociation.Extension + " value=rundll32.exe dfshim.dll, ShOpenVerbExtension " + subkey + " %1");
                        }
                        using (RegistryKey subKey4 = subKey2.CreateSubKey("shellex\\IconHandler"))
                        {
                            subKey4.SetValue((string)null, (object)subkey);
                            Logger.AddInternalState("File association icon handler created. Extension=" + fileAssociation.Extension + " value=" + subkey);
                        }
                    }
                }
                using (RegistryKey subKey2 = subKey1.CreateSubKey("CLSID"))
                {
                    using (RegistryKey subKey3 = subKey2.CreateSubKey(subkey))
                    {
                        subKey3.SetValue((string)null, (object)("Shell Icon Handler For " + fileAssociation.Description));
                        subKey3.SetValue("AppId", (object)str);
                        subKey3.SetValue("DeploymentProviderUrl", (object)deploymentProviderUri.AbsoluteUri);
                        subKey3.SetValue("IconFile", (object)fileAssociation.DefaultIcon);
                        using (RegistryKey subKey4 = subKey3.CreateSubKey("InProcServer32"))
                        {
                            subKey4.SetValue((string)null, (object)"dfshim.dll");
                            subKey4.SetValue("ThreadingModel", (object)"Apartment");
                        }
                    }
                }
            }
        }
Exemplo n.º 19
0
        //public class Instruction: Dictionary<CompilerProperty, string> {}

        #endregion

        public MainWindow()
        {
            InitializeComponent();
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("es-AR");

            // Asocio tipo de archivo
            if (!FileAssociation.IsAssociated(".h5c"))
            {
                FileAssociation.Associate(".h5c", "ghApps.HTML5Compiler", "HTML5 Compiler Proyect", "H5Clogo-256.ico", AppDomain.CurrentDomain.DomainManager.EntryAssembly.Location);
            }
            // Chequeo si abrio un proyecto desde un archivo
            // Environment.GetCommandLineArgs()
            //if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null)
            //{
            string[] arguments = Environment.GetCommandLineArgs();

            if (arguments.Length > 1)
            {
                // Cargar poryecto
                try
                {
                    string filePath = arguments[1];     // string.Empty;
                    //filePath = @"C:\Proyectos\Mobile\gecommerce\trunk\src\MobileViews\mobileView.h5c";
                    string JSONProject = File.ReadAllText(filePath, Encoding.Default);

                    var oProject = JSONHelper.Deserialize <Project>(JSONProject);
                    // Chequear si los paths de oProject son relativos y modificarlos el path pasaría a estar en "filePath"

                    if (oProject != null && oProject.Configs != null && oProject.Configs.Count > 0)
                    {
                        LoadProject(oProject);
                        if (arguments.Length > 2)
                        {
                            // TODO: leer el comando y ejecutar (probablemente el unico comando sea "compilar" asi que ewjecutar compilar)
                        }
                    }
                    else
                    {
                        SetDevice(DeviceConfig.Devices.html5);
                        SaveDevice(SelectedDevice);
                    }
                }
                catch (Exception ex)
                {
                    SetDevice(DeviceConfig.Devices.html5);
                    SaveDevice(SelectedDevice);
                    txtResult.Text = "Se produjo un error al cargar el proyecto, recuerde escapar caracteres como \"\\\", etc. El log indica: " + ex.Message + Environment.NewLine;
                }
            }
            else
            {
                SetDevice(DeviceConfig.Devices.html5);
                SaveDevice(SelectedDevice);
            }
            //}
        }
Exemplo n.º 20
0
        public void SaveChanges()
        {
            Settings.Default.RecentFiles_MaxFiles   = (int)nudMaxRecentFiles.Value;
            Settings.Default.CheckForUpdates        = chbCheckForUpdates.Checked;
            Settings.Default.RememberArchives       = chbRememberArchives.Checked;
            Settings.Default.SortArchiveDirectories = chbSortBSADirectories.Checked;
            Settings.Default.RetrieveRealSize       = chbRetrieveRealSize.Checked;
            Settings.Default.EncodingCodePage       = (cbEncodings.SelectedItem as Encoding).CodePage;

            Enums.Icons icons = Enums.Icons.None;
            if (chbIconsFileList.Checked)
            {
                icons |= Enums.Icons.FileList;
            }
            if (chbIconsFolderTree.Checked)
            {
                icons |= Enums.Icons.FolderTree;
            }
            Settings.Default.Icons = icons;

            Settings.Default.MatchLastWriteTime = chbMatchLastWriteTime.Checked;
            Settings.Default.ReplaceGNFExt      = chbReplaceGNFExt.Checked;

            Settings.Default.QuickExtractPaths.Clear();
            Settings.Default.QuickExtractPaths.AddRange(lvQuickExtract.Items
                                                        .Cast <ListViewItem>().Select(x => (QuickExtractPath)x.Tag));

            Settings.Default.PreviewMaxResolution = new Size(
                (int)nudMaxResolutionW.Value,
                (int)nudMaxResolutionH.Value);

            Settings.Default.BuiltInPreviewing.Clear();
            Settings.Default.BuiltInPreviewing.AddRange(lvPreviewing.Items
                                                        .Cast <ListViewItem>().Where(x => x.Checked).Select(x => x.Text).ToArray());

            if (this.CheckAssociationAndIntegrationChanged())
            {
                if (FileAssociation.HasAdminPrivileges() == false)
                {
                    MessageBox.Show(this,
                                    "File association and shell integration requires administrative rights.\n\nPrompt will be shown automatically.",
                                    "BSA Browser",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }

                // If file association is disabled we don't care whether shell integration has changed or not
                bool?shellIntegration = null;
                if (cbAssociateFiles.Checked)
                {
                    shellIntegration = cbShellIntegration.Checked;
                }

                this.ToggleAssociateAndIntegration(cbAssociateFiles.Checked, shellIntegration);
            }
        }
Exemplo n.º 21
0
 void fixFileAssociations()
 {
     FileAssociation.SetAssociation(
         extensions: new[] { ".sh", ".coresh", ".bash" },
         id: "ShellScript",
         description: "Shell Script",
         exePath: PlatformInfo.System.ApplicationPath,
         iconPath: Path.Combine(Path.GetDirectoryName(PlatformInfo.System.ApplicationPath), "icon.ico")
         );
 }
Exemplo n.º 22
0
        private Regex GetRegex(FileAssociation fileAssociation)
        {
            if (myCache.ContainsKey(fileAssociation.Pattern))
            {
                return(myCache[fileAssociation.Pattern]);
            }

            return(new Regex(fileAssociation.Pattern,
                             RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Singleline));
        }
    public bool Matches(FileAssociation fileAssociation, string fileName)
    {
      if (!fileAssociation.Enabled)
        return false;

      if (fileAssociation.PatternType != PatternType.FileExtension)
        return false;

      return new FileSystemPath(fileName).ExtensionWithDot.Equals(fileAssociation.Pattern, StringComparison.OrdinalIgnoreCase);
    }
Exemplo n.º 24
0
    public static void EnshurePckAssociations()
    {
        FileAssociation fa = new FileAssociation();

        fa.ExecutableFilePath  = Application.ExecutablePath;
        fa.FileTypeDescription = "Test";
        fa.IsAdd     = true;
        fa.Extension = ".pck";
        fa.ProgId    = "Perfect World Editor By JHS.";
        FileAssociations.EnsureAssociationsSet(fa);
    }
Exemplo n.º 25
0
 private static void AddFileAssociation(FileAssociation fileAssociation, DefinitionIdentity subId, Uri deploymentProviderUri)
 {
     if (CanAddFileAssociation(fileAssociation))
     {
         string str  = Guid.NewGuid().ToString("B");
         string str2 = subId.ToString();
         using (RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Classes"))
         {
             using (RegistryKey key2 = key.CreateSubKey(fileAssociation.Extension))
             {
                 key2.SetValue(null, fileAssociation.ProgID);
                 key2.SetValue("AppId", str2);
                 key2.SetValue("Guid", str);
                 key2.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri);
             }
             using (RegistryKey key3 = key.CreateSubKey(fileAssociation.ProgID))
             {
                 key3.SetValue(null, fileAssociation.Description);
                 key3.SetValue("AppId", str2);
                 key3.SetValue("Guid", str);
                 key3.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri);
                 using (RegistryKey key4 = key3.CreateSubKey("shell"))
                 {
                     key4.SetValue(null, "open");
                     using (RegistryKey key5 = key4.CreateSubKey(@"open\command"))
                     {
                         key5.SetValue(null, "rundll32.exe dfshim.dll, ShOpenVerbExtension " + str + " %1");
                         Logger.AddInternalState("File association created. Extension=" + fileAssociation.Extension + " value=rundll32.exe dfshim.dll, ShOpenVerbExtension " + str + " %1");
                     }
                     using (RegistryKey key6 = key3.CreateSubKey(@"shellex\IconHandler"))
                     {
                         key6.SetValue(null, str);
                         Logger.AddInternalState("File association icon handler created. Extension=" + fileAssociation.Extension + " value=" + str);
                     }
                 }
             }
             using (RegistryKey key7 = key.CreateSubKey("CLSID"))
             {
                 using (RegistryKey key8 = key7.CreateSubKey(str))
                 {
                     key8.SetValue(null, "Shell Icon Handler For " + fileAssociation.Description);
                     key8.SetValue("AppId", str2);
                     key8.SetValue("DeploymentProviderUrl", deploymentProviderUri.AbsoluteUri);
                     key8.SetValue("IconFile", fileAssociation.DefaultIcon);
                     using (RegistryKey key9 = key8.CreateSubKey("InProcServer32"))
                     {
                         key9.SetValue(null, "dfshim.dll");
                         key9.SetValue("ThreadingModel", "Apartment");
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 26
0
        private XmlNode CreateFileAssociationNode(XmlDocument doc, FileAssociation fileAssociation)
        {
            var xmlElement = doc.CreateElement("fileAssociation", "urn:schemas-microsoft-com:clickonce.v1");

            xmlElement.SetAttribute("defaultIcon", fileAssociation.DefaultIcon);
            xmlElement.SetAttribute("description", fileAssociation.Description);
            xmlElement.SetAttribute("extension", fileAssociation.Extension);
            xmlElement.SetAttribute("progid", fileAssociation.ProgId);

            return(xmlElement);
        }
    public bool Matches(FileAssociation fileAssociation, string fileName)
    {
      if (!fileAssociation.Enabled)
        return false;

      if (fileAssociation.PatternType != PatternType.Regex)
        return false;

      var expr = GetRegex(fileAssociation);

      return expr.IsMatch(fileName);
    }
Exemplo n.º 28
0
        void onFileAssosiate(object sender, RoutedEventArgs e)
        {
            /*
             * if (!FileAssociation.IsAssociated(".tmc"))
             * {
             *
             * }
             */
            string myExe = Process.GetCurrentProcess().MainModule.FileName;

            FileAssociation.Associate(".tmc", "tmcfile", "tmc File", myExe, myExe);
        }
Exemplo n.º 29
0
 private void btnRemoveBackup_Click(object sender, EventArgs e)
 {
     if (FileAssociation.IsAssociated(".bk"))
     {
         FileAssociation.Remove(".bk", "Firebird database backup");
         MessageBox.Show("Association removed!");
     }
     else
     {
         MessageBox.Show("Not associated!");
     }
 }
Exemplo n.º 30
0
        private void cmdAssociateCRF_Click(object sender, EventArgs e)
        {
            if (isAssociated)
            {
                FileAssociation.deleteAssociation(Program.extension);
            }
            else
            {
                FileAssociation.Associate(Program.extension, Program.executablePath);
            }

            isAssociated = FileAssociation.isAssociated(Program.extension, Program.executablePath);
        }
Exemplo n.º 31
0
        private void CmdUnassocFromPdf_Click(object sender, EventArgs e)
        {
            bool result = FileAssociation.UnAssociate(FileExt, ProgMenuItem);

            if (result)
            {
                MessageBox.Show($"Пункт '{ProgMenuItem}' успешно удален из контекстного меню расширения '{FileExt}'", "Удаление связи расширения с приложением", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show($"Пункт '{ProgMenuItem}' НЕ удален из контекстного меню расширения '{FileExt}'\n\nError: " + FileAssociation.ErrorMessage, "Удаление связи расширения с приложением", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 32
0
        public EditFileAssociationForm(FileAssociation fileAssociation)
        {
            InitializeComponent();

            myEditor = new EditFileAssociationControl(fileAssociation)
            {
                Dock = DockStyle.Fill
            };

            myPanel.Controls.Add(myEditor);

            Icon = Shell.Instance.GetComponent <IApplicationDescriptor>().ProductIcon;
        }
Exemplo n.º 33
0
        private void OpenEditor(FileAssociation association, Action <EditFileAssociationForm> onClose)
        {
            using (var form = new EditFileAssociationForm(association))
            {
                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                onClose(form);
                myThreading.ExecuteOrQueue(myLifetime, "ZenCodingOptionPage.UpdateAllNodesPresentation", () => myView.UpdateAllNodesPresentation());
            }
        }
        public bool Matches(FileAssociation fileAssociation, string fileName)
        {
            if (!fileAssociation.Enabled)
              {
            return false;
              }

              if (fileAssociation.PatternType != PatternType.FileExtension)
              {
            return false;
              }

              return Path.GetExtension(fileName).Equals(fileAssociation.Pattern, StringComparison.OrdinalIgnoreCase);
        }
Exemplo n.º 35
0
        private ListBoxItem CreateFileAssociationItem(FileAssociation association)
        {
            var item = new ListBoxItem();

            // get color for language name
            var languageColor = Theme.Instance.TextWidgetColor.ToColor();
            languageColor.A = 20;

            // build item
            var container = new StackPanel { Orientation = Orientation.Horizontal };
            var checkbox = new System.Windows.Controls.CheckBox {Content = association.Extension, Margin = new Thickness(0, 0, 10, 0)};
            container.Children.Add(checkbox);
            container.Children.Add(new TextBlock {Text = association.Language, Foreground = new SolidColorBrush(languageColor)});
            item.Content = container;

            // checked?
            if (FileTypeAssociation.GetAssociationProgId(association.Extension) == PROG_ID)
            {
                checkbox.IsChecked = true;
            }

            // connect events
            checkbox.Click += (s, e) => FileAssociationChanged(checkbox.IsChecked.Value, association);

            return item;
        }
Exemplo n.º 36
0
        private XmlNode CreateFileAssociationNode(XmlDocument doc, FileAssociation fileAssociation)
        {
            var xmlElement = doc.CreateElement("fileAssociation", "urn:schemas-microsoft-com:clickonce.v1");

            xmlElement.SetAttribute("defaultIcon", fileAssociation.DefaultIcon);
            xmlElement.SetAttribute("description", fileAssociation.Description);
            xmlElement.SetAttribute("extension", fileAssociation.Extension);
            xmlElement.SetAttribute("progid", fileAssociation.ProgId);

            return xmlElement;
        }
Exemplo n.º 37
0
 private void FileAssociationChanged(bool enabled, FileAssociation association)
 {
     if (enabled)
     {
         FileTypeAssociation.Associate(association.Extension, PROG_ID, "", Settings.ExecPath, Settings.ExecPath);
     }
     else
     {
         FileTypeAssociation.RemoveAssociation(association.Extension);
     }
 }