|
Is that true?
Thanks,
Marc
|
|
|
|
|
Thats the normal way things work.
Where would you know where to set the point, without the debug information (which is contained within the debug release) there is no way for the debugger to relate the compiled file back to the source code.
No doubt someone could/will come up with a more detailed answer but thats the gist of it.
Dave
|
|
|
|
|
How do you scroll a C# Listview vertically automatically? I am looking for something similar to what you see in SQL Server profiler..it's not very difficult to accomplish this in MFC, but in C# I can't find a ScrollWindow type of function for the Listview or anything else...
|
|
|
|
|
|
Well I am in need of a MDX function parser and do not want to reinvent the wheel.
anyone know where I can find one?
|
|
|
|
|
Hi,
I have a listView control to display some command execution results. One of the features I need to implement is to print out this control. I have been investigating on System.Drawing.Printing but not found things I could use (directly). Can someone help me out and tell me where to start it? Thank you very much!;)
|
|
|
|
|
is it help
http://www.codeproject.com/combobox/print_preview_listbox.asp
shmuelt tauber
ministry of trade
Israel
|
|
|
|
|
Interesting problem I've encountered. I'm creating an override to a TabControl as well as a TabPage.
public class MyTabControl : TabControl<br />
{<br />
...<br />
}<br />
<br />
public class MyTabPage : TabPage<br />
{<br />
...<br />
}
When I view MyTabControl inside of the property control, I can click on 'TabPages - Collection' and view the collection of TabPages.
But I want the 'Add' button to create me a MyTabPage instead of the TabPage in my overridden control.
Is there any way to tell the PropertyGrid what my overridden collection type is?
|
|
|
|
|
psdavis wrote:
When I view MyTabControl inside of the property control, I can click on 'TabPages - Collection' and view the collection of TabPages.
But I want the 'Add' button to create me a MyTabPage instead of the TabPage in my overridden control.
You will need to override the indexer ( this[] ) in your TabPageCollection derived class. Thats it. Have a look at the COllectionEditor class.
Cheers
Before you criticize a man, walk a mile in his shoes. That way, when you do criticize him, you'll be a mile away and have his shoes.
|
|
|
|
|
My problem:
There is a string contains some patterns, same as below:
<br />
expr = "(X, <OS:Size>, Z), (X, <OS:Type>, Y), (X, <OS:DateModified>, W), (X, <PDF:Title>, U)";<br />
I want to put repeated pattern "( , < >, )" to items of a string array. For example:
<br />
str[0] = "(X, <OS:Size>, Z)";<br />
str[1] = "(X, <OS:Type>, Y)";<br />
str[2] = "(X, <OS:DateModified>, W)";<br />
str[3] = "(X, <PDF:Title>, U)";
How can I implement above? Can I write the same program using Regular Expression and Match? How?
Mehdi
|
|
|
|
|
Not easily, but you could use Regex.Split(expr, "), (|(|)") to break it down to
str[0] = "";
str[1] = "X, <os:size>, Z";
str[2] = "X, <os:type>, Y";
str[3] = "X, <os:datemodified>, W";
str[4] = "X, <pdf:title>, U";
str[5] = "";
OR you could use Regex.Match to create a MatchCollection. It might be a fairly complicated Expression though, something like @"\(\S,\s\S+,\s\S\)" I dunno, I just pulled that off the top of my head. I'm not sure if a "(" can be denoted as "\(" or not. \S is non-whitespace, \S+ is multiple non-whitespace, \s is whitespace.
Paul
|
|
|
|
|
This should work:
using System.Text.RegularExpressions;
...
string expr = "(X, <OS:Size>, Z), (X, <OS:Type>, Y), (X, <OS:DateModified>, W), (X, <PDF:Title>, U)";
Regex re = new Regex("(\\([^,]*,\\s*<[^>]*>,[^)]*\\))");
MatchCollection matches = re.Matches(expr);
string[] str = new string[matches.Count];
for (int i=0; i < matches.Count; i++)
str[i] = matches[i].Value; Explanation of the regular expression:(...) - Capture the result of this expression as a match;\\(...\\) - The expression is contained within regular brackets. NB: The bracket must be escaped, since it has special meaning for regular expressions. Since this is a normal C# string, the escape character must also be escaped;[^,]*,... - Match anything except a comma zero or more times, followed by a comma;...\\s*... - Match zero or more white-space characters;...<[^>]*>,... - Match the < charcter, followed by zero or more characters which are not >, followed by >, followed by a comma;...[^)]* - Match anything except a closing bracket.
To avoid having to escape the escape characters, you could make the regular expression string a verbatim string, by prefixing it with the @ symbol:
Regex re = new Regex(@"(\([^,]*,\s*<[^>]*>,[^)]*\))");
|
|
|
|
|
I am working with some data that is being passed to me in byte[]. However, the data actually represents an array of short(s) or an array of some other value types. For example, I get an array of 8 bytes, but I need to look at it as an array of 2 int(s). There have to be some kind of way to do the conversion, but I cannot seem to think of one.
I could use some pointers...
Please let me know if you have any suggestions on what is the best way to convert byte arrays into arrays of other types.
Thank you in advance.
Kostya.
|
|
|
|
|
int[] Converter(byte[] ba)
{
int[] rtn = new int[ba.Length / 4];
int idx = 0;
foreach (int x in rtn)
{
for (int i = 0; i < 4; i++)
{
x *= 256;
x += ba[idx++];
}
}
return rtn;
}</code> UNTESTED
[edit]Forgot that return line[/edit]
Paul
|
|
|
|
|
Thank you, Paul. I have tried one of this deals (the code you have suggested) before and it does work. The problem, however, is that I will have to write one of this for each data type (at least for about 10 of them). So, I was secretly hopping that someone will know of some System.Magic.ConvertEverythingToEverything kind of things... I guess, I am not that lucky...
Thanks.
Kostya.
|
|
|
|
|
You could possibly use a class with FieldOffsetAttribute to replicate a C++ union; that might be a more flexible way of doing it.
[StructLayout(LayoutKind.Explicit)]
public class Converter
{
[FieldOffset(0)] public byte[] byteArray;
[FieldOffset(0)] public int intConverted;
[FieldOffset(0)] public string stringConverted;
} Maybe...
Paul
|
|
|
|
|
Thank you. I will look into this.
|
|
|
|
|
Konstantin Vasserman wrote:
System.Magic.ConvertEverythingToEverything kind of things... I guess, I am not that lucky...
There is one, in a way
Use the Marshal class in the following way.
1. Allocate a pointer to the size of your byte[]. Marshal.AllocHGlobal().
2. Copy the byte[] to the pointer. Marshal.Copy().
3. Copy the pointer to your selected array, eg int[] . Marshal.Copy().
4. Free the pointer. Marshal.FreeHGlobal().
Hope you get what I am saying..
Before you criticize a man, walk a mile in his shoes. That way, when you do criticize him, you'll be a mile away and have his shoes.
|
|
|
|
|
Interesting idea.
Thank you.
|
|
|
|
|
 This may not be the most efficient way of doing it, but it seems to work:
static Array ConvertByteArray(byte[] inArray, Type destType)
{
if (!destType.IsValueType)
throw new Exception("destType must be a value type!");
if (destType.IsEnum) destType = Enum.GetUnderlyingType(destType);
int iSize = System.Runtime.InteropServices.Marshal.SizeOf(destType);
if (iSize > 8)
throw new Exception("destType is too large!");
System.Diagnostics.Debug.Assert(
inArray.Length % iSize == 0,
"Invalid array length!");
Array outArray = Array.CreateInstance(
destType, inArray.Length / iSize);
for (int i=0, j=0;
i<inArray.Length && j<outArray.Length;
i += iSize, j++)
{
ulong val = 0;
for (int k=0; k<iSize && i+k < inArray.Length; k++)
val = (val * 256) + inArray[i + k];
for (int k=inArray.Length - i; k < iSize; k++)
val *= 256;
try
{
outArray.SetValue(Convert.ChangeType(val, destType), j);
}
catch (OverflowException ex)
{
ulong iMask = (ulong)Math.Pow(2, 8 * iSize - 1);
if ((val & iMask) != 0)
{
long val2;
if ((long)iMask < 0)
val2 = (long)val;
else
val2 = (long)(val & ~iMask) - (long)iMask;
outArray.SetValue(Convert.ChangeType(val2, destType), j);
}
else
throw ex;
}
}
return outArray;
}
If you know the type at compile-time, you can use:
byte[] a = new byte[6] {12, 34, 56, 78, 91, 111};
short[] b = (short[])ConvertByteArray(a, typeof(short));
This code will test the function:
static void TestConvert(Type T)
{
int tSize;
if (T.IsEnum)
tSize = System.Runtime.InteropServices.Marshal.SizeOf(
Enum.GetUnderlyingType(T));
else
tSize = System.Runtime.InteropServices.Marshal.SizeOf(T);
Random R = new Random();
int iBytes = R.Next(1, 10) * tSize;
Console.WriteLine("{0} bytes", iBytes);
byte[] a = new byte[iBytes];
for (int i=0; i<a.Length; i++)
{
a[i] = (byte)R.Next(255);
Console.WriteLine("a[{0}] = {1}", i, a[i]);
}
Array b = ConvertByteArray(a, T);
for (int i=0; i<b.Length; i++)
Console.WriteLine("b[{0}] = {1}", i, b.GetValue(i));
}
[Flags]
public enum TestEnum : byte
{
Value0 = 1,
Value1 = 2,
Value2 = 4,
Value3 = 8,
Value4 = 16,
Value5 = 32,
Value6 = 64,
Value7 = 128,
}
static void Main()
{
TestConvert(typeof(byte));
TestConvert(typeof(sbyte));
TestConvert(typeof(short));
TestConvert(typeof(ushort));
TestConvert(typeof(int));
TestConvert(typeof(uint));
TestConvert(typeof(long));
TestConvert(typeof(ulong));
TestConvert(typeof(TestEnum));
Random R = new Random();
byte[] a = new byte[4];
for (int i=0; i<4; i++)
{
a[i] = (byte)R.Next(255);
Console.WriteLine("a[{0}] = {1}", i, a[i]);
}
TestEnum[] b = (TestEnum[])ConvertByteArray(a, typeof(TestEnum));
for (int i=0; i < b.Length; i++)
Console.WriteLine("b[{0}] = {1}", i, b[i]);
}
|
|
|
|
|
Wow!
I think I can adjust your code to work with my data. My byte arrays don't come in any predefined length. It might be a byte[1] that I need to read as byte, it might be byte[8] that is int[2] or byte[16] that is uint[4] and stuff like that. Anyway, your code will help me a lot.
Thank you very much. ![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
Hi
Is there any reason why you could not update the data source in the DataTable.RowUpdated/RowDelete event functions. All the examples I've seen do the updating in another function and just use these events to (at the most) mark the grid as containing dirty data.
I don't want the user to click a button to update, I'd like it to be automatic, prompting the user if he changes or deletes a record (as these actions should be rare on the system I'm working on).
Cheers
Dave
|
|
|
|
|
Hi,
I have an application which part of its code should be done in script code in order to be modified by the user. I also should need to pass information to this script code, like instances of objects already created.
Is there any way to do it?, is there any sample or direct reference which explains it?
Thanks in advance,
Edgar
__________________________________________
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
I'm proud to announce the release of our first product Aspose.Obfuscator 1.0 on October 6, 2002! Aspose.Obfuscator is a .Net assembly obfuscator. With it, you can:
1. Obfuscate .Net Exe files while reserve all necessary names by itself
2. Obfuscate .Net Dll Files while reserve all necessary names by itself
3. Obufcate Asp.Net applications while reserve all necessary names by itself
4. Obfuscate applications whose type information is decided at runtime while reserve all necessary names by yourself
You can find more information at http://www.aspose.com and your comments or suggestions will be greatly appreciated.
Thanks,
Aspose Support Team
info@aspose.com
Aspose Pty Ltd
A .Net Component Developer
http://www.aspose.com
|
|
|
|
|
Nice cross-posting.
Who cares an obfuscator? We developers are spending most of our time trying to understand how .NET works. So obfuscation is just a useless thing to worry about.
You'd better improve your website. 15 clicks or so before I get anything shown on screen.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|