Jump to content
Xtreme .Net Talk

thomas10001

Avatar/Signature
  • Posts

    57
  • Joined

  • Last visited

Personal Information

  • Visual Studio .NET Version
    .NET Professional
  • .NET Preferred Language
    C#

thomas10001's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. No that look like a Fibonacci number series. I need the Fibonacci Heap which is a specialized data tree storages.
  2. Where can I find an implementation of a Fibonacci Heap in C#? I have found one in C++, but it doesn't work properly for me.
  3. I just found out that I did mix up the parameters FromHbitmap(hdcMem); should've been FromHbitmap(hbitmap); and it works fine! Thanks all!
  4. PrintWindow It seems that I should use PrintWindow I found the following code that I modified a bit. public static Bitmap captureHiddenWindow(IntPtr hwnd) { Bitmap bitmap = null; // Takes a snapshot of the window hwnd, stored in the memory device context hdcMem IntPtr hdc = PlatformInvokeGDI32.GetWindowDC(hwnd); if (hdc != IntPtr.Zero) { IntPtr hdcMem = PlatformInvokeGDI32.CreateCompatibleDC(hdc); if (hdcMem != IntPtr.Zero) { Rectangle rc; PlatformInvokeGDI32.GetWindowRect(hwnd,out rc); IntPtr hbitmap = PlatformInvokeGDI32.CreateCompatibleBitmap(hdc, rc.Width, rc.Height); if (hbitmap != IntPtr.Zero) { PlatformInvokeGDI32.SelectObject(hdcMem, hbitmap); Win32.PrintWindow(hwnd, hdcMem, 0); bitmap = System.Drawing.Image.FromHbitmap(hdcMem); PlatformInvokeGDI32.DeleteObject(hbitmap); } PlatformInvokeGDI32.DeleteObject(hdcMem); } PlatformInvokeGDI32.ReleaseDC(hwnd, hdc); } return bitmap; } I added the bitmap = System.Drawing.Image.FromHbitmap(hdcMem); because I need a bitmap returned. I got an exception when I tried it due to (I guess) hdcMem was negative. What do I do wrong here? Is there another way to use the dc that I am not aware of?
  5. I need to capture the image of a hidden window. Can this be done without making it the top level window? (I have already code to capture an image of the top level window. But that involves a lot of hiding and showing windows and creates problem with flickering and that the whole area is not redrawn and I do not always capture what I want.)
  6. It sounds to me that you want to eavesdrop on the data flowing to a local process. This is going to be somewhat complicated. Example: most web Yes that is what I want to do. you will have to find what ports they are using and then passively capture the data -- which is probably not easily done in .NET. I have a software that displays the ports used. But it is possible to do? Should I listen to the port on my computer or on the remote end? Does it matter? Any hints how to do this?
  7. I want to listen (read data) from a port that is in use on my computer. How can I do this? I want to find out what is sent to my port from another server. I have tried to make simple program using sockets. But I am not able to read any data. I have also tried to connect with telnet and other software but without any result. If I want to listen to a port that is in use sending/receiving data, should I connect to my local port or to the server is one question. Even if the port is in use, shouldn't I be able to connect to it and read the data somehow?
  8. Hi I have a DataGrid with a DataSet as the DataSource. But I want to hide :cool: or supress the * row. There is a property allowNew but it seems that it is only available if the DataSource is a DataView. Is there a way to hide/supress the * row when having a DataSet as DataSource? Thomas
  9. Hi I were able to get set the keys now and having gridstyles. And my delete and add works fine. Thanks. But I am not able to supress the * row with allowNew = false. Is there something that should be set on the datagrid as well to hide/supress it? Thomas
  10. Hi Another reason I just rediscovered is that I have problem to set values (primary keys I have generated if I have datagridtablestyle attached) If I just have a plain dataset, no datagridtablestyle , I do this to set the values in the new row. DataSet ds1 = getDataSet(); BindingManagerBase myMgr = (CurrencyManager) BindingContext[ds1,tableName]; if(myMgr.Count > 0) { // This is the way to set a value in a row which has not been saved yet // and merged into the normal dataset DataRowView tempRowView = (DataRowView) myMgr.Current; if(tempRowView.IsNew) { tempRowView[columnName] = columnValue; System.Console.WriteLine(tableName+"."+columnName+" = "+columnValue); } } But when I have datagridtablestyle the above code doesn't work. I don't know how to get a DataRowView or similar if I have datagridtablestyle . If I knew how to do this I would give up the arraylist for now. Thomas
  11. Hi I have made a framework where I want to be able to use other controls than a textbox in the grid. ie comboboxes etc. I thought this is the only? way to be able to use other controls. I also do not want the empty insertion row (marked *) which I don't know how to suppress. Thomas
  12. I post a bit of the code here... I post part of the DataList and DataMapping I am using in my example in case the problem lies here. I have several int's double strings etc in my code to make it general. But here I have removed them to make the code shorter. public class DataList { private string myString1 = ""; private int myInt1 = 0; private bool isNullInt1 = true; public DataList() { } public string string1 { get {return myString1;} set {myString1 = value;} } public int int1 { get {return myInt1;} set {myInt1 = value;isNullInt1 = false;} } public bool isNullint1 { get {return isNullInt1;} } } } //----------------------------------------------------------- public class DataMapping { private StringCollection myMappingName; private StringCollection myMappingTable; private StringCollection myMappingColumn; private StringCollection myInternalName; private StringCollection myRelationName; private StringCollection myType; private ArrayList myIndex; private ArrayList dataLists; private int intUsed = 0; private int stringUsed = 0; private int myCount = 0; public ArrayList arrayList { get { return dataLists; } } public void clearDataList() { dataLists.Clear(); } public DataMapping() { this.dataLists = new ArrayList(); this.myMappingName = new StringCollection(); this.myMappingTable = new StringCollection(); this.myMappingColumn = new StringCollection(); this.myInternalName = new StringCollection(); this.myRelationName = new StringCollection(); this.myType = new StringCollection(); this.myIndex = new ArrayList(); } public int getNRelations() { return this.myRelationName.Count; } public string getRelationName(int item) { return this.myRelationName[item]; } public string getTableName(int item) { return this.myMappingTable[item]; } public void Add(string mappingName,string mappingTable,string mappingColumn,string type,string relationName) { addMapping(mappingName,mappingTable,mappingColumn,type); this.myRelationName.Add(relationName); } // mappingName a unique name for this mapping // mappingTable table to find the value // mappingColumn column in mappingTable to find value // type int or string (so far) public void Add(string mappingName,string mappingTable,string mappingColumn,string type) { addMapping(mappingName,mappingTable,mappingColumn,type); this.myRelationName.Add(""); } private void addMapping(string mappingName,string mappingTable,string mappingColumn,string type) { this.myCount++; this.myMappingName.Add(mappingName); this.myMappingTable.Add(mappingTable); this.myMappingColumn.Add(mappingColumn); this.myType.Add(type); // ie: we have "round" as the first mappingname and it is an int string internalName = ""; int index = 0; switch(type) { case "int": intUsed++; index = intUsed; internalName = "int"+intUsed; break; case "string": stringUsed++; index = stringUsed; internalName = "string"+stringUsed; break; } this.myInternalName.Add(internalName); this.myIndex.Add(index); } public string getInternalName(string mappingName) { // returns the internal name corresponding the mappingName int item = this.myMappingName.IndexOf(mappingName); return this.myInternalName[item]; } public string getMappingNameFromColumnName(string columnName) { int item = this.myMappingColumn.IndexOf(columnName); return this.myMappingName[item]; } public string getColumnName(int item) { return this.myMappingColumn[item]; } public string getInternal(int item) { return this.myInternalName[item]; } public string getMapping(int item) { return this.myMappingName[item]; } public string getType(int item) { return this.myType[item]; } public int getIndex(string mappingName) { int item = this.myMappingName.IndexOf(mappingName); int index = 0; index = (int)this.myIndex[item]; return index; } public void AddDataList() { dataLists.Add(new DataList()); } public void setValue(int row,string mappingName,int intValue) { switch(getIndex(mappingName)) { case 1: ((DataList)dataLists[row]).int1 = intValue; break; } } public void setValue(int row,string mappingName,string stringValue) { switch(getIndex(mappingName)) { case 1: ((DataList)dataLists[row]).string1 = stringValue; break; } } public int getIntValue(int row,string mappingName) { switch(getIndex(mappingName)) { case 1: return ((DataList)dataLists[row]).int1; } return 0; } public bool getIsNullInt(int row,string mappingName) { switch(getIndex(mappingName)) { case 1: return ((DataList)dataLists[row]).isNullint1; } return true; } public string getStringValue(int row,string mappingName) { switch(getIndex(mappingName)) { case 1: return ((DataList)dataLists[row]).string1; } return ""; } public int Count { get {return myCount;} } } } //----------------------------------------------------------- Code for columnstyles public void addDataMapping(string mappingName,string mappingTable,string mappingColumn,string type) { dataManager.addDataMapping(mappingName,mappingTable,mappingColumn,type); } public void addDataMapping(string mappingName,string mappingTable,string mappingColumn,string type,string relationName) { dataManager.addDataMapping(mappingName,mappingTable,mappingColumn,type,relationName); } public string getDataInternalName(string mappingName) { return dataManager.getDataInternalName(mappingName); } public void addDataGridTableStyle(DataGrid dataGrid) { gridTableStyle = new DataGridTableStyle(); gridTableStyle.DataGrid = dataGrid; gridTableStyle.HeaderForeColor = System.Drawing.SystemColors.ControlText; // if using dataMappings we have an ArrayList inside the DataMapping object // and mappingName must be "ArrayList" // otherwise mappingName is the name of tables[0] // since we then should only have one table if(this.getDataMapping().Count > 0) gridTableStyle.MappingName = "ArrayList"; else gridTableStyle.MappingName = getDataSet().Tables[0].TableName; dataGrid.TableStyles.Add(gridTableStyle); } public void addGridColumnStyle(string header,string mappingName,int width,bool readOnly,string columnType,string formatString) { DataGridTextBoxColumn column = new DataGridTextBoxColumn(); column.HeaderText = header; // check if we have dataMappings if(this.getDataMapping().Count > 0) column.MappingName = getDataInternalName(mappingName); // the the internal mapping name else column.MappingName = mappingName; // mapping name is the name itself column.Width = width; column.ReadOnly = readOnly; column.TextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.KeyDown); column.TextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.KeyUp); if(!formatString.Equals("")) column.Format = formatString; gridTableStyle.GridColumnStyles.Add(column); } //----------------------------------------------------------- Code to setup my datamapping and columnstyles for my datagrid addDataMapping("bedid","bed","bedid","int"); addDataMapping("roomid","bed","roomid","int"); addDataMapping("bedname","bed","bedname","string"); ... addDataGridTableStyle(this.grid); addGridColumnStyle("BedId","bedid",0,false,"TextBox",""); addGridColumnStyle("RoomId","roomid",0,false,"TextBox",""); addGridColumnStyle("Bed Name","bedname",80,false,"TextBox","");
  13. I have a special class (DataMapping and DataList) for GridColumnStyles I use which is general so I don't have to have a hardcoded class for the items in the grid. I don't know if the problem could be in that code. But it doesn't feel like it is there. I could had posted it here unless it wasn't that much code.
  14. I do both dm.arrayList.RemoveAt(removeAt); and this.BindingContext[ds,showTable].RemoveAt(removeAt); Is it correct that I would have to delete from the dataset as well or should it be handled automatically by the arrayList since its connected to the dataset. However before I do my Update of the dataset I have to copy the values over from my arrayList into the dataset. Is this really the correct way? Thomas
  15. Hi I have a button on my form which calls my delete method. By the way when my grid is empty the headers don't show. Even though I have initialized the variables in the class that are used in the list. I read somewhere that this was required. Maybe this has something to do with this problem?!
×
×
  • Create New...