void addAnotherMailbox_Click(object sender, EventArgs e) {
   GemuTreeNode clientModelTreeNode = null;
   ClientModel clientModel = null;
   string senderName = ((LinkLabel)sender).Name;
   foreach (GemuTreeNode googleEmailUploaderTreeNodeIter in
       this.selectionTreeView.Nodes) {
     ClientModel tempClientModel =
         (ClientModel)googleEmailUploaderTreeNodeIter.TreeNodeModel;
     if (tempClientModel.Client.Name == senderName) {
       clientModel = tempClientModel;
       clientModelTreeNode = googleEmailUploaderTreeNodeIter;
       break;
     }
   }
   Debug.Assert(clientModelTreeNode != null && clientModel != null);
   OpenFileDialog openFileDialog = new OpenFileDialog();
   openFileDialog.Multiselect = false;
   openFileDialog.CheckFileExists = true;
   DialogResult dialogResult = openFileDialog.ShowDialog();
   if (dialogResult == DialogResult.OK) {
     StoreModel addedStoreModel =
         clientModel.OpenStore(openFileDialog.FileName);
     if (addedStoreModel != null) {
       GemuTreeNode addedStoreTreeNode =
           new NormalGemuTreeNode(addedStoreModel);
       clientModelTreeNode.AddStoreChild(addedStoreTreeNode);
       if (clientModelTreeNode.Checked) {
         addedStoreTreeNode.Checked = true;
       }
       this.googleEmailUploaderModel.BuildModelFlatList();
       this.UpdateSelectionInfoLabel();
       if (this.googleEmailUploaderModel.TotalSelectedItemCount == 0) {
         this.nextButton.Enabled = false;
       } else {
         this.nextButton.Enabled = true;
       }
     } else {
       MessageBox.Show(string.Format(Resources.CouldNotOpenStoreTemplateText,
                                     openFileDialog.FileName));
     }
   }
 }
 internal NormalGemuTreeNode(TreeNodeModel treeNodeModel)
   : base(treeNodeModel) {
   uint cummulativeCount = 0;
   FolderModel folderModel = treeNodeModel as FolderModel;
   if (folderModel != null) {
     cummulativeCount += folderModel.Folder.MailCount;
   }
   foreach (TreeNodeModel childTreeNodeModel in treeNodeModel.Children) {
     GemuTreeNode childTreeNodeView =
         new NormalGemuTreeNode(childTreeNodeModel);
     this.Nodes.Add(childTreeNodeView);
     cummulativeCount += childTreeNodeView.CummmulativeCount;
   }
   StoreModel storeModel = treeNodeModel as StoreModel;
   if (storeModel != null && storeModel.Store.ContactCount > 0) {
     ContactGemuTreeNode contactTreeNode =
         new ContactGemuTreeNode(storeModel);
     this.Nodes.Add(contactTreeNode);
     cummulativeCount += contactTreeNode.CummmulativeCount;
   }
   this.Text =
       treeNodeModel.DisplayName + " ["
           + cummulativeCount + "]";
   this.Checked = treeNodeModel.IsSelected;
   this.cummulativeCount = cummulativeCount;
 }
    void InitializeComponent() {
      // Selection Tree View
      this.selectionTreeView = new GemuTreeView();
      this.selectionTreeView.ShowLines = true;
      this.selectionTreeView.Location = new Point(25, 85);
      this.selectionTreeView.Size = new System.Drawing.Size(250, 160);
      this.selectionTreeView.BorderStyle = BorderStyle.FixedSingle;
      this.selectionTreeView.CheckBoxes = true;
      this.selectionTreeView.Anchor =
          AnchorStyles.Top
          | AnchorStyles.Bottom
          | AnchorStyles.Left
          | AnchorStyles.Right;
      foreach (TreeNodeModel treeNodeModel in
          this.googleEmailUploaderModel.ClientModels) {
        GemuTreeNode googleEmailUploaderTreeNode =
            new NormalGemuTreeNode(treeNodeModel);
        this.selectionTreeView.Nodes.Add(googleEmailUploaderTreeNode);
      }

      // Next Button
      this.nextButton = new Button();
      this.nextButton.Location = new Point(120, 287);
      this.nextButton.Size = new Size(72, 23);
      this.nextButton.Text = Resources.NextText;
      this.nextButton.Font = new Font("Arial", 9.25F);
      this.nextButton.BackColor = SystemColors.Control;
      this.nextButton.Enabled = false;
      this.nextButton.Click += new EventHandler(this.nextButtonInSelect_Click);

      // Back Button
      this.backButton = new Button();
      this.backButton.Location = new Point(30, 287);
      this.backButton.Size = new Size(72, 23);
      this.backButton.Text = Resources.BackText;
      this.backButton.Font = new Font("Arial", 9.25F);
      this.backButton.BackColor = SystemColors.Control;
      this.backButton.Click += new EventHandler(this.backButtonInSelect_Click);

      // SelectEmail Label.
      this.selectEmailLabel = new Label();
      this.selectEmailLabel.Location = new Point(25, 60);
      this.selectEmailLabel.Size = new Size(260, 15);
      this.selectEmailLabel.Font = new Font("Arial", 9.25F);
      this.selectEmailLabel.Text = Resources.SelectUploadFoldersText;

      this.selectionTreeView.AfterCheck +=
          new TreeViewEventHandler(this.selectionTreeView_AfterCheck);

      this.addAnotherClientMailbox = new ArrayList();
      int initialVerticalOffset = 180;
      foreach (ClientModel model in
          this.googleEmailUploaderModel.ClientModels) {
        if (model.Client.SupportsLoadingStore) {
          LinkLabel addStoreLinkLabel = new LinkLabel();
          addStoreLinkLabel.Text = string.Format(
              Resources.AddMailBoxTemplateText,
              model.Client.Name);
          addStoreLinkLabel.Location = new Point(320, initialVerticalOffset);
          addStoreLinkLabel.AutoSize = true;
          addStoreLinkLabel.Click +=
              new EventHandler(this.addAnotherMailbox_Click);
          addStoreLinkLabel.Enabled = true;
          addStoreLinkLabel.Font = new Font("Arial", 9.25F);
          addStoreLinkLabel.Name = model.Client.Name;

          initialVerticalOffset += 20;
          this.addAnotherClientMailbox.Add(addStoreLinkLabel);
        }
      }


      this.addControlsForNonCustomizedSelectDialog();

      this.ActiveControl = this.nextButton;
      this.AcceptButton = this.nextButton;
    }