Beispiel #1
0
        internal static int GetRowIndex(DataGridCell cell)
        {
            DataGridRow r2       = DataGridRow.GetRowContainingElement(cell);
            int         rowindex = r2.GetIndex();

            return(rowindex);
        }
Beispiel #2
0
        private void grdTemplatesButton_Click(object sender, RoutedEventArgs e)
        {
            DataGridRow row = DataGridRow.GetRowContainingElement(sender as FrameworkElement);

            App.FixedPattern = (FixedPattern)row.DataContext;
            Navigate("/FixedPatternTemplates");
        }
        public void PrintOperation(object sender, RoutedEventArgs e)
        {
            DataGridRow row    = DataGridRow.GetRowContainingElement(sender as FrameworkElement);
            RGReport    report = (RGReport)row.DataContext;

            CheckBox cmb = null;

            if (WebContext.Current.User.Roles.FirstOrDefault() == "Customer")
            {
                cmb = this.RGDataGridCustomer.Columns[7].GetCellContent(row) as CheckBox;
            }
            else
            {
                cmb = this.RGDataGrid.Columns[9].GetCellContent(row) as CheckBox;
            }

            //Get the root path for the XAP
            string src = Application.Current.Host.Source.ToString();

            //Get the application root, where 'ClientBin' is the known dir where the XAP is
            string appRoot = src.Substring(0, src.IndexOf("ClientBin"));

            //Uri reportURI = new Uri(string.Format(appRoot + "RGReportGenerate.aspx?ReportNo={0}", report.ReportNo), UriKind.Absolute);
            Debug.Assert(report != null, "report != null");
            Uri reportURI = new Uri(string.Format(appRoot + "RGReportGenerate.aspx?ReportId={0}&" + "ReportNo={1}&FilmSize={2}", report.ID, report.ReportNo, cmb.IsChecked), UriKind.Absolute);

            HtmlPage.Window.Navigate(reportURI, "_blank");
        }
        //[UPDATE][DELETE] Click Cell in DataGrid
        private void DataGridCell_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DataGridCell myCell = sender as DataGridCell;
            DataGridRow  row    = DataGridRow.GetRowContainingElement(myCell);
            Product      temp   = row.Item as Product;

            if (isDeleted == true)
            {
                for (int i = 0; i < listProducts.Count; i++)
                {
                    if (listProducts[i].IDProduct == temp.IDProduct)
                    {
                        if (listProducts[i].isSelected == true)
                        {
                            listProducts[i].isSelected = false;
                        }
                        else
                        {
                            listProducts[i].isSelected = true;
                        }
                    }
                }
                dataGridProduct.ItemsSource = null;
                dataGridProduct.ItemsSource = listProducts;
            }

            if (isUpdating == true)
            {
                UpdateProduct window = new UpdateProduct(temp);
                window.ShowDialog();
                reloadData();
            }
        }
        public void CopyOperation(object sender, RoutedEventArgs e)
        {
            RGReportRowForCopying = new RGReportRow();
            DataGridRow row = DataGridRow.GetRowContainingElement(sender as FrameworkElement);

            RGReportRowForCopying = (RGReportRow)row.DataContext;
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(value is DataGridCell))
            {
                return("-1");
            }

            DataGridCell cell = (DataGridCell)value;

            DataGridRow r = DataGridRow.GetRowContainingElement(cell);

            if (r == null)
            {
                return(-1);
            }

            int row = r.GetIndex();

            if (cell.DataContext is FamilyData)
            {
                FamilyData fd = (FamilyData)cell.DataContext;

                fd.ParameterValues[cell.Column.DisplayIndex].Row = row;
            }


            return(row);
        }
Beispiel #7
0
        private void ShowComment_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                // Get the Selected Row Button
                Button button = (Button)sender;

                // Check if the Button is null
                if (button != null)
                {
                    // Return the row which contains the specified button
                    DataGridRow dataGridRowSelectedRow = DataGridRow.GetRowContainingElement(button);

                    // Check if the DataGridRow is null
                    if (dataGridRowSelectedRow != null)
                    {
                        // if Collapsed -> Visible
                        if (dataGridRowSelectedRow.DetailsVisibility == System.Windows.Visibility.Collapsed)
                        {
                            dataGridRowSelectedRow.DetailsVisibility = System.Windows.Visibility.Visible;
                        }
                        // else collaps row Details
                        else
                        {
                            dataGridRowSelectedRow.DetailsVisibility = System.Windows.Visibility.Collapsed;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public void dataGridTask_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left)
     {
         DataGridRow dgr = DataGridRow.GetRowContainingElement(e.OriginalSource as FrameworkElement);
         if (dgr != null)
         {
             CO_IA.Data.Task task = dgr.DataContext as CO_IA.Data.Task;
             if (task != null)
             {
                 Window wnd;
                 if (task.FormState == AT_BC.Data.FormState.Check)
                 {
                     wnd             = new Task.ExecutorTaskConclusionWindow();
                     wnd.DataContext = task;
                     if (wnd.ShowDialog(this) == true)
                     {
                         this.executedTasks.View.Refresh();
                         this.executableTasks.View.Refresh();
                     }
                 }
             }
         }
     }
 }
        private void ClearChangeIndicator()
        {
            DataGridAutomationPeer automationPeer = (DataGridAutomationPeer)DataGridAutomationPeer.CreatePeerForElement(NodeMetadataDataGrid);

            // Get the DataGridRowsPresenterAutomationPeer so we can find the rows in the data grid...
            DataGridRowsPresenterAutomationPeer dataGridRowsPresenterAutomationPeer = automationPeer.GetChildren().
                                                                                      Where(a => (a is DataGridRowsPresenterAutomationPeer)).
                                                                                      Select(a => (a as DataGridRowsPresenterAutomationPeer)).
                                                                                      FirstOrDefault();

            if (null != dataGridRowsPresenterAutomationPeer)
            {
                foreach (var item in dataGridRowsPresenterAutomationPeer.GetChildren())
                {
                    // loop to find the DataGridCellAutomationPeer from which we can interrogate the owner -- which is a DataGridRow
                    foreach (var subitem in (item as DataGridItemAutomationPeer).GetChildren())
                    {
                        if ((subitem is DataGridCellAutomationPeer))
                        {
                            // At last -- the only public method for finding a row....
                            DataGridRow row = DataGridRow.GetRowContainingElement(((subitem as DataGridCellAutomationPeer).Owner as FrameworkElement));
                            row.Foreground = new SolidColorBrush(Colors.Black);
                        }
                    }
                }
            }
        }
        public void Execute(object parameter)
        {
            var cb        = ((object[])parameter)[0] as ComboBox;
            var viewModel = ((object[])parameter)[1] as PertPageViewModel;
            var row       = DataGridRow.GetRowContainingElement(cb);

            var edgeVm = row.Item as PertPageEdgeItemViewModel;

            if (edgeVm == null)
            {
                return;
            }

            var functionId = edgeVm.FunctionId;
            var processId  = edgeVm.ProcessId;
            var source     = viewModel.TaskSource as IEnumerable <PertPageTaskItemViewModel>;

            if (processId != null)
            {
                source = source.Where(x => x.ProcessId == processId || x.TaskId == null).ToList();
            }
            if (functionId != null)
            {
                source = source.Where(x => x.FunctionId == functionId || x.TaskId == null).ToList();
            }

            cb.ItemsSource = source;
        }
Beispiel #11
0
        private void btnExpandCollapse_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Button lObjExpandCollapse = (Button)sender;
                //checa el objeto boton si es null o no
                if (lObjExpandCollapse != null)
                {
                    // Return the Contains which specified element
                    DataGridRow DgrSelectedRowObj = DataGridRow.GetRowContainingElement(lObjExpandCollapse);

                    // Check the DataGridRow Object is Null or Not
                    if (DgrSelectedRowObj != null)
                    {
                        // si el boton ="+" expande los detalles
                        if (lObjExpandCollapse != null && lObjExpandCollapse.Content.ToString() == "+")
                        {
                            DgrSelectedRowObj.DetailsVisibility = System.Windows.Visibility.Visible;
                            lObjExpandCollapse.Content          = "-";
                        }
                        // else contrae los detalles
                        else
                        {
                            DgrSelectedRowObj.DetailsVisibility = System.Windows.Visibility.Collapsed;
                            lObjExpandCollapse.Content          = "+";
                        }
                    }
                }
            }
            catch
            {
                //CustomMessageBox.Show("Error", "No se pudieron consultar los detalles", this.GetParent());
            }
        }
Beispiel #12
0
 private void dataGridTask_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left)
     {
         DataGridRow dgr = DataGridRow.GetRowContainingElement(e.OriginalSource as FrameworkElement);
         if (dgr != null)
         {
             CO_IA.Data.Task task = dgr.DataContext as CO_IA.Data.Task;
             if (task != null)
             {
                 Window wnd;
                 if (task.FormState == AT_BC.Data.FormState.Check)
                 {
                     wnd = new TaskExecutedWindow();
                 }
                 else
                 {
                     wnd = new TaskEditWindow();
                 }
                 wnd.DataContext = task;
                 wnd.ShowDialog(this);
             }
         }
     }
 }
Beispiel #13
0
        //[UPDATE][DELETE] Click Cell in DataGrid
        private void DataGridCell_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DataGridCell myCell = sender as DataGridCell;
            DataGridRow  row    = DataGridRow.GetRowContainingElement(myCell);
            Output       temp   = row.Item as Output;

            //if (isDeleted == true)
            //{
            //    for (int i = 0; i < listOutputs.Count; i++)
            //    {
            //        if (listOutputs[i].IDOutput == temp.IDOutput)
            //        {
            //            if (listOutputs[i].isSelected == true)
            //            {
            //                listOutputs[i].isSelected = false;
            //            }
            //            else
            //            {
            //                listOutputs[i].isSelected = true;
            //            }
            //        }
            //    }
            //    dataGridOutput.ItemsSource = null;
            //    dataGridOutput.ItemsSource = listOutputs;
            //}

            if (isUpdating == true)
            {
                //UpdateOutput window = new UpdateOutput(temp);
                //window.ShowDialog();
                //reloadData();
            }
        }
        //Kept here only for the template column to work fine
        public override void DeleteOperation(object sender, RoutedEventArgs e)
        {
            if (
                MessageBox.Show("Are you sure you want to delete this item?", "Confirm Delete",
                                MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
            {
                return;
            }

            DataGridRow row = DataGridRow.GetRowContainingElement(sender as FrameworkElement);

            //commit any unsaved changes to avoid an exception
            if (Grid.CommitEdit())
            {
                var rowToBeRemoved = (RGReportRow)row.DataContext;
                RGReportRows.Remove(rowToBeRemoved);
                //also delete from the datacontext
                ((RadiographyContext)this.DomainSource.DomainContext).RGReportRows
                .Remove(rowToBeRemoved as RGReportRow);

                //mark at least one row deleted
                RGReport.RowsDeleted = true;
            }
            UpdateSourceBasedOnThickness();
        }
Beispiel #15
0
        /// <summary>
        /// Gets the list of DataGridRow objects.
        /// </summary>
        /// <param name="grid">The grid wirhrows.</param>
        /// <returns>List of rows of the grid.</returns>
        public static ICollection <DataGridRow> GetRows(this System.Windows.Controls.DataGrid grid)
        {
            var rows = new List <DataGridRow>();

            foreach (var rowItem in grid.ItemsSource)
            {
                // Ensures that all rows are loaded.
                grid.ScrollIntoView(rowItem, grid.Columns.Last());

                // Get the content of the cell.
                var el = grid.Columns.Last().GetCellContent(rowItem);

                // Retrieve the row which is parent of given element.
                var row = DataGridRow.GetRowContainingElement(el.Parent as FrameworkElement);

                // Sometimes some rows for some reason can be null.
                if (row != null)
                {
                    if (!rows.Contains(row))
                    {
                        rows.Add(row);
                    }
                }
            }

            return(rows);
        }
        private void HideShowDetails(object sender, RoutedEventArgs e)
        {
            Button      expandCollapseButton = (Button)sender;
            DataGridRow selectedRow          = DataGridRow.GetRowContainingElement(expandCollapseButton);

            if (null != expandCollapseButton && "+" == expandCollapseButton.Content.ToString())
            {
                selectedRow.DetailsVisibility = Visibility.Visible;
                expandCollapseButton.Content  = "-";
            }
            else
            {
                selectedRow.DetailsVisibility = Visibility.Collapsed;
                expandCollapseButton.Content  = "+";
                if (selectedRow.DataContext is JobPositionValueDTO)
                {
                    var parentRow = selectedRow.FindParentOfType <DataGridRow>();
                    parentRow.DetailsVisibility = Visibility.Collapsed;

                    var timer = new DispatcherTimer()
                    {
                        Interval = new TimeSpan(0, 0, 0, 0, 200)
                    };
                    timer.Tick += (ts, te) =>
                    {
                        Dispatcher.BeginInvoke(() => parentRow.DetailsVisibility = Visibility.Visible);
                        timer.Stop();
                    };
                    timer.Start();
                }
            }
        }
        /// <summary>
        /// Metodo che si attiva quando viene effettuato un click sulla cella contenente la checkbox (scelto2)
        /// - Cambia il valore della CheckBox cliccata
        /// - (se la casella cliccata è relativa ad un progetto che non esiste non abilita nessuna funzione)
        /// - se la CheckBox opposta (scelto1) è true la mette a false
        /// - cancella e ricarica la DataGrid
        /// </summary>
        void OnClick2(object sender, RoutedEventArgs e)
        {
            bool        value = ((DataGridCell)sender).Content.ToString().Split(':').Last().Equals("True") ? true : false;
            DataGridRow r2    = DataGridRow.GetRowContainingElement((DataGridCell)sender);
            int         index = r2.GetIndex();

            if (!value)
            {
                if (list[index].prog2 != null)
                {
                    list[index].scelto1 = false;
                    list[index].scelto2 = true;
                }
            }
            else
            {
                list[index].scelto2 = false;
            }
            DataGrid dataGrid = this.FindName("dataGrid2") as DataGrid;

            dataGrid.Items.Clear();
            foreach (Confronto c in list)
            {
                dataGrid.Items.Add(c);
            }
        }
Beispiel #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditOperation(object sender, RoutedEventArgs e)
        {
            DataGridRow row = DataGridRow.GetRowContainingElement(sender as FrameworkElement);
            var         registrationData = (RegistrationData)row.DataContext;

            registrationData.isEditing = true;
            OpenRegistrationWindow(registrationData);
        }
Beispiel #19
0
        /// <summary>
        ///     Remove the selected song from the MainScreen and in turn the songQueue
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void RemoveSongFromQueue(object sender, RoutedEventArgs e)
        {
            //Return the selected row.
            DataGridRow row = DataGridRow.GetRowContainingElement((DataGridCell)((Button)sender).Parent);

            player.RemoveSong(row.GetIndex());
            UpdateQueueList();
        }
Beispiel #20
0
 private void ErrorClicked(object sender, MouseButtonEventArgs e)
 {
     if ((e.MouseDevice.DirectlyOver as FrameworkElement).Parent is DataGridCell)
     {
         var item = DataGridRow.GetRowContainingElement((e.MouseDevice.DirectlyOver as FrameworkElement).Parent as FrameworkElement).Item as Warning;
         item.OpenTarget?.Invoke();
     }
 }
Beispiel #21
0
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            int selectedIndex = DataGridRow.GetRowContainingElement(sender as FrameworkElement).GetIndex();

            Matches.RemoveAt(selectedIndex);

            dataGrid.CancelEdit();
        }
        public void ExcelExportOperation(object sender, RoutedEventArgs e)
        {
            DataGridRow row    = DataGridRow.GetRowContainingElement(sender as FrameworkElement);
            RGReport    report = (RGReport)row.DataContext;

            ctx = (RadiographyContext)RGDomainDataSource.DomainContext;
            busyIndicator.IsBusy = true;
            this.ctx.Load(this.ctx.GetRGReportsQuery(report.ReportNo)).Completed += loadCompleted;;
        }
        private void grdDetailsButton_Click(object sender, RoutedEventArgs e)
        {
            DataGridRow row = DataGridRow.GetRowContainingElement(sender as FrameworkElement);

            App.FinalReport = new FinalRTReport()
            {
                RTNo = ((RTStatusReportRow)row.DataContext).RTNo
            };
            Navigate("/FinalRadiographyReport");
        }
Beispiel #24
0
        private void OnExpanded(object sender, RoutedEventArgs e)
        {
            if (sender is Expander expander)
            {
                var row = DataGridRow.GetRowContainingElement(expander);

                row.DetailsVisibility = expander.IsExpanded ? Visibility.Visible
                                                            : Visibility.Collapsed;
            }
        }
        private void DataGrid_MouseRightButtonUp_1(object sender, MouseButtonEventArgs e)
        {
            var hit = VisualTreeHelper.HitTest((Visual)sender, e.GetPosition((IInputElement)sender));
            DependencyObject cell = VisualTreeHelper.GetParent(hit.VisualHit);

            while (cell != null && !(cell is DataGridCell))
            {
                cell = VisualTreeHelper.GetParent(cell);
            }
            DataGridCell targetCell = cell as DataGridCell;
            //var celldata = targetCell.Column.DisplayIndex;
            DataGridRow r2 = DataGridRow.GetRowContainingElement(targetCell);

            if (r2 != null)
            {
                int rowindex = r2.GetIndex() + 19976;
                // At this point targetCell should be the cell that was clicked or null if something went wrong.
                SqlConnection con   = new SqlConnection(@"Server=LAPTOP-0SA5RLTP;Initial Catalog = efratDB;Trusted_Connection=True;");
                string        query = string.Format("SELECT type, carray From GameTable Where id={0}", rowindex);
                SqlCommand    cmd1  = new SqlCommand(query, con);
                con.Open();
                // cmd1.ExecuteNonQuery();
                SqlDataReader reader = cmd1.ExecuteReader();
                if (reader.Read())
                {
                    type   = (string)reader["type"];
                    xmlDoc = XDocument.Parse((string)reader["carray"]);
                    xmlDoc.Save("foo2.xml");
                }
                con.Close();
            }

            string[] pathsList = xmlDoc.Descendants("item").Select(x => x.Value).ToArray();
            arr1 = new int[pathsList.Length];

            arr2 = new int[pathsList.Length];
            int i;

            for (i = 0; i < pathsList.Length; i++)
            {
                if (pathsList[i] == "-2")
                {
                    break;
                }
                arr1[i] = Int32.Parse(pathsList[i]);
                size++;
            }
            int t = 0;

            for (int k = i + 1; k < pathsList.Length; k++)
            {
                arr2[t] = Int32.Parse(pathsList[k]);
                t++;
            }
        }
Beispiel #26
0
        private void DataGridRow_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            DataGridRow dgr = DataGridRow.GetRowContainingElement(e.OriginalSource as FrameworkElement);

            if (dgr != null)
            {
                ActivityEquipmentInfo      equip  = dgr.DataContext as ActivityEquipmentInfo;
                InterferedDetailInfoDialog dialog = new InterferedDetailInfoDialog(equip, dicInterfereResult, dicIMInterfereResult);
                dialog.Show();
            }
        }
Beispiel #27
0
 private void EquipmentGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left)
     {
         DataGridRow dgr = DataGridRow.GetRowContainingElement(e.OriginalSource as FrameworkElement);
         if (dgr != null)
         {
             ActivityEquipment equipment = dgr.DataContext as ActivityEquipment;
             ShowEquipDetail(equipment);
         }
     }
 }
        public void EditOperation(object sender, RoutedEventArgs e)
        {
            if (WebContext.Current.User.Roles.FirstOrDefault() == "Customer")
            {
                return;
            }

            DataGridRow row = DataGridRow.GetRowContainingElement(sender as FrameworkElement);

            App.RGReport = (RGReport)row.DataContext;
            Navigate("/EnterRadioGraphyReport");
        }
Beispiel #29
0
        public void Expend()
        {
            LeftImage.Source = oImage;
            isOpen           = true;

            var row = DataGridRow.GetRowContainingElement(Cell);

            if (row != null)
            {
                row.DetailsVisibility = System.Windows.Visibility.Visible;
            }
        }
        public override bool ConvertChildClientPoint(ref System.Drawing.Point clientPointWinForms, out string childUIObject)
        {
            childUIObject = string.Empty;
            var clientPoint = new Point(clientPointWinForms.X, clientPointWinForms.Y);

            //指定座標の要素取得
            var hitElement = PointUtility.GetPosElement(clientPoint, _control);

            if (hitElement == null)
            {
                return(false);
            }

            //DataGridCell取得
            DataGridCell cell = null;

            foreach (var x in TreeUtilityInTarget.VisualTree(hitElement, TreeRunDirection.Ancestors))
            {
                if (Equals(x, _control))
                {
                    break;
                }
                cell = x as DataGridCell;
                if (cell != null)
                {
                    break;
                }
            }

            if (cell == null)
            {
                return(false);
            }
            var row = DataGridRow.GetRowContainingElement(cell);

            if (row == null)
            {
                return(false);
            }

            int rowindex = row.GetIndex();
            var colIndex = cell.Column.DisplayIndex;

            //座標変換
            var screenPos  = _control.PointToScreen(clientPoint);
            var childPoint = cell.PointFromScreen(screenPos);

            clientPointWinForms.X = (int)childPoint.X;
            clientPointWinForms.Y = (int)childPoint.Y;

            childUIObject = $".GetCell({rowindex}, {colIndex})";
            return(true);
        }