Ejemplo n.º 1
0
		public static void RemoveProgramInfo(string progId)
		{
			var pai = new ProgramAssociationInfo(progId);

			if (pai.Exists)
				pai.Delete();
		}
Ejemplo n.º 2
0
        private static void checkWYZFileAssociation()
        {
            if (Properties.Settings.Default.CheckFileAssociation)
            {
                FileAssociationInfo fai = new FileAssociationInfo(".wyz");

                bool refreshAssociation = !fai.Exists;
                if (!refreshAssociation)
                {
                    ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);
                    refreshAssociation = (!pai.Exists ||
                        pai.Verbs.Length == 0 ||
                        !pai.Verbs[0].Command.ToLower().Contains(Application.ExecutablePath.ToLower()));
                }

                if (refreshAssociation)
                {
                    DlgFileAssociationCheck dlgFileAssocCheck = new DlgFileAssociationCheck();
                    if (dlgFileAssocCheck.ShowDialog() == DialogResult.Yes)
                    {
                        Process newProcess = new Process();
                        newProcess.StartInfo.FileName = Application.ExecutablePath;
                        newProcess.StartInfo.Verb = "runas";
                        newProcess.StartInfo.Arguments = CREATE_ASSOC_PARAM;
                        newProcess.Start();
                        newProcess.WaitForExit();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void RemoveProgramInfo(string progId)
        {
            var pai = new ProgramAssociationInfo(progId);

            if (pai.Exists)
            {
                pai.Delete();
            }
        }
Ejemplo n.º 4
0
		/// <summary>
		/// Associates a single executable with a list of extensions.
		/// </summary>
		/// <param name="progId">Name of program id</param>
		/// <param name="executablePath">Path to executable to start including arguments.</param>
		/// <param name="extensions">String array of extensions to associate with program id.</param>
		/// <example>progId = "MyTextFile"
		/// executablePath = "notepad.exe %1"
		/// extensions = ".txt", ".text"</example>
		public static void Associate(string progId, string executablePath, params string[] extensions)
		{
			Associate(progId, extensions);

			var pai = new ProgramAssociationInfo(progId);

			if (!pai.Exists)
				pai.Create();

			pai.AddVerb(new ProgramVerb("open", executablePath+" \"%1\"")); // Note: the %1 ensures that the opened file will be passed to the program's command line
		}
Ejemplo n.º 5
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %1"
        /// extensions = ".txt", ".text"</example>
        public static void Associate(string progId, string executablePath, params string[] extensions)
        {
            Associate(progId, extensions);

            var pai = new ProgramAssociationInfo(progId);

            if (!pai.Exists)
            {
                pai.Create();
            }

            pai.AddVerb(new ProgramVerb("open", executablePath + " \"%1\""));           // Note: the %1 ensures that the opened file will be passed to the program's command line
        }
Ejemplo n.º 6
0
 private static void AssociateTorrents(string installationPath)
 {
     var path = Path.Combine(installationPath, "Patchy.exe");
     var torrent = new FileAssociationInfo(".torrent");
     torrent.Create("Patchy");
     torrent.ContentType = "application/x-bittorrent";
     torrent.OpenWithList = new[] { "patchy.exe" };
     var program = new ProgramAssociationInfo(torrent.ProgID);
     if (!program.Exists)
     {
         program.Create("Patchy Torrent File", new ProgramVerb("Open", string.Format(
             "\"{0}\" \"%1\"", path)));
         program.DefaultIcon = new ProgramIcon(path);
     }
 }
Ejemplo n.º 7
0
 public static void Run()
 {
     FileAssociationInfo associate = new FileAssociationInfo(".plist");
     if (!associate.Exists)
     {
         associate.Create();
     }
     associate.ContentType = "Application/PList";
     associate.ProgID = "ProperityList";
     ////if (associate.OpenWithList == null)
     //{
     //    associate.OpenWithList = new string[]{
     //        args
     //    };
     //}
     //else if(!associate.OpenWithList.Contains("args"))
     //{
     //    List<string> list = new List<string>();
     //    list.Add(args);
     //    list.AddRange(associate.OpenWithList);
     //    associate.OpenWithList = list.ToArray();
     //}
     string args = Path.GetFullPath(Path.Combine(Application.StartupPath, "IPATools.PlistEditor.exe")) + " \"%1\"";
     string ico = Path.Combine(Application.StartupPath, "file.ico");
     ProgramVerb open = new ProgramVerb("Open", args);
     ProgramAssociationInfo pai = new ProgramAssociationInfo(associate.ProgID);
     if (!pai.Exists)
     {
         pai.Create("ProperityList", open);
     }
     else
     {
         for (int i = 0; i < pai.Verbs.Length; i++)
         {
             if (pai.Verbs[i].Name.Equals("open", StringComparison.OrdinalIgnoreCase))
             {
                 pai.RemoveVerb(pai.Verbs[i]);
                 pai.AddVerb(open);
                 break;
             }
         }
     }
     pai.DefaultIcon = new ProgramIcon(ico);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %1"
        /// extensions = ".txt", ".text"</example>
        public void Associate(string progId, string executablePath, params string[] extensions )
        {
            foreach (string s in extensions)
             {
            FileAssociationInfo fai = new FileAssociationInfo(s);

            if (!fai.Exists)
               fai.Create(progId);

            fai.ProgID = progId;
             }

             ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

             if (!pai.Exists)
            pai.Create();

             pai.AddVerb(new ProgramVerb("open", executablePath));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %1"
        /// extensions = ".txt", ".text"</example>
        public void Associate(string progId, string executablePath, params string[] extensions)
        {
            foreach (string s in extensions)
            {
                FileAssociationInfo fai = new FileAssociationInfo(s);

                if (!fai.Exists)
                {
                    fai.Create(progId);
                }

                fai.ProgID = progId;
            }

            ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

            if (!pai.Exists)
            {
                pai.Create();
            }

            pai.AddVerb(new ProgramVerb("open", executablePath));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %L"
        /// extensions = ".txt", ".text"</example>
        public void Associate(string progId, string executablePath, string extension, ProgramIcon icon = null)
        {
            FileAssociationInfo fai = new FileAssociationInfo(extension);

            if (!fai.Exists)
            {
                fai.Create(progId);
            }

            fai.ProgID = progId;

            ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

            if (!pai.Exists)
            {
                pai.Create();
            }

            pai.AddVerb(new ProgramVerb("open", executablePath));
            if (icon != null)
            {
                pai.DefaultIcon = icon;
            }
        }
Ejemplo n.º 11
0
      //Prompt for new program id and create it if it does not exist.
      private void newProgramAssociationButton_Click(object sender, EventArgs e)
      {
         NewProgramAssociationDialog dialog = new NewProgramAssociationDialog();

         if (dialog.ShowDialog() == DialogResult.OK)
         {
            ProgramAssociationInfo pai = new ProgramAssociationInfo(dialog.ProgramID);

            if (pai.Exists)
            {
               MessageBox.Show("Specified program already exists and will not be added");
            }
            else
            {
               pai.Create();
            }

            refreshExtensionsButton_Click(null, null);
         }

      }
Ejemplo n.º 12
0
      //Removes single verb from program id without affecting existing verbs
      private void removeSingleVerbButton_Click(object sender, EventArgs e)
      {
         TreeNode node = verbsTreeView.SelectedNode;
         if (node == null)
            return;

         if (node.Tag != null && node.Tag.ToString() == "command")
         {
            node = node.Parent;
         }

         string extension = (string)extensionsListBox.SelectedItem;
         ProgramAssociationInfo pa = new ProgramAssociationInfo(programIdTextBox.Text);

         if (!pa.Exists)
         {
            return;
         }

         pa.RemoveVerb(node.Text);

         refreshExtensionsButton_Click(null, null);
         extensionsListBox.SelectedItem = extension;

      }
Ejemplo n.º 13
0
      //Add single verb without affecting existing verbs
      private void addSingleVerbButton_Click(object sender, EventArgs e)
      {
         string extension = (string)extensionsListBox.SelectedItem;
         ProgramAssociationInfo pa = new ProgramAssociationInfo(programIdTextBox.Text);

         if (!pa.Exists)
         {
            return;
         }

         AddVerbDialog d = new AddVerbDialog();

         if (d.ShowDialog() == DialogResult.OK)
         {
            ProgramVerb[] verbs = pa.Verbs;
            ProgramVerb newVerb = new ProgramVerb(d.VerbName, d.VerbCommand);
            List<ProgramVerb> l = new List<ProgramVerb>();

            if (!l.Contains(newVerb))
            {
               pa.AddVerb(newVerb);

               refreshExtensionsButton_Click(null, null);
               extensionsListBox.SelectedItem = extension;
            }
         }
      }
Ejemplo n.º 14
0
      //Wipes out existing verbs and replaces them with provided list
      private void removeVerbButton_Click(object sender, EventArgs e)
      {
         TreeNode node = verbsTreeView.SelectedNode;
         if (node == null)
            return;

         if (node.Tag != null && node.Tag.ToString() == "command")
         {
            node = node.Parent;
         }

         string extension = (string)extensionsListBox.SelectedItem;
         ProgramAssociationInfo pa = new ProgramAssociationInfo(programIdTextBox.Text);

         if (!pa.Exists)
         {
            return;
         }

         ProgramVerb[] verbs = pa.Verbs;
         List<ProgramVerb> l = new List<ProgramVerb>();
         l.AddRange(verbs);

         ProgramVerb verbToRemove = null;

         foreach (ProgramVerb verb in l)
         {
            if (verb.Name == node.Text)
            {
               verbToRemove = verb;
               break;
            }
         }

         if (verbToRemove != null)
         {
            l.Remove(verbToRemove);
            pa.Verbs = l.ToArray();

            refreshExtensionsButton_Click(null, null);
            extensionsListBox.SelectedItem = extension;
         }


      }
Ejemplo n.º 15
0
        public FileAssociations()
        {
            InitializeComponent();

            this.chkAlwaysCheckFileAssociations.IsChecked = Properties.Settings.Default.AlwaysCheckFileAssociations;

            RegistryHelper.UseCurrentUser = true;

            //Ensure there is Program Association Info for us in the Registry
            ProgramAssociationInfo rdfEditorInfo = new ProgramAssociationInfo(RegistryProgramID);
            if (!rdfEditorInfo.Exists) rdfEditorInfo.Create();
            bool hasOpenVerb = false;
            foreach (ProgramVerb verb in rdfEditorInfo.Verbs)
            {
                if (verb.Name.Equals("open"))
                {
                    if (verb.Command.StartsWith(System.IO.Path.GetFullPath("rdfEditor.exe")))
                    {
                        hasOpenVerb = true;
                    }
                    else
                    {
                        rdfEditorInfo.RemoveVerb("open");
                    }
                }
            }
            if (!hasOpenVerb)
            {
                rdfEditorInfo.AddVerb(new ProgramVerb("open", System.IO.Path.GetFullPath("rdfEditor.exe") + " \"%1\""));
            }

            //See which extensions are currently associated to us
            foreach (FileAssociationInfo info in _associations)
            {
                if (!info.Exists)
                {
                    //If no association exists then we'll aim to create it
                    this.SetAssociationsChecked(info.Extension);
                }
                else
                {
                    //Check if the File Associations Program ID is equal to ours
                    if (info.ProgID.Equals(RegistryProgramID))
                    {
                        //Prog ID is equal to ours to we are associated with this extension
                        this._currentAssociations.Add(info.Extension);
                        this.SetAssociationsChecked(info.Extension);
                    }
                    else if (info.ProgID.Equals(String.Empty))
                    {
                        //No Prog ID specified so we'll aim to create it
                        this.SetAssociationsChecked(info.Extension);
                    }
                    else
                    {
                        ProgramAssociationInfo progInfo = new ProgramAssociationInfo(info.ProgID);
                        if (!progInfo.Exists)
                        {
                            //No program association exists so we'll aim to create it
                            this.SetAssociationsChecked(info.Extension);
                        }
                        else
                        {
                            //Associated with some other program currently
                            bool hasExistingOpen = false;
                            foreach (ProgramVerb verb in progInfo.Verbs)
                            {
                                if (verb.Name.Equals("open"))
                                {
                                    hasExistingOpen = true;
                                }
                            }
                            //No Open Verb so we'll try to associated with ourselves
                            if (!hasExistingOpen) this.SetAssociationsChecked(info.Extension);
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private static void createWYZFileAssociation()
        {
            FileAssociationInfo fai = new FileAssociationInfo(".wyz");
            if (!fai.Exists)
            {
                fai.Create("WYZTracker");
                fai.ContentType = "application/wyz-song-file";
                fai.OpenWithList = new string[] {
                        "WYZTracker.exe"
                    };
            }

            ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);
            if (!pai.Exists ||
                pai.Verbs.Length == 0 ||
                !pai.Verbs[0].Command.ToLower().Contains(Application.ExecutablePath.ToLower()))
            {
                pai.Create(
                    WYZTracker.Properties.Resources.WYZFileDesc,
                    new ProgramVerb(
                        WYZTracker.Properties.Resources.OpenVerb,
                        string.Format("\"{0}\" \"%1\"", Application.ExecutablePath)
                        )
                    );
                pai.DefaultIcon = new ProgramIcon(Application.ExecutablePath);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %L"
        /// extensions = ".txt", ".text"</example>
        public void Associate(string progId, string executablePath, string extension, ProgramIcon icon = null)
        {
            FileAssociationInfo fai = new FileAssociationInfo(extension);

              if (!fai.Exists)
              fai.Create(progId);

              fai.ProgID = progId;

              ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

              if (!pai.Exists)
              pai.Create();

              pai.AddVerb(new ProgramVerb("open", executablePath));
              if (icon != null)
            pai.DefaultIcon = icon;
        }
Ejemplo n.º 18
0
        private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.tabControl.SelectedTab == this.tabPageAssociations) {
            ProgramAssociationInfo programAssociationInfo = new ProgramAssociationInfo("TRE Explorer");
            if (!programAssociationInfo.Exists) {
              programAssociationInfo.Create(new ProgramVerb("Open", "\"" + Application.ExecutablePath + "\" \"%1\""));
              programAssociationInfo.DefaultIcon = new ProgramIcon(Application.ExecutablePath, 0);
            } else {
              if (programAssociationInfo.Verbs.Length > 0) {
            for (Int32 counter = 0; counter < programAssociationInfo.Verbs.Length; counter++) {
              if ((programAssociationInfo.Verbs[counter].Name == "Open") && (programAssociationInfo.Verbs[counter].Command != "\"" + Application.ExecutablePath + "\" \"%1\"")) {
                programAssociationInfo.RemoveVerb(programAssociationInfo.Verbs[counter]);
                programAssociationInfo.AddVerb(new ProgramVerb("Open", "\"" + Application.ExecutablePath + "\" \"%1\""));
                break;
              }
            }
              } else {
            programAssociationInfo.AddVerb(new ProgramVerb("Open", "\"" + Application.ExecutablePath + "\" \"%1\""));
              }
              if (programAssociationInfo.DefaultIcon.Path != Application.ExecutablePath) {
            programAssociationInfo.DefaultIcon = new ProgramIcon(Application.ExecutablePath, 0);
              }
            }

            for (Int32 counter = 0; counter < this.checkedListBoxFileTypes.Items.Count; counter++) {
              FileAssociationInfo fileAssociationInfo = new FileAssociationInfo("." + this.checkedListBoxFileTypes.Items[counter].ToString().ToLower());
              if (fileAssociationInfo.Exists) {
            if (fileAssociationInfo.ProgID == "TRE Explorer") {
              this.checkedListBoxFileTypes.SetItemChecked(counter, true);
            } else {
              this.checkedListBoxFileTypes.SetItemChecked(counter, false);
            }
              } else {
            this.checkedListBoxFileTypes.SetItemChecked(counter, false);
              }
            }
              }
        }
Ejemplo n.º 19
0
        public static void RegisterFileAssociation()
        {
            FileAssociationInfo fileInfo = new FileAssociationInfo(".cin");

            if (fileInfo.Exists)
                fileInfo.Delete();

            if (!fileInfo.Exists)
            {
                fileInfo.Create("YahooKeyKeyCin");
                fileInfo.ContentType = "text/plain";
                fileInfo.OpenWithList = new string[] {
                    "CinInstaller.exe", "notepad.exe", "winword.exe"
                };
            }

            string currentLocale = CultureInfo.CurrentUICulture.Name;

            ProgramAssociationInfo programInfo = new ProgramAssociationInfo(fileInfo.ProgID);

            if (programInfo.Exists)
                programInfo.Delete();

            if (!programInfo.Exists)
            {
                string cinInstallerFilename = Application.StartupPath +
                    Path.DirectorySeparatorChar + "CinInstaller.exe";

                string command = cinInstallerFilename + " %1";
                string description = "Yahoo! KeyKey Input Method Table";

                if (currentLocale.Equals("zh-TW"))
                    description = "Yahoo! \u5947\u6469\u8f38\u5165\u6cd5\u8868\u683c";
                else if (currentLocale.Equals("zh-CN"))
                    description = "Yahoo! \u5947\u6469\u8f93\u5165\u6cd5\u8868\u683c";

                programInfo.Create(description, new ProgramVerb("Open", @command));
                programInfo.DefaultIcon = new ProgramIcon(cinInstallerFilename, 1);
                programInfo.AlwaysShowExtension = true;
            }

            ProgramAssociationInfo uriInfo = new ProgramAssociationInfo("ykeykey");

            if (uriInfo.Exists)
                uriInfo.Delete();

            if (!uriInfo.Exists)
            {
                string urlHandlerFilename = Application.StartupPath +
                    Path.DirectorySeparatorChar + "PhraseEditor.exe";

                string command = urlHandlerFilename + " %1";
                string description = "URL:Yahoo! KeyKey User Phrase Protocol";

                if (currentLocale.Equals("zh-TW"))
                    description = "URL:Yahoo! \u5947\u6469\u8f38\u5165\u6cd5\u52a0\u5b57\u52a0\u8a5e\u5354\u5b9a";
                else if (currentLocale.Equals("zh-CN"))
                    description = "URL:Yahoo! \u5947\u6469\u8f93\u5165\u6cd5\u52a0\u5b57\u52a0\u8bcd\u534f\u5b9a";

                uriInfo.Create(description, new ProgramVerb("Open", @command));
                // uriInfo.DefaultIcon = new ProgramIcon(urlHandlerFilename, 1);
                uriInfo.IsURLProtocol = true;
            }
        }
Ejemplo n.º 20
0
      //Update values related to program id that have changed
      private void updateProgIdButton_Click(object sender, EventArgs e)
      {

         string extension = (string)extensionsListBox.SelectedItem;
         ProgramAssociationInfo pa = new ProgramAssociationInfo(programIdTextBox.Text);
         int[] tmpArray;

         if (pa.Exists)
         {
            if ((string)descriptionTextBox.Tag != descriptionTextBox.Text)
            {
               pa.Description = descriptionTextBox.Text;
            }

            EditFlags editFlags = EditFlags.None;

            tmpArray = GetIntArray(editFlagsListBox);
            if (!IntArraysEqual(tmpArray, (int[])editFlagsListBox.Tag))
            {

               for (int x = 0; x < tmpArray.Length; x++)
               {
                  //If value == 0 then None was selected and will override all others
                  //Do not handle first index, is None
                  if (tmpArray[x] == 0)
                     break;

                  editFlags |= (EditFlags)(1 << (tmpArray[x]-1));
               }

               pa.EditFlags = editFlags;
            }

            pa.DefaultIcon = new FileAssociation.ProgramIcon(iconPathTextBox.Text, 0);

            if (alwaysShowExtCheckBox.Checked != (bool)alwaysShowExtCheckBox.Tag)
            {
               pa.AlwaysShowExtension = alwaysShowExtCheckBox.Checked;
            }

         }

         refreshExtensionsButton_Click(null, null);
         extensionsListBox.SelectedItem = extension;
      }
Ejemplo n.º 21
0
 public void associaExt()
 {
     var filename = Assembly.GetEntryAssembly().Location;
     if (!IsAssociated(".zip"))
         Associate(".zip", "SisBackup", "SisBackup", filename, filename);
     associaExt_();
     ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);
     if (!pai.Exists)
     {
         pai.Create("Programa SisBackup", new ProgramVerb("Open", filename + " % 1"));
         pai.DefaultIcon = new ProgramIcon(filename);
     }
 }
Ejemplo n.º 22
0
      private void extensionsListBox_SelectedIndexChanged(object sender, EventArgs e)
      {
         string extension = (string)extensionsListBox.SelectedItem;

         FileAssociationInfo fa = new FileAssociationInfo(extension);

         contentTypeTextBox.Text = fa.ContentType;
         contentTypeTextBox.Tag = contentTypeTextBox.Text;

         programIdTextBox.Text = fa.ProgID;
         programIdTextBox.Tag = programIdTextBox.Text;

         openWithListBox.DataSource = fa.OpenWithList;

         PerceivedTypeComboBox.DataSource = Enum.GetNames(typeof(PerceivedTypes));
         PerceivedTypeComboBox.SelectedIndex = (int)fa.PerceivedType;
         PerceivedTypeComboBox.Tag = PerceivedTypeComboBox.SelectedIndex;

         extensionLabel.Text = fa.Extension;

         if (fa.PersistentHandler != Guid.Empty)
         {
            persistentHandlerTextBox.Text = fa.PersistentHandler.ToString();
            persistentHandlerTextBox.Tag = fa.PersistentHandler;
         }
         else
         {
            persistentHandlerTextBox.Text = "";
         }

         if (fa.PersistentHandler != Guid.Empty)
         {
            persistentHandlerTextBox.Tag = persistentHandlerTextBox.Text = fa.PersistentHandler.ToString();
         }
         else
         {
            persistentHandlerTextBox.Tag = persistentHandlerTextBox.Text = "";
         }

         ProgramAssociationInfo pa = new ProgramAssociationInfo(fa.ProgID);
         programIdLabel.Text = fa.ProgID;

         if (pa.Exists)
         {
            programIdGroupBox.Enabled = true;

            EditFlags[] editFlags = (EditFlags[])Enum.GetValues(typeof(EditFlags));

            editFlagsListBox.Items.Clear();

            foreach (EditFlags flag in editFlags)
            {
               editFlagsListBox.Items.Add(flag);
            }

            EditFlags[] flags = (EditFlags[])Enum.GetValues(typeof(EditFlags));

            EditFlags setFlags = pa.EditFlags;
            editFlagsListBox.Tag = setFlags;

            for (int x = 1; x < flags.Length; x++)
            {
               EditFlags flag = flags[x];

               if ((setFlags & flag) == flag)
               {
                  editFlagsListBox.SetItemChecked(x, true);
               }
               else
               {
                  editFlagsListBox.SetItemChecked(x, false);
               }
            }

            if (setFlags == EditFlags.None)
            {
               editFlagsListBox.SetItemChecked((int)EditFlags.None, true);
            }
            else
            {
               editFlagsListBox.SetItemChecked((int)EditFlags.None, false);
            }


            editFlagsListBox.Tag = GetIntArray(editFlagsListBox);

            ProgramVerb[] verbs = pa.Verbs;
            verbsTreeView.Nodes.Clear();
            foreach (ProgramVerb verb in verbs)
            {
               TreeNode node = new TreeNode(verb.Name);
               node.Nodes.Add(new TreeNode(verb.Command));
               node.Nodes[0].Tag = "command";
               verbsTreeView.Nodes.Add(node);
            }
            verbsTreeView.ExpandAll();

            descriptionTextBox.Text = pa.Description;
            descriptionTextBox.Tag = descriptionTextBox.Text;


            alwaysShowExtCheckBox.Checked = pa.AlwaysShowExtension;
            alwaysShowExtCheckBox.Tag = alwaysShowExtCheckBox.Checked;

            if (pa.DefaultIcon != ProgramIcon.None)
            {
               iconPathTextBox.Text = pa.DefaultIcon.Path;
               iconIndexTextBox.Text = pa.DefaultIcon.Index.ToString();
            }
            else
            {
               iconPathTextBox.Text = "";
               iconIndexTextBox.Text = "";
            }

         }
         else
         {
            programIdGroupBox.Enabled = false;

            editFlagsListBox.Items.Clear();
            verbsTreeView.Nodes.Clear();

            descriptionTextBox.Text = "";
            descriptionTextBox.Tag = "";
         }

      }
Ejemplo n.º 23
0
 private void torrentAssociationCheckBoxChecked(object sender, RoutedEventArgs e)
 {
     var torrent = new FileAssociationInfo(".torrent");
     if (torrentAssociationCheckBox.IsChecked.Value)
     {
         torrent.Create("Patchy");
         torrent.ContentType = "application/x-bittorrent";
         torrent.OpenWithList = new[] { "patchy.exe" };
         var program = new ProgramAssociationInfo(torrent.ProgID);
         if (!program.Exists)
         {
             program.Create("Patchy Torrent File", new ProgramVerb("Open", string.Format(
                 "\"{0}\" \"%1\"", Path.Combine(Assembly.GetEntryAssembly().Location))));
             program.DefaultIcon = new ProgramIcon(Assembly.GetEntryAssembly().Location);
         }
     }
     else
         torrent.Delete();
 }
Ejemplo n.º 24
0
        private void associateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!UAC.IsAdmin())
            {
                if (!UAC.RestartElevated("assoc"))
                {
                    MessageBox.Show("Can't associate extension without admin rights!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
            else
            {

                DialogResult dRes = MessageBox.Show("Associate *.wad and *.spr files with this program?", "File(s) association",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dRes == System.Windows.Forms.DialogResult.Yes)
                {
                    FileAssociationInfo faiWad = new FileAssociationInfo(".wad");
                    FileAssociationInfo faiSpr = new FileAssociationInfo(".spr");
                    faiWad.Create(Application.ProductName);
                    faiSpr.Create(Application.ProductName);
                    faiWad.OpenWithList = new string[] { Application.ExecutablePath };
                    faiSpr.OpenWithList = new string[] { Application.ExecutablePath };

                    ProgramAssociationInfo paiWad = new ProgramAssociationInfo(faiWad.ProgID);
                    ProgramAssociationInfo paiSpr = new ProgramAssociationInfo(faiSpr.ProgID);
                    paiWad.Create(new ProgramVerb("Open", Application.ExecutablePath + " \"%1\""));
                    paiSpr.Create(new ProgramVerb("Open", Application.ExecutablePath + " \"%1\""));
                }
            }
        }