private void addFileToINI(string line) { totalFiles++; FuncParser.iniWrite(appINI, "Files", "ShortcutFile_" + totalFiles.ToString(), line); createShortcut(totalFiles, line); FuncParser.iniWrite(appINI, "General", "TotalFiles", totalFiles.ToString()); }
private void closeApp(object sender, EventArgs e) { if (!File.Exists(appINI)) { FuncParser.writeToFile(appINI, new List <string>() { "[Files]", "", "[General]", "WindowTitleName=Все программы", "POS_WindowTop=100", "POS_WindowLeft=100", "MaxItemsOnLine=6", "TotalFiles=0" }); } else { if (Top >= 0 && Left >= 0) { FuncParser.iniWrite(appINI, "General", "POS_WindowTop", Top.ToString()); FuncParser.iniWrite(appINI, "General", "POS_WindowLeft", Left.ToString()); } } AppDomain.CurrentDomain.ProcessExit -= new EventHandler(closeApp); }
public FormMain() { InitializeComponent(); string[] allFolders = pathAppFolder.Split(new string[] { "/", @"\" }, StringSplitOptions.None); separateAppPath.Add(pathAppFolder); if (allFolders.Length - 1 > 0) { for (int i = 0; i < allFolders.Length - 1; i++) { separateAppPath.Add(pathAddSlash(Path.GetFullPath(separateAppPath[separateAppPath.Count - 1] + @".."))); } } allFolders = null; if (File.Exists(appINI)) { string titleName = FuncParser.stringRead(appINI, "General", "WindowTitleName"); if (titleName != null) { Text = titleName; } int wLeft = FuncParser.intRead(appINI, "General", "POS_WindowLeft"); int wTop = FuncParser.intRead(appINI, "General", "POS_WindowTop"); if (wLeft < 0 || wTop < 0) { StartPosition = FormStartPosition.CenterScreen; } else { if (wLeft > (Screen.PrimaryScreen.Bounds.Width - Size.Width)) { wLeft = Screen.PrimaryScreen.Bounds.Width - Size.Width; } if (wTop > (Screen.PrimaryScreen.Bounds.Height - Size.Height)) { wTop = Screen.PrimaryScreen.Bounds.Height - Size.Height; } StartPosition = FormStartPosition.Manual; Location = new Point(wLeft, wTop); } totalFiles = FuncParser.intRead(appINI, "General", "TotalFiles"); if (totalFiles < 0) { totalFiles = 0; } maxItemsOnLine = FuncParser.intRead(appINI, "General", "MaxItemsOnLine"); if (maxItemsOnLine < 1) { maxItemsOnLine = 6; } ClientSize = new System.Drawing.Size(ClientSize.Width + ((maxItemsOnLine - 6) * offSetX), ClientSize.Height); toolStripMenuItem3.Enabled = maxItemsOnLine > 2; parseINI(); } else { closeApp(this, new EventArgs()); } AppDomain.CurrentDomain.ProcessExit += new EventHandler(closeApp); }
private void parseINI() { appID.Clear(); appLaunchArgs.Clear(); appLaunchPath.Clear(); for (int i = 1; i <= totalFiles; i++) { if (FuncParser.keyExists(appINI, "Files", "ShortcutFile_" + i.ToString())) { createShortcut(i, FuncParser.stringRead(appINI, "Files", "ShortcutFile_" + i.ToString())); } else { totalFiles = i--; FuncParser.iniWrite(appINI, "General", "TotalFiles", i.ToString()); break; } } }
private void clickItem(object sender, EventArgs e) { int id = FuncParser.stringToInt(((Control)sender).Tag.ToString()); if (Control.ModifierKeys == Keys.None) { int index = appID.IndexOf(id); if (index != -1) { processStart(appLaunchPath[index], appLaunchArgs[index]); } } else { DialogResult dialog = MessageBox.Show("Удалить выбранный ярлык?", "Удаление элемента", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { List <string> tempList = new List <string>(); for (int i = 1; i <= totalFiles; i++) { if (i != id) { tempList.Add(FuncParser.stringRead(appINI, "Files", "ShortcutFile_" + i.ToString())); } FuncParser.deleteKey(appINI, "Files", "ShortcutFile_" + i.ToString()); } for (int i = 0; i < tempList.Count; i++) { FuncParser.iniWrite(appINI, "Files", "ShortcutFile_" + (i + 1).ToString(), tempList[i]); } totalFiles = tempList.Count; FuncParser.iniWrite(appINI, "General", "TotalFiles", totalFiles.ToString()); tempList.Clear(); Application.Restart(); } } }
private void addRemoveMenu(int value) { maxItemsOnLine = maxItemsOnLine + value; FuncParser.iniWrite(appINI, "General", "MaxItemsOnLine", maxItemsOnLine.ToString()); Application.Restart(); }
private void createShortcut(int number, string line) { itemsOnLine++; if (nextLine) { ClientSize = new System.Drawing.Size(ClientSize.Width, ClientSize.Height + offSetY); nextLine = false; } appID.Add(number); string[] parseLine = line.Split(new string[] { "|" }, StringSplitOptions.None); if (parseLine[0][1].ToString() == "A") { appLaunchPath.Add(parseLine[2]); } else if (parseLine[0][1].ToString() == "R") { appLaunchPath.Add(trimAppPath(FuncParser.stringToInt(parseLine[0][2].ToString())) + parseLine[2]); } if (parseLine.Length == 4 && !String.IsNullOrEmpty(parseLine[3])) { appLaunchArgs.Add(parseLine[3]); } else { appLaunchArgs.Add(""); } PictureBox newPictureBox = new PictureBox(); newPictureBox.BackColor = System.Drawing.Color.Transparent; newPictureBox.Location = new System.Drawing.Point(iconPosX, iconPosY); newPictureBox.Name = "NewPictureBox_" + number.ToString(); newPictureBox.Size = new System.Drawing.Size(32, 32); newPictureBox.Cursor = System.Windows.Forms.Cursors.Hand; newPictureBox.Tag = number; newPictureBox.DoubleClick += clickItem; if (parseLine[0][0].ToString() == "F") { Image image = iconFromFile(appLaunchPath[appLaunchPath.Count - 1]); if (image.Width > 32 || image.Height > 32) { image = resizeIcon(image, 32, 32); } newPictureBox.Image = image; } else if (parseLine[0][0].ToString() == "D") { newPictureBox.Image = Properties.Resources.folder; } Controls.Add(newPictureBox); newPictureBox.BringToFront(); Label newLabel = new Label(); newLabel.BackColor = System.Drawing.Color.Transparent; newLabel.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); newLabel.Location = new System.Drawing.Point(labelPosX, labelPosY); newLabel.Name = "NewLabel_" + number.ToString(); newLabel.Size = new System.Drawing.Size(78, 30); newLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter; newLabel.Text = parseLine[1]; newLabel.Cursor = System.Windows.Forms.Cursors.Hand; newLabel.Tag = number; newLabel.DoubleClick += clickItem; Controls.Add(newLabel); newLabel.BringToFront(); if (itemsOnLine < maxItemsOnLine) { iconPosX += offSetX; labelPosX += offSetX; } else { iconPosX = 35; labelPosX = 12; iconPosY += offSetY; labelPosY += offSetY; itemsOnLine = 0; nextLine = true; } }