예제 #1
0
        public static void horizontalSplitClick(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;
            String   name     = menuItem.GetValue(MenuItem.NameProperty) as String;

            String[]  splitedName = name.Split('_');
            GridPanel grid        = FindChild <GridPanel>(Application.Current.MainWindow, "grid_" + splitedName[1]);
            var       mainGrid    = (Grid)grid.FindName("grid");


            int rowSpan    = (int)grid.GetValue(Grid.RowSpanProperty);
            int columnSpan = (int)grid.GetValue(Grid.ColumnSpanProperty);

            if (columnSpan == 2)
            {
                menuItem.IsEnabled = false;
            }
            if (columnSpan != 1)
            {
                int row    = (int)grid.GetValue(Grid.RowProperty);
                int column = (int)grid.GetValue(Grid.ColumnProperty);
                grid.SetValue(Grid.ColumnSpanProperty, columnSpan / 2);
                GridPanel newGrid = new GridPanel(id_counter.ToString(), rowSpan, columnSpan / 2, column + columnSpan / 2, row);

                mainGrid.Children.Add(newGrid);
            }
        }
예제 #2
0
        private void clearViewClick(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;
            String   name     = menuItem.GetValue(MenuItem.NameProperty) as String;

            String[]  splitedName = name.Split('_');
            GridPanel gp          = FindChild <GridPanel>(Application.Current.MainWindow, "grid_" + splitedName[1]);
            var       grid        = (Grid)gp.FindName("grid");

            int rowSpan    = (int)grid.GetValue(Grid.RowSpanProperty);
            int columnSpan = (int)grid.GetValue(Grid.ColumnSpanProperty);

            gp.Children.RemoveAt(gp.Children.Count - 1);

            menuItem.IsEnabled = false;
            ((MenuItem)buttonMenu.Items.GetItemAt(2)).IsEnabled = true;
        }
예제 #3
0
        private void tableViewClick(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;
            String   name     = menuItem.GetValue(MenuItem.NameProperty) as String;

            String[]  splitedName = name.Split('_');
            GridPanel gp          = FindChild <GridPanel>(Application.Current.MainWindow, "grid_" + splitedName[1]);
            var       grid        = (Grid)gp.FindName("grid");

            DataTable table = new DataTable("Data history");

            table.Columns.Add(new DataColumn("Kolona1"));
            table.Columns.Add(new DataColumn("Kolona2"));
            table.Rows.Add("Red1", "Red1");
            table.Rows.Add("Red2", "Red2");

            int rowSpan    = (int)grid.GetValue(Grid.RowSpanProperty);
            int columnSpan = (int)grid.GetValue(Grid.ColumnSpanProperty);
            int row        = (int)grid.GetValue(Grid.RowProperty);
            int column     = (int)grid.GetValue(Grid.ColumnProperty);

            DataGrid dg = new DataGrid();

            dg.ItemsSource          = table.DefaultView;
            dg.IsReadOnly           = true;
            dg.CanUserResizeColumns = true;
            dg.VerticalAlignment    = VerticalAlignment.Stretch;
            dg.HorizontalAlignment  = HorizontalAlignment.Stretch;

            dg.MaxWidth  = 300;
            dg.MaxHeight = 300;
            //dg.HorizontalScrollBarVisibility = ;

            gp.Children.Add(dg);

            menuItem.IsEnabled = false;

            MenuItem clearView = new MenuItem();

            clearView.Name   = "clear_" + splitedName[1];
            clearView.Header = "clear view";
            clearView.Click += clearViewClick;
            buttonMenu.Items.Add(clearView);
            clearView.IsEnabled = true;
        }