public void AutoGenerateOnResetForListOfObjects()
        {
            DataGrid dataGrid = new DataGrid();
            Assert.IsNotNull(dataGrid);
            dataGrid.Width = 350;
            dataGrid.Height = 250;
            _loaded = false;
            dataGrid.Loaded += new RoutedEventHandler(DataGrid_Loaded);
            DataSourceINCC dataSource = new DataSourceINCC();
            dataGrid.ItemsSource = dataSource;
            TestPanel.Children.Add(dataGrid);

            EnqueueConditional(delegate { return _loaded; });

            this.EnqueueYieldThread();
            EnqueueCallback(delegate
            {
                dataSource.Add(new Customer());
                dataSource.Add(new Customer());
                dataSource.Add(new Customer());
                dataSource.Add(new Customer());
                dataSource.RaiseReset();
            });

            this.EnqueueYieldThread();
            EnqueueCallback(delegate
            {
                Assert.IsTrue(dataGrid.Columns.Count > 0);
                Assert.IsTrue(dataGrid.DisplayData.FirstScrollingSlot == 0);
                Assert.IsTrue(dataGrid.DisplayData.LastScrollingSlot == 3);
            });

            EnqueueTestComplete();
        }
 protected override void ApplyProperties(CellDefinition cd, DataGrid owner, CellRef cell, PropertyDefinition pd, object item)
 {
     base.ApplyProperties(cd, owner, cell, pd, item);
     cd.IsEnabledBindingSource = this.isItemEnabledSource;
     cd.IsEnabledBindingParameter = "yes";
     cd.IsEnabledBindingPath = owner.Operator.GetBindingPath(owner, cell);
 }
Esempio n. 3
0
 public DataGrid<UspController> getControllerGrid()
 {
     DataGrid<UspController> result = new DataGrid<UspController>();
     result.rows = systemService.getControllers().ToList();
     result.total = result.rows.Count;
     return result;
 }
Esempio n. 4
0
        public void DataGrid_AutomationPeer()
        {
            DataGrid dataGrid = new DataGrid();
            Assert.IsNotNull(dataGrid);
            isLoaded = false;
            dataGrid.Width = 350;
            dataGrid.Height = 250;
            dataGrid.Loaded += new RoutedEventHandler(dataGrid_Loaded);

            DataGridAutomationPeer peer = ((DataGridAutomationPeer)DataGridAutomationPeer.CreatePeerForElement(dataGrid));
            Assert.IsNotNull(peer);

            TestPanel.Children.Add(dataGrid);
            EnqueueConditional(delegate { return isLoaded; });
            this.EnqueueYieldThread();

            EnqueueCallback(delegate
            {
                Assert.AreEqual(dataGrid.Height, peer.GetBoundingRectangle().Height, "Incorrect BoundingRectangle.Height value");
                Assert.AreEqual(dataGrid.Width, peer.GetBoundingRectangle().Width, "Incorrect BoundingRectangle.Width value");
                Assert.AreEqual(dataGrid.GetType().Name, peer.GetClassName(), "Incorrect ClassName value");
                Assert.AreEqual(Automation.Peers.AutomationControlType.DataGrid, peer.GetAutomationControlType(), "Incorrect ControlType value");
                Assert.AreEqual(true, peer.IsContentElement(), "Incorrect IsContentElement value");
                Assert.AreEqual(true, peer.IsControlElement(), "Incorrect IsControlElement value");
                Assert.AreEqual(true, peer.IsKeyboardFocusable(), "Incorrect IsKeyBoardFocusable value");
                Assert.IsNotNull(peer.GetPattern(PatternInterface.Grid), "Incorrect GetPattern result for PatternInterface.Grid");
                Assert.IsNull(peer.GetPattern(PatternInterface.Scroll), "Incorrect GetPattern result for PatternInterface.Scroll");
                Assert.IsNotNull(peer.GetPattern(PatternInterface.Selection), "Incorrect GetPattern result for PatternInterface.Selection");
                Assert.IsNotNull(peer.GetPattern(PatternInterface.Table), "Incorrect GetPattern result for PatternInterface.Table");
                Assert.IsNotNull(peer.GetChildren(), "GetChildren should never return null");
            });

            EnqueueTestComplete();
        }
Esempio n. 5
0
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// dataGrid1
			// 
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(16, 24);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ReadOnly = true;
			this.dataGrid1.Size = new System.Drawing.Size(264, 216);
			this.dataGrid1.TabIndex = 0;

			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 317);
			this.Controls.Add (this.dataGrid1);
			this.Name = "Form1";
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
Esempio n. 6
0
		private void RunSelectBackGroundTemplateBeitraege ()
			{
			Grid RootGrid = m_XAMLHandler.CreateGrid (new int[] {1, 1, 1}, new int[] {1, 10, 1});
			m_XAMLHandler.SetMinMaxHeight (RootGrid, new int[] {0, 2}, 25);
			this.Content = RootGrid;
			DataSet Beitraege = m_DataBase.GetBeitraege (Von, Bis);
			DataGrid PossibleBackGroundBeitraegeDataGrid = new DataGrid ();
			PossibleBackGroundBeitraegeDataGrid.AutoGenerateColumns = true;
			PossibleBackGroundBeitraegeDataGrid.AutoGeneratedColumns +=
				new EventHandler (PossibleBackGroundBeitraegeDataGrid_AutoGeneratedColumns);
			PossibleBackGroundBeitraegeDataGrid.ItemsSource = Beitraege.Tables ["BeitraegeImZeitraum"].DefaultView;
			(PossibleBackGroundBeitraegeDataGrid.ItemsSource as DataView).RowFilter = "BeitragsTyp = 'ExternesProgramm'";
			PossibleBackGroundBeitraegeDataGrid.MouseDoubleClick +=
				new MouseButtonEventHandler (PossibleBackGroundBeitraegeDataGrid_MouseDoubleClick);
			RootGrid.Children.Add (PossibleBackGroundBeitraegeDataGrid);
			Grid.SetRow (PossibleBackGroundBeitraegeDataGrid, 1);
			Grid.SetColumn(PossibleBackGroundBeitraegeDataGrid, 0);
			Grid.SetColumnSpan (PossibleBackGroundBeitraegeDataGrid, 3);

			Button CancelButton = new Button ();
			CancelButton.Content = "Abbrechen";
			CancelButton.Click += new RoutedEventHandler (CancelButton_Click);
			RootGrid.Children.Add (CancelButton);
			Grid.SetRow (CancelButton, 2);
			Grid.SetColumn (CancelButton, 2);

			Button SelectButton = new Button ();
			SelectButton.Content = "Auswählen";
			SelectButton.Click += new RoutedEventHandler (SelectButton_Click);
			RootGrid.Children.Add (SelectButton);
			SelectButton.Tag = PossibleBackGroundBeitraegeDataGrid;
			Grid.SetRow (SelectButton, 2);
			Grid.SetColumn (SelectButton, 1);

			}
        public void BindItemsSource()
        {
            // Create the original DataContext object
            StringsContainer stringsContainer1 = new StringsContainer();
            stringsContainer1.Strings = new ObservableCollection<string> { "first", "second", "third" };

            // Create the next object to be used as DataContext
            StringsContainer stringsContainer2 = new StringsContainer();
            stringsContainer2.Strings = new ObservableCollection<string> { "one", "two", "three", "four", "five" };

            // Create the DataGrid and setup its binding
            DataGrid dataGrid = new DataGrid();
            dataGrid.DataContext = stringsContainer1;
            Binding binding = new Binding("Strings");
            binding.Mode = BindingMode.OneWay;
            dataGrid.SetBinding(DataGrid.ItemsSourceProperty, binding);
            TestPanel.Children.Add(dataGrid);

            this.EnqueueCallback(delegate
            {
                Assert.AreEqual(stringsContainer1.Strings, dataGrid.ItemsSource, "ItemsSource was not set from the original DataContext");
                Assert.AreEqual(3, dataGrid.DataConnection.Count, "ItemsSource was not set from the original DataContext");
                dataGrid.DataContext = stringsContainer2;
            });
            this.EnqueueYieldThread();

            this.EnqueueCallback(delegate
            {
                Assert.AreEqual(stringsContainer2.Strings, dataGrid.ItemsSource, "ItemsSource did not change along with the DataContext");
                Assert.AreEqual(5, dataGrid.DataConnection.Count, "ItemsSource did not change along with the DataContext");
            });
            this.EnqueueTestComplete();
        }
Esempio n. 8
0
    public static void ExportDataGrid(DataGrid dGrid, String author, String companyName, String mergeCells, int boldHeaderRows, string fileName)
    {
        if (Application.Current.HasElevatedPermissions)
        {

            var filePath ="C:" + Path.DirectorySeparatorChar +"Nithesh"+Path.DirectorySeparatorChar +fileName + ".XML";

            File.Create(filePath);
            Stream outputStream = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite);

            ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, "XML", outputStream);
        }
        else
        {
            SaveFileDialog objSFD = new SaveFileDialog() { DefaultExt = "xml", Filter = FILE_FILTER, FilterIndex = 2, DefaultFileName = fileName };

            if (objSFD.ShowDialog() == true)
            {
                string strFormat = objSFD.SafeFileName.Substring(objSFD.SafeFileName.IndexOf('.') + 1).ToUpper();
                Stream outputStream = objSFD.OpenFile();

                ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, strFormat, outputStream);
            }
        }
    }
Esempio n. 9
0
	public MainForm ()
	{
		_dataGrid = new DataGrid ();
		_column = new DataGridTextBoxColumn ();
		SuspendLayout ();
		((ISupportInitialize) (_dataGrid)).BeginInit ();
		// 
		// _dataGrid
		// 
		_dataGrid.TableStyles.Add (new DataGridTableStyle ());
		_dataGrid.TableStyles [0].GridColumnStyles.Add (_column);
		_dataGrid.Location = new Point (12, 115);
		_dataGrid.Size = new Size (268, 146);
		_dataGrid.TabIndex = 0;
		// 
		// _column
		// 
		_column.HeaderText = "Column";
		// 
		// MainForm
		// 
		ClientSize = new Size (292, 273);
		Controls.Add (_dataGrid);
		((ISupportInitialize) (_dataGrid)).EndInit ();
		ResumeLayout (false);
		Load += new EventHandler (MainForm_Load);
	}
		public void PositionToCellRange_OutOfBounds()
		{
			DataGrid grid1 = new DataGrid();
			List<int> list = new List<int>();
			grid1.DataSource = new DevAge.ComponentModel.BoundList<int>(list);
			Assert.AreEqual(Range.Empty, grid1.PositionToCellRange(new Position(5, 5)));
		}
        //---------------------------------------------------------------------
        static DisturbedSites()
        {
            // columns:    123456789
            string[] rows = new string[]{ "---------",    // row 1
                                          "---aaDa--",    // row 2
                                          "--aDDaa--",    // row 3
                                          "--aaaaaa-",    // row 4
                                          "-aaa--DD-",    // row 5
                                          "-Da---aaa",    // row 6
                                          "--aa--D--"};   // row 7
            bool[,] array = Bool.Make2DimArray(rows, "aD");
            int rowCount = array.GetLength(0);
            int colCount = array.GetLength(1);
            DataGrid<EcoregionCode> grid = new DataGrid<EcoregionCode>(rowCount, colCount);
            for (int row = 1; row <= rowCount; row++) {
                for (int col = 1; col <= colCount; col++) {
                    if (array[row-1, col-1])
                        grid[row, col] = new EcoregionCode(1, true);
                    else
                        grid[row, col] = new EcoregionCode(0, false);
                }
            }
            mixedLandscape = new Landscape(grid, 1);

            List<Location> locList = new List<Location>();
            foreach (ActiveSite site in mixedLandscape) {
                int row = site.Location.Row;
                int column = site.Location.Column;
                if (rows[row-1][column-1] == 'D')
                    locList.Add(site.Location);
            }
            locations = locList.ToArray();
        }
Esempio n. 12
0
        public virtual FrameworkElement CreateCell(DataGrid grid, CellType cellType, CellRange rng)
        {
            // cell border
            var bdr = CreateCellBorder(grid, cellType, rng);

            // bottom right cells have no content
            if (!rng.IsValid)
            {
                return bdr;
            }

            // bind/customize cell by type
            switch (cellType)
            {
                case CellType.Cell:
                    CreateCellContent(grid, bdr, rng);
                    break;

                case CellType.ColumnHeader:
                    CreateColumnHeaderContent(grid, bdr, rng);
                    break;
            }

            // done
            return bdr;
        }
    public static void ExportDataSetToExcel(DataSet ds, string filename)
    {
        try
        {
            HttpResponse response = HttpContext.Current.Response;

            // first let's clean up the response.object
            response.Clear();
            response.Charset = "";

            // set the response mime type for excel
            response.ContentType = "application/vnd.ms-excel";
            response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    // instantiate a datagrid
                    DataGrid dg = new DataGrid();
                    dg.Font.Size = 9;
                    dg.DataSource = ds.Tables[0];
                    dg.DataBind();
                    dg.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }
        catch (Exception)
        {
            throw;
        }
    }
		public void Init()
		{
			string[] rows = new string[] {	"....X..",
											"...XX.X",
											".......",
											"...XXX.",
											"X.X.X.X",
											"XXXXXXX" };
			bool [,] activeSites = Bool.Make2DimArray(rows, "X");
			mixedGrid = new DataGrid<bool>(activeSites);
			mixedMap = new ActiveSiteMap(mixedGrid);

			bool found_1stActive = false;
			bool found_1stInactive = false;
			for (uint row = 1; row <= mixedGrid.Rows; ++row) {
				for (uint column = 1; column <= mixedGrid.Columns; ++column) {
					if (mixedGrid[row, column]) {
						if (! found_1stActive) {
							mixed_1stActive = new Location(row, column);
							found_1stActive = true;
						}		
					}
					else {
						if (! found_1stInactive) {
							mixed_1stInactive = new Location(row, column);
							found_1stInactive = true;
						}		
					}
				}
			}
		}
Esempio n. 15
0
    //=================================================
    //功能描述:对DATAGRIG进行数据绑定,无排序
    //输入参数:sql,查询的SQL语句;dg,需要绑定的DATAGRID控件
    //返回值:无
    //时间:2013.08.20
    //=================================================
    public static void binddatagrid(string sql, DataGrid dg)
    {
        DataSet ds = getdataset(sql);
            dg.DataSource = ds.Tables[0].DefaultView;

        closeConnection();
            dg.DataBind();
    }
        public void Init()
        {
            EcoregionCode[,] array = new EcoregionCode[0,0];
            DataGrid<EcoregionCode> grid = new DataGrid<EcoregionCode>(array);
            landscape = new Landscape(grid, 1);

            siteVarRegistry = new SiteVarRegistry();
        }
Esempio n. 17
0
 public DataGrid<UspMenuItem> getMenuGrid()
 {
     UpdateMenu();
     DataGrid<UspMenuItem> result = new DataGrid<UspMenuItem>();
     result.rows = systemService.getMenuItems();
     result.total = result.rows.Count;
     return result;
 }
Esempio n. 18
0
 public DataGrid<UspPrivilege> getPrivilegeGrid()
 {
     //UpdatePrivilege();
     DataGrid<UspPrivilege> result = new DataGrid<UspPrivilege>();
     result.rows = systemService.getPrivileges();
     result.total = result.rows.Count;
     return result;
 }
        public void Init()
        {
            bool[,] array = new bool[0,0];
            DataGrid<bool> grid = new DataGrid<bool>(array);
            landscape = new Landscape(grid);

            siteVarRegistry = new SiteVarRegistry();
        }
 /// <summary>
 /// Default contructor
 /// </summary>
 /// <param name="owner">DataGrid</param>
 public DataGridAutomationPeer(DataGrid owner)
     : base(owner)
 {
     if (owner == null)
     {
         throw new ArgumentNullException("owner");
     }
 }
Esempio n. 21
0
        public GridLayout()
        {
            _alpha = 1;

            _items = new DataGrid<ILayoutable, GridAlignment>();
            _backgroundSprite = new SpriteFrame();
            _backgroundSprite.PixelSize = 0.5f;
            _backgroundSprite.Alpha = 0f;
        }
Esempio n. 22
0
 public virtual void DisposeCell(DataGrid grid, CellType cellType, FrameworkElement cell)
 {
     var bdr = cell as Border;
     if (bdr != null)
     {
         bdr.DataContext = null;
         bdr.Child = null;
     }
 }
Esempio n. 23
0
 public DataGrid<UP_ShowArea_Result> getAreaGrid(int page, int rows, string order, string orderType)
 {
     DataGrid<UP_ShowArea_Result> result = new DataGrid<UP_ShowArea_Result>();
     result.rows = sysAreaService.showPage(page, rows, order, orderType);
     if (result.rows.Count > 0)
     {
         result.total = (long)result.rows[0].RowCnt;
     }
     return result;
 }
Esempio n. 24
0
 public void GetValueTest()
 {
     double[][] inputData = new double[][] { new double[] { 0, 1, 2 }, new double[] { 3, 4, 5 }, new double[] { 5, 6, 7 } };
     bool isCircular = false;
     DataGrid target = new DataGrid(inputData, isCircular);
     Assert.AreEqual(4, target.GetValue(0.5, 0.5));
     Assert.AreEqual(3, target.GetValueAt(0, 1));
     Assert.AreEqual(1, target.GetXIndex(0.5));
     Assert.AreEqual(0, target.GetYIndex(0.4));
 }
Esempio n. 25
0
        public void RowDetailsTemplate()
        {
            Type propertyType = typeof(DataTemplate);
            bool expectGet = true;
            bool expectSet = true;
            bool hasSideEffects = true;

            DataGrid control = new DataGrid();
            Assert.IsNotNull(control);

            // Verify Dependency Property Property member
            FieldInfo fieldInfo = typeof(DataGrid).GetField("RowDetailsTemplateProperty", BindingFlags.Static | BindingFlags.Public);
            Assert.AreEqual(typeof(DependencyProperty), fieldInfo.FieldType, "DataGrid.RowDetailsTemplateProperty not expected type 'DependencyProperty'.");

            // Verify Dependency Property Property's value type
            DependencyProperty property = fieldInfo.GetValue(null) as DependencyProperty;

            Assert.IsNotNull(property);

            // 


            // Verify Dependency Property CLR property member
            PropertyInfo propertyInfo = typeof(DataGrid).GetProperty("RowDetailsTemplate", BindingFlags.Instance | BindingFlags.Public);
            Assert.IsNotNull(propertyInfo, "Expected CLR property DataGrid.RowDetailsTemplate does not exist.");
            Assert.AreEqual(propertyType, propertyInfo.PropertyType, "DataGrid.RowDetailsTemplate not expected type 'DataTemplate'.");

            // Verify getter/setter access
            Assert.AreEqual(expectGet, propertyInfo.CanRead, "Unexpected value for propertyInfo.CanRead.");
            Assert.AreEqual(expectSet, propertyInfo.CanWrite, "Unexpected value for propertyInfo.CanWrite.");

            // Verify that we set what we get
            if (expectSet) // if expectSet == false, this block can be removed
            {
                DataTemplate template = new DataTemplate();

                control.RowDetailsTemplate = template;

                Assert.AreEqual(template, control.RowDetailsTemplate);
            }

            // Verify Dependency Property callback
            if (hasSideEffects)
            {
                MethodInfo methodInfo = typeof(DataGrid).GetMethod("OnRowDetailsTemplatePropertyChanged", BindingFlags.Static | BindingFlags.NonPublic);
                Assert.IsNotNull(methodInfo, "Expected DataGrid.RowDetailsTemplate to have static, non-public side-effect callback 'OnRowDetailsTemplatePropertyChanged'.");

                // 
            }
            else
            {
                MethodInfo methodInfo = typeof(DataGrid).GetMethod("OnRowDetailsTemplatePropertyChanged", BindingFlags.Static | BindingFlags.NonPublic);
                Assert.IsNull(methodInfo, "Expected DataGrid.RowDetailsTemplate NOT to have static side-effect callback 'OnRowDetailsTemplatePropertyChanged'.");
            }
        }
Esempio n. 26
0
	public MainForm ()
	{
		SuspendLayout ();
		// 
		// _dataGrid
		// 
		_dataGrid = new DataGrid ();
		_dataGrid.DataMember = "";
		_dataGrid.Dock = DockStyle.Top;
		_dataGrid.Height = 200;
		_dataGrid.TabIndex = 0;
		Controls.Add (_dataGrid);
		// 
		// _tabControl
		// 
		_tabControl = new TabControl ();
		_tabControl.Dock = DockStyle.Bottom;
		_tabControl.Height = 300;
		Controls.Add (_tabControl);
		// 
		// _bugDescriptionText1
		// 
		_bugDescriptionText1 = new TextBox ();
		_bugDescriptionText1.Multiline = true;
		_bugDescriptionText1.Dock = DockStyle.Fill;
		_bugDescriptionText1.Text = string.Format (CultureInfo.InvariantCulture,
			"Steps to execute:{0}{0}" +
			"1. Click inside the \"A\" cell of the first row.{0}{0}" +
			"2. Press Tab key until you're in the \"F\" cell.{0}{0}" +
			"3. Press Shift+Tab until you're in the \"A\" cell.{0}{0}" +
			"Expected result:{0}{0}" +
			"1. The content of visible cells is:{0}{0}" +
			"   A = Miguel de Icaza (cut off){0}" +
			"   B = 2007-01-05{0}" +
			"   C = 00000000000000{0}" +
			"   D = Mono / .NET{0}" +
			"   E = Linux / Windows{0}" +
			"   ...", Environment.NewLine);
		// 
		// _tabPage1
		// 
		_tabPage1 = new TabPage ();
		_tabPage1.Text = "#1";
		_tabPage1.Controls.Add (_bugDescriptionText1);
		_tabControl.Controls.Add (_tabPage1);
		// 
		// MainForm
		// 
		ClientSize = new Size (400, 530);
		StartPosition = FormStartPosition.CenterScreen;
		Text = "bug #80453";
		Load += new EventHandler (MainForm_Load);
		ResumeLayout (false);
	}
		public void Init()
		{
			bool[,] array = new bool[0,0];
			DataGrid<bool> grid = new DataGrid<bool>(array);
			landscape = new Landscape.Landscape(grid);

			Ecoregions.IDataset ecoregions = new Ecoregions.Dataset(null);
			ecoregionsMap = new Ecoregions.Map(Data.MakeInputPath("ecoregions-0by0.gis"),
			                                   ecoregions);
			siteVars = new SiteVariables(landscape, ecoregionsMap);
		}
		public void Init()
		{
			string path = Path.Combine(Data.Directory, "mixed.txt");
			bool[,] array = Bool.Read2DimArray(path);
			grid = new DataGrid<bool>(array);
			landscape = new Landscape.Landscape(grid);

			path = Path.Combine(Data.Directory,
			                    "true-locs-in-mixed.txt");
			activeSites = Data.ReadLocations(path);
		}
Esempio n. 29
0
    public static void ExportDataGrid(DataGrid dGrid, String author, String companyName, String mergeCells, int boldHeaderRows)
    {
        SaveFileDialog objSFD = new SaveFileDialog() { DefaultExt = "xml", Filter = FILE_FILTER, FilterIndex = 2 };

        if (objSFD.ShowDialog() == true)
        {
            string strFormat = objSFD.SafeFileName.Substring(objSFD.SafeFileName.IndexOf('.') + 1).ToUpper();
            Stream outputStream = objSFD.OpenFile();

            ExportToExcel(dGrid, author, companyName, mergeCells, boldHeaderRows, strFormat, outputStream);
        }
    }
Esempio n. 30
0
 public DataGridTests()
     : base(Gtk.WindowType.Toplevel)
 {
     this.Build();
     _dataGrid = new DataGrid();
     _dataGrid.ItemsDisplayMode = ItemsDisplayMode.BindingDescriptor;
     _dataGrid.BindingDescriptor = createUserBindingDescriptor();
     this.scrolledwindow1.AddWithViewport(_dataGrid);
     this.ReshowWithInitialSize();
     this.Child.ShowAll();
     addUsers();
 }
 public Upload_Data_fromSql_toDataGrid(string a, DataGrid b, string c)
 {
     Query        = a;
     nameDatagrid = b;
     nameTable    = c;
 }
Esempio n. 32
0
 private bool CanCut([CanBeNull] DataGrid dataGrid)
 {
     return(CanCopy(dataGrid) && CanDelete(dataGrid));
 }
 public static void SetArray2D(this DataGrid element, Array value)
 {
     element.SetValue(Array2DProperty, value);
 }
Esempio n. 34
0
 /// <summary>Helper for setting <see cref="TransposedSourceProperty"/> on <paramref name="element"/>.</summary>
 /// <param name="element"><see cref="DataGrid"/> to set <see cref="TransposedSourceProperty"/> on.</param>
 /// <param name="value">TransposedSource property value.</param>
 public static void SetTransposedSource(this DataGrid element, IEnumerable value)
 {
     element.SetValue(TransposedSourceProperty, value);
 }
Esempio n. 35
0
        //TODO GroupSorting
        internal void ProcessSort(KeyModifiers keyModifiers)
        {
            // if we can sort:
            //  - DataConnection.AllowSort is true, and
            //  - AllowUserToSortColumns and CanSort are true, and
            //  - OwningColumn is bound, and
            //  - SortDescriptionsCollection exists, and
            //  - the column's data type is comparable
            // then try to sort
            if (OwningColumn != null &&
                OwningGrid != null &&
                OwningGrid.EditingRow == null &&
                OwningColumn != OwningGrid.ColumnsInternal.FillerColumn &&
                OwningGrid.DataConnection.AllowSort &&
                OwningGrid.CanUserSortColumns &&
                OwningColumn.CanUserSort &&
                OwningGrid.DataConnection.SortDescriptions != null)
            {
                DataGrid owningGrid = OwningGrid;

                DataGridSortDescription newSort;

                KeyboardHelper.GetMetaKeyState(keyModifiers, out bool ctrl, out bool shift);

                DataGridSortDescription sort           = OwningColumn.GetSortDescription();
                IDataGridCollectionView collectionView = owningGrid.DataConnection.CollectionView;
                Debug.Assert(collectionView != null);
                using (collectionView.DeferRefresh())
                {
                    // if shift is held down, we multi-sort, therefore if it isn't, we'll clear the sorts beforehand
                    if (!shift || owningGrid.DataConnection.SortDescriptions.Count == 0)
                    {
                        owningGrid.DataConnection.SortDescriptions.Clear();
                    }

                    // if ctrl is held down, we only clear the sort directions
                    if (!ctrl)
                    {
                        if (sort != null)
                        {
                            newSort = sort.SwitchSortDirection();

                            // changing direction should not affect sort order, so we replace this column's
                            // sort description instead of just adding it to the end of the collection
                            int oldIndex = owningGrid.DataConnection.SortDescriptions.IndexOf(sort);
                            if (oldIndex >= 0)
                            {
                                owningGrid.DataConnection.SortDescriptions.Remove(sort);
                                owningGrid.DataConnection.SortDescriptions.Insert(oldIndex, newSort);
                            }
                            else
                            {
                                owningGrid.DataConnection.SortDescriptions.Add(newSort);
                            }
                        }
                        else
                        {
                            string propertyName = OwningColumn.GetSortPropertyName();
                            // no-opt if we couldn't find a property to sort on
                            if (string.IsNullOrEmpty(propertyName))
                            {
                                return;
                            }

                            newSort = DataGridSortDescription.FromPath(propertyName, culture: collectionView.Culture);
                            owningGrid.DataConnection.SortDescriptions.Add(newSort);
                        }
                    }
                }
            }
        }
Esempio n. 36
0
 public QueryResultView()
     : base()
 {
     grid = new DataGrid();
     grid.ShowAll();
 }
    protected void OnButtonCommand(object sender, CommandEventArgs e)
    {
        //Event handler for command button clicked
        //Change view to Viewer and reset to clear existing data
        Master.Viewer.Reset();

        //Get parameters for the query
        string _start = this.ddpSetup.FromDate.ToString("yyyy-MM-dd");
        string _end   = this.ddpSetup.ToDate.ToString("yyyy-MM-dd");

        //Initialize control values
        LocalReport report = Master.Viewer.LocalReport;

        report.DisplayName          = REPORT_NAME;
        report.EnableExternalImages = true;
        EnterpriseGateway enterprise = new EnterpriseGateway();
        DataSet           ds         = enterprise.FillDataset(USP_REPORT, TBL_REPORT, new object[] { _start, _end });

        if (ds.Tables[TBL_REPORT].Rows.Count >= 0)
        {
            switch (e.CommandName)
            {
            case "Run":
                //Set local report and data source
                System.IO.Stream stream = Master.GetReportDefinition(REPORT_SRC);
                report.LoadReportDefinition(stream);
                report.DataSources.Clear();
                report.DataSources.Add(new ReportDataSource(REPORT_DS, ds.Tables[TBL_REPORT]));

                //Set the report parameters for the report
                ReportParameter start = new ReportParameter("FromDate", _start);
                ReportParameter end   = new ReportParameter("ToDate", _end);
                report.SetParameters(new ReportParameter[] { start, end });

                //Update report rendering with new data
                report.Refresh();

                if (!Master.Viewer.Enabled)
                {
                    Master.Viewer.CurrentPage = 1;
                }
                break;

            case "Data":
                //Set local export report and data source
                report.LoadReportDefinition(Master.CreateExportRdl(ds, REPORT_DS, "RGXSQLR.TSORT"));
                report.DataSources.Clear();
                report.DataSources.Add(new ReportDataSource(REPORT_DS, ds.Tables[TBL_REPORT]));
                report.Refresh();
                break;

            case "Excel":
                //Create Excel mime-type page
                Response.ClearHeaders();
                Response.Clear();
                Response.Charset = "";
                Response.AddHeader("Content-Disposition", "inline; filename=VitaminShoppeDelivery.xls");
                Response.ContentType = "application/vnd.ms-excel";      //application/octet-stream";
                System.IO.StringWriter       sw = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
                DataGrid dg = new DataGrid();
                dg.DataSource = ds.Tables[TBL_REPORT];
                dg.DataBind();
                dg.RenderControl(hw);
                Response.Write(sw.ToString());
                Response.End();
                break;
            }
        }
        else
        {
            Master.Status = "There were no records found.";
        }
    }
Esempio n. 38
0
        //初始化表头与显示信息
        public bool iniDataGrid(DataGrid dataGrid1, int iPos)
        {
            try
            {
                this.iniDGDataSource(dataGrid1);

                // Create a table style that will hold the new column style
                // that we set and also tie it to our customer's table from our DB
                DataGridTableStyle tableStyle = new DataGridTableStyle();

                DataTable dt = (DataTable)dataGrid1.DataSource;

                tableStyle.MappingName = dt.TableName;

                DataTable dtGprsData = null;
                ArrayList alColsCap  = null;

                //报表格式初始化
                if (getGprsData(ref dtGprsData, ref alColsCap, iPos) == false)
                {
                    return(false);
                }

                // since the dataset has things like field name and number of columns,
                // we will use those to create new columnstyles for the columns in our DB table
                int numCols = dtGprsData.Columns.Count;
                DataGridColoredTextBoxColumn aColumnTextColumn;
                delegateGetColorRowCol       d = new delegateGetColorRowCol(MyGetColorRowCol);

                int[] iColWidths = null;
                getColWidths(ref iColWidths);

                for (int i = 0; i < numCols; i++)
                {
                    aColumnTextColumn             = new DataGridColoredTextBoxColumn(d, i, dtGprsData.Columns[i].ColumnName);
                    aColumnTextColumn.HeaderText  = alColsCap[i].ToString();
                    aColumnTextColumn.Width       = iColWidths[i] - 2;
                    aColumnTextColumn.MappingName = dtGprsData.Columns[i].ColumnName;
                    tableStyle.GridColumnStyles.Add(aColumnTextColumn);
                }

                // make the dataGrid use our new tablestyle and bind it to our table
                dataGrid1.TableStyles.Clear();

                tableStyle.AllowSorting = false;
                //tableStyle.
                dataGrid1.AllowSorting = false;
                dataGrid1.TableStyles.Add(tableStyle);

                DataRow dr = dt.NewRow();
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    dr[i] = "";
                }
                dt.Rows.Add(dr);

                //tableStyle.RowHeadersVisible=false;
                dataGrid1.DataSource = dt;

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
Esempio n. 39
0
            /// <summary>
            /// Выводит информацию в указанный DataGrid;
            /// </summary>
            /// <param name="dataGrid"></param>
            /// <param name="choose"></param>
            public void OutputTable(DataGrid dataGrid, int choose = 0)
            {
                dataGrid.Items.Clear();

                string sql = string.Empty;

                switch (choose)
                {
                case 0:
                    sql = "SELECT s.id, w.second_name, w.first_name, w.middle_name, w.position, f.name, " +
                          "t.name, t.type, s.price, s.date, s.address_id FROM `sale` s " +
                          "LEFT OUTER JOIN `staff` w ON w.id = s.worker_id " +
                          "LEFT OUTER JOIN `technic` t ON t.id = s.technic_id " +
                          "LEFT OUTER JOIN `fabricators` f ON f.id = t.fabricator_id";
                    break;

                case 1:
                    sql = "SELECT s.id, w.second_name, w.first_name, w.middle_name, w.position, f.name, " +
                          "t.name, t.type, s.price, s.date, s.address_id FROM `sale` s " +
                          "LEFT OUTER JOIN `staff` w ON w.id = s.worker_id " +
                          "LEFT OUTER JOIN `technic` t ON t.id = s.technic_id " +
                          "LEFT OUTER JOIN `fabricators` f ON f.id = t.fabricator_id " +
                          "WHERE s.address_id <=> NULL";
                    break;

                case 2:
                    sql = "SELECT s.id, w.second_name, w.first_name, w.middle_name, w.position, f.name, " +
                          "t.name, t.type, s.price, s.date, s.address_id FROM `sale` s " +
                          "LEFT OUTER JOIN `staff` w ON w.id = s.worker_id " +
                          "LEFT OUTER JOIN `technic` t ON t.id = s.technic_id " +
                          "LEFT OUTER JOIN `fabricators` f ON f.id = t.fabricator_id " +
                          "WHERE s.address_id IS NOT NULL";
                    break;
                }

                MySqlCommand    command = new MySqlCommand(sql, _connection);
                MySqlDataReader reader  = command.ExecuteReader();

                List <string[]> data = new List <string[]>();

                while (reader.Read())
                {
                    data.Add(new string[9]);

                    data[data.Count - 1][0] = reader[0].ToString();

                    data[data.Count - 1][1] = reader[1].ToString() + " " +
                                              reader[2].ToString() + " " + reader[3].ToString();

                    data[data.Count - 1][2] = reader[4].ToString();
                    data[data.Count - 1][3] = reader[5].ToString();
                    data[data.Count - 1][4] = reader[6].ToString();
                    data[data.Count - 1][5] = reader[7].ToString();
                    data[data.Count - 1][6] = reader[8].ToString();
                    data[data.Count - 1][7] = reader[9].ToString().Substring(0, 10);

                    if (reader[10].ToString() == "")
                    {
                        data[data.Count - 1][8] = "получено";
                    }
                    else
                    {
                        data[data.Count - 1][8] = "доставляется";
                    }
                }
                reader.Close();

                foreach (string[] s in data)
                {
                    dataGrid.Items.Add(new Item()
                    {
                        numberSale     = s[0],
                        nameWorker     = s[1],
                        positionWorker = s[2],
                        nameFabricator = s[3],
                        nameTechnic    = s[4],
                        typeTechnic    = s[5],
                        priceSale      = s[6],
                        date           = s[7],
                        status         = s[8]
                    });
                }
            }
 public ScheduleTemplate(DataGrid _dGrid)
 {
     dGrid = _dGrid;
 }
Esempio n. 41
0
        public static void ExportDataGrid(object sender, List <ExcelHeader> headers)
        {
            DataGrid currentGrid = sender as DataGrid;

            if (currentGrid != null)
            {
                StringBuilder sbGridData  = new StringBuilder();
                List <string> listColumns = new List <string>();

                List <DataGridColumn> listVisibleDataGridColumns = new List <DataGridColumn>();

                List <string> listHeaders = new List <string>();

                Microsoft.Office.Interop.Excel.Application application = null;

                Workbook workbook = null;

                Worksheet worksheet = null;

                int rowCount = headers.Count + 3;

                int colCount = 1;

                try
                {
                    application = new Microsoft.Office.Interop.Excel.Application();
                    workbook    = application.Workbooks.Add(Type.Missing);
                    worksheet   = (Worksheet)workbook.Worksheets[1];
                    for (int i = 1; i <= headers.Count; i++)
                    {
                        worksheet.Cells[i, 1] = headers[i - 1].Header;
                        var xlHeader = worksheet.get_Range("A" + i.ToString(), getColName(currentGrid.Columns.Count) + "1");
                        xlHeader.Merge(true);
                        xlHeader.Font.Size           = headers[i - 1].FontSize;
                        xlHeader.Font.Bold           = headers[i - 1].IsBold;
                        xlHeader.HorizontalAlignment = headers[i - 1].HorizontalAllignment;
                    }

                    if (currentGrid.HeadersVisibility == DataGridHeadersVisibility.Column || currentGrid.HeadersVisibility == DataGridHeadersVisibility.All)
                    {
                        foreach (DataGridColumn dataGridColumn in currentGrid.Columns.Where(dataGridColumn => dataGridColumn.Visibility == Visibility.Visible))
                        {
                            listVisibleDataGridColumns.Add(dataGridColumn);
                            if (dataGridColumn.Header != null)
                            {
                                listHeaders.Add(dataGridColumn.Header.ToString());
                            }
                            var dataHeader = worksheet.get_Range(getColName(colCount) + rowCount.ToString());
                            dataHeader.ColumnWidth              = dataGridColumn.Width.Value / 10;
                            dataHeader.HorizontalAlignment      = Microsoft.Office.Interop.Excel.Constants.xlCenter;
                            worksheet.Cells[rowCount, colCount] = dataGridColumn.Header;
                            var border = dataHeader.Borders;
                            border[XlBordersIndex.xlEdgeLeft].LineStyle   = XlLineStyle.xlContinuous;
                            border[XlBordersIndex.xlEdgeTop].LineStyle    = XlLineStyle.xlContinuous;
                            border[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous;
                            border[XlBordersIndex.xlEdgeRight].LineStyle  = XlLineStyle.xlContinuous;
                            dataHeader.EntireColumn.NumberFormat          = "@";
                            colCount++;
                        }
                        foreach (object data in currentGrid.ItemsSource)
                        {
                            listColumns.Clear();
                            colCount = 1;
                            rowCount++;
                            foreach (DataGridColumn dataGridColumn in listVisibleDataGridColumns)
                            {
                                string              strValue            = string.Empty;
                                Binding             objBinding          = null;
                                double              ColWidth            = dataGridColumn.Width.Value;
                                DataGridBoundColumn dataGridBoundColumn = dataGridColumn as DataGridBoundColumn;

                                if (dataGridBoundColumn != null)
                                {
                                    objBinding = dataGridBoundColumn.Binding as Binding;
                                }

                                DataGridTemplateColumn dataGridTemplateColumn = dataGridColumn as DataGridTemplateColumn;

                                if (dataGridTemplateColumn != null)
                                {
                                    // This is a template column...let us see the underlying dependency object

                                    DependencyObject dependencyObject = dataGridTemplateColumn.CellTemplate.LoadContent();

                                    FrameworkElement frameworkElement = dependencyObject as FrameworkElement;
                                    if (frameworkElement != null)
                                    {
                                        FieldInfo fieldInfo = frameworkElement.GetType().GetField("ContentProperty", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
                                        if (fieldInfo == null)
                                        {
                                            if (frameworkElement is System.Windows.Controls.TextBox || frameworkElement is TextBlock || frameworkElement is ComboBox)
                                            {
                                                fieldInfo = frameworkElement.GetType().GetField("TextProperty");
                                            }
                                            else if (frameworkElement is DatePicker)
                                            {
                                                fieldInfo = frameworkElement.GetType().GetField("SelectedDateProperty");
                                            }
                                        }

                                        if (fieldInfo != null)
                                        {
                                            DependencyProperty dependencyProperty = fieldInfo.GetValue(null) as DependencyProperty;
                                            if (dependencyProperty != null)
                                            {
                                                BindingExpression bindingExpression = frameworkElement.GetBindingExpression(dependencyProperty);
                                                if (bindingExpression != null)
                                                {
                                                    objBinding = bindingExpression.ParentBinding;
                                                }
                                            }
                                        }
                                    }
                                }

                                if (objBinding != null)
                                {
                                    if (!String.IsNullOrEmpty(objBinding.Path.Path))
                                    {
                                        PropertyInfo pi;
                                        if (objBinding.Path.Path.Contains('.'))
                                        {
                                            pi = data.GetType().GetProperty(objBinding.Path.Path.Split('.')[0]);
                                            if (pi != null)
                                            {
                                                object propValue = pi.GetValue(data, null);

                                                pi = propValue.GetType().GetProperty(objBinding.Path.Path.Split('.')[1]);

                                                propValue = pi.GetValue(propValue, null);
                                                if (propValue != null)
                                                {
                                                    if (string.IsNullOrEmpty(objBinding.StringFormat))
                                                    {
                                                        strValue = Convert.ToString(propValue);
                                                    }
                                                    else
                                                    {
                                                        if (propValue.GetType() == typeof(DateTime))
                                                        {
                                                            strValue = (propValue as DateTime?).Value.ToString(objBinding.StringFormat);
                                                        }
                                                        if (propValue.GetType() == typeof(TimeSpan))
                                                        {
                                                            strValue = (propValue as TimeSpan?).Value.ToString(objBinding.StringFormat);
                                                        }
                                                        else if (propValue.GetType() == typeof(decimal) || propValue.GetType() == typeof(double))
                                                        {
                                                            strValue = (propValue as decimal?).Value.ToString(objBinding.StringFormat);
                                                        }
                                                    }
                                                }

                                                else
                                                {
                                                    strValue = string.Empty;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            pi = data.GetType().GetProperty(objBinding.Path.Path);
                                            if (pi != null)
                                            {
                                                object propValue = pi.GetValue(data, null);
                                                if (propValue != null)
                                                {
                                                    if (string.IsNullOrEmpty(objBinding.StringFormat))
                                                    {
                                                        strValue = Convert.ToString(propValue);
                                                    }
                                                    else
                                                    {
                                                        if (propValue.GetType() == typeof(DateTime))
                                                        {
                                                            strValue = (propValue as DateTime?).Value.ToString(objBinding.StringFormat);
                                                        }
                                                        if (propValue.GetType() == typeof(TimeSpan))
                                                        {
                                                            strValue = (propValue as TimeSpan?).Value.ToString(objBinding.StringFormat);
                                                        }
                                                        else if (propValue.GetType() == typeof(decimal) || propValue.GetType() == typeof(double))
                                                        {
                                                            strValue = (propValue as decimal?).Value.ToString(objBinding.StringFormat);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    strValue = string.Empty;
                                                }
                                            }
                                        }
                                    }

                                    if (objBinding.Converter != null)
                                    {
                                        if (!String.IsNullOrEmpty(strValue))
                                        {
                                            strValue = objBinding.Converter.Convert(strValue, typeof(string), objBinding.ConverterParameter, objBinding.ConverterCulture).ToString();
                                        }

                                        else
                                        {
                                            strValue = objBinding.Converter.Convert(data, typeof(string), objBinding.ConverterParameter, objBinding.ConverterCulture).ToString();
                                        }
                                    }
                                }

                                listColumns.Add(strValue);

                                var border = worksheet.get_Range(getColName(colCount) + rowCount.ToString()).Borders;
                                border[XlBordersIndex.xlEdgeLeft].LineStyle   = XlLineStyle.xlContinuous;
                                border[XlBordersIndex.xlEdgeTop].LineStyle    = XlLineStyle.xlContinuous;
                                border[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous;
                                border[XlBordersIndex.xlEdgeRight].LineStyle  = XlLineStyle.xlContinuous;
                                worksheet.Cells[rowCount, colCount]           = strValue;

                                colCount++;
                            }
                        }
                    }
                }

                catch (System.Runtime.InteropServices.COMException)
                {
                }

                finally
                {
                    application.Visible = true;
                    //workbook.PrintPreview(false);
                    //workbook.Close();
                    //application.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(application);
                }
            }
        }
 /// <summary>
 /// Helper for setting RowHeadersSource property on a DataGrid.
 /// </summary>
 /// <param name="element">DataGrid to set RowHeadersSource property on.</param>
 /// <param name="value">RowHeadersSource property value.</param>
 public static void SetRowHeadersSource(this DataGrid element, IEnumerable value)
 {
     element.SetValue(RowHeadersSourceProperty, value);
 }
 public static IEnumerable GetRowHeadersSource(this DataGrid element)
 {
     return((IEnumerable)element.GetValue(RowHeadersSourceProperty));
 }
Esempio n. 44
0
        public static void Read(string tblFile, Dispatcher dp, ProgressBar progressBar, DataGrid dg)
        {
            new Thread(() =>
            {
                var columns = new List <Column>();
                var table   = new DataTable();

                try
                {
                    using (var dbReader = new BinaryReader(new MemoryStream(File.ReadAllBytes(tblFile))))
                    {
                        DBHeader header = new DBHeader();
                        {
                            header.Signature         = dbReader.ReadString(4, false);
                            header.Version           = dbReader.ReadUInt32();    // Not used
                            header.TableNameLength   = dbReader.ReadUInt64();
                            header.Unknown           = dbReader.ReadUInt64();    // Not used
                            header.RecordSize        = dbReader.ReadUInt64();
                            header.FieldCount        = dbReader.ReadUInt64();
                            header.DescriptionOffset = dbReader.ReadUInt64();
                            header.RecordCount       = dbReader.ReadUInt64();
                            header.FullRecordSize    = dbReader.ReadUInt64();    // Not used
                            header.EntryOffset       = dbReader.ReadUInt64();
                            header.MaxId             = dbReader.ReadUInt64();    // Not used
                            header.IDLookupOffset    = dbReader.ReadUInt64();    // Not used
                            header.Unknown2          = dbReader.ReadUInt64();    // Not used
                        }

                        if (header.IsValidTblFile)
                        {
                            var tableName = dbReader.ReadString((int)header.TableNameLength);

                            if (!Globals.DBTables.TryAdd(Globals.SelectedItem, null))
                            {
                                MessageBox.Show(tableName + " already loaded as table");

                                // Exit current reader
                                dbReader.Dispose();

                                return;
                            }

                            table.BeginLoadData();

                            for (uint i = 0; i < header.FieldCount; i++)
                            {
                                dbReader.BaseStream.Position = (long)(header.DescriptionOffset + 0x60 + (0x18 * i));

                                var column = new Column
                                {
                                    NameLength = dbReader.ReadUInt32(),
                                    Unknown    = dbReader.ReadUInt32(),
                                    NameOffset = dbReader.ReadUInt64(),
                                    DataType   = dbReader.ReadUInt16(),
                                    Unknown2   = dbReader.ReadUInt16(),
                                    Unknown3   = dbReader.ReadUInt32(),
                                };

                                var namePos = (long)(((0x60 + header.FieldCount * 0x18) + header.DescriptionOffset) + column.NameOffset);

                                // Read name for column
                                dbReader.BaseStream.Position = header.FieldCount % 2 == 0 ? namePos : namePos + 8;

                                column.Name = dbReader.ReadString((int)column.NameLength - 1);

                                table.Columns.Add(column.Name);
                                columns.Add(column);

                                switch (column.DataType)
                                {
                                case 3:
                                    table.Columns[column.Name].DataType = typeof(uint);
                                    break;

                                case 4:
                                    table.Columns[column.Name].DataType = typeof(float);
                                    break;

                                case 11:
                                    table.Columns[column.Name].DataType = typeof(string);
                                    break;

                                case 20:
                                    table.Columns[column.Name].DataType = typeof(ulong);
                                    break;

                                case 130:
                                    table.Columns[column.Name].DataType = typeof(string);
                                    break;

                                default:
                                    MessageBox.Show("Not supported data type '" + column.DataType + "'");
                                    break;
                                }
                            }

                            var firstEntryPos = header.EntryOffset + 0x60;
                            ulong ctr         = 0;

                            for (uint i = 0; i < header.RecordCount; i++)
                            {
                                var row      = table.NewRow();
                                var lastType = 0;
                                bool skip    = false;

                                dbReader.BaseStream.Position = (long)((long)firstEntryPos + ((long)header.RecordSize * i));

                                for (int j = 0; j < (int)header.FieldCount; j++)
                                {
                                    var column = columns[j];

                                    if (skip && column.DataType != 130 && lastType == 130)
                                    {
                                        dbReader.BaseStream.Position += 4;
                                    }

                                    switch (column.DataType)
                                    {
                                    case 3:
                                        row[column.Name] = dbReader.ReadUInt32();
                                        break;

                                    case 4:
                                        row[column.Name] = dbReader.ReadSingle();
                                        break;

                                    case 11:
                                        row[column.Name] = Convert.ToBoolean(dbReader.ReadUInt32()).ToString();
                                        break;

                                    case 20:
                                        row[column.Name] = dbReader.ReadUInt64();
                                        break;

                                    case 130:
                                        var stringOffset  = dbReader.ReadUInt32();
                                        var stringOffset2 = dbReader.ReadUInt32();

                                        if (stringOffset == 0)
                                        {
                                            skip = true;
                                        }

                                        var lastPosition = dbReader.BaseStream.Position;

                                        dbReader.BaseStream.Position = (long)((stringOffset > 0 ? stringOffset : stringOffset2) + firstEntryPos);

                                        row[column.Name] = dbReader.ReadWString();

                                        dbReader.BaseStream.Position = lastPosition;
                                        break;

                                    default:
                                        break;
                                    }

                                    lastType = column.DataType;
                                }

                                table.Rows.Add(row);

                                // Let's cheat a bit with our progressbar :)
                                if (i == (header.RecordCount / 100) * ctr)
                                {
                                    dp.Invoke(new Action(() => progressBar.Value = ctr++ - ctr * 0.01), DispatcherPriority.Send);
                                }
                            }

                            table.EndLoadData();

                            Globals.DBTables.TryUpdate(Globals.SelectedItem, table, null);
                        }

                        dp.Invoke(new Action(() => dg.ItemsSource    = table.DefaultView), DispatcherPriority.DataBind);
                        dp.Invoke(new Action(() => progressBar.Value = 100.0), DispatcherPriority.Send);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Error while loading {0}: {1}", tblFile, ex.Message));
                }
            }).Start();
        }
Esempio n. 45
0
 public UIViewModel(DataGrid dg)
 {
     this.dg = dg;
 }
Esempio n. 46
0
        //public void Search(int UserId)
        //{

        //}

        public static void Search(string FullName, DataGrid userstable)
        {
        }
Esempio n. 47
0
        private void FormatGrid(DataGrid grd)
        {
            try
            {
                DataGridTableStyle grdTableStyle = new DataGridTableStyle();
                grd.TableStyles.Clear();

                //Select
                DataGridBoolColumn grdColSelect = new DataGridBoolColumn();
                grdColSelect.MappingName = "Select";
                grdColSelect.HeaderText  = "Chọn";
                grdColSelect.NullText    = "";
                grdColSelect.Width       = 45;
                grdColSelect.AllowNull   = false;
                grdColSelect.Alignment   = HorizontalAlignment.Center;

                //STT
                DataGridTextBoxColumn grdColSTT = new DataGridTextBoxColumn();
                grdColSTT.MappingName  = "STT";
                grdColSTT.HeaderText   = "Số Thứ Tự";
                grdColSTT.NullText     = "";
                grdColSTT.Width        = 60;
                grdColSelect.Alignment = HorizontalAlignment.Center;

                //TenDangNhap
                DataGridTextBoxColumn grdColTenDangNhap = new DataGridTextBoxColumn();
                grdColTenDangNhap.MappingName = "TenDangNhap";
                grdColTenDangNhap.HeaderText  = "Tên Đăng Nhập";
                grdColTenDangNhap.NullText    = "";
                grdColTenDangNhap.Width       = 90;
                grdColTenDangNhap.Alignment   = HorizontalAlignment.Center;

                //NgayBatDau
                DataGridTextBoxColumn grdColNgayBatDau = new DataGridTextBoxColumn();
                grdColNgayBatDau.MappingName = "NgayBatDau";
                grdColNgayBatDau.HeaderText  = "Ngày Bắt Đầu";
                grdColNgayBatDau.NullText    = "";
                grdColNgayBatDau.Width       = 80;
                grdColNgayBatDau.Alignment   = HorizontalAlignment.Center;

                //NgayKetThuc
                DataGridTextBoxColumn grdColNgayKetThuc = new DataGridTextBoxColumn();
                grdColNgayKetThuc.MappingName = "NgayKetThuc";
                grdColNgayKetThuc.HeaderText  = "Ngày Kết Thúc";
                grdColNgayKetThuc.NullText    = "";
                grdColNgayKetThuc.Width       = 80;
                grdColNgayKetThuc.Alignment   = HorizontalAlignment.Center;

                //GioBatDau
                DataGridTextBoxColumn grdColGioBatDau = new DataGridTextBoxColumn();
                grdColGioBatDau.MappingName = "GioBatDau";
                grdColGioBatDau.HeaderText  = "Giờ Bắt Đầu";
                grdColGioBatDau.NullText    = "";
                grdColGioBatDau.Width       = 70;
                grdColGioBatDau.Alignment   = HorizontalAlignment.Center;

                //GioKetThuc
                DataGridTextBoxColumn grdColGioKetThuc = new DataGridTextBoxColumn();
                grdColGioKetThuc.MappingName = "GioKetThuc";
                grdColGioKetThuc.HeaderText  = "Giờ Kết Thúc";
                grdColGioKetThuc.NullText    = "";
                grdColGioKetThuc.Width       = 70;
                grdColGioKetThuc.Alignment   = HorizontalAlignment.Center;

                //NoiDungCongViec
                DataGridTextBoxColumn grdColNoiDungCongViec = new DataGridTextBoxColumn();
                grdColNoiDungCongViec.MappingName = "NoiDungCongViec";
                grdColNoiDungCongViec.HeaderText  = "Nội Dung Công Việc";
                grdColNoiDungCongViec.NullText    = "";
                grdColNoiDungCongViec.Width       = 120;
                grdColNoiDungCongViec.Alignment   = HorizontalAlignment.Center;

                //TrangThaiThucHien
                DataGridTextBoxColumn grdColTrangThaiThucHien = new DataGridTextBoxColumn();
                grdColTrangThaiThucHien.MappingName = "TrangThaiThucHien";
                grdColTrangThaiThucHien.HeaderText  = "Trạng Thái Thực Hiện";
                grdColTrangThaiThucHien.NullText    = "";
                grdColTrangThaiThucHien.Width       = 120;
                grdColTrangThaiThucHien.Alignment   = HorizontalAlignment.Center;

                grdTableStyle.GridColumnStyles.AddRange(new DataGridColumnStyle[] { grdColSelect, grdColSTT, grdColTenDangNhap, grdColNgayBatDau, grdColNgayKetThuc, grdColGioBatDau, grdColGioKetThuc, grdColNoiDungCongViec, grdColTrangThaiThucHien });
                grd.TableStyles.Add(grdTableStyle);
            }
            catch
            { }
        }
Esempio n. 48
0
        public NannyCard(Nanny NannyToShow, DataGrid dataGridInput)
        {
            InitializeComponent();
            dataGridToRefresh = dataGridInput;
            bl                           = FactoryBL.GetBL();
            nannyOfCard                  = NannyToShow.GetCopy();
            ID_TextBox.Text              = NannyToShow.NannyId.ToString();
            FirstName_TextBox.Text       = NannyToShow.NannyPrivateName;
            LastName_TextBox.Text        = NannyToShow.NannyFamilyName;
            PhoneNumber_TextBox.Text     = "0" + NannyToShow.NannyPhoneNum.ToString();
            birth_TextBox.Text           = NannyToShow.NannyDateOfBirth.Day + "/" + NannyToShow.NannyDateOfBirth.Month + "/" + NannyToShow.NannyDateOfBirth.Year;
            Adress_TextBox.Text          = NannyToShow.NannyAdress;
            Floor_TextBox.Text           = NannyToShow.NannyFloor.ToString();
            Elevator_CheckBox.IsChecked  = NannyToShow.NannyIsElevator;
            Experience_TextBox.Text      = NannyToShow.NannyYearsOfExperience.ToString();
            Maxchildrens_TextBox.Text    = NannyToShow.NannyMaxInfants.ToString();
            AgeRange_TextBox.Text        = NannyToShow.NannyMinInfantAge.ToString() + "-" + NannyToShow.NannyMaxInfantAge.ToString();
            Vacation_TextBox.Text        = NannyToShow.NannyIsElevator ? "Ministry of Education" : "Ministry of Industry and Trade";
            MonthlySalary_TextBox.Text   = NannyToShow.NannyMonthlySalary.ToString() + " NIS";
            HourlySalary_TextBox.Text    = NannyToShow.NannyIsHourlySalary ? NannyToShow.NannyHourlySalary.ToString() + " NIS" : "Does not allow hourly salary";
            Recommendations_TextBox.Text = NannyToShow.NannyRecommendations;


            for (int i = 0; i < 6; i++)
            {
                if (NannyToShow.NannyWorkingDays[i])
                {
                    switch (i)
                    {
                    case 0:
                        Sunday_Day_TextBlock.Visibility  = Visibility.Visible;
                        Sunday_Time_TextBlock.Visibility = Visibility.Visible;
                        Sunday_Day_TextBlock.Text        = UiTools.NumToDay(i);
                        Sunday_Time_TextBlock.Text       = NannyToShow.NannyWorkingHours[i].ToString();
                        break;

                    case 1:
                        Monday_Day_TextBlock.Visibility  = Visibility.Visible;
                        Monday_Time_TextBlock.Visibility = Visibility.Visible;
                        Monday_Day_TextBlock.Text        = UiTools.NumToDay(i);
                        Monday_Time_TextBlock.Text       = NannyToShow.NannyWorkingHours[i].ToString();
                        break;

                    case 2:
                        Tuesday_Day_TextBlock.Visibility  = Visibility.Visible;
                        Tuesday_Time_TextBlock.Visibility = Visibility.Visible;
                        Tuesday_Day_TextBlock.Text        = UiTools.NumToDay(i);
                        Tuesday_Time_TextBlock.Text       = NannyToShow.NannyWorkingHours[i].ToString();
                        break;

                    case 3:
                        Wednesday_Day_TextBlock.Visibility  = Visibility.Visible;
                        Wednesday_Time_TextBlock.Visibility = Visibility.Visible;
                        Wednesday_Day_TextBlock.Text        = UiTools.NumToDay(i);
                        Wednesday_Time_TextBlock.Text       = NannyToShow.NannyWorkingHours[i].ToString();
                        break;

                    case 4:
                        Thursday_Day_TextBlock.Visibility  = Visibility.Visible;
                        Thursday_Time_TextBlock.Visibility = Visibility.Visible;
                        Thursday_Day_TextBlock.Text        = UiTools.NumToDay(i);
                        Thursday_Time_TextBlock.Text       = NannyToShow.NannyWorkingHours[i].ToString();
                        break;

                    case 5:
                        Friday_Day_TextBlock.Visibility  = Visibility.Visible;
                        Friday_Time_TextBlock.Visibility = Visibility.Visible;
                        Friday_Day_TextBlock.Text        = UiTools.NumToDay(i);
                        Friday_Time_TextBlock.Text       = NannyToShow.NannyWorkingHours[i].ToString();
                        break;

                    default:
                        break;
                    }
                }
            }


            NannyToShow = new Nanny();
        }
Esempio n. 49
0
 protected internal abstract DataGridColumn CreateColumn(DataGrid dataGrid, object property);
Esempio n. 50
0
 public DataGridHelper(DataGrid view) : base(view)
 {
     view.PreparingCellForEdit += CellEditBeginning;
     view.CellEditEnding       += CellEditEnding;
 }
        public void RowBackgroundColorInit()
        {
            var dg = new DataGrid();

            Assert.IsTrue(dg.RowsBackgroundColorPalette == DataGrid.RowsBackgroundColorPaletteProperty.DefaultValue);
        }
Esempio n. 52
0
        protected void ValidateEditVariant_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            if (SessionState.User.HasCapability(Business.CapabilitiesEnum.MANAGE_RESOURCES))
            {
                if (SessionState.User.IsReadOnly)
                {
                    variantsGrid.EditItemIndex = -1;
                    return;
                }

                DataGridItem item = (DataGridItem)((System.Web.UI.WebControls.ImageButton)sender).Parent.Parent;
                if (item != null && variantsGrid.EditItemIndex == item.ItemIndex)
                {
                    Variant variant = CurrentResource.Variants[(int)variantsGrid.DataKeys[item.ItemIndex]];

                    if (variant != null)
                    {
                        DropDownList   editVariantCulture    = (DropDownList)item.FindControl("editVariantCulture");
                        DataGrid       editVariantAttributes = (DataGrid)item.FindControl("editVariantAttributes");
                        HtmlInputFile  editVariantFileValue  = (HtmlInputFile)item.FindControl("editVariantFileValue");
                        WebDateChooser editVariantBOPValue   = (WebDateChooser)item.FindControl("editVariantBOPValue");
                        WebDateChooser editVariantEOPValue   = (WebDateChooser)item.FindControl("editVariantEOPValue");

                        if (editVariantCulture != null)
                        {
                            variant.CultureCode = editVariantCulture.SelectedValue;
                        }
                        if (editVariantAttributes != null)
                        #region variant attributes
                        {
                            foreach (DataGridItem paramItem in editVariantAttributes.Items)
                            {
                                Label editVariantAttributeName = (Label)paramItem.FindControl("editVariantAttributeName");
                                if (editVariantAttributeName != null)
                                {
                                    string           attrName = editVariantAttributeName.Text;
                                    VariantAttribute attrDef  = variant.Attributes.GetAttributeDefinition(attrName);
                                    if (attrDef.UserDefined)
                                    {
                                        TextBox      editVariantAttributeBox  = (TextBox)paramItem.FindControl("editVariantAttributeBox");
                                        DropDownList editVariantAttributeList = (DropDownList)paramItem.FindControl("editVariantAttributeList");
                                        if (attrDef.PossibleValues.Count > 0 && editVariantAttributeList != null)
                                        {
                                            variant.Attributes[attrName] = editVariantAttributeList.SelectedValue;
                                        }
                                        else if (editVariantAttributeBox != null)
                                        {
                                            variant.Attributes[attrName] = editVariantAttributeBox.Text;
                                        }
                                    }
                                }
                            }
                        }
                        #endregion
                        if (editVariantFileValue != null && editVariantFileValue.PostedFile != null && editVariantFileValue.PostedFile.ContentLength > 0)
                        {
                            if (editVariantBOPValue != null && editVariantEOPValue != null)
                            {
                                //,editVariantBOPValue.Value!=null?(DateTime)editVariantBOPValue.Value:DateTime.MinValue,editVariantEOPValue.Value!=null?(DateTime)editVariantEOPValue.Value:DateTime.MaxValue);
                                if (variant.AddFile(editVariantFileValue.PostedFile.InputStream, Path.GetExtension(editVariantFileValue.PostedFile.FileName)) == null)
                                {
                                    SetMessage(propertiesMsgLbl, "Sorry, an error occured, file could not be updated.", MessageLevel.Error);
                                }
                            }
                            else if (variant.AddFile(editVariantFileValue.PostedFile.InputStream, Path.GetExtension(editVariantFileValue.PostedFile.FileName)) == null)
                            {
                                SetMessage(propertiesMsgLbl, "Sorry, an error occured, file could not be updated.", MessageLevel.Error);
                            }
                        }

                        if (variant.Save())
                        {
                            variantsGrid.EditItemIndex = -1;
                            BindVariantGrid();
                        }
                    }
                }
            }
        }
        private void BindMouseEvents(ModelUIElement3D model, Node elm)
        {
            var tagGuid = @"35DA1A20-AA6D-4436-890E-CBFA341F9E51";

            Material oldfrontm = null;
            Material oldbackm  = null;

            #region MouseEnter

            model.MouseEnter += (sender, e) =>
            {
                var tb = MainCanvas.Children
                         .Cast <UIElement>()
                         .Where(i => i is Border)
                         .Cast <Border>()
                         .FirstOrDefault(i => tagGuid.Equals(i.Tag));

                if (tb == null)
                {
                    MainCanvas.Children.Add(tb = new Border()
                    {
                        Tag = tagGuid
                    });
                    tb.Child             = new TextBlock();
                    tb.MouseMove        += (o, args) => { args.Handled = false; };
                    tb.PreviewMouseMove += (o, args) => { args.Handled = false; };
                    StyleTexblock(tb);
                }

                var tx = tb.Child as TextBlock;

                if (tx != null)
                {
                    tx.Text = "NODE: " + elm.Label;
                }


                var geo = model.Model as GeometryModel3D;

                if (geo != null)
                {
                    oldfrontm = geo.Material;
                    oldbackm  = geo.BackMaterial;

                    geo.Material = geo.BackMaterial = MaterialHelper.CreateMaterial(Brushes.Aqua);
                }
            };

            #endregion

            #region MouseMove

            model.MouseMove += (sender, e) =>
            {
                Border tb = null;

                foreach (var child in MainCanvas.Children)
                {
                    if (child is Border)
                    {
                        if (tagGuid.Equals((child as Border).Tag))
                        {
                            tb = child as Border;
                            break;
                        }
                    }
                }

                if (tb == null)
                {
                    return;
                }

                tb.Visibility = Visibility.Visible;

                var mousePos = e.GetPosition(MainCanvas);

                Canvas.SetLeft(tb, mousePos.X - tb.ActualWidth - 10);
                Canvas.SetTop(tb, mousePos.Y - tb.ActualHeight - 10);
            };

            #endregion

            #region MouseLeave

            model.MouseLeave += (sender, args) =>
            {
                Border tb = null;

                foreach (var child in MainCanvas.Children)
                {
                    if (child is Border)
                    {
                        if (tagGuid.Equals((child as Border).Tag))
                        {
                            tb = child as Border;
                            break;
                        }
                    }
                }

                if (tb == null)
                {
                    return;
                }

                tb.Visibility = Visibility.Collapsed;

                var geo = model.Model as GeometryModel3D;

                if (geo != null)
                {
                    geo.Material     = oldfrontm;
                    geo.BackMaterial = oldbackm;
                }
            };

            #endregion

            model.MouseDown += (sender, args) =>
            {
                var grd = new DataGrid();

                PropertyHelper.Populate(grd, elm);

                grd.ItemsSource = new[] { elm };

                if (DisableEditingProperties)
                {
                    grd.IsReadOnly = true;
                }

                var wnd = new Window();
                wnd.Content = grd;
                wnd.ShowDialog();
                args.Handled = true;
            };
        }
Esempio n. 54
0
 public static ScrollViewer GetScrollViewer(this DataGrid dataGrid)
 {
     return(dataGrid.Template.FindName("DG_ScrollViewer", dataGrid) as ScrollViewer);
 }
Esempio n. 55
0
 private void CutSelected([CanBeNull] DataGrid dataGrid)
 {
     CopySelected(dataGrid);
     DeleteSelected(dataGrid);
 }
Esempio n. 56
0
 public static IEnumerable GetTransposedSource(this DataGrid element)
 {
     return((IEnumerable)element.GetValue(TransposedSourceProperty));
 }
 public static Array GetArray2D(this DataGrid element)
 {
     return((Array)element.GetValue(Array2DProperty));
 }