/// <summary>
        /// Default constructor builds a ComboBox inline editor template.
        /// </summary>
        public CultureInfoEditor()
        {
            // not using databinding here because Silverlight does not support
            // the WPF CultureConverter that is used by Blend.
            FrameworkElementFactory comboBox = new FrameworkElementFactory(typeof(ComboBox));
            comboBox.AddHandler(
                ComboBox.LoadedEvent,
                new RoutedEventHandler(
                    (sender, e) =>
                    {
                        _owner = (ComboBox)sender;
                        _owner.SelectionChanged += EditorSelectionChanged;
                        INotifyPropertyChanged data = _owner.DataContext as INotifyPropertyChanged;
                        if (data != null)
                        {
                            data.PropertyChanged += DatacontextPropertyChanged;
                        }
                        _owner.DataContextChanged += CultureDatacontextChanged;
                    }));

            comboBox.SetValue(ComboBox.IsEditableProperty, false);
            comboBox.SetValue(ComboBox.DisplayMemberPathProperty, "DisplayName");
            comboBox.SetValue(ComboBox.ItemsSourceProperty, CultureInfo.GetCultures(CultureTypes.SpecificCultures));
            DataTemplate dt = new DataTemplate();
            dt.VisualTree = comboBox;

            InlineEditorTemplate = dt;
        }
Exemplo n.º 2
0
		public EditableTextBlock()
		{
			var textBox = new FrameworkElementFactory(typeof(TextBox));
			textBox.SetValue(Control.PaddingProperty, new Thickness(1)); // 1px for border
			textBox.AddHandler(FrameworkElement.LoadedEvent, new RoutedEventHandler(TextBox_Loaded));
			textBox.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(TextBox_KeyDown));
			textBox.AddHandler(UIElement.LostFocusEvent, new RoutedEventHandler(TextBox_LostFocus));
			textBox.SetBinding(TextBox.TextProperty, new Windows.UI.Xaml.Data.Binding("Text") { Source = this, Mode = BindingMode.TwoWay
#if TODO_XAML
				, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged 
#endif
			});
			var editTemplate = new DataTemplate { VisualTree = textBox };

			var textBlock = new FrameworkElementFactory(typeof(TextBlock));
			textBlock.SetValue(FrameworkElement.MarginProperty, new Thickness(2));
			textBlock.AddHandler(UIElement.PointerPressedEvent, (s, e) => {
				PointerPoint pt;
				if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse &&
					(pt = e.GetCurrentPoint(textBlock) != null) &&
#if TODO_XAML
					e.ClickCount >= 2 &&
#endif
					pt.Properties.IsLeftButtonPressed)
				{
					IsInEditMode = true;
					e.Handled = true;
				}

			});
			textBlock.SetBinding(TextBlock.TextProperty, new Windows.UI.Xaml.Data.Binding("Text") { Source = this });
			var viewTemplate = new DataTemplate { VisualTree = textBlock };

			var style = new Windows.UI.Xaml.Style(typeof(EditableTextBlock));
			var trigger = new Trigger { Property = IsInEditModeProperty, Value = true };
			trigger.Setters.Add(new Setter { Property = ContentTemplateProperty, Value = editTemplate });
			style.Triggers.Add(trigger);

			trigger = new Trigger { Property = IsInEditModeProperty, Value = false };
			trigger.Setters.Add(new Setter { Property = ContentTemplateProperty, Value = viewTemplate });
			style.Triggers.Add(trigger);
			Style = style;
		}
Exemplo n.º 3
0
 public override void OnInitialize(CellView cellView, FrameworkElementFactory factory)
 {
     factory.AddHandler(SWC.Primitives.TextBoxBase.TextChangedEvent, new SWC.TextChangedEventHandler(OnTextChanged));
     base.OnInitialize(cellView, factory);
 }
        public void GenerarColumnasDinamicas()
        {
            //Variables Auxiliares
            GridViewColumn          Columna;
            FrameworkElementFactory Txt;
            Assembly assembly;
            string   TipoDato;

            #region Columna Estatus Diagnostico

            //IList<MMaster> ListadoStatusDiagnostico = service.GetMMaster(new MMaster { MetaType = new MType { Code = "ESTATUSD" } });
            //Columna = new GridViewColumn();
            //assembly = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.ComboBox, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
            //TipoDato = "System.Windows.Controls.ComboBox";
            //Columna.Header = "Status Diagnostico";
            //Txt = new FrameworkElementFactory(assembly.GetType(TipoDato));
            //Txt.SetValue(ComboBox.ItemsSourceProperty, ListadoStatusDiagnostico);
            //Txt.SetValue(ComboBox.DisplayMemberPathProperty, "Name");
            //Txt.SetValue(ComboBox.SelectedValuePathProperty, "Code");
            //Txt.SetBinding(ComboBox.SelectedValueProperty, new System.Windows.Data.Binding("Estatus_Diagnostico"));
            //Txt.SetValue(ComboBox.WidthProperty, (double)110);


            //// add textbox template
            //Columna.CellTemplate = new DataTemplate();
            //Columna.CellTemplate.VisualTree = Txt;
            //View.ListadoEquipos.Columns.Add(Columna); //Creacion de la columna en el GridView
            //View.Model.ListRecords.Columns.Add("Estatus_Diagnostico", typeof(String)); //Creacion de la columna en el DataTable


            Columna        = new GridViewColumn();
            assembly       = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.TextBlock, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
            TipoDato       = "System.Windows.Controls.TextBlock";
            Columna.Header = "Status Diagnostico";
            Txt            = new FrameworkElementFactory(assembly.GetType(TipoDato));
            Txt.SetValue(TextBlock.MinWidthProperty, (double)100);
            Txt.SetBinding(TextBlock.TextProperty, new System.Windows.Data.Binding("Estatus_Diagnostico"));

            // add textbox template
            Columna.CellTemplate            = new DataTemplate();
            Columna.CellTemplate.VisualTree = Txt;
            View.ListadoEquipos.Columns.Add(Columna);                                  //Creacion de la columna en el GridView
            View.Model.ListRecords.Columns.Add("Estatus_Diagnostico", typeof(String)); //Creacion de la columna en el DataTable

            #endregion

            #region Columna Tipo Diagnostico

            Columna        = new GridViewColumn();
            assembly       = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.TextBox, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
            TipoDato       = "System.Windows.Controls.TextBox";
            Columna.Header = "Tipo Diagnostico";
            Txt            = new FrameworkElementFactory(assembly.GetType(TipoDato));
            Txt.SetValue(TextBox.MinWidthProperty, (double)100);
            Txt.SetBinding(TextBox.TextProperty, new System.Windows.Data.Binding("TIPO_DIAGNOSTICO"));
            Txt.SetValue(TextBox.TabIndexProperty, (int)0);//Interruption Point
            Txt.SetValue(TextBox.IsTabStopProperty, true);

            // add textbox template
            Columna.CellTemplate            = new DataTemplate();
            Columna.CellTemplate.VisualTree = Txt;
            View.ListadoEquipos.Columns.Add(Columna);                               //Creacion de la columna en el GridView
            View.Model.ListRecords.Columns.Add("TIPO_DIAGNOSTICO", typeof(String)); //Creacion de la columna en el DataTable

            #endregion

            #region Columna Falla Equipo

            IList <MMaster> ListadoFallaEquipoDiagnostico = service.GetMMaster(new MMaster {
                MetaType = new MType {
                    Code = "FALLADIR"
                }
            });
            Columna        = new GridViewColumn();
            assembly       = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.ComboBox, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
            TipoDato       = "System.Windows.Controls.ComboBox";
            Columna.Header = "Falla Equipo";
            Txt            = new FrameworkElementFactory(assembly.GetType(TipoDato));
            Txt.SetValue(ComboBox.ItemsSourceProperty, ListadoFallaEquipoDiagnostico);
            Txt.SetValue(ComboBox.DisplayMemberPathProperty, "Name");
            Txt.SetValue(ComboBox.SelectedValuePathProperty, "Code");
            Txt.SetBinding(ComboBox.SelectedValueProperty, new System.Windows.Data.Binding("FALLA_DIAGNOSTICO"));
            Txt.SetValue(ComboBox.WidthProperty, (double)110);
            Txt.SetBinding(ComboBox.TagProperty, new System.Windows.Data.Binding("Serial"));
            Txt.AddHandler(System.Windows.Controls.ComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(OnValidarDiagnostico)); //NUEVO EVENTO

            // add textbox template
            Columna.CellTemplate            = new DataTemplate();
            Columna.CellTemplate.VisualTree = Txt;
            View.ListadoEquipos.Columns.Add(Columna);                                //Creacion de la columna en el GridView
            View.Model.ListRecords.Columns.Add("FALLA_DIAGNOSTICO", typeof(String)); //Creacion de la columna en el DataTable

            #endregion

            #region Columna SubFalla Equipo

            IList <MMaster> ListadosSubFallaEquipoDiagnostico = service.GetMMaster(new MMaster {
                MetaType = new MType {
                    Code = "SUBFALLA"
                }
            });
            Columna        = new GridViewColumn();
            assembly       = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.ComboBox, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
            TipoDato       = "System.Windows.Controls.ComboBox";
            Columna.Header = "Sub-Falla Equipo";
            Txt            = new FrameworkElementFactory(assembly.GetType(TipoDato));
            Txt.SetValue(ComboBox.ItemsSourceProperty, ListadosSubFallaEquipoDiagnostico);
            Txt.SetValue(ComboBox.DisplayMemberPathProperty, "Name");
            Txt.SetValue(ComboBox.SelectedValuePathProperty, "Name");
            Txt.SetBinding(ComboBox.SelectedValueProperty, new System.Windows.Data.Binding("SUBFALLA"));
            Txt.SetValue(ComboBox.WidthProperty, (double)110);

            // add textbox template
            Columna.CellTemplate            = new DataTemplate();
            Columna.CellTemplate.VisualTree = Txt;
            View.ListadoEquipos.Columns.Add(Columna);                       //Creacion de la columna en el GridView
            View.Model.ListRecords.Columns.Add("SUBFALLA", typeof(String)); //Creacion de la columna en el DataTable

            #endregion

            #region Columna Tecnico Diagnosticador

            //IList<Rol> ObtRol1 = service.GetRol(new Rol { RolCode = "DTVDIAG" });
            //String ObtRol = service.GetUserByRol(new UserByRol { Rol = (Rol)ObtRol1 }).Select(f => f.Rol).ToString();
            //IList<SysUser> ListadoTecnicoDiagnosticadorCalidad = service.GetSysUser(new SysUser { UserRols = (List<UserByRol>)ObtRol });

            IList <SysUser> ListadoTecnicoDiagnosticadorCalidad = service.GetSysUser(new SysUser());
            Columna        = new GridViewColumn();
            assembly       = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.ComboBox, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
            TipoDato       = "System.Windows.Controls.ComboBox";
            Columna.Header = "Tecnico";
            Txt            = new FrameworkElementFactory(assembly.GetType(TipoDato));
            Txt.SetValue(ComboBox.ItemsSourceProperty, ListadoTecnicoDiagnosticadorCalidad);
            Txt.SetValue(ComboBox.DisplayMemberPathProperty, "FullDesc");
            Txt.SetValue(ComboBox.SelectedValuePathProperty, "UserName");
            Txt.SetBinding(ComboBox.SelectedValueProperty, new System.Windows.Data.Binding("TECNICO_DIAG"));
            Txt.SetValue(ComboBox.WidthProperty, (double)110);

            // add textbox template
            Columna.CellTemplate            = new DataTemplate();
            Columna.CellTemplate.VisualTree = Txt;
            View.ListadoEquipos.Columns.Add(Columna);                           //Creacion de la columna en el GridView
            View.Model.ListRecords.Columns.Add("TECNICO_DIAG", typeof(String)); //Creacion de la columna en el DataTable

            #endregion

            #region Columna Nivel Candidato

            Columna        = new GridViewColumn();
            assembly       = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.TextBlock, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
            TipoDato       = "System.Windows.Controls.TextBlock";
            Columna.Header = "Nivel Candidato";
            Txt            = new FrameworkElementFactory(assembly.GetType(TipoDato));
            Txt.SetValue(TextBlock.MinWidthProperty, (double)100);
            Txt.SetBinding(TextBlock.TextProperty, new System.Windows.Data.Binding("NIVEL_CANDIDATO"));

            // add textbox template
            Columna.CellTemplate            = new DataTemplate();
            Columna.CellTemplate.VisualTree = Txt;
            View.ListadoEquipos.Columns.Add(Columna);                              //Creacion de la columna en el GridView
            View.Model.ListRecords.Columns.Add("NIVEL_CANDIDATO", typeof(String)); //Creacion de la columna en el DataTable

            #endregion
        }
Exemplo n.º 5
0
 public override void OnInitialize(CellView cellView, FrameworkElementFactory factory)
 {
     factory.AddHandler(UngroupedRadioButton.ToggleEvent, new RoutedEventHandler(HandleToggled));
     base.OnInitialize(cellView, factory);
 }
        public SelectorColumn()
        {
            FieldName    = CheckedColumnFieldName;
            UnboundType  = UnboundColumnType.Boolean;
            EditSettings = new CheckEditSettings();
            Fixed        = FixedStyle.None;
            HorizontalHeaderContentAlignment = HorizontalAlignment.Center;

            #region Header Template

            DataTemplate            _template   = new DataTemplate();
            FrameworkElementFactory GridFactory = new FrameworkElementFactory(typeof(System.Windows.Controls.Grid));
            GridFactory.SetValue(System.Windows.Controls.Grid.HorizontalAlignmentProperty, HorizontalAlignment.Center);
            GridFactory.SetValue(System.Windows.Controls.Grid.VerticalAlignmentProperty, VerticalAlignment.Center);
            GridFactory.SetValue(System.Windows.Controls.Grid.VerticalAlignmentProperty, VerticalAlignment.Center);
            FrameworkElementFactory header = new FrameworkElementFactory(typeof(CheckEdit));
            header.SetValue(CheckEdit.VerticalAlignmentProperty, VerticalAlignment.Center);
            header.SetValue(CheckEdit.HorizontalAlignmentProperty, HorizontalAlignment.Center);
            header.AddHandler(CheckEdit.EditValueChangedEvent, new EditValueChangedEventHandler(chkHeader_EditValueChanged));

            Binding binding = new Binding
            {
                Path   = new PropertyPath("IsSelectAll"),
                Source = this,
                Mode   = BindingMode.TwoWay,
                NotifyOnSourceUpdated = true
            };

            Binding bindingHeaderVisibility = new Binding
            {
                Path   = new PropertyPath("HeaderVisibility"),
                Source = this,
                Mode   = BindingMode.TwoWay,
                NotifyOnSourceUpdated = true
            };

            header.SetBinding(CheckEdit.VisibilityProperty, bindingHeaderVisibility);
            header.SetBinding(CheckEdit.EditValueProperty, binding);
            GridFactory.AppendChild(header);
            _template.VisualTree = GridFactory;

            HeaderTemplate = _template;
            #endregion
            //< DataTemplate >
            //< CheckBox IsChecked = "{Binding RowData.Row.IsSelected}" IsEnabled = "{Binding RowData.Row.IsTest}" HorizontalAlignment = "Center" VerticalAlignment = "Center" />

            //</ DataTemplate >
            #region Cell Template
            DataTemplate            _cellTemplate   = new DataTemplate();
            FrameworkElementFactory cellGridFactory = new FrameworkElementFactory(typeof(System.Windows.Controls.Grid));
            cellGridFactory.SetValue(System.Windows.Controls.Grid.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
            cellGridFactory.SetValue(System.Windows.Controls.Grid.VerticalAlignmentProperty, VerticalAlignment.Stretch);

            FrameworkElementFactory cellFactory = new FrameworkElementFactory(typeof(CheckEdit));
            cellFactory.SetValue(CheckEdit.VerticalAlignmentProperty, VerticalAlignment.Center);
            cellFactory.SetValue(CheckEdit.HorizontalAlignmentProperty, HorizontalAlignment.Center);

            Binding cellBinding = new Binding
            {
                Path = new PropertyPath("RowData.Row.IsSelected")
                       //Mode = BindingMode.TwoWay
            };

            Binding cellReadBinding = new Binding
            {
                Path = new PropertyPath("RowData.Row.SelectReadOnly")
                       //Mode = BindingMode.TwoWay
            };

            Binding cellEnableBinding = new Binding
            {
                Path      = new PropertyPath("RowData.Row.SelectReadOnly"),
                Converter = new DevExpress.Xpf.Core.BoolInverseConverter()
                            //Mode = BindingMode.TwoWay
            };
            cellFactory.AddHandler(CheckEdit.EditValueChangedEvent, new EditValueChangedEventHandler(Cell_EditValueChanged));
            cellFactory.SetValue(CheckEdit.EditValueProperty, cellBinding);
            cellFactory.SetValue(CheckEdit.IsReadOnlyProperty, cellReadBinding);
            cellFactory.SetValue(CheckEdit.IsEnabledProperty, cellEnableBinding);


            cellGridFactory.AppendChild(cellFactory);
            _cellTemplate.VisualTree = cellGridFactory;

            CellTemplate = _cellTemplate;
            #endregion
        }
Exemplo n.º 7
0
 void UcTableView_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (dt == null)
     {
         return;
     }
     _gridview.Columns.Clear();
     foreach (DataColumn c in dt.Columns)
     {
         GridViewColumn gvc = new GridViewColumn();
         gvc.Header = c.ColumnName;
         if (_listview.ActualWidth > 0)
         {
             if (BShowDetails || BShowModify)
             {
                 gvc.Width = (_listview.ActualWidth - 65) / dt.Columns.Count;
             }
             else
             {
                 gvc.Width = (_listview.ActualWidth - 25) / dt.Columns.Count;
             }
         }
         gvc.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Center);
         //gvc.DisplayMemberBinding = (new Binding(c.ColumnName));
         FrameworkElementFactory text = new FrameworkElementFactory(typeof(TextBlock));
         text.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
         text.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Center);
         text.SetBinding(TextBlock.TextProperty, new Binding(c.ColumnName));
         DataTemplate dataTemplate = new DataTemplate()
         {
             VisualTree = text
         };
         gvc.CellTemplate = dataTemplate;
         _gridview.Columns.Add(gvc);
     }
     if (BShowDetails)
     {
         GridViewColumn gvc_details = new GridViewColumn();
         gvc_details.Header = "详情";
         FrameworkElementFactory button_details = new FrameworkElementFactory(typeof(Button));
         button_details.SetResourceReference(Button.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
         button_details.SetValue(Button.WidthProperty, 40.0);
         button_details.AddHandler(Button.ClickEvent, new RoutedEventHandler(details_Click));
         button_details.SetBinding(Button.TagProperty, new Binding(dt.Columns[1].ColumnName));
         button_details.SetValue(Button.ContentProperty, ">>");
         button_details.SetValue(Button.ForegroundProperty, Brushes.White);
         button_details.SetValue(Button.FontSizeProperty, 14.0);
         button_details.SetBinding(Button.VisibilityProperty, new Binding(dt.Columns[0].ColumnName)
         {
             Converter = new VisibleBtnConverter()
         });
         DataTemplate dataTemplate_details = new DataTemplate()
         {
             VisualTree = button_details
         };
         gvc_details.CellTemplate = dataTemplate_details;
         _gridview.Columns.Add(gvc_details);
     }
     if (BShowModify)
     {
         GridViewColumn gvc_modify = new GridViewColumn();
         gvc_modify.Header = "设置";
         FrameworkElementFactory button_modify = new FrameworkElementFactory(typeof(Button));
         button_modify.SetResourceReference(Button.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
         button_modify.SetValue(Button.WidthProperty, 20.0);
         button_modify.AddHandler(Button.ClickEvent, new RoutedEventHandler(modify_Click));
         button_modify.SetBinding(Button.TagProperty, new Binding(dt.Columns[1].ColumnName));
         button_modify.SetResourceReference(Button.StyleProperty, "ListModifyImageButtonTemplate");
         DataTemplate dataTemplate_modify = new DataTemplate()
         {
             VisualTree = button_modify
         };
         gvc_modify.CellTemplate = dataTemplate_modify;
         _gridview.Columns.Add(gvc_modify);
     }
     _listview.ItemsSource = null;
     _listview.ItemsSource = dt.DefaultView;
 }
Exemplo n.º 8
0
        /// <summary>
        /// metodo que carga los registros de empalme al control de empalmes
        /// </summary>
        /// <param name="DynamicWrapPanel">control wrap panel de la vista</param>
        /// <param name="ListHoras">lista horas del imputado seleccionado</param>
        /// <param name="ListGrupos">lista grupo de imputado seleccionado</param>
        private void LoadEmpalmes(WrapPanel DynamicWrapPanel, List <DetalleEmpalmeHora> ListHoras, List <GRUPO> ListGrupos)
        {
            try
            {
                #region [Crear Grid]
                //declaracion del grid
                DynamicGrid.Children.Clear();
                DynamicGrid.RowDefinitions.Clear();
                DynamicGrid.ColumnDefinitions.Clear();

                //declaracoin de renglon
                DynamicGrid.RowDefinitions.Add(new RowDefinition());

                //declaracion de columna
                DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(.2, GridUnitType.Star)
                });
                DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition());
                DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(.4, GridUnitType.Star)
                });
                DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(.4, GridUnitType.Star)
                });
                DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(.4, GridUnitType.Star)
                });

                //declaracion de encabezados
                var arrayHeader = new string[] { "PRIORIDAD", "ACTIVIDAD", "% DE ASISTENCIA", "HORAS ASIGNADAS", "% DE HORAS EMPALMADAS" }.ToList();
                var addTextBlock = new TextBlock();
                foreach (var item in arrayHeader)
                {
                    addTextBlock.Text       = item;
                    addTextBlock.FontSize   = 14;
                    addTextBlock.Margin     = new Thickness(5);
                    addTextBlock.Foreground = Brushes.Black;
                    addTextBlock.FontWeight = FontWeights.Bold;

                    Grid.SetRow(addTextBlock, 0);
                    Grid.SetColumn(addTextBlock, arrayHeader.IndexOf(item));
                    DynamicGrid.Children.Add(addTextBlock);
                    addTextBlock = new TextBlock();
                }

                //declaracion de las actividades empalmadas en forma de listado
                var addTextBox = new TextBox();
                foreach (var item in ListGrupos)
                {
                    DynamicGrid.RowDefinitions.Add(new RowDefinition());
                    foreach (var itemHeader in arrayHeader)
                    {
                        addTextBox.Name       = "TB_" + item.ID_GRUPO + "_" + arrayHeader.IndexOf(itemHeader);
                        addTextBox.IsReadOnly = true;
                        addTextBox.Text       = itemHeader == "PRIORIDAD" ? (item.ACTIVIDAD.PRIORIDAD.HasValue ? item.ACTIVIDAD.PRIORIDAD.Value.ToString() : string.Empty) : itemHeader == "ACTIVIDAD" ? item.ACTIVIDAD.DESCR : itemHeader == "% DE ASISTENCIA" ? ObtenerAsistencia(item, item.ID_GRUPO, SelectedParticipante) : itemHeader == "HORAS ASIGNADAS" ? ObtenerHorasAsignadas(item, SelectedParticipante) : string.Empty;
                        Grid.SetRow(addTextBox, (ListGrupos.IndexOf(item) + 1));
                        Grid.SetColumn(addTextBox, arrayHeader.IndexOf(itemHeader));
                        DynamicGrid.Children.Add(addTextBox);
                        addTextBox = new TextBox();
                    }
                }

                #endregion
                #region [Crear WrapPanel]
                // limpieza de wrappanel
                foreach (var item in DynamicWrapPanel.Children.Cast <Grid>().ToList())
                {
                    item.Children.Clear();
                }

                DynamicWrapPanel.Children.Clear();

                //rendereo de grids de fechas empalmadas

                //definimos grid
                var addGrid = new Grid();
                //definicon de renglon
                addGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
                addGrid.RowDefinitions.Add(new RowDefinition());

                //declaramos el datagrid y las columnas del datagrid y bindiamos
                var addDataGrid = new DataGrid();
                addDataGrid.Columns.Add(new DataGridTextColumn()
                {
                    Binding = new Binding("HORA_INICIO")
                    {
                        StringFormat = "dd/MM/yyyy"
                    }, Header = "FECHA", CanUserSort = false, IsReadOnly = true, FontSize = 12, MaxWidth = 150, ElementStyle = new Style(typeof(TextBlock))
                    {
                        Setters = { new Setter(TextBlock.TextWrappingProperty, TextWrapping.Wrap) }
                    }
                });

                foreach (var item in SelectedParticipante.PorHora.GroupBy(g => new { g.DEPARTAMENTO, g.PROGRAMA, g.ACTIVIDAD, g.ID_EJE }).OrderBy(o => o.FirstOrDefault().FEC_REGISTRO))
                {
                    var RadioFactory = new FrameworkElementFactory(typeof(RadioButton));
                    RadioFactory.SetValue(RadioButton.GroupNameProperty, new Binding("HORA_INICIO"));
                    RadioFactory.AddHandler(RadioButton.CheckedEvent, new RoutedEventHandler(chkSelect_Checked));
                    RadioFactory.AddHandler(RadioButton.UncheckedEvent, new RoutedEventHandler(chkSelect_Unchecked));
                    RadioFactory.SetValue(RadioButton.HorizontalAlignmentProperty, HorizontalAlignment.Center);
                    RadioFactory.SetValue(RadioButton.VerticalAlignmentProperty, VerticalAlignment.Center);
                    RadioFactory.SetValue(RadioButton.TagProperty, item.FirstOrDefault().ID_GRUPO);

                    RadioFactory.SetValue(RadioButton.IsCheckedProperty, new Binding("HORA_INICIO")
                    {
                        Converter = new IsCheckedAssistConverter(), ConverterParameter = new object[] { SelectedParticipante.PorHora, item.FirstOrDefault().ID_GRUPO }
                    });
                    RadioFactory.SetValue(RadioButton.VisibilityProperty, new Binding("HORA_INICIO")
                    {
                        Converter = new IsVisibleConverter(), ConverterParameter = new object[] { SelectedParticipante.PorHora, item.FirstOrDefault().ID_GRUPO }
                    });

                    var triggerEnabled = new DataTrigger {
                        Binding = new Binding("HORA_INICIO")
                        {
                            Converter = new IsEnabledDateConverter()
                        }, Value = true
                    };
                    triggerEnabled.Setters.Add(new Setter {
                        Property = RadioButton.IsEnabledProperty, Value = false
                    });

                    var template = new DataTemplate {
                        VisualTree = RadioFactory
                    };
                    template.Triggers.Add(triggerEnabled);

                    addDataGrid.Columns.Add(new DataGridTemplateColumn()
                    {
                        Header = "DEPARTAMENTO: " + item.Key.DEPARTAMENTO + "\n" + "PROGRAMA: " + item.Key.PROGRAMA + "\n" + "ACTIVIDAD: " + item.Key.ACTIVIDAD + "\n" + "GRUPO: " + item.FirstOrDefault().GRUPO, CellTemplate = template
                    });
                }

                // configuramos propiedades del datagrid
                addDataGrid.Name                = "ContenedorGrid";
                addDataGrid.FontSize            = 14;
                addDataGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
                addDataGrid.VerticalAlignment   = VerticalAlignment.Top;
                addDataGrid.Margin              = new Thickness(5);
                addDataGrid.AutoGenerateColumns = false;


                //var style = new Style(typeof(DataGrid), (Style)Application.Current.FindResource("MetroDataGrid"));
                //style.Setters.Add(new Setter(DataGrid.GridLinesVisibilityProperty, DataGridGridLinesVisibility.Horizontal));
                //Resources.Add(typeof(TextBlock), style);

                addDataGrid.Style             = (Style)Application.Current.FindResource("MetroDataGrid");
                addDataGrid.CanUserAddRows    = false;
                addDataGrid.CanUserDeleteRows = false;
                addDataGrid.BeginningEdit    += (s, e) =>
                {
                    e.Cancel = true;
                };
                addDataGrid.VerticalGridLinesBrush = Brushes.Black;
                addDataGrid.GridLinesVisibility    = DataGridGridLinesVisibility.Vertical;
                addDataGrid.SelectionMode          = DataGridSelectionMode.Single;
                addDataGrid.AutoGenerateColumns    = false;
                //igualamos el datasource a la lista de horas empalmadas
                addDataGrid.ItemsSource = ListHoras.GroupBy(g => new { g.HORA_INICIO.Value.Date }).OrderBy(o => o.FirstOrDefault().HORA_INICIO);

                //agregamos el datagrid
                Grid.SetRow(addDataGrid, 1);
                Grid.SetColumn(addDataGrid, 0);

                //agregamos el texbox y el datagrid al grid
                addGrid.Children.Add(addTextBlock);
                addGrid.Children.Add(addDataGrid);

                //agregamos el grid al wrappanel
                DynamicWrapPanel.Children.Add(addGrid);
                #endregion
            }
            catch (Exception ex)
            {
                StaticSourcesViewModel.ShowMessageError("Algo pasó...", "Ocurrió un error al cargar la información", ex);
            }
        }
Exemplo n.º 9
0
        public FieldDefListView(RuleApplicationDef ruleAppDef, Options includedOptions, List <UnusedFieldAction> actions, string defaultSortColumnName)
        {
            this.Background          = Brushes.White;
            TargetRuleApplicationDef = ruleAppDef;
            DefaultSortColumnName    = defaultSortColumnName;

            DataContext       = this;
            _hasLoaded        = false;
            this.Initialized += FieldDefListView_Initialized;
            InitializeComponent();

            DataTemplate cardLayout = new DataTemplate();

            //cardLayout.DataType = typeof(CreditCardPayment);

            //set up the stack panel


            if (includedOptions.HasFlag(Options.NameColumn))
            {
                AddColumn("NameColumn");
            }
            if (includedOptions.HasFlag(Options.TypeNameColumn))
            {
                AddColumn("TypeNameColumn");
            }


            actions = new List <UnusedFieldAction>(actions);

            FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(StackPanel));

            //spFactory.Name = "myComboFactory";
            spFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            int count = 0;

            foreach (var action in actions)
            {
                action.ListView = this;
                if (count > 0)
                {
                    var borderFactory = new FrameworkElementFactory(typeof(Border));
                    borderFactory.SetValue(Button.BorderThicknessProperty, new Thickness(1, 0, 0, 0));
                    borderFactory.SetValue(Button.BorderBrushProperty, Brushes.DarkGray);
                    //borderFactory.SetValue(Button.PaddingProperty, new Thickness(5,3,5,3));
                    borderFactory.SetValue(Button.MarginProperty, new Thickness(5, 5, 5, 5));
                    spFactory.AppendChild(borderFactory);
                }
                count++;
                FrameworkElementFactory buttonFactory = new FrameworkElementFactory(typeof(Button));
                buttonFactory.SetValue(Button.ContentProperty, action.DisplayName);
                buttonFactory.AddHandler(Button.ClickEvent, new RoutedEventHandler(action.ExecuteAction_Click));
                buttonFactory.SetValue(Button.StyleProperty, this.Resources["LinkButton"]);
                spFactory.AppendChild(buttonFactory);
            }


            //set the visual tree of the data template
            cardLayout.VisualTree = spFactory;

            var actionColumn = AddColumn("ActionColumn");

            //set the item template to be our shiny new data template
            actionColumn.CellTemplate = cardLayout;

            ListViewSortManager = new ListViewSortManager(this.lstViewValues);
            ListViewSortManager.GetColumnDefaultSortDirection = GetColumnDefaultSortDirection;

            HideErrorMessage();
            HideHistoryBorder();

            this.OnCloseView += OnClosingView;
        }
Exemplo n.º 10
0
        public UIElement GetEditor(XmlNode nd)
        {
            DataGrid dataGrid = new DataGrid()
            {
                AutoGenerateColumns   = false,
                CanUserReorderColumns = true,
                CanUserResizeColumns  = true
            };

            DataGridTextColumn col1 = new DataGridTextColumn()
            {
                Header  = "Name",
                Binding = new Binding("Name")
            };

            dataGrid.Columns.Add(col1);

            DataGridTextColumn col2 = new DataGridTextColumn()
            {
                Header   = "FileName",
                Binding  = new Binding("FileName"),
                MinWidth = 200
            };

            dataGrid.Columns.Add(col2);

            var buttonTemplate = new FrameworkElementFactory(typeof(Button));

            buttonTemplate.SetValue(Button.ContentProperty, "...");
            buttonTemplate.AddHandler(
                Button.ClickEvent,
                new RoutedEventHandler((o, e) => {
                //Row3 r = ((FrameworkElement)o).DataContext as Row3;

                DependencyObject dep = (DependencyObject)e.OriginalSource;

                // iteratively traverse the visual tree --> search row
                while ((dep != null) && !(dep is DataGridRow))
                {
                    dep = VisualTreeHelper.GetParent(dep);
                }

                if (dep != null)
                {
                    DataGridRow row = (DataGridRow)dep;

                    Row3 r = null;
                    if (row.Item is Row3)
                    {
                        r = (Row3)row.Item;
                    }
                    else
                    {
                        r = new Row3();
                    }

                    OpenFileDialog dlg = new OpenFileDialog();
                    bool?result        = dlg.ShowDialog();

                    if (result == true)
                    {
                        r.FileName = dlg.SafeFileName;
                        row.Item   = r;
                    }
                }
            })
                );

            DataGridTemplateColumn col3 = new DataGridTemplateColumn()
            {
                CellTemplate = new DataTemplate()
                {
                    VisualTree = buttonTemplate
                },
                Width = 16
            };

            dataGrid.Columns.Add(col3);

            ObservableCollection <Row3> rows = new ObservableCollection <Row3>();

            foreach (XmlNode child in nd.ChildNodes)
            {
                Row3 r = new Row3();

                var attr = child.Attributes["Name"];
                if (attr != null)
                {
                    r.Name = attr.Value;
                }

                attr = child.Attributes["FileName"];
                if (attr != null)
                {
                    r.FileName = attr.Value;
                }

                rows.Add(r);
            }
            dataGrid.ItemsSource = rows;

            return(dataGrid);
        }
Exemplo n.º 11
0
        private void pobierzIDdekretacji()
        {
            try
            {
                using (SqlConnection _con = new SqlConnection(connectionString))
                {
                    string queryStatement = "SELECT * FROM tblIdentyfikatoryAutodekretacji";
                    using (SqlCommand _cmd = new SqlCommand(queryStatement, _con))
                    {
                        DataTable      Iddekretacji = new DataTable("IdDekretacji");
                        SqlDataAdapter _dap         = new SqlDataAdapter(_cmd);
                        _con.Open();
                        _dap.Fill(Iddekretacji);
                        _con.Close();
                        IdDekretacjiDG.ItemsSource = Iddekretacji.AsDataView();
                    }
                }
            }
            catch (Exception error)
            {
                Error komunikat = new Error(error);
            }


            IdDekretacjiDG.AutoGeneratingColumn += (s, e) =>
            {
                if (e.PropertyType == typeof(System.DateTime))
                {
                    (e.Column as DataGridTextColumn).Binding.StringFormat = "dd/MM/yyyy";
                }
                if (e.PropertyType == typeof(System.Decimal))
                {
                    (e.Column as DataGridTextColumn).Binding.StringFormat = "{0:N}" + " ZŁ";
                }
                if (e.PropertyName == "NrDokumentu")
                {
                    e.Column.Header = "Nr Dokumentu";
                }
                if (e.PropertyName == "kontrahent")
                {
                    e.Column.Header = "Kontrahent";
                }
                if (e.PropertyName == "ksiegujacy")
                {
                    e.Column.Header = "Księgujący";
                }
                if (e.PropertyName == "dataAutodekretacji")
                {
                    e.Column.Header = "Data Dekretacji";
                }
                if (e.PropertyName == "opisAutodekrtacji")
                {
                    e.Column.Header = "Opis";
                }
                if (e.PropertyName == "IdAutodekretacji")
                {
                    e.Column.Header = "ID Autodekretacji";
                }
                if (e.PropertyName == "doUsuniecia")
                {
                    e.Column.Header = "Usuń";
                    DataGridTemplateColumn  buttonColumn   = new DataGridTemplateColumn();
                    DataTemplate            buttonTemplate = new DataTemplate();
                    FrameworkElementFactory buttonFactory  = new FrameworkElementFactory(typeof(Button));
                    buttonTemplate.VisualTree = buttonFactory;
                    buttonFactory.AddHandler(Button.ClickEvent, new RoutedEventHandler(Usun_Click));
                    buttonFactory.SetValue(ContentProperty, "Usuń");
                    buttonColumn.CellTemplate = buttonTemplate;
                    e.Column = buttonColumn;
                }
            };
        }
        private void ConfigureBooksCatalog()
        {
            dgBooksCatalog.IsReadOnly                    = true;
            dgBooksCatalog.CanUserResizeColumns          = false;
            dgBooksCatalog.CanUserResizeRows             = false;
            dgBooksCatalog.CanUserReorderColumns         = false;
            dgBooksCatalog.HorizontalAlignment           = HorizontalAlignment.Center;
            dgBooksCatalog.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            dgBooksCatalog.VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled;
            dgBooksCatalog.RowHeight = 50;
            dgBooksCatalog.FontSize  = 18;

            DataGridTextColumn column1 = new DataGridTextColumn();

            column1.Header  = "Autor";
            column1.Binding = new Binding("Autor");
            column1.Width   = 200;
            dgBooksCatalog.Columns.Add(column1);

            DataGridTextColumn column2 = new DataGridTextColumn();

            column2.Header  = "Tytuł";
            column2.Binding = new Binding("Tytul");
            column2.Width   = 200;
            dgBooksCatalog.Columns.Add(column2);

            DataGridTextColumn column3 = new DataGridTextColumn();

            column3.Header  = "Wydawnictwo";
            column3.Binding = new Binding("Wydawnictwo");
            column3.Width   = 130;
            dgBooksCatalog.Columns.Add(column3);

            DataGridTextColumn column4 = new DataGridTextColumn();

            column4.Header  = "Rok wydania";
            column4.Binding = new Binding("RokWydania");
            column4.Width   = 120;
            dgBooksCatalog.Columns.Add(column4);

            DataGridTextColumn column5 = new DataGridTextColumn();

            column5.Header  = "Opis";
            column5.Binding = new Binding("Opis");
            column5.Width   = 210;
            dgBooksCatalog.Columns.Add(column5);

            DataGridTextColumn column6 = new DataGridTextColumn();

            column6.Header  = "Ilość";
            column6.Binding = new Binding("Ilosc");
            column6.Width   = 50;
            dgBooksCatalog.Columns.Add(column6);

            if (DatabaseManager.user != null && DatabaseManager.user.levelAccess == "Bibliotekarz")
            {
                return;
            }

            DataTemplate            dataTemplate = new DataTemplate();
            FrameworkElementFactory button       = new FrameworkElementFactory(typeof(Button));
            FrameworkElementFactory image        = new FrameworkElementFactory(typeof(Image));

            image.SetValue(Image.SourceProperty, new BitmapImage(new Uri("pack://application:,,,/basket.jpg")));
            button.AppendChild(image);
            button.AddHandler(Button.ClickEvent, new RoutedEventHandler(BtnClickEvent));
            dataTemplate.VisualTree = button;
            DataGridTemplateColumn column7 = new DataGridTemplateColumn();

            column7.CellTemplate = dataTemplate;
            column7.Width        = 50;
            dgBooksCatalog.Columns.Add(column7);
        }
Exemplo n.º 13
0
        private HierarchicalDataTemplate setUpTheHierarchy()
        {
            //Class Topic_Keywords
            FrameworkElementFactory ft = new FrameworkElementFactory(typeof(StackPanel));

            ft.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            FrameworkElementFactory im = new FrameworkElementFactory(typeof(Image));

            im.SetValue(Image.SourceProperty, findImageSource("../../img/icons/folder-icon-16x16.png"));
            im.SetValue(Image.WidthProperty, Double.Parse("14"));
            im.SetValue(Image.HeightProperty, Double.Parse("14"));
            im.SetValue(Image.MarginProperty, new Thickness(4, 0, 0, 0));
            ft.AppendChild(im);

            FrameworkElementFactory tb = new FrameworkElementFactory(typeof(TextBlock));

            tb.SetBinding(TextBlock.TextProperty, new Binding("Date"));
            tb.SetValue(TextBlock.MarginProperty, new Thickness(4, 0, 0, 0));

            ft.AppendChild(tb);

            HierarchicalDataTemplate t = new HierarchicalDataTemplate(typeof(Topic_Keyword));

            t.ItemsSource = new Binding("Items");
            t.VisualTree  = ft;


            //Class Keywords

            FrameworkElementFactory ff = new FrameworkElementFactory(typeof(StackPanel));

            ff.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            FrameworkElementFactory ima = new FrameworkElementFactory(typeof(Image));

            ima.SetValue(Image.SourceProperty, findImageSource("../../img/icons/feed-icon-14x14.png"));
            ima.SetValue(Image.WidthProperty, Double.Parse("14"));
            ima.SetValue(Image.HeightProperty, Double.Parse("14"));
            ima.SetValue(Image.MarginProperty, new Thickness(4, 0, 0, 0));
            ff.AppendChild(ima);

            FrameworkElementFactory tbt = new FrameworkElementFactory(typeof(TextBlock));

            tbt.SetBinding(TextBlock.TextProperty, new Binding("Text"));
            //tbt.SetBinding(TextBlock, new Binding() { RelativeSource= RelativeSource.Self });
            tbt.SetValue(TextBlock.MarginProperty, new Thickness(4, 0, 0, 0));
            ff.AppendChild(tbt);



            FrameworkElementFactory f = new FrameworkElementFactory(typeof(CheckBox));

            f.SetBinding(CheckBox.ClickModeProperty, new Binding("ThreeWay"));
            f.SetBinding(CheckBox.DataContextProperty, new Binding());
            f.AppendChild(ff);
            f.AddHandler(CheckBox.CheckedEvent, new RoutedEventHandler(isChecked));
            f.AddHandler(CheckBox.UncheckedEvent, new RoutedEventHandler(isUnchecked));


            HierarchicalDataTemplate tmp = new HierarchicalDataTemplate(typeof(Keyword));

            tmp.ItemsSource = new Binding("Items");

            tmp.VisualTree = f;

            t.ItemTemplate = tmp;

            return(t);
        }
Exemplo n.º 14
0
        /*
         * El metodo GenerarObjetos() crea un template para el listbox pruebaLista.
         * El objeto DataTemplate sirve para crear la plantilla de datos.
         * El objeto DataBinding sirve para obtener la informacón de las clases.
         * El objeto FrameWorkElementFactory nos ayuda a crear objetos mediante codigo.
         */
        private void GenerarObjetos()
        {
            try
            {
                #region -> Plantilla y Bindeos.
                dt = new DataTemplate();                                   // Creamos un objeto DataTemplate

                bindingId      = new System.Windows.Data.Binding();        // Creamos un objeto DataBinding
                bindingId.Path = new PropertyPath("Id");                   //Asignamos al objeto DataBinding el Id de datosNotas

                bindingTitulo      = new System.Windows.Data.Binding();    // Creamos un objeto DataBinding
                bindingTitulo.Path = new PropertyPath("Titulo");           //Asignamos al objeto DataBinding el Titulo de datosNotas

                bindingContenido      = new System.Windows.Data.Binding(); // Creamos un objeto DataBinding
                bindingContenido.Path = new PropertyPath("Contenido");     //Asignamos al objeto DataBinding el Contenido de datosNotas

                bindingFecha      = new System.Windows.Data.Binding();     // Creamos un objeto DataBinding
                bindingFecha.Path = new PropertyPath("Fecha");             //Asignamos al objeto DataBinding la Fecha de datosNotas
                #endregion
                #region -> Objetos y Propiedades.
                textoTitulo = new FrameworkElementFactory(typeof(TextBlock));         // Creamos un objeto FrameworkElementFactory de tipo TextBlock
                textoTitulo.SetBinding(TextBlock.TextProperty, bindingTitulo);        // Le añadimos un bind (bindingTitulo).
                textoTitulo.SetValue(MarginProperty, new Thickness(15d, 5d, 0d, 0d)); // Alteramos las propiedades del objeto.
                textoTitulo.SetValue(ForegroundProperty, Brushes.White);
                textoTitulo.SetValue(FontWeightProperty, FontWeights.Bold);
                textoTitulo.SetValue(FontSizeProperty, 21d);

                textoContenido = new FrameworkElementFactory(typeof(System.Windows.Controls.TextBox));     // Creamos un objeto FrameworkElementFactory de tipo TextBox
                textoContenido.SetBinding(System.Windows.Controls.TextBox.TextProperty, bindingContenido); // Le añadimos un bind (bindingContenido).
                textoContenido.SetValue(MarginProperty, new Thickness(0d, 2d, 15d, 0d));                   // Alteramos las propiedades del objeto.
                textoContenido.SetValue(PaddingProperty, new Thickness(0d, 0d, 10d, 0d));
                textoContenido.SetValue(System.Windows.Controls.TextBox.HeightProperty, 145d);
                textoContenido.SetValue(System.Windows.Controls.TextBox.MaxHeightProperty, 145d);
                textoContenido.SetValue(System.Windows.Controls.TextBox.MinWidthProperty, 1055d);
                textoContenido.SetValue(System.Windows.Controls.TextBox.MaxWidthProperty, 1060d);
                textoContenido.SetValue(ForegroundProperty, Brushes.DimGray);
                textoContenido.SetValue(FontWeightProperty, FontWeights.Regular);
                textoContenido.SetValue(BackgroundProperty, Brushes.Transparent);
                textoContenido.SetValue(System.Windows.Controls.TextBox.IsReadOnlyProperty, true);
                textoContenido.SetValue(FontSizeProperty, 12d);
                textoContenido.SetValue(System.Windows.Controls.TextBox.TextWrappingProperty, TextWrapping.Wrap);
                textoContenido.SetValue(System.Windows.Controls.TextBox.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Auto);
                textoContenido.SetValue(BorderThicknessProperty, new Thickness(0));

                textoFecha = new FrameworkElementFactory(typeof(TextBlock));            // Creamos un objeto FrameworkElementFactory de tipo TextBlock
                textoFecha.SetBinding(TextBlock.TextProperty, bindingFecha);            // Le añadimos un bind (bindingFecha).
                textoFecha.SetValue(MarginProperty, new Thickness(945d, 15d, 20d, 0d)); // Alteramos las propiedades del objeto.
                textoFecha.SetValue(ForegroundProperty, Brushes.DimGray);
                textoFecha.SetValue(FontWeightProperty, FontWeights.Regular);
                textoFecha.SetValue(FontStyleProperty, FontStyles.Italic);
                textoFecha.SetValue(FontSizeProperty, 11d);

                botonEliminar = new FrameworkElementFactory(typeof(System.Windows.Controls.Button)); // Creamos un objeto FrameworkElementFactory de tipo button
                botonEliminar.SetBinding(System.Windows.Controls.Button.NameProperty, bindingId);    // Le añadimos un bind (bindingId).
                botonEliminar.SetValue(System.Windows.Controls.Button.ContentProperty, "Eliminar");  // Alteramos las propiedades del objeto.
                botonEliminar.SetValue(WidthProperty, 80d);
                botonEliminar.SetValue(HeightProperty, 40d);
                botonEliminar.SetValue(ForegroundProperty, Brushes.IndianRed);
                botonEliminar.SetValue(BackgroundProperty, Brushes.Transparent);
                botonEliminar.SetValue(FontWeightProperty, FontWeights.Bold);
                botonEliminar.SetValue(BorderThicknessProperty, new Thickness(0, 0, 1, 0));
                botonEliminar.SetValue(BorderBrushProperty, Brushes.Wheat);
                botonEliminar.AddHandler(System.Windows.Controls.Button.ClickEvent, new RoutedEventHandler(BotonEliminar_Click)); // Añadimos un Click event.

                botonEditar = new FrameworkElementFactory(typeof(System.Windows.Controls.Button));                                // Creamos un objeto FrameworkElementFactory de tipo button
                botonEditar.SetBinding(System.Windows.Controls.Button.NameProperty, bindingId);                                   // Le añadimos un bind (bindingId).
                botonEditar.SetValue(ContentProperty, "Editar");                                                                  // Alteramos las propiedades del objeto.
                botonEditar.SetValue(WidthProperty, 80d);
                botonEditar.SetValue(HeightProperty, 40d);
                botonEditar.SetValue(ForegroundProperty, Brushes.White);
                botonEditar.SetValue(BackgroundProperty, Brushes.Transparent);
                botonEditar.SetValue(FontWeightProperty, FontWeights.Bold);
                botonEditar.SetValue(BorderThicknessProperty, new Thickness(0));
                botonEditar.AddHandler(System.Windows.Controls.Button.ClickEvent, new RoutedEventHandler(BotonEditar_Click)); // Añadimos un Click event.

                stackTitulo = new FrameworkElementFactory(typeof(StackPanel));                                                // Creamos un objeto FrameworkElementFactory de tipo StackPanel.
                stackTitulo.SetValue(MinWidthProperty, 910d);                                                                 // Alteramos las propiedades del objeto.
                stackTitulo.SetValue(MaxWidthProperty, 910d);
                stackTitulo.AppendChild(textoTitulo);                                                                         // Agregamos un hijo (textTitulo).

                wrap = new FrameworkElementFactory(typeof(WrapPanel));                                                        // Creamos un objeto FrameworkElementFactory de tipo WrapPanel.
                wrap.SetValue(BackgroundProperty, Brushes.DarkSalmon);                                                        // Alteramos las propiedades del objeto.
                wrap.SetValue(MinWidthProperty, 1080d);
                wrap.SetValue(MaxWidthProperty, 1080d);
                wrap.AppendChild(stackTitulo); // Agregamos los hijos.
                wrap.AppendChild(botonEliminar);
                wrap.AppendChild(botonEditar);

                stack = new FrameworkElementFactory(typeof(StackPanel)); // Creamos un objeto FrameworkElementFactory de tipo StackPanel.
                stack.SetValue(HeightProperty, 220d);                    // Alteramos las propiedades del objeto.
                stack.SetValue(MinWidthProperty, 1080d);
                stack.SetValue(MaxWidthProperty, 1080d);
                stack.SetValue(MarginProperty, new Thickness(5));
                stack.AppendChild(wrap); // Agregamos los hijos.
                stack.AppendChild(textoContenido);
                stack.AppendChild(textoFecha);

                border = new FrameworkElementFactory(typeof(Border)); // Creamos un objeto FrameworkElementFactory de tipo Border.
                border.SetValue(MinWidthProperty, 1080d);             // Alteramos las propiedades del objeto.
                border.SetValue(MaxWidthProperty, 1080d);
                border.SetValue(MarginProperty, new Thickness(0d, 10d, 0d, 0d));
                border.SetValue(BackgroundProperty, Brushes.White);
                border.SetValue(BorderBrushProperty, Brushes.LightGray);
                border.SetValue(BorderThicknessProperty, new Thickness(0, 1, 0, 1));
                border.SetValue(Border.CornerRadiusProperty, new CornerRadius(3));
                border.AppendChild(stack); // Agregamos el hijo (stack).
                #endregion

                dt.VisualTree = border;              // Añadimos el objeto border que amacena todos los restantes al DataTemplate (dt).

                pruebaLista.ItemTemplate = dt;       // Añadimos dt al listbox (pruebalista) ItemTemplate que agrega el diseño del template.

                pruebaLista.ItemsSource = listNotas; // Añadimos la lista (listNotas) ItemsSource que agrega los objetos de la lista.
            }
            catch (Exception e)
            {
                Console.Write(e.ToString());
            }
        }
        public void GenerarColumnasDinamicas()
        {
            //Variables Auxiliares
            GridViewColumn          Columna;
            FrameworkElementFactory Txt;
            Assembly assembly;
            string   TipoDato;

            try
            {
                #region Columna Estatus Verificacion

                //IList<MMaster> ListadoStatusDiagnostico = service.GetMMaster(new MMaster { MetaType = new MType { Code = "ESTATUSVE" } });
                //Columna = new GridViewColumn();
                //assembly = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.ComboBox, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
                //TipoDato = "System.Windows.Controls.ComboBox";
                //Columna.Header = "Status Verificacion";
                //Txt = new FrameworkElementFactory(assembly.GetType(TipoDato));
                //Txt.SetValue(ComboBox.ItemsSourceProperty, ListadoStatusDiagnostico);
                //Txt.SetValue(ComboBox.DisplayMemberPathProperty, "Name");
                //Txt.SetValue(ComboBox.SelectedValuePathProperty, "Code");
                //Txt.SetBinding(ComboBox.SelectedValueProperty, new System.Windows.Data.Binding("ESTATUS_VERIFICACION"));
                //Txt.SetValue(ComboBox.WidthProperty, (double)110);

                //// add textbox template
                //Columna.CellTemplate = new DataTemplate();
                //Columna.CellTemplate.VisualTree = Txt;
                //View.ListadoEquipos.Columns.Add(Columna); //Creacion de la columna en el GridView
                //View.Model.ListRecords.Columns.Add("ESTATUS_VERIFICACION", typeof(String)); //Creacion de la columna en el DataTable

                Columna        = new GridViewColumn();
                assembly       = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.TextBlock, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
                TipoDato       = "System.Windows.Controls.TextBlock";
                Columna.Header = "Status Verificacion";
                Txt            = new FrameworkElementFactory(assembly.GetType(TipoDato));
                Txt.SetValue(TextBlock.MinWidthProperty, (double)100);
                Txt.SetBinding(TextBlock.TextProperty, new System.Windows.Data.Binding("ESTATUS_VERIFICACION"));

                // add textbox template
                Columna.CellTemplate            = new DataTemplate();
                Columna.CellTemplate.VisualTree = Txt;
                View.ListadoEquipos.Columns.Add(Columna);                                   //Creacion de la columna en el GridView
                View.Model.ListRecords.Columns.Add("ESTATUS_VERIFICACION", typeof(String)); //Creacion de la columna en el DataTable

                #endregion

                #region Columna Tipo Calidad

                //IList<MMaster> ListadoTipoCalidad = service.GetMMaster(new MMaster { MetaType = new MType { Code = "TIPOCALIDAD_DIRECTV" } });
                //Columna = new GridViewColumn();
                //assembly = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.ComboBox, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
                //TipoDato = "System.Windows.Controls.ComboBox";
                //Columna.Header = "Tipo";
                //Txt = new FrameworkElementFactory(assembly.GetType(TipoDato));
                //Txt.SetValue(ComboBox.ItemsSourceProperty, ListadoTipoCalidad);
                //Txt.SetValue(ComboBox.DisplayMemberPathProperty, "Name");
                //Txt.SetValue(ComboBox.SelectedValuePathProperty, "Code");
                //Txt.SetBinding(ComboBox.SelectedValueProperty, new System.Windows.Data.Binding("TIPO_CALIDAD"));
                //Txt.SetValue(ComboBox.WidthProperty, (double)110);

                //// add textbox template
                //Columna.CellTemplate = new DataTemplate();
                //Columna.CellTemplate.VisualTree = Txt;
                //View.ListadoEquipos.Columns.Add(Columna); //Creacion de la columna en el GridView
                //View.Model.ListRecords.Columns.Add("TIPO_CALIDAD", typeof(String)); //Creacion de la columna en el DataTable

                #endregion

                #region Columna Falla Equipo Calidad

                IList <MMaster> ListadoFallaEquipoCalidad = service.GetMMaster(new MMaster {
                    MetaType = new MType {
                        Code = "FALLADIR"
                    }
                });
                Columna        = new GridViewColumn();
                assembly       = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.ComboBox, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
                TipoDato       = "System.Windows.Controls.ComboBox";
                Columna.Header = "Falla Equipo";
                Txt            = new FrameworkElementFactory(assembly.GetType(TipoDato));
                Txt.SetValue(ComboBox.ItemsSourceProperty, ListadoFallaEquipoCalidad);
                Txt.SetValue(ComboBox.DisplayMemberPathProperty, "Name");
                Txt.SetValue(ComboBox.SelectedValuePathProperty, "Code");
                Txt.SetBinding(ComboBox.SelectedValueProperty, new System.Windows.Data.Binding("FALLA_EQUIPO_VERIF"));
                Txt.SetValue(ComboBox.WidthProperty, (double)110);
                Txt.SetBinding(ComboBox.TagProperty, new System.Windows.Data.Binding("Serial"));
                Txt.AddHandler(System.Windows.Controls.ComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(OnValidarDiagnostico)); //NUEVO EVENTO

                // add textbox template
                Columna.CellTemplate            = new DataTemplate();
                Columna.CellTemplate.VisualTree = Txt;
                View.ListadoEquipos.Columns.Add(Columna);                                 //Creacion de la columna en el GridView
                View.Model.ListRecords.Columns.Add("FALLA_EQUIPO_VERIF", typeof(String)); //Creacion de la columna en el DataTable

                #endregion

                #region Columna SubFalla Equipo

                IList <MMaster> ListadosSubFallaEquipoDiagnostico = service.GetMMaster(new MMaster {
                    MetaType = new MType {
                        Code = "SUBFALLA"
                    }
                });
                Columna        = new GridViewColumn();
                assembly       = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.ComboBox, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
                TipoDato       = "System.Windows.Controls.ComboBox";
                Columna.Header = "Sub-Falla Equipo";
                Txt            = new FrameworkElementFactory(assembly.GetType(TipoDato));
                Txt.SetValue(ComboBox.ItemsSourceProperty, ListadosSubFallaEquipoDiagnostico);
                Txt.SetValue(ComboBox.DisplayMemberPathProperty, "Name");
                Txt.SetValue(ComboBox.SelectedValuePathProperty, "Name");
                Txt.SetBinding(ComboBox.SelectedValueProperty, new System.Windows.Data.Binding("SUBFALLA"));
                Txt.SetValue(ComboBox.WidthProperty, (double)110);

                // add textbox template
                Columna.CellTemplate            = new DataTemplate();
                Columna.CellTemplate.VisualTree = Txt;
                View.ListadoEquipos.Columns.Add(Columna);                       //Creacion de la columna en el GridView
                View.Model.ListRecords.Columns.Add("SUBFALLA", typeof(String)); //Creacion de la columna en el DataTable

                #endregion

                #region Columna Estado Material.

                IList <MMaster> ListadoFalla = service.GetMMaster(new MMaster {
                    MetaType = new MType {
                        Code = "ESTADOS"
                    }
                });

                Columna  = new GridViewColumn();
                assembly = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.ComboBox, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
                TipoDato = "System.Windows.Controls.ComboBox";

                Columna.Header = "Estado Smart Card";

                Txt = new FrameworkElementFactory(assembly.GetType(TipoDato));
                Txt.SetValue(ComboBox.ItemsSourceProperty, ListadoFalla);
                Txt.SetValue(ComboBox.DisplayMemberPathProperty, "Name");
                Txt.SetValue(ComboBox.SelectedValuePathProperty, "Code");
                Txt.SetBinding(ComboBox.SelectedValueProperty, new System.Windows.Data.Binding("ESTADO_MATERIAL"));
                Txt.SetValue(ComboBox.WidthProperty, (double)130);

                //add textbox template
                Columna.CellTemplate            = new DataTemplate();
                Columna.CellTemplate.VisualTree = Txt;

                View.ListadoEquipos.Columns.Add(Columna);                              //Creacion de la columna en el GridView
                View.Model.ListRecords.Columns.Add("ESTADO_MATERIAL", typeof(String)); //Creacion de la columna en el DataTable

                #endregion

                #region Columna Tecnico Diagnosticador

                //IList<MMaster> ListadoDiagnosticador = service.GetMMaster(new MMaster { MetaType = new MType { Code = "DIAGNOSTI" } });
                Columna        = new GridViewColumn();
                assembly       = Assembly.GetAssembly(Type.GetType("System.Windows.Controls.TextBlock, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"));
                TipoDato       = "System.Windows.Controls.TextBlock";
                Columna.Header = "Tecnico";
                Txt            = new FrameworkElementFactory(assembly.GetType(TipoDato));
                Txt.SetValue(TextBlock.TextProperty, App.curUser.UserName.ToString());
                //Txt.SetValue(ComboBox.DisplayMemberPathProperty, "Name");
                //Txt.SetValue(ComboBox.SelectedValuePathProperty, "Code");
                //Txt.SetBinding(ComboBox.SelectedValueProperty, new System.Windows.Data.Binding("Diagnosticador"));
                Txt.SetValue(TextBlock.WidthProperty, (double)110);

                // add textbox template
                Columna.CellTemplate            = new DataTemplate();
                Columna.CellTemplate.VisualTree = Txt;
                View.ListadoEquipos.Columns.Add(Columna);                                           //Creacion de la columna en el GridView
                View.Model.ListRecords.Columns.Add("TECNICO_DIAGNOSTICADOR_VERIF", typeof(String)); //Creacion de la columna en el DataTable



                #endregion
            }
            catch (Exception ex) { Util.ShowError(ex.Message); };
        }
Exemplo n.º 16
0
        private void InitializeTeamGrid()
        {
            var memberNameColumn = new DataGridTextColumn
            {
                Header     = "Member",
                Width      = DataGridLength.SizeToCells,
                Binding    = new Binding("MemberName"),
                IsReadOnly = true
            };

            _teamAttendance.Columns.Add(memberNameColumn);

            var idx = 0;

            foreach (var dayOfWeek in new[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" })
            {
                var btn = new FrameworkElementFactory(typeof(Button));
                btn.SetValue(Button.TagProperty, idx);
                btn.SetBinding(Button.ContentProperty, new Binding($"Attendance[{idx}]")
                {
                    Converter = new BoolToStatusConverter()
                });
                btn.SetBinding(Button.BackgroundProperty, new Binding($"Attendance[{idx}]")
                {
                    Converter = new BoolToColorConverter()
                });
                btn.AddHandler(Button.ClickEvent, new RoutedEventHandler((s, e) =>
                {
                    var cellIdx = (int)((Button)s).Tag;
                    var item    = (TeamAttendanceViewModel)_teamAttendance.SelectedItem;
                    item.Attendance[cellIdx] = !item.Attendance[cellIdx];
                    CollectionViewSource.GetDefaultView(_teamAttendance.ItemsSource).Refresh();
                }));

                var column = new DataGridTemplateColumn
                {
                    Header       = dayOfWeek,
                    Width        = 100,
                    IsReadOnly   = true,
                    CellTemplate = new DataTemplate
                    {
                        VisualTree = btn
                    }
                };
                _teamAttendance.Columns.Add(column);
                idx++;
            }

            foreach (var dayOfWeek in new[] { "Saturday", "Sunday" })
            {
                var tb = new FrameworkElementFactory(typeof(TextBlock));
                tb.SetValue(TextBlock.BackgroundProperty, Brushes.LightGray);
                var column = new DataGridTemplateColumn
                {
                    Header       = dayOfWeek,
                    Width        = 100,
                    IsReadOnly   = true,
                    CellTemplate = new DataTemplate
                    {
                        VisualTree = tb
                    }
                };
                _teamAttendance.Columns.Add(column);
                idx++;
            }
        }
Exemplo n.º 17
0
        private void ApllyTemplate()
        {
            var grid = new FrameworkElementFactory(typeof(Grid));

            var column1 = new FrameworkElementFactory(typeof(ColumnDefinition));

            //column1.SetValue(ColumnDefinition.WidthProperty, GridLength.Auto);
            column1.SetValue(ColumnDefinition.WidthProperty, new GridLength(90D, GridUnitType.Star));
            grid.AppendChild(column1);
            var column2 = new FrameworkElementFactory(typeof(ColumnDefinition));

            column2.SetValue(ColumnDefinition.WidthProperty, new GridLength(13D));
            grid.AppendChild(column2);

            var row1 = new FrameworkElementFactory(typeof(ColumnDefinition));

            row1.SetValue(RowDefinition.HeightProperty, new GridLength(13D));
            grid.AppendChild(row1);
            var row2 = new FrameworkElementFactory(typeof(ColumnDefinition));

            row2.SetValue(RowDefinition.HeightProperty, new GridLength(13D));
            grid.AppendChild(row2);

            var textbox = new FrameworkElementFactory(typeof(TextBox));

            textbox.Name = "_TextBox";
            textbox.SetValue(Grid.RowProperty, 0);
            textbox.SetValue(Grid.ColumnProperty, 0);
            textbox.SetValue(Grid.RowSpanProperty, 2);
            textbox.SetValue(Grid.ColumnSpanProperty, 1);
            textbox.SetValue(TextBox.TextAlignmentProperty, TextAlignment.Right);
            textbox.SetValue(RepeatButton.ForegroundProperty, GetValue(Control.ForegroundProperty));
            Binding binding = new Binding("Text");

            //binding.Path = new PropertyPath(Text);
            binding.Source = this;
            textbox.SetBinding(TextBox.TextProperty, binding);
            grid.AppendChild(textbox);

            var btnup = new FrameworkElementFactory(typeof(RepeatButton));

            btnup.Name = "_UpButton";
            btnup.SetValue(Grid.ColumnProperty, 1);
            btnup.SetValue(Grid.RowProperty, 0);
            btnup.SetValue(RepeatButton.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
            btnup.SetValue(RepeatButton.VerticalContentAlignmentProperty, VerticalAlignment.Bottom);
            btnup.SetValue(RepeatButton.HeightProperty, 13D);
            btnup.SetValue(RepeatButton.VerticalAlignmentProperty, VerticalAlignment.Top);
            btnup.SetValue(RepeatButton.FontFamilyProperty, new FontFamily("Marlett"));
            btnup.SetValue(RepeatButton.FontSizeProperty, 9D);
            btnup.SetValue(RepeatButton.FontWeightProperty, FontWeights.UltraBlack);
            btnup.SetValue(RepeatButton.ForegroundProperty, GetValue(Control.ForegroundProperty));
            btnup.SetValue(RepeatButton.ContentProperty, "5");
            btnup.AddHandler(RepeatButton.ClickEvent, new RoutedEventHandler(_UpButton_Click));
            grid.AppendChild(btnup);

            var btndown = new FrameworkElementFactory(typeof(RepeatButton));

            btndown.Name = "_DownButton";
            btndown.SetValue(Grid.ColumnProperty, 1);
            btndown.SetValue(Grid.RowProperty, 1);
            btndown.SetValue(RepeatButton.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
            btndown.SetValue(RepeatButton.VerticalContentAlignmentProperty, VerticalAlignment.Top);
            btndown.SetValue(RepeatButton.HeightProperty, 13D);
            btndown.SetValue(RepeatButton.VerticalAlignmentProperty, VerticalAlignment.Bottom);
            btndown.SetValue(RepeatButton.FontFamilyProperty, new FontFamily("Marlett"));
            btndown.SetValue(RepeatButton.FontSizeProperty, 9D);
            btnup.SetValue(RepeatButton.FontWeightProperty, FontWeights.UltraBlack);
            btndown.SetValue(RepeatButton.ForegroundProperty, GetValue(Control.ForegroundProperty));
            btndown.SetValue(RepeatButton.ContentProperty, "6");
            btndown.AddHandler(RepeatButton.ClickEvent, new RoutedEventHandler(_DownButton_Click));
            grid.AppendChild(btndown);

            ControlTemplate template = new ControlTemplate(typeof(NumericUpDown));

            template.VisualTree = grid;
            SetValue(Control.TemplateProperty, template);
        }
Exemplo n.º 18
0
        public List <DataGridColumn> getGridColumns()
        {
            List <DataGridColumn> columnsList = new List <DataGridColumn>();


            /*CheckBox checkbox1 = new CheckBox
             * {
             *  FlowDirection = FlowDirection.RightToLeft
             * };
             */
            var buttonTemplate = new FrameworkElementFactory(typeof(CheckBox));

            buttonTemplate.SetBinding(Button.ContentProperty, new Binding("Name"));
            buttonTemplate.SetBinding(Button.ContentProperty, new Binding("TabIndex"));
            //buttonTemplate.tag = "mtan";
            //buttonTemplate.

            /*buttonTemplate.SetBinding(Button.IsEnabledProperty, new Binding("Status")
             * {
             *  Converter = new StatusToEnabledConverter()
             * });*/
            buttonTemplate.AddHandler(
                CheckBox.CheckedEvent,
                new RoutedEventHandler((o, e) => {
                CheckBox checkbox = o as CheckBox;
                MessageBox.Show(checkbox.Tag + "");
                //(checkbox.Parent.GetValue.)
            })
                );

            buttonTemplate.AddHandler(
                CheckBox.UncheckedEvent,
                new RoutedEventHandler((o, e) => {
            } /*MessageBox.Show("Uncheck")*/)
                );


            CheckBox ch = new CheckBox
            {
                TabIndex = 0
            };

            //  https://stackoverflow.com/questions/38177490/loop-through-checkboxcolumn-in-datagrid-in-wpf-checked-or-not

            /*if (isDeleteAble)
             *  columnsList.Add(new DataGridCheckBoxColumn
             *  {
             *        ElementStyle = new ContentElement
             *  })*/
            /*columnsList.Add(new DataGridTemplateColumn
             * {
             *  Header = "מחיקה",
             *  CellTemplate = new DataTemplate() {    Template = ch },
             *
             *
             * });*/



            //if(isUpdateAble)



            if (ToShow.Count > 0)
            {
                foreach (PropertiesData property in ToShow)
                {
                    if (NotToShow.Contains(property) || !columns.ContainsKey(property))
                    {
                        continue;
                    }



                    DataGridTextColumn gridColumn = new DataGridTextColumn
                    {
                        Header = columns[property].Header,
                        Width  = columns[property].Width,
                    };

                    if (columns[property].isBindNeeded)
                    {
                        gridColumn.Binding = new Binding {
                            Path = new PropertyPath(columns[property].Path)
                        };
                    }



                    columnsList.Add(gridColumn);
                }
            }
            else
            {
                foreach (var column in columns)
                {
                    if (NotToShow.Contains(column.Key))
                    {
                        continue;
                    }


                    DataGridTextColumn gridColumn = new DataGridTextColumn
                    {
                        Header = column.Value.Header,
                        Width  = column.Value.Width,
                    };

                    if (column.Value.isBindNeeded)
                    {
                        gridColumn.Binding = new Binding {
                            Path = new PropertyPath(column.Value.Path)
                        };
                    }



                    columnsList.Add(gridColumn);
                }
            }

            return(columnsList);
        }
Exemplo n.º 19
0
        public PendingAbilitiesCanvas(MainWindow mainWindow)
        {
            Background = Brushes.LightGray;
            Visibility = Visibility.Hidden;

            _mainGrid.ColumnDefinitions.Add(new ColumnDefinition());
            _mainGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(TitleHeight)
            });
            _mainGrid.RowDefinitions.Add(new RowDefinition());

            TextBlock textBlockTitle = new TextBlock()
            {
                TextAlignment = TextAlignment.Center, Text = "Pending abilities", VerticalAlignment = VerticalAlignment.Center
            };

            Grid.SetColumn(textBlockTitle, 0);
            Grid.SetRow(textBlockTitle, 0);
            _mainGrid.Children.Add(textBlockTitle);

            Grid.SetColumn(_listViewAbilities, 0);
            Grid.SetRow(_listViewAbilities, 1);
            _mainGrid.Children.Add(_listViewAbilities);

            Children.Add(_mainGrid);

            SizeChanged += CanvasSizeChanged;

            FrameworkElementFactory abilityCanvasFactory = new FrameworkElementFactory(typeof(AbilityCanvas));
            FrameworkElementFactory stackPanelFactory    = new FrameworkElementFactory(typeof(StackPanel));

            stackPanelFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            _listViewAbilities.ItemsPanel = new ItemsPanelTemplate()
            {
                VisualTree = stackPanelFactory
            };

            abilityCanvasFactory.SetBinding(HeightProperty, new Binding("ActualHeight")
            {
                Source = _listViewAbilities, Converter = new ListViewSizeToCardCanvasSizeConverter(), ConverterParameter = 0.96
            });
            abilityCanvasFactory.SetBinding(WidthProperty, new Binding("ActualHeight")
            {
                Source = _listViewAbilities, Converter = new ListViewSizeToCardCanvasSizeConverter(), ConverterParameter = 0.96
            });

            MultiBinding multiBinding = new MultiBinding()
            {
                Converter = new SetAndIdConverter()
            };

            multiBinding.Bindings.Add(new Binding("Source.Set"));
            multiBinding.Bindings.Add(new Binding("Source.Id"));
            abilityCanvasFactory.SetBinding(AbilityCanvas.SetAndIdProperty, multiBinding);
            abilityCanvasFactory.SetBinding(AbilityCanvas.AbilityProperty, new Binding(""));

            abilityCanvasFactory.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(mainWindow.AbilityCanvas_MouseLeftButtonDown));
            _listViewAbilities.ItemTemplate = new DataTemplate()
            {
                VisualTree = abilityCanvasFactory
            };
        }
        Style MakeDataGridColumnHeaderStyle()
        {
            ControlTemplate template = new ControlTemplate {
                TargetType = typeof(DataGridColumnHeader)
            };

            //This is the actual contents of the header
            var grid = new FrameworkElementFactory(typeof(Grid));

            var border = new FrameworkElementFactory(typeof(DataGridHeaderBorder));

            border.SetValue(DataGridHeaderBorder.BorderBrushProperty, new TemplateBindingExtension(Control.BorderBrushProperty));
            border.SetValue(Border.BorderThicknessProperty, new TemplateBindingExtension(Control.BorderThicknessProperty));
            border.SetValue(Border.BackgroundProperty, new TemplateBindingExtension(Control.BackgroundProperty));
            border.SetValue(DataGridHeaderBorder.IsClickableProperty, new TemplateBindingExtension(DataGridColumn.CanUserSortProperty));
            border.SetValue(DataGridHeaderBorder.IsPressedProperty, new TemplateBindingExtension(ButtonBase.IsPressedProperty));
            border.SetValue(DataGridHeaderBorder.IsHoveredProperty, new TemplateBindingExtension(UIElement.IsMouseOverProperty));
            border.SetValue(Border.PaddingProperty, new TemplateBindingExtension(Control.PaddingProperty));
            border.SetValue(DataGridHeaderBorder.SortDirectionProperty, new TemplateBindingExtension(DataGridColumn.SortDirectionProperty));
            border.SetValue(DataGridHeaderBorder.SeparatorBrushProperty, new TemplateBindingExtension(DataGridColumnHeader.SeparatorBrushProperty));
            border.SetValue(DataGridHeaderBorder.SeparatorVisibilityProperty, new TemplateBindingExtension(DataGridColumnHeader.SeparatorVisibilityProperty));

            var contentPresenter = new FrameworkElementFactory(typeof(ContentPresenter));

            contentPresenter.SetValue(FrameworkElement.HorizontalAlignmentProperty, new TemplateBindingExtension(Control.HorizontalContentAlignmentProperty));
            contentPresenter.SetValue(FrameworkElement.VerticalAlignmentProperty, new TemplateBindingExtension(Control.VerticalContentAlignmentProperty));
            contentPresenter.SetValue(UIElement.SnapsToDevicePixelsProperty, new TemplateBindingExtension(Control.SnapsToDevicePixelsProperty));

            contentPresenter.AddHandler(UIElement.MouseEnterEvent, new MouseEventHandler(ColumnHeader_MouseEnter));
            contentPresenter.AddHandler(UIElement.MouseLeaveEvent, new MouseEventHandler(ColumnHeader_MouseLeave));

            border.AppendChild(contentPresenter);

            var thumb1 = new FrameworkElementFactory(typeof(Thumb));

            thumb1.SetValue(FrameworkElement.NameProperty, "PART_LeftHeaderGripper");
            thumb1.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            thumb1.SetValue(FrameworkElement.StyleProperty, MakeColumnHeaderGripperStyle());

            var thumb2 = new FrameworkElementFactory(typeof(Thumb));

            thumb2.SetValue(FrameworkElement.NameProperty, "PART_RightHeaderGripper");
            thumb2.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Right);
            thumb2.SetValue(FrameworkElement.StyleProperty, MakeColumnHeaderGripperStyle());

            grid.AppendChild(border);
            grid.AppendChild(thumb1);
            grid.AppendChild(thumb2);

            template.VisualTree = grid;

            var style = new Style()
            {
                TargetType = typeof(DataGridColumnHeader)
            };

            style.Setters.Add(new Setter(Control.TemplateProperty, template));
            style.Setters.Add(new Setter(Control.VerticalContentAlignmentProperty, VerticalAlignment.Center));

            return(style);
        }
        private void update()
        {
            if (table == null)
            {
                return;
            }
            _gridview.Columns.Clear();
            //int sumWidth = 0;
            //for (int j = 0; j < table.Columns.Count; j++)
            //{
            //    int maxWidth = System.Text.Encoding.Default.GetByteCount(table.Columns[j].ColumnName.ToString());
            //    for (int i = 0; i < table.Rows.Count; i++)
            //    {
            //        if (maxWidth < System.Text.Encoding.Default.GetByteCount(table.Rows[i][j].ToString().Trim()))
            //        {
            //            maxWidth = System.Text.Encoding.Default.GetByteCount(table.Rows[i][j].ToString().Trim());
            //        }
            //    }
            //    sumWidth += maxWidth;
            //    myColumns[table.Columns[j].ColumnName.ToLower()].Width = maxWidth;
            //}
            for (int i = 0; i < table.Columns.Count; i++)
            {
                DataColumn c = table.Columns[i];
                if (myColumns[c.ColumnName.ToLower()].Column_show == "总行数")
                {
                    if (table.Rows.Count != 0)
                    {
                        RowTotal  = Convert.ToInt32(table.Rows[0][c.ColumnName].ToString());
                        PageTotal = (int)Math.Ceiling((double)RowTotal / (double)RowMax);
                    }
                    else
                    {
                        RowTotal  = 0;
                        PageTotal = 0;
                    }
                }


                if (!myColumns[c.ColumnName.ToLower()].BShow)
                {
                    continue;
                }
                GridViewColumn gvc = new GridViewColumn();
                gvc.Header = myColumns[c.ColumnName.ToLower()].Column_show;
                FrameworkElementFactory text = new FrameworkElementFactory(typeof(TextBlock));
                text.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
                text.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Center);
                text.SetBinding(TextBlock.ForegroundProperty, new Binding(c.ColumnName)
                {
                    Converter = new RedFontConverter()
                });
                if (table.Columns[i].ColumnName.ToLower().Contains("date"))
                {
                    text.SetBinding(TextBlock.TextProperty, new Binding(c.ColumnName));
                }
                else
                {
                    text.SetBinding(TextBlock.TextProperty, new Binding(c.ColumnName));
                }
                //当检测结果是疑似阳性或者阳性时,内容为红色
                if (myColumns[c.ColumnName.ToLower()].Column_show == "疑似阳性" || myColumns[c.ColumnName.ToLower()].Column_show == "阳性")
                {
                    text.SetValue(TextBlock.ForegroundProperty, Brushes.Red);
                }

                DataTemplate dataTemplate = new DataTemplate()
                {
                    VisualTree = text
                };
                gvc.CellTemplate = dataTemplate;
                gvc.Width        = 10 * myColumns[c.ColumnName.ToLower()].Width;
                _gridview.Columns.Add(gvc);
            }
            if (BShowModify)
            {
                GridViewColumn gvc_modify = new GridViewColumn();
                gvc_modify.Header = "修改";
                FrameworkElementFactory button_modify = new FrameworkElementFactory(typeof(Button));
                button_modify.SetResourceReference(Button.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
                button_modify.SetValue(Button.WidthProperty, 20.0);
                button_modify.AddHandler(Button.ClickEvent, new RoutedEventHandler(modify_Click));
                button_modify.SetBinding(Button.TagProperty, new Binding(table.Columns[0].ColumnName));
                button_modify.SetResourceReference(Button.StyleProperty, "ListModifyImageButtonTemplate");
                DataTemplate dataTemplate_modify = new DataTemplate()
                {
                    VisualTree = button_modify
                };
                gvc_modify.CellTemplate = dataTemplate_modify;
                _gridview.Columns.Add(gvc_modify);
            }

            if (BShowDelete)
            {
                GridViewColumn gvc_delete = new GridViewColumn();
                gvc_delete.Header = "删除";
                FrameworkElementFactory button_delete = new FrameworkElementFactory(typeof(Button));
                button_delete.SetValue(Button.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
                button_delete.SetValue(Button.WidthProperty, 20.0);
                button_delete.AddHandler(Button.ClickEvent, new RoutedEventHandler(delete_Click));
                button_delete.SetResourceReference(Button.StyleProperty, "ListDeleteImageButtonTemplate");
                button_delete.SetBinding(Button.TagProperty, new Binding(table.Columns[0].ColumnName));
                DataTemplate dataTemplate_delete = new DataTemplate()
                {
                    VisualTree = button_delete
                };

                gvc_delete.CellTemplate = dataTemplate_delete;
                _gridview.Columns.Add(gvc_delete);
            }

            if (BShowDetails)
            {
                GridViewColumn gvc_details = new GridViewColumn();
                gvc_details.Header = "详情";
                FrameworkElementFactory button_details = new FrameworkElementFactory(typeof(Button));
                button_details.SetResourceReference(Button.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
                button_details.SetValue(Button.WidthProperty, 40.0);
                button_details.AddHandler(Button.ClickEvent, new RoutedEventHandler(details_Click));
                button_details.SetBinding(Button.TagProperty, new Binding(table.Columns[0].ColumnName));
                //button_details.SetResourceReference(Button.StyleProperty, "ListDetailsImageButtonTemplate");
                button_details.SetValue(Button.ContentProperty, ">>");
                button_details.SetValue(Button.ForegroundProperty, Brushes.White);
                button_details.SetValue(Button.FontSizeProperty, 14.0);
                //button_details.SetValue(Button.FontFamilyProperty, "黑体");
                DataTemplate dataTemplate_details = new DataTemplate()
                {
                    VisualTree = button_details
                };
                gvc_details.CellTemplate = dataTemplate_details;
                _gridview.Columns.Add(gvc_details);
            }
            if (BShowState)
            {
                GridViewColumn gvc_state = new GridViewColumn();
                gvc_state.Header = "状态";
                FrameworkElementFactory button_state = new FrameworkElementFactory(typeof(Button));
                button_state.SetResourceReference(Button.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
                button_state.SetValue(Button.WidthProperty, 60.0);
                button_state.AddHandler(Button.ClickEvent, new RoutedEventHandler(state_Click));
                button_state.SetBinding(Button.TagProperty, new Binding(table.Columns[0].ColumnName));
                button_state.SetBinding(Button.ContentProperty, new Binding(table.Columns[1].ColumnName));
                button_state.SetValue(Button.ForegroundProperty, Brushes.White);
                button_state.SetValue(Button.FontSizeProperty, 12.0);

                DataTemplate dataTemplate_state = new DataTemplate()
                {
                    VisualTree = button_state
                };
                gvc_state.CellTemplate = dataTemplate_state;
                _gridview.Columns.Add(gvc_state);
            }

            if (BShowSold)
            {
                GridViewColumn gvc_sold = new GridViewColumn();
                gvc_sold.Header = "出栏";
                FrameworkElementFactory button_sold = new FrameworkElementFactory(typeof(Button));
                button_sold.SetResourceReference(Button.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
                button_sold.SetValue(Button.WidthProperty, 40.0);
                button_sold.AddHandler(Button.ClickEvent, new RoutedEventHandler(Sold_Click));
                button_sold.SetBinding(Button.TagProperty, new Binding(table.Columns[0].ColumnName));
                //button_sold.SetResourceReference(Button.StyleProperty, "ListDetailsImageButtonTemplate");
                button_sold.SetValue(Button.ContentProperty, "出栏");
                button_sold.SetValue(Button.ForegroundProperty, Brushes.White);
                button_sold.SetValue(Button.FontSizeProperty, 14.0);
                //button_sold.SetValue(Button.FontFamilyProperty, "黑体");
                DataTemplate dataTemplate_sold = new DataTemplate()
                {
                    VisualTree = button_sold
                };
                gvc_sold.CellTemplate = dataTemplate_sold;
                _gridview.Columns.Add(gvc_sold);
            }
            _listview.ItemsSource = null;
            _listview.ItemsSource = table.DefaultView;

            if (PageTotal > 1)
            {
                _page.Visibility = Visibility.Visible;
            }
            else
            {
                _page.Visibility = Visibility.Hidden;
            }
        }
Exemplo n.º 22
0
 public override void OnInitialize(CellView cellView, FrameworkElementFactory factory)
 {
     factory.AddHandler(SWC.Primitives.ToggleButton.CheckedEvent, new RoutedEventHandler(HandleChecked));
     factory.AddHandler(SWC.Primitives.ToggleButton.UncheckedEvent, new RoutedEventHandler(HandleChecked));
     base.OnInitialize(cellView, factory);
 }
Exemplo n.º 23
0
        private void AddColumns()
        {
            SessionInfo.BatchIndex++;
            DataGridTemplateColumn _DataGridTemplateColumn = new DataGridTemplateColumn()
            {
                Header = "检测项目", Width = new DataGridLength(100, DataGridLengthUnitType.Star)
            };
            var TestItems = new TestItemController().GetActiveTestItemConfigurations();
            FrameworkElementFactory _StackPanel = new FrameworkElementFactory(typeof(StackPanel));

            _StackPanel.SetValue(StackPanel.VerticalAlignmentProperty, System.Windows.VerticalAlignment.Center);
            _StackPanel.SetValue(StackPanel.HorizontalAlignmentProperty, System.Windows.HorizontalAlignment.Center);
            _StackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            foreach (TestingItemConfiguration _TestingItem in TestItems)
            {
                FrameworkElementFactory checkBox = new FrameworkElementFactory(typeof(CheckBox));
                checkBox.SetValue(CheckBox.DataContextProperty, _TestingItem);
                checkBox.SetValue(CheckBox.MarginProperty, new System.Windows.Thickness(5, 0, 5, 0));
                checkBox.SetValue(CheckBox.IsCheckedProperty, false);
                checkBox.SetValue(CheckBox.ContentProperty, _TestingItem.TestingItemName);

                checkBox.AddHandler(CheckBox.CheckedEvent, new RoutedEventHandler(checkBox_Checked));
                checkBox.AddHandler(CheckBox.UncheckedEvent, new RoutedEventHandler(checkBox_Unchecked));
                _StackPanel.AppendChild(checkBox);

                TextBlock textBlock = new TextBlock();
                textBlock.Height = 16;
                textBlock.Margin = new Thickness(5, 0, 0, 0);
                textBlock.Width  = 16;
                textBlock.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                textBlock.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                textBlock.Background          = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_TestingItem.TestingItemColor));
                sp_pointout.Children.Add(textBlock);

                Label label = new Label();
                label.Content             = _TestingItem.TestingItemName;
                label.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                label.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                label.Width = 65;
                sp_pointout.Children.Add(label);
            }
            DataTemplate dataTemplate = new DataTemplate();

            dataTemplate.VisualTree = _StackPanel;
            _DataGridTemplateColumn.CellTemplate = dataTemplate;
            dg_TubesGroup.Columns.Insert(2, _DataGridTemplateColumn);

            PoolingRules = new WanTai.Controller.PoolingRulesConfigurationController().GetPoolingRulesConfiguration();
            List <LiquidType> LiquidTypeList = SessionInfo.LiquidTypeList = WanTai.Common.Configuration.GetLiquidTypes();
            StringBuilder     stringBuilder  = new StringBuilder();

            foreach (LiquidType _LiquidType in LiquidTypeList)
            {
                if (_LiquidType.TypeId == 1)
                {
                    txt_Complement.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_LiquidType.Color));
                    lab_Complement.Content    = _LiquidType.TypeName;
                }
                if (_LiquidType.TypeId == 2)
                {
                    txt_PositiveControl.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_LiquidType.Color));
                    lab_PositiveControl.Content    = _LiquidType.TypeName;
                }
                if (_LiquidType.TypeId == 3)
                {
                    txt_NegativeControl.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_LiquidType.Color));
                    lab_NegativeControl.Content    = _LiquidType.TypeName;
                }
                stringBuilder.Append(_LiquidType.TypeName + "、");
            }
            if (stringBuilder.ToString().Length > 0)
            {
                lab_tip.Content = "(" + stringBuilder.ToString().Substring(0, stringBuilder.ToString().Length - 1) + "不能分组!)";
            }
            //  dg_TubesGroup.ItemsSource = (TubeGroupList=new List<TubeGroup>());
            //<TextBlock Height="20" Margin="5,0,0,0"  Width="20" Grid.Row="1" Name="txt_NegativeControl" HorizontalAlignment="Left"  Background="LightGray" VerticalAlignment="Center" />
            //      <Label Content="阴性对照物" Name="lab_NegativeControl" Grid.Row="1" HorizontalAlignment="Left"   VerticalAlignment="Center" />
            // StringBuilder SBuilder = new StringBuilder();
            //SBuilder.Append("<DataGridTemplateColumn ");
            //SBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' ");
            //SBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
            //SBuilder.Append("xmlns:local='clr-namespace:WanTai.View;assembly=WanTai.View' ");
            //SBuilder.Append("Header=\"混样模式\" Width=\"120\" >");
            //SBuilder.Append("<DataGridTemplateColumn.CellTemplate>");
            //SBuilder.Append("<DataTemplate >");
            //SBuilder.Append(" <ComboBox Name=\"cb_PoolingRulesConfigurations\" HorizontalAlignment=\"Stretch\" SelectedIndex=\"0\" SelectedValue=\"{Binding PoolingRulesID}\" SelectedValuePath=\"PoolingRulesID\" DisplayMemberPath=\"PoolingRulesName\"  ItemsSource=\"{Binding Source={StaticResource PoolingRulesConfigurations }}\" VerticalAlignment=\"Stretch\"  />");
            //SBuilder.Append("</DataTemplate>");
            //SBuilder.Append("</DataGridTemplateColumn.CellTemplate>");
            //SBuilder.Append("</DataGridTemplateColumn>");

            //SBuilder.Append("<DataGridTemplateColumn ");
            //SBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' ");
            //SBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
            //SBuilder.Append("xmlns:local='clr-namespace:WanTai.View;assembly=WanTai.View' ");
            //SBuilder.Append("Header=\"检测项目\" Width=\"200\" >");
            //SBuilder.Append("<DataGridTemplateColumn.CellTemplate>");
            //SBuilder.Append("<DataTemplate >");
            //SBuilder.Append("<StackPanel HorizontalAlignment=\"Center\"  VerticalAlignment=\"Center\"  >");

            //SBuilder.Append("</StackPanel>");
            //SBuilder.Append("</DataTemplate>");
            //SBuilder.Append("</DataGridTemplateColumn.CellTemplate>");
            //SBuilder.Append("</DataGridTemplateColumn>");

            //Stream stream = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(SBuilder.ToString()));
            //DataGridTemplateColumn colIcon = XamlReader.Load(stream) as DataGridTemplateColumn;
            //this.dg_TubesGroup.Columns.Insert(1, colIcon);
            //SBuilder.Append("<DataGridTemplateColumn ");
            //SBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' ");
            //SBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
            //SBuilder.Append("xmlns:local='clr-namespace:WanTai.View;assembly=WanTai.View' ");
            //SBuilder.Append("Header=\"操作\" Width=\"100\">");
            //SBuilder.Append(" <DataGridTemplateColumn.CellTemplate>");
            //SBuilder.Append("<DataTemplate >");
            //SBuilder.Append("<StackPanel Orientation=\"Horizontal\"  HorizontalAlignment=\"Center\" VerticalAlignment=\"Center\" >");
            //SBuilder.Append("<Button Content=\"删除\" Height=\"26\" Width=\"75\" HorizontalAlignment=\"Center\" Click=\"btn_del_Click\"  Name=\"btn_del\" VerticalAlignment=\"Center\"  />");
            //SBuilder.Append(" </StackPanel>");
            //SBuilder.Append("</DataTemplate>");
            //SBuilder.Append("</DataGridTemplateColumn.CellTemplate>");
            //SBuilder.Append("</DataGridTemplateColumn>");
            //SBuilder.Append("<DataGridTemplateColumn ");
            //SBuilder.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' ");
            //SBuilder.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
            //SBuilder.Append("xmlns:local='clr-namespace:WanTai.View;assembly=WanTai.View' ");

            //SBuilder.Append("Header=\"采血管\" Width=\"*\" >");
            //SBuilder.Append("<DataGridTemplateColumn.CellTemplate>");
            //SBuilder.Append(" <DataTemplate >");
            //SBuilder.Append("<StackPanel Orientation=\"Horizontal\"  HorizontalAlignment=\"Left\" VerticalAlignment=\"Center\" >");
            //SBuilder.Append(" <Label Content=\"{Binding Path=TubesPosition}\" HorizontalAlignment=\"Left\"  Name=\"lab_TubesPosition\" VerticalAlignment=\"Center\" />");
            //SBuilder.Append("</StackPanel>");
            //SBuilder.Append("</DataTemplate>");
            //SBuilder.Append("</DataGridTemplateColumn.CellTemplate>");
            //SBuilder.Append("</DataGridTemplateColumn>");


            //Stream stream = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(SBuilder.ToString()));
            //  DataGridTemplateColumn colIcon = XamlReader.Load(stream) as DataGridTemplateColumn;
            //  colIcon.Header = i.ToString();
            // dg_Bules.Columns.Add(colIcon);
        }
Exemplo n.º 24
0
        private void QueryBuilder1_OnQueryElementControlCreated(QueryElement owner, IQueryElementControl control)
        {
            if (!(control is IQueryColumnListControl))
            {
                return;
            }

            var queryColumnListControl = (IQueryColumnListControl)control;
            var dataGridView           = (DataGrid)queryColumnListControl.DataGrid;

            // Create binding and templates for the custom column
            var textBlock = new FrameworkElementFactory(typeof(TextBlock));

            textBlock.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center);
            textBlock.SetValue(MarginProperty, new Thickness(2, 0, 0, 0));
            textBlock.SetBinding(TextBlock.TextProperty,
                                 new Binding("CustomData")
            {
                Mode = BindingMode.OneWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });


            // Creating a template to browse a cell
            var templateCell = new DataTemplate {
                VisualTree = textBlock
            };

            var columnLeft = new FrameworkElementFactory(typeof(ColumnDefinition));

            columnLeft.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Star));

            var columnRight = new FrameworkElementFactory(typeof(ColumnDefinition));

            columnRight.SetValue(ColumnDefinition.WidthProperty, new GridLength(1, GridUnitType.Auto));

            var gridRoot = new FrameworkElementFactory(typeof(Grid));

            gridRoot.SetValue(BackgroundProperty, Brushes.White);
            gridRoot.AppendChild(columnLeft);
            gridRoot.AppendChild(columnRight);

            var comboBox = new FrameworkElementFactory(typeof(ComboBox));

            comboBox.SetBinding(Selector.SelectedItemProperty,
                                new Binding("CustomData")
            {
                Mode = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            comboBox.SetValue(ItemsControl.ItemsSourceProperty, _customValuesProvider);
            comboBox.SetValue(MarginProperty, new Thickness(0, 0, 0, 0));
            comboBox.SetValue(BorderThicknessProperty, new Thickness(0));
            comboBox.SetValue(VerticalContentAlignmentProperty, VerticalAlignment.Center);
            comboBox.SetValue(Grid.ColumnProperty, 0);
            comboBox.SetValue(PaddingProperty, new Thickness(1, 0, 0, 0));

            // Defining a handler which is fired on loading the editor for a cell
            comboBox.AddHandler(LoadedEvent, new RoutedEventHandler(LoadComboBox));
            gridRoot.AppendChild(comboBox);

            var button = new FrameworkElementFactory(typeof(Button));

            button.SetValue(Grid.ColumnProperty, 1);
            button.SetValue(MarginProperty, new Thickness(2));
            button.SetValue(ContentProperty, "...");
            button.SetValue(VerticalAlignmentProperty, VerticalAlignment.Center);
            button.SetValue(VerticalContentAlignmentProperty, VerticalAlignment.Center);
            button.SetValue(WidthProperty, 16.0);

            // Defining a handler of cliking the ellipsis button in a cell
            button.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ClickButton));
            gridRoot.AppendChild(button);

            // Creating a template to edit the custom cell
            var templateCellEdit = new DataTemplate {
                VisualTree = gridRoot
            };

            var customColumn = new DataGridTemplateColumn()
            {
                Header      = "Custom Column",
                Width       = new DataGridLength(200),
                HeaderStyle =
                    new Style
                {
                    Setters =
                    {
                        new Setter(FontFamilyProperty, new FontFamily("Arial")),
                        new Setter(FontWeightProperty, FontWeights.Bold)
                    }
                },
                // assigning templates to a column
                CellTemplate        = templateCell,
                CellEditingTemplate = templateCellEdit
            };

            // Insert new column to the specified position
            dataGridView.Columns.Insert(2, customColumn);

            // Handle the necessary events
            dataGridView.BeginningEdit  += DataGridView_BeginningEdit;
            dataGridView.CellEditEnding += dataGridView_CellEditEnding;
            dataGridView.LoadingRow     += dataGridView_LoadingRow;
        }
Exemplo n.º 25
0
        private void cmbOdeljenje_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (cmbOdeljenje.SelectedIndex != -1)
            {
                for (int i = 0; i < trenutniPredmeti.Count; i++)
                {
                    ((GridView)lvv.View).Columns.RemoveAt(1);
                }

                int raz = Convert.ToInt32(cmbRazred.SelectedValue);
                int ode = Convert.ToInt32(cmbOdeljenje.SelectedValue);
                trenutniUcenici  = Ucenik.Daj().Where(u => u.razred == raz && u.odeljenje == ode).ToList();
                cursmer          = trenutniUcenici[0].smer;
                lbSmer.Content   = cursmer.naziv;
                trenutniPredmeti = Smer.DajPredmete(cursmer, raz).ToList();

                DataTable sors = new DataTable();
                sors.Columns.Add("ime", typeof(string));

                foreach (Predmet pr in trenutniPredmeti)
                {
                    string x = pr.naziv.Trim().Replace(".", "");
                    sors.Columns.Add(x, typeof(string));

                    GridViewColumn col = new GridViewColumn();
                    col.Header = pr.naziv;

                    DataTemplate temp = new DataTemplate();

                    FrameworkElementFactory bor = new FrameworkElementFactory(typeof(Border));
                    bor.SetValue(Border.BorderBrushProperty, Brushes.LightGray);
                    bor.SetValue(Border.BorderThicknessProperty, new Thickness(0, 0, 1, 1));
                    bor.SetValue(Border.MarginProperty, new Thickness(-6, 0, -6, 0));

                    RoutedEventHandler izgubioFokus = Fokus;
                    RoutedEventHandler dobioFokus   = DFokus;

                    FrameworkElementFactory title = new FrameworkElementFactory(typeof(TextBox));
                    title.SetValue(TextBox.FontWeightProperty, FontWeights.Bold);
                    title.SetBinding(TextBox.TextProperty, new Binding(x));
                    title.SetValue(TextBox.MarginProperty, new Thickness(5));
                    title.AddHandler(TextBox.LostFocusEvent, izgubioFokus);
                    title.AddHandler(TextBox.GotFocusEvent, dobioFokus);
                    title.SetValue(TextBox.WidthProperty, (double)23);
                    title.SetValue(TextBox.TabIndexProperty, 1);
                    title.SetValue(TextBox.IsTabStopProperty, true);

                    bor.AppendChild(title);
                    temp.VisualTree  = bor;
                    col.CellTemplate = temp;

                    ((GridView)lvv.View).Columns.Add(col);
                }

                foreach (Ucenik uc in trenutniUcenici)
                {
                    DataRow row = sors.NewRow();
                    row[0] = uc.naziv;
                    int i = 1;
                    foreach (Predmet pr in trenutniPredmeti)
                    {
                        int?ocena = Ucenik.OcenaIz((int)uc.broj, pr.id, App.Godina());;
                        if (ocena == null)
                        {
                            row[i] = "";
                        }
                        else
                        {
                            row[i] = ocena.ToString();
                        }
                        i++;
                    }
                    sors.Rows.Add(row);
                }

                trenutniSors    = sors.Copy();
                lvv.ItemsSource = sors.DefaultView;
                ((GridView)lvv.View).Columns[0].Width = 200;
            }
        }
Exemplo n.º 26
0
        private void createUI()
        {
            DataTemplate dt = new DataTemplate();
            // FrameworkElementFactory expander = new FrameworkElementFactory(typeof(Expander));
            FrameworkElementFactory stackPanel = new FrameworkElementFactory(typeof(StackPanel));

            stackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            FrameworkElementFactory label = new FrameworkElementFactory(typeof(Label));

            label.SetValue(Label.ContentProperty, string.Format("{0} [{1}]", this.data.TagName, this.data.Childrens.Count));

            if (this.data.Childrens.Count > 0)
            {
                FrameworkElementFactory button = new FrameworkElementFactory(typeof(Button));
                button.SetValue(Button.ContentProperty, "+");
                button.SetValue(Button.BackgroundProperty, Brushes.Transparent);
                button.SetValue(Button.BorderBrushProperty, Brushes.White);
                button.SetValue(Button.IsTabStopProperty, false);
                LengthConverter lc = new LengthConverter();
                string          qualifiedDouble = "24px";

                var converted = lc.ConvertFrom(qualifiedDouble);
                button.SetValue(Button.WidthProperty, converted);
                button.SetValue(Button.HeightProperty, converted);
                button.SetValue(Button.BorderThicknessProperty, new Thickness(0));
                button.AddHandler(Button.ClickEvent, new RoutedEventHandler(ExpanderClick));
                button.AddHandler(Button.LoadedEvent, new RoutedEventHandler(LoaderBtn));
                //Create a style
                Style st = new Style();

                Trigger tg = new Trigger()
                {
                    Property = Button.IsMouseOverProperty,
                    Value    = true
                               //     <Trigger Property="IsMouseOver" Value="true">
                               //                    <!--<Setter Property="Fill" TargetName="checkBoxFill" Value="{StaticResource OptionMark.MouseOver.Background}"/>-->
                               //                    <Setter Property="Fill" TargetName="optionMark" Value="{StaticResource OptionMark.MouseOver.Glyph}"/>
                               //                    <Setter Property="Fill" TargetName="indeterminateMark" Value="{StaticResource OptionMark.MouseOver.Glyph}"/>
                               //                </Trigger>
                               //Binding = new Binding("CustomerId"),
                               //Value = 1
                };

                tg.Setters.Add(new Setter()
                {
                    Property = Button.BackgroundProperty,
                    Value    = Brushes.Red
                });

                st.Triggers.Add(tg);
                //end style

                button.SetValue(Button.StyleProperty, st);

                // expander.SetValue(Expander.HeaderProperty, this.data.TagName);
                stackPanel.AppendChild(button);
            }
            stackPanel.AppendChild(label);

            this.HeaderTemplate = dt;
            dt.VisualTree       = stackPanel;
        }
Exemplo n.º 27
0
        private void Build(String text, String arrayText, String dataGridName)
        {
            Console.WriteLine("arrayText " + arrayText);
            StackPanel spMain = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Thickness(20, 10, 0, 0)
            };
            TextBlock lblText = new TextBlock
            {
                VerticalAlignment = VerticalAlignment.Center,
                Margin            = new Thickness(0, 30, 10, 0),
                Text = text
            };
            TextBox tbText = new TextBox
            {
                Name  = "txt_" + dataGridName,
                Width = 300,
                HorizontalAlignment = HorizontalAlignment.Left,
                BorderBrush         = Brushes.White,
                BorderThickness     = new Thickness(1),
                Background          = Brushes.LightGray,
                Foreground          = Brushes.Black,
                Margin = new Thickness(0, 0, 10, 0),
            };
            Button btnAdd = new Button
            {
                Name                = "btn_" + dataGridName,
                Content             = "追加",
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center,
                Tag = dataGridName,
            };

            btnAdd.AddHandler(Button.ClickEvent, new RoutedEventHandler(btnAdd_Click));
            StackPanel spChild = new StackPanel
            {
                Orientation         = Orientation.Horizontal,
                Margin              = new Thickness(0, 0, 0, 10),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center
            };

            spChild.Children.Add(tbText);
            spChild.Children.Add(btnAdd);
            dataGrid = new DataGrid
            {
                Name                = dataGridName,
                BorderBrush         = Brushes.Green,
                BorderThickness     = new Thickness(1),
                HorizontalAlignment = HorizontalAlignment.Left,
                MaxHeight           = 300,
                CanUserAddRows      = false,
                AutoGenerateColumns = false
            };
            DataGridTextColumn col1 = new DataGridTextColumn();
            var ab = arrayText.Trim().Split(',');

            for (int i = 0; i < ab.Length; i++)
            {
                dataGrid.Items.Add(new Data()
                {
                    Value = ab[i]
                });
            }
            col1.Header  = "Value";
            col1.Binding = new Binding("Value");
            dataGrid.Columns.Add(col1);

            DataGridTemplateColumn col = new DataGridTemplateColumn();

            col.Header = "削除";
            DataTemplate dt = new DataTemplate();
            var          sp = new FrameworkElementFactory(typeof(StackPanel));

            sp.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            var btnDelete = new FrameworkElementFactory(typeof(Button));

            btnDelete.SetValue(Button.TagProperty, dataGridName);
            btnDelete.SetValue(Button.ContentProperty, "削除");
            btnDelete.AddHandler(Button.ClickEvent, new RoutedEventHandler(btnDelete_Click));
            btnDelete.SetValue(Button.MarginProperty, new Thickness(0, 0, 10, 0));
            sp.AppendChild(btnDelete);

            dt.VisualTree    = sp;
            col.CellTemplate = dt;
            dataGrid.Columns.Add(col);
            spSettings.Children.Add(lblText);
            spSettings.Children.Add(spChild);
            spSettings.Children.Add(dataGrid);
        }
Exemplo n.º 28
0
        private DataGrid AddCloums(Type T)
        {
            DataGrid            dg     = new DataGrid();
            DataGridBoundColumn dc     = null;
            string AttributeCode       = string.Empty;
            DataGridTemplateColumn DTC = new DataGridTemplateColumn();

            PropertyInfo[] Property = T.GetProperties();
            for (int index = 0; index < Property.Length; index++)
            {
                Console.WriteLine(Property[index].PropertyType);
                AttributeCode = "";
                //if (Property[index].PropertyType.Name == "String")
                if (((NameAttribute)Property[index].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes.Contains("DateTime"))//DateTime类型的特殊处理
                {
                    DTC = new DataGridTemplateColumn();
                    FrameworkElementFactory MyFactory = new FrameworkElementFactory(typeof(DatePicker));
                    Binding TimeBinding = new Binding(Property[index].Name);
                    TimeBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                    TimeBinding.Mode = BindingMode.TwoWay;
                    MyFactory.SetValue(DatePicker.TextProperty, TimeBinding);
                    DataTemplate dt = new DataTemplate();
                    MyFactory.SetValue(DatePicker.IsEnabledProperty, IsEnable);
                    dt.VisualTree           = MyFactory;
                    DTC.Header              = ((NameAttribute)Property[index].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes.Replace("DateTime", string.Empty);
                    DTC.CellTemplate        = dt;
                    DTC.CellEditingTemplate = dt;
                    dg.Columns.Add(DTC);
                }
                else if (((NameAttribute)Property[index].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes.Contains("Button"))//Button的特殊处理
                {
                    //ButtonSet
                    DTC = new DataGridTemplateColumn();
                    FrameworkElementFactory MyF = new FrameworkElementFactory(typeof(Button));
                    Binding ButtonBinding       = new Binding(Property[index].Name);
                    MyF.SetValue(Button.ContentProperty, ButtonBinding);
                    DataTemplate dt = new DataTemplate();
                    MyF.SetValue(Button.IsEnabledProperty, IsEnable);
                    //事件绑定
                    MyF.AddHandler(Button.ClickEvent, new RoutedEventHandler(DicDelegate[((NameAttribute)Property[index].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes]));//根据字典 查找对面的事件
                    dt.VisualTree           = MyF;
                    DTC.Header              = ((NameAttribute)Property[index].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes.Replace("Button", string.Empty);
                    DTC.CellTemplate        = dt;
                    DTC.CellEditingTemplate = dt;
                    dg.Columns.Add(DTC);
                }
                else if (((NameAttribute)Property[index].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes.Contains("List"))//特殊处理list的绑定,
                {
                    DTC = new DataGridTemplateColumn();
                    FrameworkElementFactory fef = new FrameworkElementFactory(typeof(ComboBox));
                    DataTemplate            dt  = new DataTemplate();
                    //Binding binding = new Binding();
                    //binding.Path = new PropertyPath("MarketIndicator");

                    /**根据指定键值获取指定列表
                     */
                    PropertyInfo[] CTProperty = EntityType[((NameAttribute)Property[index].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes].GetProperties();
                    for (int counts = 0; counts < CTProperty.Length; counts++)
                    {
                        Console.WriteLine(((NameAttribute)CTProperty[counts].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes);
                        if ((((NameAttribute)CTProperty[counts].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes) == "Display")
                        {
                            fef.SetValue(ComboBox.DisplayMemberPathProperty, CTProperty[counts].Name);
                        }
                        if (((NameAttribute)CTProperty[counts].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes == "Selected")
                        {
                            fef.SetValue(ComboBox.SelectedValuePathProperty, CTProperty[counts].Name);
                        }
                    }
                    Binding s = new Binding();
                    // s.Mode = BindingMode.Default;
                    s.Source = DicSoure[((NameAttribute)Property[index].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes];
                    fef.SetValue(ComboBox.ItemsSourceProperty, s);
                    Binding ValueBinding = new Binding(Property[index].Name);
                    ValueBinding.Mode = BindingMode.TwoWay;
                    ValueBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                    fef.SetBinding(ComboBox.SelectedValueProperty, ValueBinding);
                    fef.SetValue(ComboBox.ForegroundProperty, Brushes.Black);
                    fef.SetValue(ComboBox.BackgroundProperty, Brushes.WhiteSmoke);
                    fef.SetValue(ComboBox.StyleProperty, CommboxStyle);
                    fef.SetValue(ComboBox.IsEnabledProperty, IsEnable);
                    fef.SetValue(ComboBox.IsReadOnlyProperty, IsReadOnly);
                    dt.VisualTree = fef;
                    DTC.Header    = ((NameAttribute)Property[index].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes.Replace("List", string.Empty);
                    //     DTC.Binding = new Binding(Property[index].Name);
                    DTC.CellTemplate        = dt;
                    DTC.CellEditingTemplate = dt;
                    dg.Columns.Add(DTC);
                }
                else
                {
                    dc         = new DataGridTextColumn();
                    dc.Header  = ((NameAttribute)Property[index].GetCustomAttributes(typeof(NameAttribute)).FirstOrDefault()).Attributes;
                    dc.Binding = new Binding(Property[index].Name);
                    dg.Columns.Add(dc);
                }
            }
            dg.AutoGenerateColumns = false;
            dg.Style = MyDataGridStyle;
            return(dg);
        }
Exemplo n.º 29
0
        /// <summary>
        /// 构造方法
        /// </summary>
        public CSWin()
        {
            var ctemp = new ControlTemplate(typeof(Window));

            {
                var _border = new FrameworkElementFactory(typeof(Border));
                _border.SetValue(Border.BackgroundProperty, Brushes.Transparent);
                _border.SetValue(Border.SnapsToDevicePixelsProperty, true);
                _border.SetBinding(Border.BorderBrushProperty, new Binding()
                {
                    Source = this,
                    Path   = new PropertyPath("CSBorderBrush"),
                    Mode   = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                });
                _border.SetBinding(Border.BorderThicknessProperty, new Binding()
                {
                    Source = this,
                    Path   = new PropertyPath("CSBorderThickness"),
                    Mode   = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                });
                _border.SetBinding(Border.CornerRadiusProperty, new Binding()
                {
                    Source = this,
                    Path   = new PropertyPath("CSCornerRadius"),
                    Mode   = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                });
                {
                    var _workarea = new FrameworkElementFactory(typeof(Grid));
                    _workarea.SetBinding(Grid.MarginProperty, new Binding()
                    {
                        Source = this,
                        Path   = new PropertyPath("CSWorkareaMargin"),
                        Mode   = BindingMode.TwoWay,
                        UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                    });
                    _workarea.SetBinding(Grid.BackgroundProperty, new Binding()
                    {
                        Source = this,
                        Path   = new PropertyPath("Background"),
                        Mode   = BindingMode.TwoWay,
                        UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                    });
                    {
                        var __waRd1 = new FrameworkElementFactory(typeof(RowDefinition));
                        var __waRd2 = new FrameworkElementFactory(typeof(RowDefinition));
                        __waRd1.SetBinding(RowDefinition.HeightProperty, new Binding()
                        {
                            Source = this,
                            Path   = new PropertyPath("TitleHeight"),
                            Mode   = BindingMode.TwoWay,
                            UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                        });
                        __waRd2.SetBinding(RowDefinition.HeightProperty, new Binding()
                        {
                            Source = this,
                            Path   = new PropertyPath("WorkareaHeight"),
                            Mode   = BindingMode.TwoWay,
                            UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                        });
                        _workarea.AppendChild(__waRd1);
                        _workarea.AppendChild(__waRd2);
                    }
                    {
                        var _grid = new FrameworkElementFactory(typeof(Grid));
                        _grid.SetValue(Grid.RowProperty, 0);
                        _grid.AddHandler(Grid.MouseMoveEvent, new MouseEventHandler(TitleBar_MouseMove));
                        _grid.SetBinding(Grid.BackgroundProperty, new Binding()
                        {
                            Source = this,
                            Path   = new PropertyPath("TitleBackground"),
                            Mode   = BindingMode.TwoWay,
                            UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                        });
                        {
                            var _title = new FrameworkElementFactory(typeof(TextBlock));
                            _title.SetBinding(TextBlock.FontSizeProperty, new Binding()
                            {
                                Source = this,
                                Path   = new PropertyPath("TitleFontSize"),
                                Mode   = BindingMode.TwoWay,
                                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                            });
                            _title.SetBinding(TextBlock.HorizontalAlignmentProperty, new Binding()
                            {
                                Source = this,
                                Path   = new PropertyPath("TitleHorizontalAlignment"),
                                Mode   = BindingMode.TwoWay,
                                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                            });
                            _title.SetBinding(TextBlock.TextProperty, new Binding()
                            {
                                Source = this,
                                Path   = new PropertyPath("Title"),
                                Mode   = BindingMode.TwoWay,
                                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                            });

                            var _dp = new FrameworkElementFactory(typeof(DockPanel));
                            _dp.SetValue(DockPanel.HorizontalAlignmentProperty, HorizontalAlignment.Right);
                            _dp.SetValue(DockPanel.DockProperty, Dock.Right);
                            {
                                var btn_max = new FrameworkElementFactory(typeof(CSWinbtn.MinMax));
                                btn_max.SetValue(CSWinbtn.MinMax.PathDataProperty, Geometry.Parse("M0 0 H15 V11 H0 V2 H1 V10 H14 V2 H0 V0"));
                                btn_max.SetBinding(Button.VisibilityProperty, new Binding()
                                {
                                    Source = this,
                                    Path   = new PropertyPath("TitleMaxBtnVisibility"),
                                    Mode   = BindingMode.TwoWay,
                                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                                });
                                btn_max.SetBinding(Button.WidthProperty, new Binding()
                                {
                                    Source = this,
                                    Path   = new PropertyPath("TitleBtnWidth"),
                                    Mode   = BindingMode.TwoWay,
                                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                                });
                                btn_max.AddHandler(Button.ClickEvent, handler: new RoutedEventHandler(btn_max_Click));

                                var btn_min = new FrameworkElementFactory(typeof(CSWinbtn.MinMax));
                                btn_min.SetBinding(Button.VisibilityProperty, new Binding()
                                {
                                    Source = this,
                                    Path   = new PropertyPath("TitleMinBtnVisibility"),
                                    Mode   = BindingMode.TwoWay,
                                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                                });
                                btn_min.SetBinding(Button.WidthProperty, new Binding()
                                {
                                    Source = this,
                                    Path   = new PropertyPath("TitleBtnWidth"),
                                    Mode   = BindingMode.TwoWay,
                                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                                });
                                btn_min.AddHandler(Button.ClickEvent, handler: new RoutedEventHandler(btn_min_Click));

                                var btn_close = new FrameworkElementFactory(typeof(CSWinbtn.Close));
                                btn_close.SetBinding(Button.VisibilityProperty, new Binding()
                                {
                                    Source = this,
                                    Path   = new PropertyPath("TitleCloseBtnVisibility"),
                                    Mode   = BindingMode.TwoWay,
                                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                                });
                                btn_close.SetBinding(Button.WidthProperty, new Binding()
                                {
                                    Source = this,
                                    Path   = new PropertyPath("TitleBtnWidth"),
                                    Mode   = BindingMode.TwoWay,
                                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                                });
                                btn_close.AddHandler(Button.ClickEvent, handler: new RoutedEventHandler(btn_close_Click));

                                _dp.AppendChild(btn_min);
                                _dp.AppendChild(btn_max);
                                _dp.AppendChild(btn_close);
                            }
                            var content = new FrameworkElementFactory(typeof(ContentPresenter));
                            content.SetValue(Grid.RowProperty, 1);

                            _grid.AppendChild(_title);
                            _grid.AppendChild(_dp);

                            _workarea.AppendChild(content);
                        }
                        _workarea.AppendChild(_grid);
                    }
                    _border.AppendChild(_workarea);
                }
                ctemp.VisualTree = _border;
            }
            WindowChrome.SetWindowChrome(this, new WindowChrome()
            {
                ResizeBorderThickness = new Thickness(5),
                CaptionHeight         = 0
            });
            this.Template      = ctemp;
            WindowStyle        = WindowStyle.None;
            AllowsTransparency = true;
            Loaded            += _window_Loaded;
            Deactivated       += CSWin_Deactivated;
            Activated         += CSWin_Activated;
            activatedBrush     = CSBorderBrush;
        }
Exemplo n.º 30
0
        private void bwLoad_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            btnSearch.IsEnabled = true;
            btnSearch.IsDefault = true;
            this.Cursor         = null;

            if (sizeRunList.Count() == 0)
            {
                MessageBox.Show("Not Found !", this.Title, MessageBoxButton.OK, MessageBoxImage.Information);
                txtProductNo.Focus();
                txtProductNo.SelectAll();

                return;
            }

            // Created Column
            dt.Columns.Add("CreatedDate", typeof(DateTime));
            DataGridTextColumn columnCreatedDate = new DataGridTextColumn();

            columnCreatedDate.Header  = "Date";
            columnCreatedDate.Binding = new Binding("CreatedDate");
            columnCreatedDate.Binding.StringFormat = "MM/dd";
            dgOutsoleWHFG.Columns.Add(columnCreatedDate);

            dt.Columns.Add("Status", typeof(String));
            DataGridTextColumn columnStatus = new DataGridTextColumn();

            columnStatus.Header  = productNo;
            columnStatus.Binding = new Binding("Status");

            columnStatus.IsReadOnly = true;
            columnStatus.MinWidth   = 80;

            dgOutsoleWHFG.Columns.Add(columnStatus);

            for (int i = 0; i <= sizeRunList.Count - 1; i++)
            {
                SizeRunModel sizeRun = sizeRunList[i];
                dt.Columns.Add(String.Format("Column{0}", i), typeof(Int32));
                DataGridTextColumn column = new DataGridTextColumn();
                column.SetValue(TagProperty, sizeRun.SizeNo);
                column.Header   = String.Format("{0}\n({1})", sizeRun.SizeNo, sizeRun.Quantity);
                column.MinWidth = 40;
                column.Binding  = new Binding(String.Format("Column{0}", i))
                {
                    Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.LostFocus
                };
                dgOutsoleWHFG.Columns.Add(column);
            }

            dt.Columns.Add("Total", typeof(Int32));
            DataGridTextColumn columnTotal = new DataGridTextColumn();

            columnTotal.Header  = string.Format("Total\n{0}", sizeRunList.Select(s => s.Quantity).Sum());
            columnTotal.Binding = new Binding("Total")
            {
                Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.LostFocus
            };
            columnTotal.MinWidth   = 50;
            columnTotal.IsReadOnly = true;
            dgOutsoleWHFG.Columns.Add(columnTotal);

            DataGridTemplateColumn  buttonColumn   = new DataGridTemplateColumn();
            DataTemplate            buttonTemplate = new DataTemplate();
            FrameworkElementFactory buttonFactory  = new FrameworkElementFactory(typeof(Button));

            buttonTemplate.VisualTree = buttonFactory;
            buttonFactory.AddHandler(Button.ClickEvent, new RoutedEventHandler(btnOK_Click));
            buttonFactory.SetValue(ContentProperty, "OK");
            buttonColumn.CellTemplate = buttonTemplate;
            dgOutsoleWHFG.Columns.Add(buttonColumn);


            Style style = new Style(typeof(DataGridCell));

            style.Setters.Add(new Setter(TextBlock.TextAlignmentProperty, TextAlignment.Center));
            dgOutsoleWHFG.CellStyle = style;

            // Fill data
            if (outsoleWHFGList.Count() > 0)
            {
                var createdDateList = outsoleWHFGList.Select(s => s.CreatedDate).Distinct().ToList();
                foreach (var createdDate in createdDateList)
                {
                    DataRow dr = dt.NewRow();
                    dr["CreatedDate"] = createdDate;
                    dr["Status"]      = "Quantity";
                    var sizeNoAndQtyList = outsoleWHFGList.Where(w => w.CreatedDate == createdDate).Select(s => new { SizeNo = s.SizeNo, Quantity = s.Quantity }).ToList();
                    for (int i = 0; i < sizeNoAndQtyList.Count; i++)
                    {
                        dr[String.Format("Column{0}", i)] = sizeNoAndQtyList[i].Quantity;
                    }
                    dr["Total"] = outsoleWHFGList.Where(w => w.CreatedDate == createdDate).Select(s => s.Quantity).Sum();

                    dt.Rows.Add(dr);
                }
            }

            dgOutsoleWHFG.ItemsSource = dt.AsDataView();

            btnAddRow.IsEnabled  = true;
            btnBalance.IsEnabled = true;
        }
Exemplo n.º 31
0
        public BuildFiltersWindow()
        {
            InitializeComponent();

            DataContext = this;

            ItemContainerStyle = new Style(typeof(ListBoxItem));
            ItemContainerStyle.Setters.Add(new Setter(AllowDropProperty, true));
            ItemContainerStyle.Setters.Add(new EventSetter(DropEvent, new DragEventHandler(Filters_Drop)));
            lbFiltersGS.ItemContainerStyle = ItemContainerStyle;

            SlotListBoxDT = new DataTemplate();
            FrameworkElementFactory dp = new FrameworkElementFactory(typeof(DockPanel));

            FrameworkElementFactory btn = new FrameworkElementFactory(typeof(Button));

            btn.SetValue(DockPanel.DockProperty, Dock.Left);
            btn.SetValue(WidthProperty, 25.0);
            btn.SetBinding(ContentProperty, new Binding("Priority"));
            btn.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Left);
            btn.SetValue(CursorProperty, Cursors.ScrollNS);
            btn.AddHandler(PreviewMouseDownEvent, new MouseButtonEventHandler(FiltersPriority_PreviewMouseDown));
            dp.AppendChild(btn);

            FrameworkElementFactory cb = new FrameworkElementFactory(typeof(ComboBox));

            cb.SetValue(DockPanel.DockProperty, Dock.Left);
            cb.SetValue(MarginProperty, new Thickness(2, 0, 0, 0));
            cb.SetValue(WidthProperty, 70.0);
            cb.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Left);
            cb.SetBinding(ComboBox.SelectedValueProperty, new Binding {
                Path = new PropertyPath("Include"), Mode = BindingMode.TwoWay
            });
            cb.SetValue(ComboBox.SelectedValuePathProperty, "Content");
            FrameworkElementFactory cbi = new FrameworkElementFactory(typeof(ComboBoxItem));

            cbi.SetValue(ContentProperty, "Include");
            cb.AppendChild(cbi);
            cbi = new FrameworkElementFactory(typeof(ComboBoxItem));
            cbi.SetValue(ContentProperty, "Exclude");
            cb.AppendChild(cbi);
            dp.AppendChild(cb);

            btn = new FrameworkElementFactory(typeof(Button));
            btn.SetValue(DockPanel.DockProperty, Dock.Right);
            btn.SetValue(WidthProperty, 20.0);
            btn.SetValue(MarginProperty, new Thickness(2, 0, 0, 0));
            btn.AddHandler(Button.ClickEvent, new RoutedEventHandler(FiltersSlotDelete_Clicked));
            btn.SetValue(ContentProperty, "X");
            dp.AppendChild(btn);

            cb = new FrameworkElementFactory(typeof(ComboBox));
            cb.SetValue(MarginProperty, new Thickness(2, 0, 0, 0));
            cb.SetBinding(ComboBox.ItemsSourceProperty, new Binding("AvailableProperties"));
            cb.SetBinding(ComboBox.SelectedItemProperty, new Binding {
                Path = new PropertyPath("ItemProperty"), Mode = BindingMode.TwoWay
            });
            cb.SetValue(ComboBox.DisplayMemberPathProperty, "Property");
            cb.AddHandler(ComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(FilterAvailableProperties_SelectionChanged));
            dp.AppendChild(cb);

            cb = new FrameworkElementFactory(typeof(ComboBox));
            cb.SetValue(MarginProperty, new Thickness(2, 0, 0, 0));
            cb.SetBinding(ComboBox.ItemsSourceProperty, new Binding("AvailableTypes"));
            cb.SetBinding(ComboBox.SelectedItemProperty, new Binding {
                Path = new PropertyPath("Type"), Mode = BindingMode.TwoWay
            });
            dp.AppendChild(cb);

            SlotListBoxDT.VisualTree = dp;
        }
Exemplo n.º 32
0
        private void datagrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
        {
            string header = (string)e.Column.Header;

            //var stack = new StackPanel();
            //stack.Orientation = Orientation.Horizontal;

            //var btn = new Button()
            //{
            //    Content = new Image()
            //    {
            //        Source = new BitmapImage(new Uri("/Styles/chart_line.png", UriKind.Relative))
            //    },
            //    Margin = new Thickness(1, 1, 5, 1),
            //};

            //if (header == "Experiment" || header == "Measur\x2024") btn.Visibility = Visibility.Collapsed;

            //btn.Click += (s_, e_) => GenerateSeries(header);

            //stack.Children.Add(btn);

            //stack.Children.Add(new TextBlock()
            //{
            //    Text = header,
            //    Background = Brushes.Transparent,
            //    //FontSize = 8,
            //});



            var template = new DataTemplate();

            var stackFactory = new FrameworkElementFactory(typeof(StackPanel));

            stackFactory.Name = "stack";
            stackFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);

            var     img     = new FrameworkElementFactory(typeof(Image));
            Binding binding = new Binding();

            binding.Source = new Uri("/Styles/chart_line.png", UriKind.Relative);
            img.SetBinding(Image.SourceProperty, binding);
            img.SetValue(Image.VisibilityProperty, Visibility.Visible);
            img.AddHandler(Image.MouseDownEvent, new MouseButtonEventHandler((s_, e_) =>
            {
                GenerateSeries(header);
                e_.Handled = true;
            }));
            img.SetValue(Image.MarginProperty, new Thickness(1, 1, 5, 1));
            img.SetValue(Image.CursorProperty, Cursors.Hand);
            img.SetValue(Image.ToolTipProperty, "Click to view Detailed Report");
            if (header == "Experiment" || header == "Measur\x2024")
            {
                img.SetValue(Image.VisibilityProperty, Visibility.Collapsed);
            }
            stackFactory.AppendChild(img);

            var textBlockFactory = new FrameworkElementFactory(typeof(TextBlock));

            textBlockFactory.SetValue(TextBlock.TextProperty, header);
            textBlockFactory.SetValue(TextBlock.BackgroundProperty, Brushes.Transparent);
            stackFactory.AppendChild(textBlockFactory);

            template.VisualTree = stackFactory;


            e.Column.HeaderTemplate = template;
        }