Beispiel #1
0
 private void refreshSharesButton_Click(object sender, EventArgs e)
 {
     if (App.fileList.isUpdating)
     {
         MessageBox.Show("Already in the process of updating.");
     }
     else
     {
         App.fileList.clear();
         System.Threading.Thread t = new System.Threading.Thread(delegate()
         {
             int numShares = App.fileListDatabase.getInt(App.settings.settings, "Root Share Count", 0);
             for (int i = 0; i < numShares; i++)
             {
                 Model.RootShare g = App.fileListDatabase.getObject <Model.RootShare>(App.settings.settings, "Root Share " + i.ToString());
                 if (g != null)
                 {
                     g.lastModified = 0;
                     App.fileListDatabase.setObject <Model.RootShare>(App.settings.settings, "Root Share " + i.ToString(), g);
                 }
             }
         });
         t.IsBackground = true;
         t.Name         = "File list update thread";
         t.Start();
     }
 }
Beispiel #2
0
        void upsertShare(Model.RootShare r)
        {
            int numShares = App.fileListDatabase.getInt(App.settings.settings, "Root Share Count", 0);

            for (int i = 0; i < numShares; i++)
            {
                Model.RootShare g = App.fileListDatabase.getObject <Model.RootShare>(App.settings.settings, "Root Share " + i.ToString());
                if (g == null)
                {
                    r.index = i;
                    App.fileListDatabase.setObject <Model.RootShare>(App.settings.settings, "Root Share " + i.ToString(), r);
                    updateSharesNamed(r, i);
                    return;
                }
                else
                {
                    if (g.fullPath == r.fullPath)
                    {
                        App.fileListDatabase.setObject <Model.RootShare>(App.settings.settings, "Root Share " + i.ToString(), r);
                        updateSharesNamed(r, i);
                        return;
                    }
                }
            }

            r.index = numShares;
            App.fileListDatabase.setObject <Model.RootShare>(App.settings.settings, "Root Share " + numShares.ToString(), r);

            App.fileListDatabase.setInt(App.settings.settings, "Root Share Count", numShares + 1);
            updateSharesNamed(r, numShares);
        }
Beispiel #3
0
        private void addShareButton_Click(object sender, EventArgs e)
        {
            folderBrowserDialog.SelectedPath = "";
            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                //add the folder
                string fullPath = folderBrowserDialog.SelectedPath.Replace('\\', '/');
                string name     = fullPath;
                if (name.EndsWith(":/"))
                {
                    name = name.Substring(0, name.IndexOf(":"));
                }
                if (name.Contains("/"))
                {
                    name = name.Substring(name.LastIndexOf("/") + 1);
                }
                bool clear = false;
                while (!clear)
                {
                    clear = true;
                    foreach (Model.RootShare q in App.fileListDatabase.getRootShares())
                    {
                        if (q != null)
                        {
                            if (q.name == name)
                            {
                                clear = false;
                            }
                        }
                    }
                    if (!clear)
                    {
                        name = name + " (2)";
                    }
                }

                /*int numShares = App.fileList.getInt(App.settings.settings, "Root Share Count", 0);
                 * for (int i = 0; i < numShares; i++)
                 *  if (App.fileList.getObject<Model.RootShare>(App.settings.settings, "Root Share " + i.ToString()).fullPath.ToLower() == fullPath.ToLower())
                 *  {
                 *      MessageBox.Show("You have already added that share.");
                 *      return;
                 *  }*/

                Model.RootShare r = new Model.RootShare();
                r.name     = name;
                r.fullPath = fullPath;
                r.id       = App.fileListDatabase.allocateId();

                ListViewItem li = new ListViewItem(r.name);
                li.SubItems.Add(r.fullPath.Replace('/', System.IO.Path.DirectorySeparatorChar));
                li.SubItems.Add("");
                li.Tag = r;
                sharesListView.Items.Add(li);

                upsertShare(r);
            }
        }
Beispiel #4
0
        void load()
        {
            if (App.settings.getBool("Use UPnP", true))
            {
                UPnPButton.Checked = true;
                manuallyForwardPortsButton.Checked = false;
            }
            else
            {
                UPnPButton.Checked = false;
                manuallyForwardPortsButton.Checked = true;
            }
            udpDataPortBox.Value    = App.settings.getInt("Default Data Port", 0);
            dhtPortBox.Value        = App.settings.getInt("Default DHT Port", 0);
            udpControlPortBox.Value = App.settings.getInt("Default Control Port", Model.NetConstants.controlPort);
            usernameBox.Text        = App.settings.getString("Username", Environment.MachineName);
            descriptionBox.Text     = App.settings.getString("Description", "");

            downloadFolderInput.Text = App.settings.getString("Default Download Folder", "C:\\Downloads");
            flashNameDropBox.Checked = App.settings.getBool("Flash on Name Drop", true);
            playSoundsBox.Checked    = App.settings.getBool("Play sounds", true);

            minimizeToTrayBox.Checked = App.settings.getBool("Minimize to Tray", true);
            autoRejoinBox.Checked     = App.settings.getBool("Auto Rejoin on Startup", true);
            showAFKBox.Checked        = App.settings.getBool("Show AFK", true);

            updateWithoutPromptingBox.Checked = App.settings.getBool("Update Without Prompting", false);

            reverseDefaultBox.Checked      = App.settings.getBool("Default to Reverse Connection", false);
            alwaysRendezvousButton.Checked = App.settings.getBool("Always Rendezvous", false);

            fontSelectBox.Text = App.settings.getString("Font", "Lucida Console");
            if (App.comicSansOnly)
            {
                fontSelectBox.Items.Clear();
                fontSelectBox.Items.Add("Comic Sans MS");
                fontSelectBox.SelectedIndex = 0;
            }
            int numShares = App.fileListDatabase.getInt(App.settings.settings, "Root Share Count", 0);

            for (int i = 0; i < numShares; i++)
            {
                Model.RootShare r = App.fileListDatabase.getObject <Model.RootShare>(App.settings.settings, "Root Share " + i.ToString());

                if (r != null)
                {
                    ListViewItem li = new ListViewItem(r.name);
                    li.SubItems.Add(r.fullPath.Replace('/', System.IO.Path.DirectorySeparatorChar));
                    li.SubItems.Add(ByteFormatter.formatBytes(r.size));
                    li.Tag = r;
                    sharesListView.Items.Add(li);
                }
            }
        }
Beispiel #5
0
        private void renameButton_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem i in sharesListView.SelectedItems)
            {
                RenameShareForm r = new RenameShareForm(i.Text);
                r.ShowDialog();

                Model.RootShare r2 = (Model.RootShare)i.Tag;
                r2.name = r.theName;
                i.Text  = r2.name;

                App.fileListDatabase.setObject <Model.RootShare>(App.settings.settings, "Root Share " + i.Index, r2);
            }
        }
Beispiel #6
0
        private void deleteShareButton_Click(object sender, EventArgs e)
        {
            List <ListViewItem> toRemove = new List <ListViewItem>();

            foreach (ListViewItem i in sharesListView.SelectedItems)
            {
                toRemove.Add(i);

                Model.RootShare r = (Model.RootShare)i.Tag;

                App.fileListDatabase.setObject <Model.RootShare>(App.settings.settings, "Root Share " + r.index, null);

                removeSharesNamed(r.name, r.index);
            }
            foreach (ListViewItem i in toRemove)
            {
                sharesListView.Items.Remove(i);
            }
            App.fileListDatabase.setInt(App.settings.settings, "Root Share Count", sharesListView.Items.Count);
        }
Beispiel #7
0
 void updateSharesNamed(Model.RootShare r, int index)
 {
 }