Beispiel #1
0
 private void buscarProductos()
 {
     if (textBox1.Text.IndexOf('*') != -1)
     {
         String[] arre = textBox1.Text.Split('*');
         for (int i = 0; i < productos.GetUpperBound(0); i++)
         {
             if (arre[1] == productos[i, 0])
             {
                 dataGridView1.Rows.Add(productos[i, 2], productos[i, 1], arre[0], float.Parse(productos[i, 2]) * float.Parse(arre[0]));
             }
         }
     }
     else
     {
         for (int i = 0; i < productos.GetUpperBound(0); i++)
         {
             if (textBox1.Text == productos[i, 0])
             {
                 dataGridView1.Rows.Add(productos[i, 2], productos[i, 1], "1", productos[i, 2]);
             }
         }
     }
     total();
 }
    public static void Main()
    {
        //https://docs.google.com/spreadsheets/d/1v90ZW65jDo-c3_5oWHT7UYIYtDB3ma44uUdaoYh8TeQ/
        String[,] grid = {
            {"_0", "_1", "_2", "_3"},
            {"_8", "_9", "_10", "_11"},
            {"_16", "_17", "_18", "_19"},
            {"_24", "_25", "_26", "_27"},
        };
        Console.WriteLine("Grid valid? " + gridValid(grid, 4, 4));

        InfoOfEachTile topLeft = new InfoOfEachTile("_9");
        InfoOfEachTile topRight = new InfoOfEachTile("_10");
        InfoOfEachTile bottomLeft = new InfoOfEachTile("_17");
        InfoOfEachTile bottomRight = new InfoOfEachTile("_18");
        InfoOfEachTile.connectHorizontal(topLeft, topRight);
        InfoOfEachTile.connectHorizontal(bottomLeft, bottomRight);
        InfoOfEachTile.connectVertical(topLeft, bottomLeft);
        InfoOfEachTile.connectVertical(topRight, bottomRight);

        String[,] miniGrid = miniGridFromTile(topLeft);
        for (var y = miniGrid.GetLowerBound(0); y <= miniGrid.GetUpperBound(0); y++)
        {
            for (var x = miniGrid.GetLowerBound(1); x <= miniGrid.GetUpperBound(1); x++)
            {
                Console.Write(miniGrid[y, x] == null ? "__ " : miniGrid[y, x] + " ");
            }
            Console.WriteLine();
        }
        Console.WriteLine("GRID VALID: " + validateTile(bottomRight));
    }
Beispiel #3
0
    protected void setSiteMapObject(Control setSiteMapTo, String[,] siteMapArray)
    {
        setSiteMapTo.Controls.Clear();
        for (int i = 0; i <= siteMapArray.GetUpperBound(0); i++)
        {
            LinkButton newLB = new LinkButton();
            newLB.ID              = "newLB" + i.ToString();
            newLB.Text            = siteMapArray[i, 0].ToString();
            newLB.Click          += new EventHandler(newLB_Click);
            newLB.CommandName     = siteMapArray[i, 1].ToString();
            newLB.CommandArgument = siteMapArray[i, 2].ToString();
            if (!main_top_menu.FindItem(siteMapArray[i, 2].ToString()).Selectable)
            {
                newLB.Enabled = false;
            }

            newLB.CssClass = "MapLine";
            setSiteMapTo.Controls.Add(newLB);
            if (siteMapArray.GetUpperBound(0) > 0 && i < siteMapArray.GetUpperBound(0))
            {
                Label newLbl = new Label();
                newLbl.ID   = "newLbl" + i.ToString();
                newLbl.Text = " : ";
                setSiteMapTo.Controls.Add(newLbl);
            }
        }
    }
        static void userInputs(String[,] world, String randomSnakeCordinate)
        {
            int matrixRowCount        = world.GetUpperBound(0) + 1;
            int matrixColumnCount     = world.GetUpperBound(1) + 1;
            int randomSnakeCordinateX = Convert.ToInt32(randomSnakeCordinate[0].ToString());
            int randomSnakeCordinateY = Convert.ToInt32(randomSnakeCordinate[2].ToString());

            int userInputedSnakeX = randomSnakeCordinateX;
            int userInputedSnakeY = randomSnakeCordinateY;

            do
            {
                switch (userInput())
                {
                case ConsoleKey.RightArrow:
                    userInputedSnakeY++;
                    break;

                case ConsoleKey.LeftArrow:
                    userInputedSnakeY--;
                    break;

                case ConsoleKey.UpArrow:
                    userInputedSnakeX--;
                    break;

                case ConsoleKey.DownArrow:
                    userInputedSnakeX++;
                    break;

                default:
                    break;
                }
                Console.Clear();
                int worldSizeX = world.GetUpperBound(0) + 1;
                int worldSizeY = world.GetUpperBound(1) + 1;
                if (userInputedSnakeX >= worldSizeX - 1)
                {
                    Console.WriteLine($"line 86 ::: {userInputedSnakeX}");
                    world[-userInputedSnakeX, userInputedSnakeY] = "S";
                }
                else if (userInputedSnakeY >= worldSizeY - 1)
                {
                    Console.WriteLine($"line 90 ::: {userInputedSnakeY}");
                    Console.WriteLine($"line 91 ::: {userInputedSnakeX}");
                    world[userInputedSnakeX, -userInputedSnakeY] = "S";
                }
                else
                {
                    Console.WriteLine($"line 95 ::: {userInputedSnakeX}, {userInputedSnakeY}");
                    world[userInputedSnakeX, userInputedSnakeY] = "S";
                }
                printTheWorld(world);
            } while (userInput() != ConsoleKey.Escape);
        }
Beispiel #5
0
        /// <summary>
        /// Expands embedded aliases (such as _KG) in-place. The alias table is responseAliases.
        /// </summary>
        /// <param name="response"></param>
        /// <returns></returns>
        private string expandAliases(string response)
        {
            int numAliases = responseAliases.GetUpperBound(0) + 1;

            for (int i = 0; i < numAliases; i++)
            {
                String alias     = responseAliases[i, 0];
                String expansion = responseAliases[i, 1];
                response = response.Replace(alias, expansion);
            }
            return(response);
        }
    private static String getTileFromGrid(String[,] grid, int x, int y)
    {
        if (x < grid.GetLowerBound(1) || x > grid.GetUpperBound(1))
        {
            return null;
        }
        if (y < grid.GetLowerBound(0) || y > grid.GetUpperBound(0))
        {
            return null;
        }

        return getTile(grid[y, x]);
    }
        static void Main(string[] args)
        {
            String[,] world = initTheWorld(20, 50);
            // GetUpperBound(0) and GetUpperBound(1) return 4 in 5x5 matrix
            int matrixRowCount    = world.GetUpperBound(0) + 1;
            int matrixColumnCount = world.GetUpperBound(1) + 1;

            String randomSnakeCordinate  = snakeRandomCordinate(matrixRowCount, matrixColumnCount);
            int    randomSnakeCordinateX = Convert.ToInt32(randomSnakeCordinate[0].ToString());
            int    randomSnakeCordinateY = Convert.ToInt32(randomSnakeCordinate[2].ToString());

            world[randomSnakeCordinateX, randomSnakeCordinateY] = "S";

            printTheWorld(world);
            userInputs(world, randomSnakeCordinate);
        }
Beispiel #8
0
        //move all methods into here
        //validation


        //create book class
        //create author class
        //create distributer class

        //methods
        public bool CheckCustomerId(String[,] distributor, String currentDistributerID)
        {
            bool customerIDExist = false;

            for (int outer = 0; outer < distributor.GetUpperBound(0) + 1; outer++)
            {
                for (int inner = 0; inner < distributor.GetUpperBound(1) + 1; inner++)
                {
                    if (currentDistributerID == distributor[outer, inner])
                    {
                        customerIDExist = true;
                        break;
                    }
                }
            }
            return(customerIDExist);
        }
Beispiel #9
0
        internal string save_All(string path)
        {
            String dataToString = "";

            if (dataArrayList == null)
            {
                return("ARRAY EMPTY");
            }
            else
            {
                dataToString += "ARRAY " + (dataArrayList.GetUpperBound(0) + 1) + "," +
                                (dataArrayList.GetUpperBound(1) + 1) + "\r\n";
                for (int i = 0; i <= dataArrayList.GetUpperBound(1); i++)
                {
                    dataToString += dataView.Columns[i].Name + ",";
                }


                for (int i = 0; i <= dataArrayList.GetUpperBound(0); i++)
                {
                    for (int j = 0; j <= dataArrayList.GetUpperBound(1); j++)
                    {
                        if (j == dataArrayList.GetUpperBound(1) && i == dataArrayList.GetUpperBound(0))
                        {
                            dataToString += dataArrayList[i, j];
                        }
                        else
                        {
                            dataToString += dataArrayList[i, j] + ",";
                        }
                    }
                }
                return(dataToString);
            }
        }
        public int MatrisKolonHesapla(String[,] hesaplanacakMatris)
        {
            int len = hesaplanacakMatris.Length;

            int columns = 0;

            for (int i = 0; i <= hesaplanacakMatris.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= hesaplanacakMatris.GetUpperBound(1); j++)
                {
                    if (columns <= hesaplanacakMatris.GetUpperBound(1))
                    {
                        columns++;
                    }
                }
                break;
            }
            return(columns);
        }
Beispiel #11
0
 public int posicaoNaoTerminal(String[,] vet, String letra)
 {
     for (int i = 0; i < vet.GetUpperBound(0) + 1; i++)
     {
         if (vet[i, 0] == letra)
         {
             return(i);
         }
     }
     throw new Exception("ERROR: Terminal '" + letra + "' não reconhecido.");
 }
Beispiel #12
0
 private int indexOfMe(String[,] obj, String kata)
 {
     for (int i = 0; i < obj.GetUpperBound(1) + 1; i++)
     {
         if (obj[index, i].Equals(kata))
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #13
0
 public int posicaoTerminal(String[,] vet, char letra)
 {
     for (int i = 0; i < vet.GetUpperBound(1) + 1; i++)
     {
         if (vet[0, i] == letra.ToString())
         {
             Console.WriteLine(vet[0, i]);
             return(i);
         }
     }
     throw new Exception("ERROR: Terminal '" + letra + "' não reconhecido.");
 }
        static void printTheWorld(String[,] world)
        {
            int matrixRowCount    = world.GetUpperBound(0) + 1;
            int matrixColumnCount = world.GetUpperBound(1) + 1;

            for (int i = 0; i < matrixRowCount; i++)
            {
                for (int j = 0; j < matrixColumnCount; j++)
                {
                    if (world[i, j] == "S")
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write(world[i, j]);
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.Write(world[i, j]);
                    }
                }
                Console.WriteLine();
            }
        }
Beispiel #15
0
        private void submitTable_Click(object sender, EventArgs e)
        {
            int rows = dataView.RowCount - 1;
            int cols = dataView.ColumnCount;

            dataArrayList = new string[rows, cols]; //check for null
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < cols; j++)
                {
                    dataArrayList[i, j] = dataView.Rows[i].Cells[j].Value.ToString();
                }
            }
            //check if first col = row names
            if (dataArrayList[0, 0].Any(x => !char.IsLetter(x)))
            {
            }
            dataSeriesList = new string[cols, rows];
            for (int i = 0; i <= dataSeriesList.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= dataSeriesList.GetUpperBound(1); j++)
                {
                    dataSeriesList[i, j] = dataArrayList[j, i];
                }
            }

            bindData(dataSeriesList);


            // Debug table creator
            //StringBuilder sb = new StringBuilder();
            //foreach (var VARIABLE in dataArrayList)
            //{
            //    sb.Append(VARIABLE.ToString());
            //}
            //MessageBox.Show(sb.ToString());
        }
Beispiel #16
0
 private static void spread(ITileData tile, int x, int y, String[,] grid)
 {
     if (tile == null)
     {
         return;
     }
     if (x < grid.GetLowerBound(1) || x > grid.GetUpperBound(1))
     {
         return;
     }
     if (y < grid.GetLowerBound(0) || y > grid.GetUpperBound(0))
     {
         return;
     }
     if (grid[y, x] != "NOT VISITED")
     {
         return;
     }
     grid[y, x] = tile.getId();
     spread(tile.getLeft(), x - 1, y, grid);
     spread(tile.getRight(), x + 1, y, grid);
     spread(tile.getUp(), x, y - 1, grid);
     spread(tile.getDown(), x, y + 1, grid);
 }
Beispiel #17
0
        void m_initialize(CertificateAuthority certificateAuthority)
        {
            if (!certificateAuthority.IsEnterprise)
            {
                throw new PlatformNotSupportedException();
            }

            version      = certificateAuthority.Version;
            sku          = certificateAuthority.Sku;
            configString = certificateAuthority.ConfigString;

            ICertPropReaderD propReader;

            if (certificateAuthority.PingRequest())
            {
                propReader = new CertPropReaderD(configString, false);
            }
            else if (certificateAuthority.PingAdmin())
            {
                propReader = new CertPropReaderD(configString, true);
            }
            else
            {
                var e = new ServerUnavailableException(certificateAuthority.DisplayName);
                e.Data.Add(nameof(e.Source), OfflineSource.DCOM);
                throw e;
            }

            Name         = certificateAuthority.Name;
            DisplayName  = certificateAuthority.DisplayName;
            ComputerName = certificateAuthority.ComputerName;

            String[,] templates = propReader.GetCaTemplates();
            for (Int32 i = 0; i <= templates.GetUpperBound(0); i++)
            {
                _templates.Add(CertificateTemplate.FromCommonName(templates[i, 0]));
            }
        }
Beispiel #18
0
        /// <summary>
        /// Create DataTable structure and fill the information from the array
        ///
        /// Not the best solution to create a grid with a button and 2 textboxes.
        /// But DataGrid proven to be a pain in the neck, so is DataRepeater.
        /// So this is a quick and dirty way of doing what I need.
        /// this is only a freaking help screen after all, no over-engineering here please!
        /// </summary>
        private void CreateControlsTable()
        {
            int Y_padding = 3;

            for (int i = 0; i < information.GetUpperBound(0) + 1; i++)
            {
                // tabs are special here!
                int tabCount = 10 * i;

                // say what location we want.
                // Y-location is computed based on the number of buttons already on the screen and by vertical padding
                int Y = TemplateBtnCopyPattern.Location.Y + i * (TemplateBtnCopyPattern.Height + Y_padding);
                // X location is copied from the template controls
                int X = TemplateTxtPattern.Location.X;

                // First Text Box
                TextBox pattern = CreateTextBox(X, Y, information[i, 0], TemplateTxtPattern, tabCount + 1);
                panel1.Controls.Add(pattern);

                // Copy button
                X = TemplateBtnCopyPattern.Location.X;
                Button copy = new Button();
                copy.Location = new Point(X, Y);
                copy.Text     = TemplateBtnCopyPattern.Text;
                copy.Size     = new Size(TemplateBtnCopyPattern.Width, TemplateBtnCopyPattern.Height);
                copy.Click   += new System.EventHandler(this.CopyButton_Click);
                copy.Tag      = pattern; // we need to associate a button with pattern textbox, so we can reference it later
                copy.TabIndex = tabCount;
                panel1.Controls.Add(copy);

                //Second text Box
                X = TemplateTxtExplanation.Location.X;
                TextBox expl = CreateTextBox(X, Y, information[i, 1], TemplateTxtExplanation, tabCount + 2);
                panel1.Controls.Add(expl);
            }
        }
        public bool placeship(int startrow, int startcolumn, string shiptype, string align)
        {
            var rtnsucces  = true;
            var shiplength = getShipLength(shiptype);

            if (align == "horizontal")
            {
                bool noships = true;
                int  bound   = board.GetUpperBound(1);
                // first check if no ships occupied
                for (int i = 0; i < shiplength; i++)
                {
                    if ((startcolumn + i) >= 0 && (startcolumn + i) <= bound) // check if it is not outside bounds
                    {
                        string shipvalue = board[startrow, startcolumn + i];
                        if (!(String.IsNullOrEmpty(shipvalue) || shipvalue == shiptype))
                        {
                            noships = false;
                            break;
                        }
                    }
                    else
                    {
                        noships = false;
                        break;
                    }
                }

                if (noships)
                {
                    // if we have this ship previously placed remove it so that it can be places in a new position
                    removeExistingShipfromBoard(shiptype);
                    // now place the ships
                    for (int i = 0; i < shiplength; i++)
                    {
                        board[startrow, startcolumn + i] = shiptype;
                    }
                }
                else
                {
                    rtnsucces = false;
                }
            }
            else
            {
                bool noships = true;
                int  bound   = board.GetUpperBound(0);
                // first check if no ships occupied
                for (int i = 0; i < shiplength; i++)
                {
                    if ((startrow + i) >= 0 && (startrow + i) <= bound) // check if it is not outside bounds
                    {
                        string shipvalue = board[startrow + i, startcolumn];
                        if (!(String.IsNullOrEmpty(shipvalue) || shipvalue == shiptype))
                        {
                            noships = false;
                            break;
                        }
                    }
                    else
                    {
                        noships = false;
                        break;
                    }
                }
                if (noships)
                {
                    // if we have this ship previously placed remove it so that it can be places in a new position
                    removeExistingShipfromBoard(shiptype);
                    // place in a column the ship
                    for (int i = 0; i < shiplength; i++)
                    {
                        board[startrow + i, startcolumn] = shiptype;
                    }
                }
                else
                {
                    rtnsucces = false;
                }
            }

            return(rtnsucces);
        }
Beispiel #20
0
        private void bindData(String[,] array)
        {
            double x = 0.5;
            double y = 1.5;

            chart1.Series.Clear();
            //row1 col 1                    //row2 col1
            //MessageBox.Show(array[0, 0].ToString() + "\r\n" + array[0,1].ToString());
            //check if first col = row names
            if (array[0, 0].Any(chr => char.IsLetter(chr)))
            {
                for (int i = 0; i < dataView.RowCount - 1; i++)
                {
                    string seriesName = array[0, i].ToString();
                    chart1.Series.Add(seriesName);
                }

                for (int i = 0; i <= array.GetUpperBound(1); i++)
                {
                    ArrayList list = new ArrayList();

                    for (int j = 1; j <= array.GetUpperBound(0); j++)
                    {
                        int strToInt = Convert.ToInt32(array[j, i]);
                        list.Add(strToInt);
                    }
                    chart1.Series[i].Points.DataBindY(list);
                }

                int c = 1;

                for (int i = 1; i < dataView.ColumnCount; i++)
                {
                    chart1.ChartAreas[0].AxisX.CustomLabels.Add(x, y, dataView.Columns[i].Name);
                    x++;
                    y++;
                }
            }
            else
            {
                for (int i = 0; i < dataView.RowCount - 1; i++)
                {
                    string seriesName = "Row: " + (i + 1);
                    chart1.Series.Add(seriesName);
                }

                for (int i = 0; i <= array.GetUpperBound(1); i++)
                {
                    ArrayList list = new ArrayList();

                    for (int j = 0; j <= array.GetUpperBound(0); j++)
                    {
                        int strToInt = Convert.ToInt32(array[j, i]);
                        list.Add(strToInt);
                    }
                    chart1.Series[i].Points.DataBindY(list);
                }
                int c = 0;
                foreach (var VARIABLE in dataView.Columns)
                {
                    chart1.ChartAreas[0].AxisX.CustomLabels.Add(x, y, dataView.Columns[c].Name);
                    x++;
                    c++;
                    y++;
                }
            }


            chart1.SaveImage("C:\\Users\\admin\\Source\\Repos\\BusinessPlanWriter\\BPWChartImages\\" + name + ".png", System.Drawing.Imaging.ImageFormat.Png);
            // C: \Users\admin\Source\Repos\BusinessPlanWriter\BPWChartImages
            // C:\\Users\admin\Source\\Repos
        }