public void importShortcuts()
        {
            listBoxFavs.Items.Clear();
            if (Directory.Exists(userDataFolder))
            {
                ListBoxEntry entryMain = new ListBoxEntry();
                entryMain.title = mainTitle;
                entryMain.url   = mainUrl;
                listBoxFavs.Items.Add(entryMain);
                String shortcutFolder = userDataFolder + "\\shortcuts";
                if (!Directory.Exists(shortcutFolder))
                {
                    Directory.CreateDirectory(shortcutFolder);
                }
                else
                {
                    String filename = userDataFolder + "\\shortcuts\\" + mainTitle + ".links";
                    if (File.Exists(filename))
                    {
                        StreamReader str = new StreamReader(filename);
                        String       line;
                        while ((line = str.ReadLine()) != null)
                        {
                            if (line.Contains("="))
                            {
                                String       entry        = line.Substring(0, line.IndexOf("="));
                                String       content      = line.Substring(line.IndexOf("=") + 1);
                                ListBoxEntry listBoxEntry = new ListBoxEntry();
                                listBoxEntry.title = entry.Trim();
                                listBoxEntry.url   = content.Trim();
                                listBoxFavs.Items.Add(listBoxEntry);
                            }
                        }
                        str.Close();
                    }
                }
                ListBoxEntry entryNew = new ListBoxEntry();
                entryNew.title = "- Add Current URL";
                listBoxFavs.Items.Add(entryNew);
                listBoxFavs.SelectedIndex = 0;
            }
            int height = 110;

            if (listBoxFavs.Items.Count > 1)
            {
                height = listBoxFavs.Items.Count * 55 + 50;
            }
            if (height >= 720)
            {
                height = 720;
            }
            this.Size = new Size(this.Size.Width, height);
        }
        public FormFavourites(String userDataFolder)
        {
            InitializeComponent();
            if (Directory.Exists(userDataFolder))
            {
                DirectoryInfo dir = new DirectoryInfo(userDataFolder + "\\sites");
                foreach (FileInfo file in dir.GetFiles())
                {
                    if (file.FullName.EndsWith(".link"))
                    {
                        ListBoxEntry listBoxEntry = new ListBoxEntry();
                        StreamReader str          = new StreamReader(file.FullName);
                        String       line;
                        while ((line = str.ReadLine()) != null)
                        {
                            if (line.Contains("="))
                            {
                                String entry   = line.Substring(0, line.IndexOf("="));
                                String content = line.Substring(line.IndexOf("=") + 1);
                                if (entry == "title")
                                {
                                    listBoxEntry.title = content.Trim();
                                }
                                else if (entry == "url")
                                {
                                    listBoxEntry.url = content.Trim();
                                }
                            }
                        }
                        str.Close();
                        listBoxFavs.Items.Add(listBoxEntry);
                    }
                }
                if (listBoxFavs.Items.Count > 0)
                {
                    listBoxFavs.SelectedIndex = 0;
                }
            }
            int height = 110;

            if (listBoxFavs.Items.Count > 1)
            {
                height = listBoxFavs.Items.Count * 55 + 50;
            }
            if (height >= 720)
            {
                height = 720;
            }
            this.Size = new Size(this.Size.Width, height);
        }
Beispiel #3
0
        public FormContextMenu()
        {
            InitializeComponent();
            ListBoxEntry listBoxEntry = new ListBoxEntry();

            listBoxEntry.title = "Enter URL";
            listBoxMenu.Items.Add(listBoxEntry);
            listBoxEntry       = new ListBoxEntry();
            listBoxEntry.title = "Show Keyboard";
            listBoxMenu.Items.Add(listBoxEntry);
            listBoxEntry       = new ListBoxEntry();
            listBoxEntry.title = "Show Magnifier";
            listBoxMenu.Items.Add(listBoxEntry);
            listBoxEntry       = new ListBoxEntry();
            listBoxEntry.title = "Show Favourites";
            listBoxMenu.Items.Add(listBoxEntry);
            listBoxEntry       = new ListBoxEntry();
            listBoxEntry.title = "Show Shortcuts";
            listBoxMenu.Items.Add(listBoxEntry);
            listBoxEntry       = new ListBoxEntry();
            listBoxEntry.title = "Double Click";
            listBoxMenu.Items.Add(listBoxEntry);
            listBoxEntry       = new ListBoxEntry();
            listBoxEntry.title = "Press TAB";
            listBoxMenu.Items.Add(listBoxEntry);
            listBoxEntry       = new ListBoxEntry();
            listBoxEntry.title = "Press ESC";
            listBoxMenu.Items.Add(listBoxEntry);
            listBoxEntry       = new ListBoxEntry();
            listBoxEntry.title = "Press F5";
            listBoxMenu.Items.Add(listBoxEntry);
            if (listBoxMenu.Items.Count > 0)
            {
                listBoxMenu.SelectedIndex = 0;
            }
            int height = 110;

            if (listBoxMenu.Items.Count > 1)
            {
                height = listBoxMenu.Items.Count * 55 + 50;
            }
            if (height >= 720)
            {
                height = 720;
            }
            this.Size = new Size(this.Size.Width, height);
        }