Example #1
0
 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);
 }
Example #2
0
 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;
         }
     }
 }
Example #3
0
        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();
                }
            }
        }