Esempio n. 1
0
 /// <summary>
 /// 改变焦点
 /// </summary>
 /// <param name="changeType">0:获取默认,1:获取下一行,2:获取上一行</param>
 public void GetGridFocus(int changeType = 0)
 {
     if (changeType == 1)
     {
         if (dataGrid.SelectedIndex > 0)
         {
             dataGrid.SelectedIndex -= 1;
         }
     }
     else if (changeType == 2)
     {
         dataGrid.SelectedIndex += 1;
     }
     else
     {
         dataGrid.SelectedIndex = 0;
     }
     dataGrid.Focus();
     if (dataGrid.SelectedItem == null)
     {
         return;
     }
     System.Windows.Controls.DataGridCell cell = (dataGrid.Columns[0].GetCellContent(dataGrid.SelectedItem))?.Parent as System.Windows.Controls.DataGridCell; if (cell == null)
     {
         return;
     }
     cell.IsTabStop = false;
     cell.Focus();
 }
Esempio n. 2
0
 private void AssignTaskType(string participantName, string plannerName, IList <DataGridCellInfo> selectedCells, string taskTypeName)
 {
     try
     {
         string    day, time;
         DataTable task = new DataTable();
         task.Columns.Add("tvp_Task_Day");
         task.Columns.Add("tvp_Task_Time");
         task.Columns.Add("tvp_Task_TaskType_Name");
         foreach (DataGridCellInfo selectedCell in selectedCells)
         {
             day = selectedCell.Column.Header.ToString();
             DataGridRow dataGridRow = (DataGridRow)PlannerDataGrid.ItemContainerGenerator.ContainerFromItem(selectedCell.Item);
             time = dataGridRow.Header.ToString();
             DataGridCell dataGridCell = DataGridExtension.GetCell(PlannerDataGrid, dataGridRow.GetIndex(), selectedCell.Column.DisplayIndex);
             TextBlock    textBlock    = dataGridCell.Content as TextBlock;
             textBlock.Text = taskTypeName;
             task.Rows.Add(day, time, taskTypeName);
         }
         DbAdapter.EditTasks(participantName, plannerName, task);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 3
0
            protected override sw.FrameworkElement GenerateEditingElement(swc.DataGridCell cell, object dataItem)
            {
                var element = (swc.TextBox)base.GenerateEditingElement(cell, dataItem);

                element.Name = "control";
                element.SetBinding(swc.TextBlock.TextAlignmentProperty, CreateBinding(nameof(TextAlignment)));
                element.SetBinding(swc.TextBlock.VerticalAlignmentProperty, CreateBinding(nameof(VerticalAlignment)));
                element.Text = Handler.GetValue(dataItem);
                Handler.FormatCell(element, cell, dataItem);
                if (Handler.UseMouseSelectionOnly)
                {
                    element.PreviewMouseLeftButtonDown += (sender, e) =>
                    {
                        element.Select(0, 0);
                    };
                }

                element.DataContextChanged += (sender, e) =>
                {
                    var control = sender as swc.TextBox;
                    control.Text = Handler.GetValue(control.DataContext);
                    Handler.FormatCell(control, cell, control.DataContext);
                };
                return(Handler.SetupCell(element, cell));
            }
Esempio n. 4
0
            protected override sw.FrameworkElement GenerateElement(swc.DataGridCell cell, object dataItem)
            {
                var element = (swc.ComboBox)base.GenerateElement(cell, dataItem);

                Initialize(cell, element, dataItem);
                return(Handler.SetupCell(element));
            }
Esempio n. 5
0
        private void Gr_scraps_LostFocus(object sender, RoutedEventArgs e)
        {
            string       HoldValueCell = this.DataFileService.CurrentFile.InitialQty;
            DataGridCell cell          = e.OriginalSource as DataGridCell;

            if (cell == null)
            {
                TextBox TextBx = e.OriginalSource as TextBox;
                string  val    = TextBx.Text;
                Quality scrap  = this.DataFileService.CurrentFile.Scrap.FirstOrDefault(s => s.Qty == "");
                if (scrap == null)
                {
                    IEnumerable collectionFiles = this.gr_scraps.Items.SourceCollection;
                    return;
                }

                scrap.Qty        = val;
                this.tb_qty.Text = this.DataFileService.CurrentFile.Qty;
            }
            else if (cell != null && (string)cell.Column.Header == "Qty")
            {
                string tbvalue      = this.DataFileService.CurrentFile.Qty;
                string txtHoldvalue = HoldValueCell.ToString(CultureInfo.InvariantCulture);
                if (tbvalue != txtHoldvalue)
                {
                    this.tb_qty.Text = tbvalue;
                }
                else
                {
                    this.tb_qty.Text = txtHoldvalue;
                }
            }
        }
Esempio n. 6
0
        private void DataGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            return;


            var hit = VisualTreeHelper.HitTest((Visual)sender, e.GetPosition((IInputElement)sender));
            DependencyObject cell = VisualTreeHelper.GetParent(hit.VisualHit);

            while (cell != null && !(cell is System.Windows.Controls.DataGridCell))
            {
                cell = VisualTreeHelper.GetParent(cell);
            }
            System.Windows.Controls.DataGridCell targetCell = cell as System.Windows.Controls.DataGridCell;
            //Order o = (Order)targetCell.GetValue();
            string nn = ((TextBlock)targetCell.Content).Text;

            //string nn = targetCell.Content;
            //ContentControl.Content ct = targetCell.Content;
            if (nn == "Running")
            {
            }
            else if (nn == "Stopped")
            {
                //DataContext.mestart_menu
                //this.
            }
        }
Esempio n. 7
0
            protected override sw.FrameworkElement GenerateEditingElement(swc.DataGridCell cell, object dataItem)
            {
                var element = (swc.CheckBox)base.GenerateEditingElement(cell, dataItem);

                InitializeElement(element, cell, dataItem);
                if (!IsControlEditInitialized(element))
                {
                    element.Checked += (sender, e) =>
                    {
                        if (!enableEvents)
                        {
                            return;
                        }
                        var control = (swc.CheckBox)sender;
                        Handler.SetValue(control.DataContext, control.IsChecked);
                    };
                    element.Unchecked += (sender, e) =>
                    {
                        if (!enableEvents)
                        {
                            return;
                        }
                        var control = (swc.CheckBox)sender;
                        Handler.SetValue(control.DataContext, control.IsChecked);
                    };
                    SetControlEditInitialized(element, true);
                }
                return(Handler.SetupCell(element));
            }
 protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
 {
     NumericUpDown numericUpDown = new NumericUpDown();
     ApplyColumnProperties(numericUpDown);
     numericUpDown.VerticalAlignment = VerticalAlignment.Center;
     return numericUpDown;
 }
        private void MouseEnterOnDataGridCell(object sender, System.Windows.Input.MouseEventArgs e)
        {
            //	var currentCell = sender as System.Windows.Controls.DataGridCell;
            _dataGridCurrentCell = sender as System.Windows.Controls.DataGridCell;
            _datagridColumnIndex = _dataGridCurrentCell.Column.DisplayIndex;

            if (_dataGridCurrentCell.Content.ToString() != "" && _data == "")
            {
                // do nothing
            }
            else
            {
                if (_datagridColumnIndex == 1 || _datagridColumnIndex == 2)
                {
                    _dataGridCurrentCell.Content = _data;
                    SessionGrid.CurrentCell      = new DataGridCellInfo(_dataGridCurrentCell);
                }
            }
            //  SessionGrid.Items.Refresh();
            //var currentObject = _dataGridCurrentCell?.Content;
            //if (currentObject.GetType() != typeof(TextBlock))
            //{
            //	return;
            //}
        }
        private void MouseEnterOnDataGridCell(object sender, System.Windows.Input.MouseEventArgs e)
        {
            _dataGridCurrentCell = sender as System.Windows.Controls.DataGridCell;
            if (_dataGridCurrentCell == null)
            {
                return;
            }

            _datagridColumnIndex = _dataGridCurrentCell.Column.DisplayIndex;

            if (!(_dataGridCurrentCell.Content.ToString() != "" && _data == ""))
            {
                if (_datagridColumnIndex >= 1 && _datagridColumnIndex <= 13)
                {
                    var fileNameTokens = _data.Split('\\');

                    //currentCell.Content = fileNameTokens?[fileNameTokens.Length - 1];//_data;
                    _dataGridCurrentCell.Content  = _data;
                    MushraSessionGrid.CurrentCell = new DataGridCellInfo(_dataGridCurrentCell);
                }
            }

            //var currentObject = _dataGridCurrentCell?.Content;
            //if (currentObject.GetType() != typeof(TextBlock))
            //{
            //	return;
            //}

            //var value = ((TextBlock)currentObject).Text;
            //if (value != "")
            //{
            //	ToolTipService.SetToolTip(_dataGridCurrentCell, new System.Windows.Controls.ToolTip { Content = value });
            //}
        }
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            StackPanel panel = GeneratePanel(dataItem);
            panel.Children.Add(base.GenerateElement(cell,dataItem));

            return panel;
        }
Esempio n. 12
0
 public void FormatCell(ICellHandler cell, sw.FrameworkElement element, swc.DataGridCell gridcell, object dataItem)
 {
     if (GridHandler != null)
     {
         GridHandler.FormatCell(this, cell, element, gridcell, dataItem);
     }
 }
Esempio n. 13
0
            EtoCanvas Create(swc.DataGridCell cell)
            {
                var control = cell.Content as EtoCanvas;

                if (control == null)
                {
                    control = new EtoCanvas {
                        Column = this
                    };
                    control.DataContextChanged += (sender, e) =>
                    {
                        var ctl = sender as EtoCanvas;
                        ctl.IsSelected = cell.IsSelected;
                        Handler.FormatCell(ctl, cell, ctl.DataContext);
                        ctl.InvalidateVisual();
                    };
                    cell.Selected += (sender, e) =>
                    {
                        control.IsSelected = cell.IsSelected;
                        control.InvalidateVisual();
                    };
                    cell.Unselected += (sender, e) =>
                    {
                        control.IsSelected = cell.IsSelected;
                        control.InvalidateVisual();
                    };
                }
                return(control);
            }
Esempio n. 14
0
        // データ編集用コントロールの設定
        protected override FrameworkElement GenerateEditingElement(DataGridCell cell, Object dataItem)
        {
            TextBox textBox = (TextBox)base.GenerateEditingElement(cell, dataItem);

            // 最大桁数
            textBox.MaxLength = 5;
            // 垂直方向配置
            textBox.VerticalContentAlignment = VerticalAlignment.Center;
            // 水平方向配置
            textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
            // IMEを強制的にOFF
            textBox.SetValue(InputMethod.IsInputMethodEnabledProperty, false);
            // 折り返し表示の禁止
            textBox.TextWrapping = TextWrapping.NoWrap;
            // Enterによるフォーカス移動
            textBox.SetValue(EnterThenNextFocus.EnterThenNextFocusProperty, true);
            // フォーカス取得時にテキスト全選択
            textBox.SetValue(SelectOnFocus.SelectOnFocusProperty, true);
            // 時刻フォーマット変換
            textBox.SetValue(TimeFormat.TimeFormatProperty, true);
            // 入力可能文字列の制限
            textBox.SetValue(InputCharcter.InputCharcterProperty, RegexCheck.InputChar.Time_Only);
            // 表示フォーマット
            string stringFormat = (String)this.GetValue(DisplayFormat.DisplayFormatProperty);
            base.SetStringFormat(textBox, stringFormat);

            return textBox;
        }
 protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
 {
     if (!string.IsNullOrEmpty(this.Resource) && !string.IsNullOrEmpty(this.CustomResourceFormat))
     {
         Image icon = UiHelper.CreateIcon(UriResources.GetImage(String.Format(this.CustomResourceFormat,this.Resource)));
         return icon;
     }
     if (!string.IsNullOrEmpty(this.Resource))
     {             
         if (dataItem is KpiView && Resource == "Status")
         {
             Image icon = UiHelper.CreateIcon(UriResources.GetImage(GetKpiIconByPath(this.Resource,(dataItem as KpiView).StatusGraphic)));
             return icon;
         }
         if (dataItem is KpiView && Resource == "Trend")
         {
             Image icon = UiHelper.CreateIcon(UriResources.GetImage(GetKpiIconByPath(this.Resource,(dataItem as KpiView).TrendGraphic)));
             return icon;
         }
     }
     TextBlock block = new TextBlock();
     block.Margin = new Thickness(4.0);
     block.VerticalAlignment = VerticalAlignment.Center;
     block.Text = dataItem.ToString();
     return block;
 }
Esempio n. 16
0
            EtoBorder Create(swc.DataGridCell cell)
            {
                var control = GetControl <EtoBorder>(cell);

                if (control == null)
                {
                    control = new EtoBorder {
                        Column = this
                    };
                    control.Unloaded                     += HandleControlUnloaded;
                    control.Loaded                       += HandleControlLoaded;
                    control.DataContextChanged           += HandleControlDataContextChanged;
                    control.PreviewMouseDown             += HandlePreviewMouseDown;
                    control.IsKeyboardFocusWithinChanged += HandleIsKeyboardFocusWithinChanged;

                    if (!Equals(cell.GetValue(dpSelectedHookedUp), true))
                    {
                        cell.SetValue(dpSelectedHookedUp, true);
                        cell.Selected   += HandleCellSelectedChanged;
                        cell.Unselected += HandleCellSelectedChanged;
                    }
                    var grid = cell.GetVisualParent <swc.DataGrid>();
                    if (grid != null && !Equals(grid.GetValue(dpSelectedHookedUp), true))
                    {
                        grid.SetValue(dpSelectedHookedUp, true);
                        grid.IsKeyboardFocusWithinChanged += HandleRowFocusChanged;
                    }
                }
                return(control);
            }
Esempio n. 17
0
 protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
 {
     DatePicker picker = new DatePicker();
     picker.SetBinding(DatePicker.SelectedDateProperty, this.Binding);
     picker.IsDropDownOpen = true;
     return picker;
 }
Esempio n. 18
0
            void SetValue(swc.DataGridCell cell, swc.Grid grid, swc.ProgressBar bar, swc.TextBlock text, object dataItem)
            {
                // Get the value
                float?value = Handler.GetValue(dataItem);

                // If the value is -1
                if (!value.HasValue)
                {
                    // Hide the bar and text
                    bar.Visibility  = sw.Visibility.Hidden;
                    text.Visibility = sw.Visibility.Hidden;
                }
                else
                {
                    // Hide the bar and text
                    bar.Visibility  = sw.Visibility.Visible;
                    text.Visibility = sw.Visibility.Visible;
                }

                // Set the value of the progress bar and make sure that it is above 0.
                bar.Value = value ?? 0;
                // Set the text on the percentage text text block
                text.Text = (int)(bar.Value * 100f) + "%";

                Handler.FormatCell(grid, cell, dataItem);
            }
Esempio n. 19
0
 /// <summary>
 /// Gets a <see cref="T:System.Windows.Controls.TextBox" /> control that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding" /> property value.
 /// </summary>
 /// <param name="cell">The cell that will contain the generated element.</param>
 /// <param name="dataItem">The data item represented by the row that contains the intended cell.</param>
 /// <returns>
 /// A new text box control that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding" /> property value.
 /// </returns>
 protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
 {
     TextBox textBox = (TextBox)base.GenerateEditingElement(cell, dataItem);
     textBox.GotFocus += this.OnTextBoxGotFocus;
     DataGridColumnToolTipHelper.SetToolTip(textBox, this.ToolTip, this.ToolTipTemplate, dataItem);
     return textBox;
 }
Esempio n. 20
0
        private List<Tuple<int, int>> GetRowAndColumnIndicesFromGivenCell(DataGrid dataGrid, DataGridCell cell)
        {
            List<Tuple<int, int>> cellList = null;

              var columnIndex = cell.Column.DisplayIndex;
              var parent = VisualTreeHelper.GetParent(cell);
              while (parent != null && parent.GetType() != typeof (DataGridRow))
              {
            parent = VisualTreeHelper.GetParent(parent);
              }

              if (parent is DataGridRow)
              {
            var dataGridRow = parent as DataGridRow;
            var item = dataGridRow.Item;
            if (item != null)
            {
              var rowIndex = dataGrid.Items.IndexOf(item);
              if (rowIndex != -1)
              {
            cellList = new List<Tuple<int, int>>()
            {
              new Tuple<int, int>(rowIndex, columnIndex)
            };
              }
            }
              }

              return cellList;
        }
        IRawElementProviderSimple IGridProvider.GetItem(int row, int column)
        {
            if (this.OwningDataGrid != null &&
                this.OwningDataGrid.DataConnection != null &&
                row >= 0 && row < this.OwningDataGrid.SlotCount &&
                column >= 0 && column < this.OwningDataGrid.Columns.Count)
            {
                object item = null;
                if (!this.OwningDataGrid.IsSlotVisible(this.OwningDataGrid.SlotFromRowIndex(row)))
                {
                    item = this.OwningDataGrid.DataConnection.GetDataItem(row);
                }
                this.OwningDataGrid.ScrollIntoView(item, this.OwningDataGrid.Columns[column]);

                DataGridRow dgr = this.OwningDataGrid.DisplayData.GetDisplayedRow(row);
                if (this.OwningDataGrid.ColumnsInternal.RowGroupSpacerColumn.IsRepresented)
                {
                    column++;
                }
                Debug.Assert(column >= 0);
                Debug.Assert(column < this.OwningDataGrid.ColumnsItemsInternal.Count);
                DataGridCell   cell = dgr.Cells[column];
                AutomationPeer peer = CreatePeerForElement(cell);
                if (peer != null)
                {
                    return(ProviderFromPeer(peer));
                }
            }
            return(null);
        }
Esempio n. 22
0
            private swc.Grid GenerateProgressBar(swc.DataGridCell cell, object dataItem)
            {
                swc.Grid element = GetControl <swc.Grid>(cell) ?? new swc.Grid();
                cell.SetResourceReference(swc.Control.ForegroundProperty, sw.SystemColors.ControlTextBrushKey);

                // Add a progress bar to the grid
                var progressBar = new swc.ProgressBar {
                    Value = 0, Minimum = 0, Maximum = 1
                };

                element.Children.Add(progressBar);

                // Add a text block that shows the progress percentage to the grid
                swc.TextBlock textBlock = new swc.TextBlock
                {
                    Text = (int)progressBar.Value + "%",
                    HorizontalAlignment = sw.HorizontalAlignment.Center,
                    VerticalAlignment   = sw.VerticalAlignment.Center
                };
                element.Children.Add(textBlock);

                SetValue(cell, element, progressBar, textBlock, dataItem);

                element.DataContextChanged += (sender, e) =>
                {
                    var grid = (swc.Grid)sender;

                    var bar  = grid.FindChild <swc.ProgressBar>();
                    var text = grid.FindChild <swc.TextBlock>();

                    SetValue(cell, grid, bar, text, grid.DataContext);
                };

                return(element);
            }
        internal void RaiseAutomationInvokeEvents(DataGridEditingUnit editingUnit, DataGridColumn column, DataGridRow row)
        {
            switch (editingUnit)
            {
            case DataGridEditingUnit.Cell:
            {
                DataGridCell   cell = row.Cells[column.Index];
                AutomationPeer peer = FromElement(cell);
                if (peer != null)
                {
                    peer.InvalidatePeer();
                }
                else
                {
                    peer = CreatePeerForElement(cell);
                }

                if (peer != null)
                {
                    peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
                }
                break;
            }

            case DataGridEditingUnit.Row:
            {
                DataGridItemAutomationPeer peer = GetOrCreateItemPeer(row.DataContext);
                peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
                break;
            }
            }
        }
Esempio n. 24
0
        private void DataGrid_OnGotFocus(object sender, RoutedEventArgs e)
        {
            DependencyObject dep = (DependencyObject)e.OriginalSource;

            //here we just find the cell got focused ...
            //then we can use the cell key down or key up
            // iteratively traverse the visual tree
            while ((dep != null) && !(dep is System.Windows.Controls.DataGridCell) && !(dep is DataGridColumnHeader))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }

            if (dep == null)
            {
                return;
            }

            if (dep is System.Windows.Controls.DataGridCell)
            {
                System.Windows.Controls.DataGridCell cell = dep as System.Windows.Controls.DataGridCell;
                //raise key down event of cell
                //                cell.IsSelected = true;
                cell.IsTabStop = false;
                cell.KeyDown  += new System.Windows.Input.KeyEventHandler(cell_KeyDown);
            }

            textBox.Focus();
        }
Esempio n. 25
0
        private void DgvUrls_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            DependencyObject dep = (DependencyObject)e.OriginalSource;

            while ((dep != null) && !(dep is System.Windows.Controls.DataGridCell))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }
            if (dep == null)
            {
                return;
            }
            System.Windows.Controls.DataGridCell cell1 = dep as System.Windows.Controls.DataGridCell;
            while ((dep != null) && !(dep is DataGridRow))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }
            dgRow1 = dep as DataGridRow;
            if (dgRow1 == null)
            {
                return;
            }
            //string strType = dgRow1.Item.GetType().ToString();  // MeineFinanzen.Model.VorgabeInt2
            System.Windows.Controls.DataGrid dataGrid = ItemsControl.ItemsControlFromItemContainer(dgRow1) as System.Windows.Controls.DataGrid;
            var item = dataGrid.ItemContainerGenerator.ItemFromContainer(dgRow1);

            if (item.ToString() == "{NewItemPlaceholder}")
            {
                return;
            }
            _ColHeaderVorgabe = cell1.Column.Header.ToString();
            //string strIsin = ((MeineFinanzen.Model.WertpapSynchroNeu)item).WPVISIN;
        }
Esempio n. 26
0
 protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
 {
     CheckBox checkBox = new CheckBox();
     // 
     checkBox.Margin = new Thickness(0);
     ConfigureCheckBox(checkBox);
     return checkBox;
 }
Esempio n. 27
0
 protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
 { 
   var binding = new Binding(((Binding)Binding).Path.Path); 
   binding.Source = dataItem; 
  var content = new ContentControl(); 
  content.ContentTemplate = (DataTemplate)cell.FindResource(TemplateName); 
  content.SetBinding(ContentControl.ContentProperty, binding); return content; 
 } 
 /// <summary>
 /// AutomationPeer for DataGridCell. 
 /// This automation peer should not be part of the automation tree. 
 /// It should act as a wrapper peer for DataGridCellItemAutomationPeer
 /// </summary> 
 /// <param name="owner">DataGridCell</param>
 public DataGridCellAutomationPeer(DataGridCell owner)
     : base(owner)
 { 
     if (owner == null)
     { 
         throw new ArgumentNullException("owner"); 
     }
 } 
Esempio n. 29
0
        protected override FrameworkElement GenerateElement(System.Windows.Controls.DataGridCell cell, object dataItem)
        {
            FrameworkElement fe = base.GenerateElement(cell, dataItem);

            fe.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Right);

            return(fe);
        }
Esempio n. 30
0
            EtoBorder Create(swc.DataGridCell cell)
            {
                var control = new EtoBorder {
                    Column = this
                };

                control.Args = new WpfCellEventArgs(-1, null, CellStates.None);
                control.DataContextChanged += (sender, e) =>
                {
                    var ctl = sender as EtoBorder;
                    ctl.Args.SetSelected(cell.IsSelected);
                    ctl.Args.SetDataContext(ctl.DataContext);
                    var id    = Handler.Callback.OnGetIdentifier(Handler.Widget, ctl.Args);
                    var child = ctl.Control;
                    if (id != ctl.Identifier || child == null)
                    {
                        Stack <Control> cache;
                        if (child != null)
                        {
                            // store old child into cache
                            cache = GetCached(ctl.Identifier);
                            cache.Push(child);
                        }
                        // get new from cache or create if none created yet
                        cache = GetCached(id);
                        if (cache.Count > 0)
                        {
                            child = cache.Pop();
                        }
                        else
                        {
                            child = Handler.Callback.OnCreateCell(Handler.Widget, ctl.Args);
                        }
                        ctl.Control = child;
                        var handler = child.GetWpfFrameworkElement();
                        if (handler != null)
                        {
                            handler.SetScale(true, true);
                        }
                        ctl.Child = child.ToNative(true);
                    }
                    Handler.Callback.OnConfigureCell(Handler.Widget, ctl.Args, child);

                    Handler.FormatCell(ctl, cell, ctl.DataContext);
                    ctl.InvalidateVisual();
                };
                cell.Selected += (sender, e) =>
                {
                    control.Args.SetSelected(cell.IsSelected);
                    Handler.Callback.OnConfigureCell(Handler.Widget, control.Args, control.Control);
                };
                cell.Unselected += (sender, e) =>
                {
                    control.Args.SetSelected(cell.IsSelected);
                    Handler.Callback.OnConfigureCell(Handler.Widget, control.Args, control.Control);
                };
                return(control);
            }
Esempio n. 31
0
        private void DgvVorgabeInt2_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            /* var source = e.Source;
             * if (e.RightButton == MouseButtonState.Pressed) {
             *  URLsVerwaltenContextMenu gk = new URLsVerwaltenContextMenu();
             *  gk.ShowDialog();
             * } */
            base.OnMouseDown(e);
            e.Handled = true;
            DependencyObject dep = (DependencyObject)e.OriginalSource;

            while ((dep != null) && !(dep is System.Windows.Controls.DataGridCell))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }
            if (dep == null)
            {
                return;
            }
            System.Windows.Controls.DataGridCell cell1 = dep as System.Windows.Controls.DataGridCell;
            while ((dep != null) && !(dep is DataGridRow))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }
            dgRow1 = dep as DataGridRow;
            if (dgRow1 == null)
            {
                return;
            }
            //string strType = dgRow1.Item.GetType().ToString();  // MeineFinanzen.Model.VorgabeInt2
            System.Windows.Controls.DataGrid dataGrid = ItemsControl.ItemsControlFromItemContainer(dgRow1) as System.Windows.Controls.DataGrid;
            var item = dataGrid.ItemContainerGenerator.ItemFromContainer(dgRow1);

            if (item.ToString() == "{NewItemPlaceholder}")
            {
                return;
            }
            _ColHeaderVorgabe = cell1.Column.Header.ToString();
            _Url1             = ((UrlVerwalten)item).Url1;
            _Url2             = ((UrlVerwalten)item).Url2;
            _BoxAnfang        = ((UrlVerwalten)item).Boxanfang;

            /* if (dgRow1.DetailsVisibility == Visibility.Collapsed) {
             *   dgRow1.DetailsVisibility = Visibility.Visible;
             * } else {
             *  //dgRow1.DetailsVisibility = Visibility.Collapsed;
             * }
             * Console.WriteLine("_ColHeaderVorgabe: {0,12} {1,20} {2,20} _BoxAnfang: {3,20}", _ColHeaderVorgabe, _Url1, _Url2, _BoxAnfang);
             * if (((VorgabeInt2)item).Vg2Color == "Eingefügt") {
             *  strAnzeige = "xxxxxxxxxxEingefügtxxxxxxxxxxxxxx";
             * } else {
             *  strAnzeige = "yyyyyyyyyyyyyyyyyyyyyyyyyyy " + cell1.Column.Header;
             *  strAnzeige += Environment.NewLine + "mach was";
             * } */
            Meldung("Vorgabe " + _Url1 + " " + _Url2);
            DataContext = null;
            DataContext = this;
        }
        protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
        {
            var checkBox = (CheckBox)base.GenerateEditingElement(cell, dataItem);

            checkBox.Checked   += checkBox_Checked;
            checkBox.Unchecked += checkBox_Unchecked;

            return(checkBox);
        }
 protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
 {
     FrameworkElement frameworkElement = base.GenerateElement(cell, dataItem);
     Binding binding = new Binding(this.ColumnName) {
         Source = dataItem
     };
     frameworkElement.SetBinding(ContentControl.ContentProperty, binding);
     return frameworkElement;
 }
        public static int GetRowIndex(DataGridCell dataGridCell)
        {
            // Use reflection to get DataGridCell.RowDataItem property value.
            PropertyInfo rowDataItemProperty = dataGridCell.GetType().GetProperty("RowDataItem", BindingFlags.Instance | BindingFlags.NonPublic);

            DataGrid dataGrid = GetDataGridFromChild(dataGridCell);

            return dataGrid.Items.IndexOf(rowDataItemProperty.GetValue(dataGridCell, null));
        }
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            var element = base.GenerateElement(cell, dataItem);

            element.HorizontalAlignment = HorizontalAlignment;
            element.VerticalAlignment   = VerticalAlignment;

            return(element);
        }
        protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
        {
            var textBox = (TextBox)base.GenerateEditingElement(cell, dataItem);

            textBox.TextAlignment            = GetTextAlignment();
            textBox.VerticalContentAlignment = VerticalAlignment;

            return(textBox);
        }
        protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
        {
            var checkBox = (CheckBox)base.GenerateEditingElement(cell, dataItem);

            checkBox.Checked += checkBox_Checked;
            checkBox.Unchecked += checkBox_Unchecked;

            return checkBox;
        }
Esempio n. 38
0
            sw.FrameworkElement SetupCell(sw.FrameworkElement element, swc.DataGridCell cell)
            {
                element.HorizontalAlignment = sw.HorizontalAlignment.Stretch;
                var container = new swc.DockPanel();

                container.Children.Add(CreateImage());
                container.Children.Add(element);
                return(Handler.SetupCell(container, cell));
            }
Esempio n. 39
0
 protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
 {
     var element = new DatePicker
     {
         Style = Application.Current.Resources["DatePickerStyle"] as Style
     };
     element.SetBinding(DatePicker.SelectedDateProperty, Binding);
     return element;
 }
Esempio n. 40
0
 void Initialize(swc.DataGridCell cell, swc.ComboBox control, object dataItem)
 {
     if (!IsControlInitialized(control))
     {
         control.DataContextChanged += (sender, e) => SetValue(control.GetParent <swc.DataGridCell>(), (swc.ComboBox)sender, e.NewValue);
         SetControlInitialized(control, true);
     }
     SetValue(cell, control, dataItem);
 }
        private void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            if (RowToColor != null)
            {
                try
                {
                    DataGridRow dgr = e.Row;
                    DataRowView drv = (DataRowView)dgr.Item;

                    e.Row.Background = defaultBackGroundBrush;
                    e.Row.Foreground = defaultForeGroundBrush;

                    bool bStrikeRow = false;

                    //Go through each of the columns and look for a match
                    for (int i = 0; i < this.Columns.Count; i++)
                    {
                        //For the coloring, go through the RowToColor property
                        for (int j = 0; j < RowToColor.Count; j++)
                        {
                            if (this.Columns[i].Header.ToString() == RowToColor[j].ColumnHeader)
                            {
                                if (drv[i].ToString() == RowToColor[j].ColumnValue)
                                {
                                    e.Row.Background = RowToColor[j].RowBackGroundBrushColor;
                                    e.Row.Foreground = RowToColor[j].RowForeGroundBrushColor;
                                }
                            }
                        }
                    }

                    if (bStrikeRow == true)
                    {
                        DataGridCellsPresenter presenter = DataGridHelper.GetVisualChild <DataGridCellsPresenter>(dgr);
                        if (presenter != null)
                        {
                            for (int i = 0; i < this.Columns.Count; i++)
                            {
                                DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(i);
                                if (cell == null)
                                {
                                    this.ScrollIntoView(dgr, this.Columns[i]);
                                    cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(i);
                                }
                                TextBlock tb = DataGridHelper.GetVisualChild <TextBlock>(cell);
                                tb.TextDecorations = TextDecorations.Strikethrough;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string sNoMessage = ex.Message;
                }
            }
        }
Esempio n. 42
0
 protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
 {
     DatePicker picker = new DatePicker();
     picker.MinHeight = 16;
     picker.Padding = new Thickness(0);
     picker.BorderThickness = new Thickness(0);
     picker.SetBinding(DatePicker.SelectedDateProperty, Binding);
     picker.IsDropDownOpen = true;
     return picker;
 }
        protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
        {
            var editElement = new ComboBox();
            editElement.SetBinding(Selector.SelectedItemProperty, Binding);

            var prop = dataItem.GetType().GetProperty(Binding.Path.Path,
                BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
            Utilities.FillObjects(editElement, prop.PropertyType, new[] { dataItem });
            return editElement;
        }
Esempio n. 44
0
            public void SetSelected(swc.DataGridCell cell)
            {
                var grid     = cell.GetVisualParent <swc.DataGrid>();
                var selected = cell.IsSelected;

                IsSelected = selected;
                var focused = grid?.IsKeyboardFocusWithin != false;

                CellTextColor = selected && focused ? Eto.Drawing.SystemColors.HighlightText : Eto.Drawing.SystemColors.ControlText;
            }
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            var comboBox = base.GenerateElement(cell, cell);

            if (ItemsSourceBinding != null)
                comboBox.SetBinding(ItemsControl.ItemsSourceProperty, ItemsSourceBinding);
            ApplyStyle(false, false, comboBox);

            return comboBox;
        }
        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++;
            }
        }
Esempio n. 47
0
        /// <summary> 
        ///     Creates the visual tree for text based cells.
        /// </summary> 
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            TextBlock textBlock = new TextBlock();
 
            SyncProperties(textBlock);
 
            ApplyStyle(/* isEditing = */ false, /* defaultToElementStyle = */ false, textBlock); 
            ApplyBinding(textBlock, TextBlock.TextProperty);
 
            return textBlock;
        }
Esempio n. 48
0
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            var presenter = new TreeGridExpanderPresenter();

            BindingOperations.SetBinding(presenter, ContentControl.ContentProperty, new Binding());

            presenter.ContentTemplate = this.CellTemplate;
            presenter.ContentTemplateSelector = this.CellTemplateSelector;

            return presenter;
        }
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            var textBlock = new TextBlock();
            textBlock.SetValue(FrameworkElement.StyleProperty, ElementStyle);

            Dispatcher.BeginInvoke(
                DispatcherPriority.Loaded,
                new Action<TextBlock>(x => x.SetBinding(TextBlock.TextProperty, Binding)),
            textBlock);
            return textBlock;
        }
Esempio n. 50
0
            protected override sw.FrameworkElement GenerateElement(swc.DataGridCell cell, object dataItem)
            {
                var element = base.GenerateElement(cell, dataItem);

                element.DataContextChanged += (sender, e) => {
                    var control = sender as swc.CheckBox;
                    control.IsChecked = Handler.GetValue(control.DataContext);
                    Handler.FormatCell(control, cell, dataItem);
                };
                return(Handler.SetupCell(element));
            }
Esempio n. 51
0
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            TextBlock block = new TextBlock
            {
                Margin = new Thickness(4.0),
                VerticalAlignment = VerticalAlignment.Center
            };

            block.SetBinding(TextBlock.TextProperty, this.Binding);
            return block;
        }
        /// <summary>
        ///     Creates the visual tree for text based cells.
        /// </summary>
        protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
        {
            if (comboBox.Columns.Count == 0)
            {
                //Add columns to DataGrid columns
                for (int i = 0; i < columns.Count; i++)
                    comboBox.Columns.Add(columns[i]);
            }

            return comboBox;
        }
Esempio n. 53
0
        protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
        {
            Border b = new Border();

            SimpleExpander Expander = new SimpleExpander();
            Expander.SetBinding(SimpleExpander.IsExpandedProperty, this.Binding);
            Expander.Visibility = ((dataItem as IGanttNode).ChildNodes.Count > 0) ? Visibility.Visible : Visibility.Collapsed;
            b.Child = Expander;

            return b;
        }
Esempio n. 54
0
        /// <summary>
        ///     Creates a structure that identifies the specific cell container.
        /// </summary> 
        /// <param name="cell">
        ///     A reference to a cell. 
        ///     This structure does not maintain a strong reference to the cell. 
        ///     Changes to the cell will not affect this structure.
        /// </param> 
        /// <remarks>
        ///     This constructor will tie the DataGridCellInfo to the specific
        ///     DataGrid that owns the cell container.
        /// </remarks> 
        public DataGridCellInfo(DataGridCell cell)
        { 
            if (cell == null) 
            {
                throw new ArgumentNullException("cell"); 
            }

            _item = cell.RowDataItem;
            _column = cell.Column; 
            _owner = new WeakReference(cell.DataGridOwner);
        } 
        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            Image image = (cell != null) ? (cell.Content as Image) : null;
            if (image == null)
                image = new Image();

            image.Stretch = Stretch.None;
            image.SnapsToDevicePixels = true;
            BindingOperations.SetBinding(image, Image.SourceProperty, Binding);
            return image;
        }
        // データ表示用コントロールの設定
        protected override FrameworkElement GenerateElement(DataGridCell cell, Object dataItem)
        {
            ComboBox txtBlock = (ComboBox)base.GenerateElement(cell, dataItem);

            //// 垂直方向配置
            txtBlock.VerticalAlignment = VerticalAlignment.Center;
            //// 表示フォーマット
            //string stringFormat = (string)this.GetValue(DisplayFormat.DisplayFormatProperty);
            //base.SetStringFormat(txtBlock, stringFormat);

            return txtBlock;
        }
Esempio n. 57
0
        protected override System.Windows.FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            if (dataItem.GetType() == typeof(DataRowView))
            {

                Button b = new Button();
                b.Content = "set";
                b.Click += b_Click;
                return b;
            }
            return null;
        }
Esempio n. 58
0
        /// <summary>
        ///     Creates a structure that identifies the specific cell container.
        /// </summary>
        /// <param name="cell">
        ///     A reference to a cell.
        ///     This structure does not maintain a strong reference to the cell.
        ///     Changes to the cell will not affect this structure.
        /// </param>
        /// <remarks>
        ///     This constructor will tie the DataGridCellInfo to the specific
        ///     DataGrid that owns the cell container.
        /// </remarks>
        public DataGridCellInfo(DataGridCell cell)
        {
            if (cell == null)
            {
                throw new ArgumentNullException("cell");
            }

            DataGrid owner = cell.DataGridOwner;
            _info = owner.NewItemInfo(cell.RowDataItem, cell.RowOwner);
            _column = cell.Column;
            _owner = new WeakReference(owner);
        }
 protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
 {
     //return base.GenerateEditingElement(cell, dataItem);
     var bind = new Binding(LevelPath);
     bind.Converter = IndentConverter;
     var be = new BindingEvaluator(bind);
     be.DataContext = dataItem;
     var left = (double)be.Value + 16;
     var element = base.GenerateEditingElement(cell, dataItem);
     element.Margin = new Thickness(element.Margin.Left + left, element.Margin.Top, element.Margin.Right, element.Margin.Bottom);
     return element;
 }
 protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
 {
     var txt = new TextBlock {VerticalAlignment = VerticalAlignment.Center};
     if (DateFormat != null)
     {
         var dtc = new DateTimeConverter();
         Binding.Converter = dtc;
         Binding.ConverterParameter = DateFormat;
     }
     txt.SetBinding(TextBlock.TextProperty, Binding);
     return txt;
 }