예제 #1
0
 // update the image/caption
 private void updatePicture(ResultBox resultBox, Bitmap new_image, String new_text)
 {
     if (this.InvokeRequired)
     {
         Invoke(new delegateUpdateImage(updatePicture), new object[] { resultBox, new_image, new_text });
     }
     else
     {
         //write code here
         resultBox.SetResult(new_image, new_text);
     }
 }
예제 #2
0
 // a sub-"method" created so that we can create a new thread
 // update the caption
 private void updateText(ResultBox resultBox, String new_text)
 {
     if (this.InvokeRequired)
     {
         Invoke(new delegateUpdateText(updateText), new object[] { resultBox, new_text });
     }
     else
     {
         //write code here
         resultBox.SetText(new_text);
     }
 }
예제 #3
0
        // Creates the resultBoxes array, and draws/positions them appropriately, based on number. If already created, re-calcs position
        private void initResultBoxes(int num)
        {
            #region If there are no resultBoxes, or their # has changed, we have to re-init the array
            if (resultBoxes == null || resultBoxes.Length != num)
            {
                // Dispose
                if (resultBoxes != null)
                {
                    foreach (ResultBox rb in resultBoxes)
                    {
                        rb.Dispose();
                    }
                }

                // Initialize Array
                resultBoxes = new ResultBox[num];
                for (int i = 0; i < num; i++)
                {
                    resultBoxes[i] = new ResultBox();                       // Create a new box
                    resultBoxes[i].Parent = topPanel;                       // Add it to the panel
                    resultBoxes[i].Show();
                }
            }
            #endregion

            #region Calculate box width and x, y positions, based on number of boxes
            int num_rows = 2;   // default vals
            int num_cols = 3;   // default vals

            // determine number of rows & cols, based on number of windows
            if (num <= 3) { num_rows = 1; num_cols = 3; }
            else if (num > 3 && num < 6) { num_rows = 2; num_cols = 3; }

            int padding = 10;   // padding between boxes (in px)

            int img_width = (topPanel.Width / num_cols) - padding * 2;
            int img_height = (topPanel.Height / num_rows) - padding * 2;

            for (int row = 0; row < num_rows; row++)        // start counting at zero for resultBox select math
            {
                for (int col = 1; col <= num_cols; col++)   // start counting at 1 for resultBox select math
                {
                    int i = row * num_cols + col - 1;       // figure out what box we're working with (-1 because working with indices)
                    if (i >= num) { break; }

                    int x = padding + (col - 1) * (img_width + padding);    // get x coord (based on how many already drawn)
                    int y = padding + (row) * (img_height + padding);       // get y coord (based on how many already drawn)

                    resultBoxes[i].SetBounds(x, y, img_width, img_height);  // set the location/dimension of it
                }
            }
            #endregion
        }