Esempio n. 1
0
        private void gridLinks_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DependencyObject dep = (DependencyObject)e.OriginalSource;

            // iteratively traverse the visual tree
            while ((dep != null) && !(dep is DataGridCell) && !(dep is DataGridColumnHeader))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }

            if (dep == null)
            {
                return;
            }

            if (dep is DataGridCell)
            {
                DataGridCell cell = dep as DataGridCell;
                path = cell.ToString().Substring(("System.Windows.Controls.DataGridCell: ").Length);
            }
            string server     = txtVaultServer.Text != string.Empty ? txtVaultServer.Text : "localhost";
            var    pathString = path.Replace("/", "%2f");

            vaultAddress         = generateVaultHyperlink(server, pathString);
            txtVaultAddress.Text = vaultAddress;
        }
Esempio n. 2
0
// <Snippet1>
    private void Grid_MouseUp
        (object sender, System.Windows.Forms.MouseEventArgs e)
    {
        DataGrid     dg     = (DataGrid)sender;
        DataGridCell myCell = dg.CurrentCell;

        Console.WriteLine(myCell.ToString());
    }
Esempio n. 3
0
        //method that occurs when a cell in any of the grids is clicked: it
        //gets the cell's respective account's name, data, and balance
        private void DataGridCell_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //open a new window for the account
            SingleAccount accountWindow = new SingleAccount();

            accountWindow.Show();

            //get the account name and set in new window
            DataGridCell cell        = (DataGridCell)sender;
            string       cellName    = cell.ToString();
            int          index       = cellName.IndexOf(":");
            string       accountName = cellName.Substring(index + 2);

            accountWindow.accountName.Content = accountName;

            //get account data
            Entry_tacc tacc = new Entry_tacc();

            for (int i = 0; i < Database.TEntries.Count; i++)
            {
                if (accountName.Equals(Database.TEntries[i].Account))
                {
                    tacc.Debit.AddRange(Database.TEntries[i].Debit);
                    tacc.Credit.AddRange(Database.TEntries[i].Credit);
                    tacc.Balance = Database.TEntries[i].Balance;
                }
            }

            //set account data in new window

            for (int i = 0; i < tacc.Debit.Count; i++)
            {
                Account account = new Account();
                account.Debit = tacc.Debit[i];
                if (account.Debit != 0)
                {
                    accountWindow.debitGrid.Items.Add(account);
                }
            }
            for (int i = 0; i < tacc.Credit.Count; i++)
            {
                Account account = new Account();
                account.Credit = tacc.Credit[i];
                if (account.Credit != 0)
                {
                    accountWindow.creditGrid.Items.Add(account);
                }
            }

            accountWindow.balanceLbl.Content = tacc.Balance.ToString();

            //to clear duplicate cells that pop up after user clicks a cell
            Refresh();
        }
Esempio n. 4
0
        public DataGridCellTests()
        {
            DataGridCell dg = new DataGridCell();

            Console.WriteLine("DataGridCell default --- ");
            Console.WriteLine("Column {0}", dg.RowNumber);
            Console.WriteLine("Row {0}", dg.ColumnNumber);

            dg.RowNumber    = 10;
            dg.ColumnNumber = 5;

            Console.WriteLine("ToString {0}", dg.ToString());
            Console.WriteLine("GetHashCode {0}", dg.GetHashCode());
        }
Esempio n. 5
0
    private void Grid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
        DataGrid     dg      = (DataGrid)sender;
        DataGridCell myCell  = dg.CurrentCell;
        string       tempkey = myCell.ToString();

        Console.WriteLine("Temp " + tempkey);
        if (myHashTable.Contains(tempkey))
        {
            return;
        }
        myHashTable.Add(tempkey, myCell.GetHashCode());
        Console.WriteLine("Hashcode: " + myCell.GetHashCode().ToString());
    }
Esempio n. 6
0
        public void DataGridCell_ToString_Invoke_ReturnsExpected()
        {
            var cell = new DataGridCell(1, 2);

            Assert.Equal("DataGridCell {RowNumber = 1, ColumnNumber = 2}", cell.ToString());
        }