Exemple #1
0
        //private Dictionary<String, int> parseText(String text, int width)
        //{
        //    String line = String.Empty;
        //    String returnString = String.Empty;
        //    //String[] wordArray = text.Split(' ');
        //    //count records how many rows it has.
        //    int count = 1;
        //    Dictionary<String, int> result = new Dictionary<String, int>();
        //    for (int i = 0; i < text.Length; i++)
        //    {
        //        char word = text[i];
        //        if (ResourceManager.font_.MeasureString(line + word).X > width)
        //        {
        //            int tempAddwidth = 0;
        //            while (i < text.Length && text[i] != ' ' && ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z')))
        //            {
        //                word = text[i];
        //                line = line + word;
        //                tempAddwidth += (int)ResourceManager.font_.MeasureString(word.ToString()).X;
        //                i++;
        //            }
        //            if (tempAddwidth > addwidth)
        //                addwidth = tempAddwidth;
        //            if (i < text.Length)
        //            {
        //                returnString = returnString + line + '\n';
        //                count++;
        //                line = String.Empty;
        //            }
        //        }
        //        if(i < text.Length)
        //            line = line + text[i];
        //    }
        //    result[returnString + line] = count;
        //    return result;
        //}
        //left 2; right 2; up & down 4; alignment
        public Vector2 drawTags(int startX, int startY, float angleDisplay, int height, float scale)
        {
            //int YOffset = 0;
            //int resultWidth = 0;
            if (allTags.Count > 1 && wallLabel == null)
            {
                //string result = String.Empty;
                wallLabel = new System.Windows.Forms.DataGridView();
                wallLabel.ColumnCount = 1;
                wallLabel.ColumnHeadersVisible = false;
                wallLabel.RowHeadersVisible = false;
                //change line automatically
                wallLabel.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
                wallLabel.BorderStyle = System.Windows.Forms.BorderStyle.None;
                wallLabel.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal;
                wallLabel.DefaultCellStyle.WrapMode = System.Windows.Forms.DataGridViewTriState.True;

                //set column to fill the whole width
                wallLabel.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
                //background
                wallLabel.BackgroundColor = System.Drawing.Color.White;

                //wallLabel.MultiSelect = true;
                //wallLabel.SelectionChanged += new EventHandler(wallLabel_SelectionChanged);
                wallLabel.ReadOnly = true;
                wallLabel.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(wallLabel_CellMouseClick);
                //wallLabel.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(wallLabel_CellBeginEdit);
                wallLabel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
                wallLabel.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.White;
                wallLabel.DefaultCellStyle.SelectionForeColor = System.Drawing.Color.Red;
                //wallLabel.EditMode = System.Windows.Forms.DataGridViewEditMode.
                foreach (String tag in allTags)
                {
                    if(tag.Length > 0)
                        wallLabel.Rows.Add(tag);
                    //Dictionary<String, int> result = parseText(tag, width - left - right);
                    //if (result.Values.First() > 1)
                    //    resultWidth = width + addwidth;
                    //else if (resultWidth < width && resultWidth < ResourceManager.font_.MeasureString(tag).Length() + 5)
                    //    resultWidth = (int)ResourceManager.font_.MeasureString(tag).Length() + 5;
                    //if (activeTagList.Contains(tag))
                    //{
                    //    Browser.Instance.batch_.DrawString(ResourceManager.font_, result.Keys.First(), new Vector2(startX + left, startY + YOffset), Color.Red);
                    //}
                    //else
                    //    Browser.Instance.batch_.DrawString(ResourceManager.font_, result.Keys.First(), new Vector2(startX + left, startY + YOffset), Color.Gray);
                    //Vector2 size = ResourceManager.font_.MeasureString(tag);
                    ////create bounding box for every tag
                    //tagBox[tag] = new BoundingBox2D(new Vector2(startX, startY + YOffset), new Vector2(startX + resultWidth, startY + YOffset + size.Y * result.Values.First()), angleDisplay);
                    //YOffset +=(int) size.Y * result.Values.First()+ up;

                }
                wallLabel.Location = new System.Drawing.Point(startX, startY);
                wallLabel.Size = new System.Drawing.Size(width, height);
                Browser.Instance.wall.Controls.Add(wallLabel);
                wallLabel.ClearSelection();
                wallLabel.Focus();
                Browser.Instance.wall.AddLabel(wallLabel);
            }
            else if (wallLabel != null)
            {
                //wallLabel.Update(new System.Drawing.Point(startX + (int)Browser.Instance.clientBounds.Min.X, startY + (int)Browser.Instance.clientBounds.Min.Y), new System.Drawing.Size((int)(width), height));
                wallLabel.Location = new System.Drawing.Point(startX, startY);
                wallLabel.Size = new System.Drawing.Size(width, height);

            }
            return new Vector2(width, 0);
        }
Exemple #2
0
        private void CalculateOptions()
        {
            optionsTable.Visible = true;
            robotLimit           = Int32.Parse(maxRobot.Text);
            operatorLimit        = Int32.Parse(maxOperator.Text);
            optimums.Clear();
            form.TotalCount = 0;
            form.ReadCache  = 0;
            indexes         = new List <Index>();
            if (calculate != 0)
            {
                optionsTable.Rows.Clear();
                optionsTable.Columns.Clear();
                optionsTable.ClearSelection();
                combinationMap.Clear();
            }
            if (calculate > 0 && Form1.getCacheCount() <= 0)
            {
                combinationMap.Clear();
            }
            if (maxRobot.Text.Length == 0 || maxOperator.Text.Length == 0)
            {
                MessageBox.Show("Please give me the maximum limits!", "Missing number.");
            }
            else
            {
                stopwatch.Start();
                stopwatchAll.Start();
                optimum = form.getPrevOptVal(tables.Count - 1, robotLimit, operatorLimit, ref idxs);
                stopwatch.Stop();

                for (int i = 0; i <= robotInterval; ++i)      // default 5
                {
                    for (int z = 0; z <= workerInterval; ++z) // default 5
                    {
                        string k;
                        // RobotLimit-- OperatorLimit++
                        if (robotLimit - i >= 0)
                        {
                            k = (robotLimit - i).ToString() + "," + (operatorLimit + z).ToString();
                            if (combinationMap.Keys.Contains(k))
                            {
                                continue;
                            }
                            OptimumsCalculator(i, z, k, 1);
                        }
                        // Robotlimit-- Operatorlimit--
                        if (robotLimit - i >= 0 && operatorLimit - z >= 0)
                        {
                            k = (robotLimit - i).ToString() + "," + (operatorLimit - z).ToString();
                            if (combinationMap.Keys.Contains(k))
                            {
                                continue;
                            }
                            OptimumsCalculator(i, z, k, 0);
                        }
                        // Robotlimit++ Operatorlimit--
                        if (operatorLimit - z >= 0)
                        {
                            k = (robotLimit + i).ToString() + "," + (operatorLimit - z).ToString();
                            if (combinationMap.Keys.Contains(k))
                            {
                                continue;
                            }
                            OptimumsCalculator(i, z, k, 2);
                        }
                    }
                }
                for (int i = 0; i <= robotInterval; ++i)
                {
                    for (int z = 0; z <= workerInterval; ++z)
                    {
                        string k = (robotLimit + i).ToString() + "," + (operatorLimit + z).ToString();

                        if (combinationMap.Keys.Contains(k))
                        {
                            continue;
                        }
                        //Plus
                        OptimumsCalculator(i, z, k, 3);
                    }
                }

                stopwatchAll.Stop();
                fillOptions();
                calculate++;
            }
        }