Example #1
0
        void MainFormLoad(object sender, EventArgs e)
        {
            participle = "during MainFormLoad";
            //try {
            mainFlowLayoutPanel.Location = new Point(0, 0);
            participle = "loading args";
            string result = ProgChooser.load(args);

            participle = "getting choices list";
            if (result != null)
            {
                MessageBox.Show(result);
            }
            ArrayList thisAL = ProgChooser.showChoicesToArrayList();
            int       index  = 0;

            if (thisAL != null)
            {
                participle = "showing choices";
                foreach (string thisString in thisAL)                   //for (int index=0; index<4; index++) {
                {
                    participle = "processing choice:" + ((thisString != null)?("\"" + thisString + "\""):"null");
                    //				Button newButton=new Button();
                    //				this.mainFlowLayoutPanel.Controls.Add(newButton);
                    //				newButton.Location = new System.Drawing.Point(3, 3);
                    //				newButton.Name = "button"+progButtons.Count.ToString();
                    //				newButton.Size = new System.Drawing.Size(75, 23);
                    //				newButton.TabIndex = 0;
                    //				newButton.Text = "button"+progButtons.Count.ToString();
                    //				newButton.UseVisualStyleBackColor = true;
                    //				newButton.Click += new System.EventHandler(this.AnyProgramButtonClick);
                    //				progButtons.Add(newButton);
                    Label newLabel = new System.Windows.Forms.Label();
                    this.mainFlowLayoutPanel.Controls.Add(newLabel);
                    newLabel.Location = new System.Drawing.Point(3, 0);
                    newLabel.Name     = "programLabel" + index.ToString();
                    newLabel.Tag      = index.ToString();
                    newLabel.Size     = new System.Drawing.Size(100, 23);
                    newLabel.TabIndex = 0;
                    newLabel.Text     = thisString;               //"item "+index.ToString();
                    newLabel.AutoSize = true;
                    newLabel.Click   += new System.EventHandler(this.AnyProgramLabelClick);
                    progLabels.Add(newLabel);
                    index++;
                }
            }
            else
            {
                participle = "showing program options since no args";
                string thisString = "There was no file sent to ProgChooser. The purpose of the program is to send files to a program you choose using one keystroke.";
                if (args.Length > 1)
                {
                    string extAndQuotesIfPresent_string      = "no";
                    string temp_extAndQuotesIfPresent_string = ProgChooser.getExtensionString();
                    if (!string.IsNullOrEmpty(temp_extAndQuotesIfPresent_string))
                    {
                        extAndQuotesIfPresent_string = "\"" + temp_extAndQuotesIfPresent_string + "\"";
                    }
                    thisString = "ProgChooser has not been setup for files with " + extAndQuotesIfPresent_string + " extension.";
                }
                else
                {
                    this.Text = "ProgChooser";
                }
                Label newLabel = new System.Windows.Forms.Label();
                this.mainFlowLayoutPanel.Controls.Add(newLabel);
                newLabel.Location = new System.Drawing.Point(3, 0);
                newLabel.Name     = "programLabel" + index.ToString();
                newLabel.Tag      = index.ToString();
                newLabel.Size     = new System.Drawing.Size(100, 23);
                newLabel.TabIndex = 0;
                newLabel.Text     = thisString;           //"item "+index.ToString();
                newLabel.AutoSize = true;
                //progLabels.Add(newLabel);
                Console.Error.WriteLine("Got null list of programs");
            }
            //}
            //catch (Exception exn) {
            //	Console.Error.WriteLine(("Could not finish "+participle+" ").TrimEnd()+" in MainFormLoad for the following reason: "+exn.ToString());
            //}
        }