public int Compare(object x, object y) { ListViewItem a = (ListViewItem)x; ListViewItem b = (ListViewItem)y; IcoListData icoa = (IcoListData)a.Tag; IcoListData icob = (IcoListData)b.Tag; return(icoa.Order.CompareTo(icob.Order)); }
public void AddIcon(string id, string name, string group, string icofile, string exec, int order, bool ShellEx, IcoListRegType t) { foreach (IcoListData ico in icos) { if (ico.ID == id && ico.Type == t) { if (DeleteIcon(id, t) == false) { return; } break; } } IcoListData newico = new IcoListData(id, name, group, icofile, exec, order, ShellEx, t); if (newico.InitSuccess == false) { return; } RegistryKey reg; if (t == IcoListRegType.User) { reg = Registry.CurrentUser.CreateSubKey(RegKey); } else { reg = Registry.LocalMachine.CreateSubKey(RegKey); } if (reg == null) { return; } RegistryKey sreg = reg.CreateSubKey(id); if (sreg == null) { return; } sreg.SetValue("Name", newico.Name); sreg.SetValue("IcoFile", newico.IcoFile); sreg.SetValue("Group", newico.Group); sreg.SetValue("Execute", newico.Execute); sreg.SetValue("Order", newico.Order, RegistryValueKind.DWord); sreg.SetValue("UseShellEx", newico.UseShellEx == true ? 1 : 0, RegistryValueKind.DWord); sreg.Close(); reg.Close(); AddIcon(newico); icos.Add(newico); }
private void deleteItemToolStripMenuItem_Click(object sender, EventArgs e) { if (lstPrograms.SelectedItems.Count == 0) { return; } IcoListData data = (IcoListData)lstPrograms.SelectedItems[0].Tag; if (MessageBox.Show(this, "Do you really want to delete the item " + data.Name + "?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != System.Windows.Forms.DialogResult.Yes) { return; } icolist.DeleteIcon(data.ID, data.Type); }
void AddIcon(IcoListData ico) { ListViewItem lst = new ListViewItem(ico.Name); if (icogroup.ContainsKey(ico.Group.ToLower()) == false) { ListViewGroup lg = new ListViewGroup(ico.Group); icogroup.Add(ico.Group.ToLower(), lg); lstList.Groups.Add(icogroup[ico.Group.ToLower()]); } lst.Tag = ico; lst.Group = icogroup[ico.Group.ToLower()]; lstList.SmallImageList.Images.Add(ico.Ico); lstList.LargeImageList.Images.Add(ico.Ico); lst.ImageIndex = lstList.SmallImageList.Images.Count - 1; lstList.Items.Add(lst); }
private void lstPrograms_DoubleClick(object sender, EventArgs e) { if (lstPrograms.SelectedItems.Count == 0) { return; } IcoListData data = (IcoListData)lstPrograms.SelectedItems[0].Tag; try { Process proc = new Process(); proc.StartInfo.FileName = Environment.ExpandEnvironmentVariables(data.Execute); proc.StartInfo.UseShellExecute = data.UseShellEx; proc.Start(); } catch { } }
private void cmdOK_Click(object sender, EventArgs e) { int Order; if (int.TryParse(txtOrder.Text, out Order) == false) { MessageBox.Show(this, "Invalid Order number", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (ico == null) { IcoListData icon = new IcoListData(txtID.Text, txtName.Text, lstGroup.Text, txtIcon.Text, txtExec.Text, Order, chkUseShellEx.Checked, lstType.SelectedIndex == 0 ? IcoListRegType.User : IcoListRegType.System); if (icon.InitSuccess == false) { MessageBox.Show(this, "Some data are not complete", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (Program.maindlg.icolist.IDExists(icon.ID, icon.Type) == true) { MessageBox.Show(this, "The ID " + ico.ID + " already exists", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } Program.maindlg.icolist.AddIcon(icon.ID, icon.Name, icon.Group, icon.IcoFile, icon.Execute, icon.Order, icon.UseShellEx, icon.Type); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { IcoListData icon = new IcoListData(txtID.Text, txtName.Text, lstGroup.Text, txtIcon.Text, txtExec.Text, Order, chkUseShellEx.Checked, lstType.SelectedIndex == 0 ? IcoListRegType.User : IcoListRegType.System); if (icon.InitSuccess == false) { MessageBox.Show(this, "Some data are not complete", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } Program.maindlg.icolist.AddIcon(icon.ID, icon.Name, icon.Group, icon.IcoFile, icon.Execute, icon.Order, icon.UseShellEx, icon.Type); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } }
static void PipeServerThread() { try { Pipe = new NamedPipeServerStream(PipeName, PipeDirection.InOut, 10, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); do { try { if (StopThread == true) { break; } Pipe.WaitForConnectionEx(cancel); XmlSerializer reader = new XmlSerializer(typeof(IcoListData)); IcoListData i = new IcoListData(); i = (IcoListData)reader.Deserialize(Pipe); switch (i.Action) { case IcoListAction.Delete: Program.maindlg.THREADDeleteIcon(i.ID, i.Type); break; case IcoListAction.Add: Program.maindlg.THREADAddIcon(i.ID, i.Name, i.Group, i.IcoFile, i.Execute, i.Order, i.UseShellEx, i.Type); break; } Pipe.Disconnect(); } catch (Exception ee) { Debug.WriteLine("INNER CATCH"); Debug.WriteLine(ee.ToString()); } }while (true); } catch (Exception ee) { Debug.WriteLine("OUTER CATCH"); Debug.WriteLine(ee.ToString()); } }
void InitRegistry(RegistryKey root, IcoListRegType T) { RegistryKey dir = root.OpenSubKey(RegKey, false); if (dir == null) { return; } foreach (string keyname in dir.GetSubKeyNames()) { RegistryKey key = dir.OpenSubKey(keyname, false); if (key == null) { continue; } IcoListData ico = new IcoListData(keyname, T, key); if (ico.InitSuccess == true) { icos.Add(ico); } } dir.Close(); }
public frmItemProperty() { ico = null; InitializeComponent(); }
public frmItemProperty(IcoListData i) { ico = i; InitializeComponent(); }
static void Main(string[] args) { Console.WriteLine("Fox Shell Icon"); Console.WriteLine(""); if (args.Length < 3) { Console.WriteLine("Usage:"); Console.WriteLine(""); Console.WriteLine("delete ID TYPE"); Console.WriteLine(" ID \"ID\" of the icon"); Console.WriteLine(" TYPE \"USER\" or \"SYSTEM\""); Console.WriteLine(""); Console.WriteLine("add ID TYPE NAME GROUP EXECUTABLE [ICONFILE] [ORDER] [USESHELLEX]"); Console.WriteLine(" ID \"ID\" of the icon"); Console.WriteLine(" TYPE \"USER\" or \"SYSTEM\""); Console.WriteLine(" NAME Name of the icon"); Console.WriteLine(" GROUP Group of the icon"); Console.WriteLine(" EXECUTABLE Executable"); Console.WriteLine(" ICONFILE Different icon, if specified"); Console.WriteLine(" ORDER Custom ordering, numeric, if specified"); Console.WriteLine(" USESHELLEX Use ShellEx, TRUE or FALSE (default: FALSE)"); return; } switch (args[0].ToLower()) { case "delete": { IcoListData ico = new IcoListData(); ico.ID = args[1]; switch (args[2].ToLower()) { case "user": ico.Type = IcoListRegType.User; break; case "system": ico.Type = IcoListRegType.System; break; default: Console.WriteLine("Unknown type"); return; } IcoListNamedPipes.DeleteIcon(ico.ID, ico.Type); break; } case "add": { if (args.Length < 6) { Console.WriteLine("Not enough argurments"); break; } IcoListData ico = new IcoListData(); ico.ID = args[1]; switch (args[2].ToLower()) { case "user": ico.Type = IcoListRegType.User; break; case "system": ico.Type = IcoListRegType.System; break; default: Console.WriteLine("Unknown type"); return; } ico.Name = args[3]; ico.Group = args[4]; ico.Execute = args[5]; if (args.Length > 6) { ico.IcoFile = args[6]; } else { ico.IcoFile = ico.Execute; } if (args.Length > 7) { if (int.TryParse(args[7], out ico.Order) == false) { ico.Order = 0; } } else { ico.Order = 0; } if (args.Length > 8) { switch (args[8].ToLower()) { case "true": ico.UseShellEx = true; break; case "false": ico.UseShellEx = false; break; default: Console.WriteLine("Unknown type"); return; } } else { ico.UseShellEx = false; } IcoListNamedPipes.AddIcon(ico.ID, ico.Name, ico.Group, ico.IcoFile, ico.Execute, ico.Order, ico.UseShellEx, ico.Type); break; } default: Console.WriteLine("Unknown action"); return; } }