Exemple #1
0
    public FileUploadForm(API api, Dictionary<string, int> projects, Dictionary<string, int> companies)
    {
      this.api = api;
      this.projects = projects;
      this.companies = companies;

      InitializeComponent();

      foreach (string project in projects.Keys)
        projectsListBox.Items.Add(project);

      RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Kenwalt\\SysCAD\\FileUpload");
      if (registryKey != null)
      {
        projectsListBox.SelectedItem = registryKey.GetValue("SelectedProject") as string;
        SetNotificationList(registryKey.GetValue("NotificationList") as string);
        //category done later after we have the category list.
        //notification save needs to be added.
        descriptionTextBox.Text = registryKey.GetValue("Description") as string;
        nameTextBox.Text = registryKey.GetValue("Name") as string;
        filenameTextBox.Text = registryKey.GetValue("Filename") as string;
      }

      EnableForm(true);
    }
Exemple #2
0
    static void Main()
    {
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
    
      EnterDetailsForm enterDetailsForm = new BasecampAPI.EnterDetailsForm();

      Dictionary<string, int> projects = null;
      Dictionary<string, int> companies = null;

      do
      {
        RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Kenwalt\\SysCAD\\FileUpload");
        if (registryKey != null)
        {
          enterDetailsForm.siteTextBox.Text = registryKey.GetValue("Site") as string;
          enterDetailsForm.usernameTextBox.Text = registryKey.GetValue("Username") as string;
          enterDetailsForm.passwordTextBox.Text = registryKey.GetValue("Password") as string;
        }

        enterDetailsForm.ShowDialog();
        if (enterDetailsForm.DialogResult == DialogResult.OK)
        {
          registryKey = Registry.CurrentUser.CreateSubKey("Kenwalt\\SysCAD\\FileUpload");
          registryKey.SetValue("Site", enterDetailsForm.siteTextBox.Text);
          registryKey.SetValue("Username", enterDetailsForm.usernameTextBox.Text);
          registryKey.SetValue("Password", enterDetailsForm.passwordTextBox.Text);

          API api = new API(enterDetailsForm.siteTextBox.Text,
                            enterDetailsForm.usernameTextBox.Text,
                            enterDetailsForm.passwordTextBox.Text);

          projects = api.GetProjectList();
          companies = api.GetCompanyList();

          if ((projects != null) && (companies != null))
            Application.Run(new FileUploadForm(api, projects, companies));
        }
      }
      while ((projects == null) && (enterDetailsForm.DialogResult != DialogResult.Cancel));
    }