|
Hi there!
I am trying to compare the rows of a Datagridview and that it removes the rows that are repeated.
I think that I´m doing something wrong, need some of help!!
my mind is not clear today! (maybe x-mas holyday! )
here´s the code:
public void Compare(DataGridView grv)
{
grv.Sort(grv.Columns[0],ListSortDirection.Ascending);
for ( int row = 0; row < grv.Rows.Count; row++)
{
for ( int col = 0; col < grv.Columns.Count; col++)
{
int rowx=1;
if (grv.Rows[row].Cells[col].Value != null && grv.Rows[row].Cells[col].Value.Equals(grv.Rows[rowx].Cells[col].Value))
{
if (col == grv.Columns.Count - 1)
{
grv.Rows.RemoveAt(row);
grv.Sort(grv.Columns[0], ListSortDirection.Descending);
}
}
else
{
grv.FirstDisplayedScrollingRowIndex = grv.RowCount - 1;
grv.Rows[grv.RowCount - 1].Selected = true;
}
}
}
}
|
|
|
|
|
hi,
you forgot the a counter if all cols in a row are equal to the ones in rowx? in this case you would delete the row always if the last col is equal. Maybe thats it?
cu
|
|
|
|
|
Hi all,
Adding an optional field to my class instantly prevents older versions from being deserialized:
[OptionalField]
public Aurigma.GraphicsMill.Bitmap origStaticImage = null;
This is baffling; optional fields are supposed to PREVENT this! The [NonSerialized] attribute produces the same behavior. I have many other optional fields in this class that have been added over the years, and they work perfectly. If I remove the field, I can again deserialize older versions.
Any suggestions how to get around this? Thanks!
====================
Solved it; an exception was being thrown in my RunAfterDeserialization method, making it appear that deserialization had failed. Doh!
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
modified 6-Dec-12 11:50am.
|
|
|
|
|
Hi thanks in advance,
I really need to know is how to expose a layer of memory data on data tables that can be updated from time to time and who are available for consultation in memory for faster access and query the database to each time.
|
|
|
|
|
RICARDOR270874 wrote: I really need to know is how to expose a layer of memory data on data tables that can be updated from time to time and who are available for consultation in memory for faster access and query the database to each time.
Memory is a volatile space; loose power to the PC, you loose data.
If your database "feels" slow, I suggest you first look at the structure, rethink the indexes, partitioning. Reading data from a harddisk (not even talking SSD) is very fast, and unlikely to be the bottleneck.
If you "want" an in-memory-database, take a look at TimesTen[^].
|
|
|
|
|
I have the need to localize the ColorDialog at runtime. I know it grabs its culture from the version of Windows running on the machine.
I have an app that I allow switching the language through its configuration and it works fine to set the strings using ResourceManager class. I would like to do something similar with the ColorDialog also.
Is there any way to do it easily? I am using C# for my app.
|
|
|
|
|
I don't think there is an easy way for doing that. What I am doing is hosting this control[^] in a custom dialog and localizing that dialog.
I am sure searching this site will bring up some more information, but I am too tired to do anything else right now.
Hope this helps!
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
I have an enum definition that I wanted to put in my interface, but I'm getting a compilation error:
Mode: interfaces cannot declare types
public enum Mode
{
Off = 0,
On1 = 1,
On2 = 2
}
and the interface has a method in it that classes implementing it must define, where I want to pass the mode as a param:
int ProcessTWrit(ref Byte[] wDat, ref Byte[] sDat, ref Byte[] dataCk, int theMode);
So, I had to put separate definitions of the enum in both my El.cs and the class that it's calling through the interface.
I have my El.cs that I have also defined the enum above and want to call the above method:
result = cr.ProcessTWrit(ref wDat, ref sDat, ref dataCk, (int)Mode.On1);
My question is, is there a way that I can put my Mode enum in the interface so that the calling class and the receiving class can pass/use the enum values, so I don't have to have multiple definitions of the enum? There doesn't seem to be any other class that it would make sense for me to put the Mode definition in. This is a factory implementation. It looks like this:
El.cs =======> iCR.cs ==========================> CR5.cs
..........calls................ ProcessTWrit()................................................................ ProcessTWrit(){}
with multiple definitions of Mode in El.cs and CR5.cs. The three classes discussed above are in separate Visual Studio projects, if it makes a difference.
|
|
|
|
|
If the existing projects don't reference each other then the only other way is to create another common project (dll class library), put any common objects in there and reference the new project (after building) in the existing ones
|
|
|
|
|
MichCl wrote: class ... to put the Mode definition in
An enumeration is a type and doesn't need to be in a class. You could put the enumeration and interface definition in their own project/DLL and reference it from the others, but generally a DLL should hold more than just those two things.
|
|
|
|
|
i want to develop a small communication apps like there will be one wcf service hosted in server and one desktop client would be there. suppose two people interact in each other through wcf service. when client1 will send data to client2 then data will go to wcf service and wcf service will push the data to client2. developing basic communication application with the help of wcf service easy. i want to add one utility into our apps called screen sharing.
client1 will send his desktop screen to client2. i know it is very easy to capture desktop image and convert the whole image to byte array and then pass the byte array to client2 and client2 can convert the byte array to image and set the image to his picturebox.if i send the whole image over the network every time then performance will be bad and slow. so i need to know how people develop apps to share their screen with other and how they send minimum data over the network. i search google a lot to get actual standard though but got none.
so i request every one of this forum please discuss this issue in detail with real life concept.
My Points are
----------------
1) just tell me how could i send the difference only between two images over the network instead of sending whole image again & again. lots of image processing library available which can be use to get the difference between two images but i do not know which one is the best and would be very faster....just take few ms to get the difference between two images.
2) after extarcting difference between two images i can send the difference over the network but on the client2 side how can i apply the difference on the present image. this is very important.
3) when picturebox will be updated frequently at client2 then a flicker may be noticable. how could i avoid this flicker rather how could i achieve the smooth change over of the images on client2 side.
the way i need the help like if it would be possible then please suggest me library with code snippet which i can use to extract the difference between two images.
also tell me what routine i can use to apply the diff on the current image at client2 side.
again tell me how could i achieve the smooth change over of the images on client2 side without flickering.
lots of scholar person visit this forum every second so i would expect good discusion in detail with pesudo code in c#. thanks
tbhattacharjee
|
|
|
|
|
Tridip Bhattacharjee wrote: 1) just tell me how could i send the difference only between two images over the network instead of sending whole image again & again. lots of image processing library available which can be use to get the difference between two images but i do not know which one is the best and would be very faster....just take few ms to get the difference between two images.
Getting the "difference" could be done by comparing each pixel, and making a list of all the pixels that aren't equal. Knowing which pixels differ is not enough to recreate the second image based on the original and the differences - you'd need to know their "new" values. See here[^].
AFAIK, there's no "competition" where the graphics-libraries are compared to each other objectively. I've heard some good things on the AForge.NET open source framework[^] on the forums here, but still, you'd have to try and experiment.
Alternatively, you could do a binary diff, comparing the raw data. An image is an array of bytes after all, and comparing those might be faster.
Tridip Bhattacharjee wrote: 2) after extarcting difference between two images i can send the difference over the network but on the client2 side how can i apply the difference on the present image. this is very important.
That's the reason why most screen-sharing applications do not "send images" back and forth.
Tridip Bhattacharjee wrote: 3) when picturebox will be updated frequently at client2 then a flicker may be noticable. how could i avoid this flicker rather how could i achieve the smooth change over of the images on client2 side.
Set double buffering on.
Tridip Bhattacharjee wrote: lots of scholar person visit this forum every second so i would expect good discusion in detail with pesudo code in c#. thanks
I'm not a scholar, but I suggest you look into the RDP-protocol.
|
|
|
|
|
thanks for your discussion. you said two things very briefly which is not very clear to me.
you said
"Alternatively, you could do a binary diff, comparing the raw data. An image is an array of bytes after all, and comparing those might be faster."
can you drive me to few sample code or article from where i can know how to do binary diff on image and get the difference.
you said
"That's the reason why most screen-sharing applications do not "send images" back and forth."
if any screen sharing apps do not send image then how they send change to other end. please tell me in details whatever you know about how screen sharing apps send change to other end again and again.
i would expect good discussion on the above 2 points. thanks a lot.
tbhattacharjee
|
|
|
|
|
Tridip Bhattacharjee wrote: can you drive me to few sample code or article from where i can know how to do binary diff on image and get the difference.
Binary diff is simple to explain; you calculate the difference between two arrays of byte.
Tridip Bhattacharjee wrote: please tell me in details whatever you know about how screen sharing apps send change to other end again and again.
http://en.wikipedia.org/wiki/Remote_Desktop_Protocol[^]
Tridip Bhattacharjee wrote: i would expect good discussion on the above 2 points.
Why?
|
|
|
|
|
What i am trying to achieve is to select multiple folders and files simultaneously from the OpenFileDialog.
The suggested solution of setting :
OpenFileDialog.Multiselect = true;
OpenFileDialog.ValidateNames = false;
OpenFileDialog.CheckFileExists = false;
OpenFileDialog.CheckPathExists = true;
OpenFileDialog.FileName = "Dummy";
OpenFileDialog.Filter = string.Empty;
fails for the use case when user selects a folder and a file simultaneously.
I am looking for a solution via which i can close the dialog when user presses the open button and get the path for the selected file(s) and folder(s).
|
|
|
|
|
OpenFileDialog is used to get file names, not folders. If the user clicks a folder then it will open that folder and display the files held therein.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I know that, that's why i am asking if anyone has extended its functionality to multiple selection of folder and files simultaneously
|
|
|
|
|
It'd be easier and faster to create your own form, fill a listbox, and return the selection.
|
|
|
|
|
You could have tried searching the CodeProject articles: I found Example for FolderBrowserDialog in C#[^] in a couple of seconds.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
can anyone tell me how to bring picturebox in motion like marquee in html i,m new in omage processing/
|
|
|
|
|
You just use a timer and display a sequence of images at regular intervals. For a simple marquee you just need to repaint the text at a different position on the screen each time, starting from one side.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
PictureBox[^] offers a lot of functionality that is totally useless for your purpose. Its purpose is to show a picture, or series of pictures, with minimal effort from your side.
If you want to draw anything programatically, use a Panel[^] or derive a class from System.Windows.Forms.Control[^].
Ciao,
luker
|
|
|
|
|
Hi,
I have crl file and it has some information, such as Valid form 02.11.2012, Next update 02.01.2013, and ect. I need to get this two datetime, and compare with real time (DateTime.Now) and when it will be 31.12.2012 (2 days before) send email to admins.
How to get this data from crl file. I find WinCrypt32
public static class WinCrypt32
{
#region APIs
[DllImport("CRYPT32.DLL", EntryPoint = "CryptQueryObject", CharSet = CharSet.Auto, SetLastError = true)]
public static extern Boolean CryptQueryObject(
Int32 dwObjectType,
IntPtr pvObject,
Int32 dwExpectedContentTypeFlags,
Int32 dwExpectedFormatTypeFlags,
Int32 dwFlags,
IntPtr pdwMsgAndCertEncodingType,
IntPtr pdwContentType,
IntPtr pdwFormatType,
ref IntPtr phCertStore,
IntPtr phMsg,
ref IntPtr ppvContext
);
[DllImport("CRYPT32.DLL", EntryPoint = "CertFreeCRLContext", SetLastError = true)]
public static extern Boolean CertFreeCRLContext(
IntPtr pCrlContext
);
[DllImport("CRYPT32.DLL", EntryPoint = "CertNameToStr", CharSet = CharSet.Auto, SetLastError = true)]
public static extern Int32 CertNameToStr(
Int32 dwCertEncodingType,
ref CRYPTOAPI_BLOB pName,
Int32 dwStrType,
StringBuilder psz,
Int32 csz
);
[DllImport("CRYPT32.DLL", EntryPoint = "CertFindExtension", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr CertFindExtension(
[MarshalAs(UnmanagedType.LPStr)]String pszObjId,
Int32 cExtensions,
IntPtr rgExtensions
);
[DllImport("CRYPT32.DLL", EntryPoint = "CryptFormatObject", CharSet = CharSet.Auto, SetLastError = true)]
public static extern Boolean CryptFormatObject(
Int32 dwCertEncodingType,
Int32 dwFormatType,
Int32 dwFormatStrType,
IntPtr pFormatStruct,
[MarshalAs(UnmanagedType.LPStr)]String lpszStructType,
IntPtr pbEncoded,
Int32 cbEncoded,
StringBuilder pbFormat,
ref Int32 pcbFormat
);
#endregion APIs
#region Structs
[StructLayout(LayoutKind.Sequential)]
public struct CRYPT_OBJID_BLOB
{
public uint cbData;
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)]
public byte[] pbData;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct CERT_PUBLIC_KEY_INFO
{
public CRYPT_ALGORITHM_IDENTIFIER Algorithm;
public CRYPTOAPI_BLOB PublicKey;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CERT_EXTENSION
{
[MarshalAs(UnmanagedType.LPStr)]
public string pszObjId;
public bool fCritical;
public CRYPTOAPI_BLOB Value;
}
[StructLayout(LayoutKind.Sequential)]
public struct CERT_CONTEXT
{
public uint dwCertEncodingType;
public IntPtr pbCertEncoded;
public uint cbCertEncoded;
public IntPtr pCertInfo;
public IntPtr hCertStore;
}
public struct CERT_INFO
{
public int dwVersion;
public CRYPTOAPI_BLOB SerialNumber;
public CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
public CRYPTOAPI_BLOB Issuer;
public FILETIME NotBefore;
public FILETIME NotAfter;
public CRYPTOAPI_BLOB Subject;
public CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo;
public CRYPTOAPI_BLOB IssuerUniqueId;
public CRYPTOAPI_BLOB SubjectUniqueId;
public int cExtension;
public CERT_EXTENSION rgExtension;
}
[StructLayout(LayoutKind.Sequential)]
public struct CRL_CONTEXT
{
public Int32 dwCertEncodingType;
public IntPtr pbCrlEncoded;
public Int32 cbCrlEncoded;
public IntPtr pCrlInfo;
public IntPtr hCertStore;
}
[StructLayout(LayoutKind.Sequential)]
public struct CRL_INFO
{
public Int32 dwVersion;
public CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm;
public CRYPTOAPI_BLOB Issuer;
public FILETIME ThisUpdate;
public FILETIME NextUpdate;
public Int32 cCRLEntry;
public IntPtr rgCRLEntry;
public Int32 cExtension;
public IntPtr rgExtension;
}
[StructLayout(LayoutKind.Sequential)]
public struct CRYPT_ALGORITHM_IDENTIFIER
{
[MarshalAs(UnmanagedType.LPStr)]
public String pszObjId;
public CRYPTOAPI_BLOB Parameters;
}
[StructLayout(LayoutKind.Sequential)]
public struct CRYPTOAPI_BLOB
{
public Int32 cbData;
public IntPtr pbData;
}
[StructLayout(LayoutKind.Sequential)]
public struct FILETIME
{
public Int32 dwLowDateTime;
public Int32 dwHighDateTime;
}
[StructLayout(LayoutKind.Sequential)]
public struct CRL_ENTRY
{
public CRYPTOAPI_BLOB SerialNumber;
public FILETIME RevocationDate;
public Int32 cExtension;
public IntPtr rgExtension;
}
#endregion Structs
#region Consts
public const Int32 CERT_QUERY_OBJECT_FILE = 0x00000001;
public const Int32 CERT_QUERY_OBJECT_BLOB = 0x00000002;
public const Int32 CERT_QUERY_CONTENT_CRL = 3;
public const Int32 CERT_QUERY_CONTENT_FLAG_CRL = 1 << CERT_QUERY_CONTENT_CRL;
public const Int32 CERT_QUERY_FORMAT_BINARY = 1;
public const Int32 CERT_QUERY_FORMAT_BASE64_ENCODED = 2;
public const Int32 CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED = 3;
public const Int32 CERT_QUERY_FORMAT_FLAG_BINARY = 1 << CERT_QUERY_FORMAT_BINARY;
public const Int32 CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED = 1 << CERT_QUERY_FORMAT_BASE64_ENCODED;
public const Int32 CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED = 1 << CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED;
public const Int32 CERT_QUERY_FORMAT_FLAG_ALL = CERT_QUERY_FORMAT_FLAG_BINARY | CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED | CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED;
public const Int32 X509_ASN_ENCODING = 0x00000001;
public const Int32 PKCS_7_ASN_ENCODING = 0x00010000;
public const Int32 X509_NAME = 7;
public const Int32 CERT_SIMPLE_NAME_STR = 1;
public const Int32 CERT_OID_NAME_STR = 2;
public const Int32 CERT_X500_NAME_STR = 3;
public const String szOID_CRL_REASON_CODE = "2.5.29.21";
public enum Disposition : uint
{
CERT_STORE_ADD_NEW = 1,
CERT_STORE_ADD_USE_EXISTING = 2,
CERT_STORE_ADD_REPLACE_EXISTING = 3,
CERT_STORE_ADD_ALWAYS = 4,
CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES = 5,
CERT_STORE_ADD_NEWER = 6,
CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES = 7,
}
[Flags]
public enum FindFlags : int
{
CRL_FIND_ISSUED_BY_AKI_FLAG = 0x1,
CRL_FIND_ISSUED_BY_SIGNATURE_FLAG = 0x2,
CRL_FIND_ISSUED_BY_DELTA_FLAG = 0x4,
CRL_FIND_ISSUED_BY_BASE_FLAG = 0x8,
}
public enum FindType : int
{
CRL_FIND_ANY = 0,
CRL_FIND_ISSUED_BY = 1,
CRL_FIND_EXISTING = 2,
CRL_FIND_ISSUED_FOR = 3
}
#endregion
}
How to use it and get the necessary information?
|
|
|
|
|
You can use the DateTime.TryParse() [^] method to convert your strings, and then use the other methods of the DateTime class to perform your calculations.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
A "Certificate Revocation List"?
It seems that you already have an answer on your question in Q&A. Was it not satisfactory?
|
|
|
|
|