|
Can anybody help me convert this delphi code to vb .net or c#... tnx in advance... basically, what it does is compress data...
//Ex: '3F045F188888888867A' >> 3F045F1{89}67A
procedure BinToHexCompact(BinBuffer, HexCompBuffer: PChar; Const HexaSize, BinSize: Integer);
implementation
Uses Classes, SysUtils, PhUtils, PhRaise;
Const
Start_digit = '{';
End_digit = '}';
MinDigitsCompact = 5;
procedure BinToHexCompact(BinBuffer, HexCompBuffer: PChar; Const HexaSize, BinSize: Integer);
Var
LenH: Integer;
L: Integer;
H, HR: String;
Begin
Try
FillChar(HexCompBuffer[0],HexaSize, 0);
If (BinSize = 0) Then Exit;
LenH:= LenBuffer(BinBuffer[0], BinSize) Shl 1;
If (LenH = 0) Then Exit;
SetLength(H, LenH);
FillChar(H[1],LenH, 0);
BinToHex(BinBuffer, pChar(H), LenH shr 1);
HR:= CompacteBytesStr(pChar(H));
If (Length(HR) > HexaSize) Then ErrDevel(AEIP, 'PhUtils.BinToHexCompact, HexaSize trop petit');
Move(HR[1], HexCompBuffer[0], Length(HR));
Finally
H:= '';
HR:= '';
End;
End;
function CompacteBytesStr(Const BytesStr: pChar): String;
function isComp(pS: pChar): Boolean;
Var
i: Integer;
D0: Char;
Begin
Result:= False;
If (StrLen(pS) < MinDigitsCompact) Then Exit;
D0:= pS[0];
For i:= 1 To MinDigitsCompact - 1 Do
Begin
If (pS[i] <> D0) Then Exit;
End;
Result:= True;
End;
Var
i: Integer;
DigitStart, Digit: Char;
HasBeginDigit: Boolean;
DigitCount: Integer;
iLen: Integer;
R: String;
Begin
Result:= BytesStr;
iLen:= StrLen(BytesStr);
If (iLen = 0) Then Exit;
Dec(iLen);
If (iLen + 1 < MinDigitsCompact) Then Exit;
R:= '';
i:= 0;
DigitCount:= 0;
HasBeginDigit:= False;
DigitStart:= #0;
Repeat
If (i > iLen) Then Break;
Digit:= BytesStr[i];
If (i = iLen) Then
Begin
If HasBeginDigit Then
Begin
If (DigitCount > 0)
Then R:= R + IntToStr(DigitCount) + End_digit
Else R:= R + End_digit;
HasBeginDigit:= False;
DigitCount:= 0;
End Else R:= R + BytesStr[i];
End else If not HasBeginDigit And isComp(BytesStr + i) Then
Begin
HasBeginDigit:= True;
R:= R + Start_digit + Digit;
DigitStart:= Digit;
DigitCount:= - 1;
End Else If HasBeginDigit And (BytesStr[i + 1] = DigitStart) Then Inc(DigitCount)
Else If HasBeginDigit Then
Begin
If (DigitCount > 0)
Then R:= R + IntToStr(DigitCount) + End_digit
Else R:= R + End_digit;
HasBeginDigit:= False;
DigitCount:= 0;
DigitStart:= #0;
End Else R:= R + Digit;
Inc(i);
Until False;
Result:= R;
End;
end.
|
|
|
|
|
This looks fairly simple code to translate, except a few functions like "BytesStr[i]" and others witch I don't know how to replace...
In C# there are no submethods or global variables, so you need to place the whole thing into a class and seperate the method into 3 methods. The main thing doing that is to get right with the variables that are used in submethods in a main method.
<br />
public class Compact<br />
{<br />
private char startdigit;<br />
private char enddigit;<br />
...<br />
public void BinToHexCompact(...);<br />
public string CompacteBytesStr(...);<br />
public bool isComp(...);<br />
...<br />
}<br />
|
|
|
|
|
Is it possible to detect whether or not you are running from an NGEN'ed assembly or not?
I ask because as a side-effect of an NGEN experiment, I found that I can NGEN a running application without any problems.
Given that my assembly runs a bit faster NGEN'ed than not, I'd like to detect whether or not the .NET Framework has detected that my assembly is no longer NGEN'ed, and if it is not, NGEN it for next time the assembly is launched.
While the NGEN executable is able to detect whether or not your assembly has been NGEN'ed and does a quick exit if it has, I don't want to waste the cycles creating the process if I don't have to.
|
|
|
|
|
hi friends,
I have an existing crystal report with data (abc.rpt) in the server. I created a webfom in C# and if a link is clicked this report has to be displayed in the browser.It's working fine with the visual studio.net environment.
But i want to work this in the .NET frame work only.
I copied the application's .dll ,aspx pages and abc.rpt file to a system which have the .net framework installed.
I copied the CrystalDecisions.web.dll and CrystalDecisions.shared.dll to the bin folder.
When i clicked on the link in the aspx page, the error was "null reference exception-object reference not set to an instance of an object
CrystalDecisions.Web.CrystalReportViewer.OnInit(EventArgs e)".
1)Need i to copy any other dlls to bin folder?
2)Need i to register any controls?
Vipin k.mathews
|
|
|
|
|
Hello,
I want to establish the comunication between my application and the server in two diferent ways:
In one scenario, by compressing and encrypting the information. In the other one, only by executing a standard remoting call.
I thought to define two diferent tcp channels, but I don't know how to address the request through the right channel.
Any idea?
Thanks.
Ivan Fernandez
|
|
|
|
|
<sources xmlns="http://www.microsoft.com/ObjectSpaces-v1">
the question is how can i add the username and password. i've tried two methods:
1 Data Source=username:password@192.168.0.51
2 Data Source=192.168.0.51; user=username; password=password;
but neither of them works ,anyone can help me ,thanks!
P.S:The ObjectSpaces ,which i used,was published in 2002 and is in the namespace:Microsoft.ObjectSpaces
|
|
|
|
|
There is a blank area at the top of your post. Did you post XML or text containing <s and >s?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event[^].
|
|
|
|
|
sorry!
Below is what i want to post:
I can't connect to the database which requires the username and password. The connect.xml which i used is :
source name="Example" adapter="sql" connection="Data Source=LocalHost; Integrated Security=SSPI; Database=Northwind"/
the question is how can i add the username and password. i've tried two methods:
1 Data Source=username:password@192.168.0.51
2 Data Source=192.168.0.51; user=username; password=password;
but neither of them works ,anyone can help me ,thanks!
P.S:The ObjectSpaces ,which i used,was published in 2002 and is in the namespace:Microsoft.ObjectSpaces
|
|
|
|
|
source name="Example" adapter="sql" connection="Data Source=LocalHost; Integrated Security=SSPI; Database=Northwind"/
you need:
source name="Example" adapter="sql" connection="Data Source=LocalHost;
User id=sa;password=pw; Integrated Security=; Database=Northwind"/
|
|
|
|
|
I'm trying to find a method for denormalising a unicode string. In other words I want to take a string that contains accented characters and split it up into the letter and the accent. For example:
ç becomes c + ¸ (the cedilla)
ñ becomes n + ~ (the tilde)
This is because I want to compare two characters but the comparison must be accent insensitive and case insensitive. So u==U==ú==Ú==ü==Ü for instance.
The Compare method on the CultureInfo class doesn't appear to work the way I expected. If there is anything in the .NET Framework that can do this then that would be the best solution.
Any help would be great, thanks.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event[^].
|
|
|
|
|
Just to answer my own quesion:
I need to use the invarient culture. See the following example:
using System;
using System.Globalization;
namespace AccentInsensitive
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
CultureInfo ci = CultureInfo.InvariantCulture;
string s1 = "aA eE iI oO uU";
string s2 = "áÁ éÉ íÍ óÓ úÚ";
for (int i = 0; i<s1.Length; i++)
{
string cmp1 = new string(s1[i],1);
string cmp2 = new string(s2[i],1);
int res = ci.CompareInfo.Compare(cmp1, cmp2,
CompareOptions.IgnoreNonSpace |
CompareOptions.IgnoreCase);
if (res < 0)
Console.WriteLine("{0} < {1}", cmp1, cmp2);
else if (res > 0)
Console.WriteLine("{0} > {1}", cmp1, cmp2);
else
Console.WriteLine("{0} = {1}", cmp1, cmp2);
}
Console.ReadLine();
}
}
}
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event[^].
|
|
|
|
|
Hi all
Is posible make AppBar using .NET ?
|
|
|
|
|
Do you mean under "AppBar" a special toolbar that can dock at any desktop edge ? In that case I see no reason why not. As far as I know, it basicly just a form-like control that is stretched to a desktop edge. The only problem could be how the desktop size is reduced (so that icons would not get under the appbar), I think that is managed through a Win32 API call (in that case you should be able to import the dll that contains the functions, and if not, just make it auto-hideable).
|
|
|
|
|
Yes. This is managed through a Win32 API call, but API demand special combination of windows styles and extended styles. If yuo make ToolBar look window from Form, and then take windw extended style, you got 0 (but need WS_EX_TOOLWINDOW)
|
|
|
|
|
I've heared people talking about these hashtables a lot but I don't know what are they for (what are they good for). From the System.Collections.Hashtable namespace I can see it's some kind of collection. Could anyone please fill me up on this ?
Regards, Desmond
|
|
|
|
|
Hi Desmond. A hashtable is a collection object which contains items in key/value pairs. The keys function as indexes, and through them relatively fast searches are supported. Make sure you look at the examples in the .NET Framework documentation.
Here's a link to a W3Schools tutorial[^]
on hashtables you may find helpful.
|
|
|
|
|
hi forum,
I am going to work in a project related with electronic signature. The project (which is not well defined yet) must be developed with the Microsoft .NET technology. Really i don´t know anything about .net technology, so my question is:
Is MS .Net technology "especially helpful" in the development of this kind of applications?
...and if is possible, Could you give me any link/article/book which talks about this issue?
a lot of thanks and sorry for my poor english.
bye.
|
|
|
|
|
|
My C# project Form is splitted into two parts,
the left side is a tree view,
the right side is a PictureBox.
I want to design a function,
When I click the menu button <new_page>,
A new PictureBox will appear,
like the MDI Form does.
How to new a PictureBox like that...??
or there are other better solutions...??
My original PictureBox's image must be saved,
so I can't just change it's image,
But if I want to new many pages,
New many PictureBoxes doesn't seem to a good way...??
Please give me a hand,thanks a lot!!
|
|
|
|
|
you can save the picture and then load the new one
to save:
System.Drawing.Image img = pictureBox1.Image;
img.Save(path, ImageFormat);
to load a new one:
System.Drawing.Image img2 = System.Drawing.Image.FromFile(path);
pictureBox1.Image = img2;
|
|
|
|
|
A quick side note:
if you only need the images to be saved during run-time (i.e. for GUI purposes) you can also
crate a list or array of System.Drawing.Image just to keep them in memory,
this could save you the usage of files, which you should afterwards clean up, might be easier.
Fade (Amit BS)
|
|
|
|
|
I am trying to write programme code in Visual Studio.Net to make a btn return different values if clicked more than once.Eg the button I am trying to write code for would be similar to one found on a mobile phone, ie it can enter both numerical and alphabetical characters.
For example if the button contained the digit 2 as well as the letters abc, Clicking a button for the first time causes the first letter of the sequence to be added to a string (a). Rapid clicking should advance within the sequence ie, 2 clicks causes the second letter to be entered (b), 3 clicks causes the 3 letter (c). After reaching the end of the sequence, the sequence restarts (a). Selecting a letter from a sequence must be completed within 1 second otherwise the sequence restarts(a).
What I cannot work out is the code required to measure the time in between clicks and the function description to indicate a button has been clicked more than once or multiple times.
|
|
|
|
|
a.
For the time monitoring you should use the System.Timers.Timer Class.
create a timer object
System.Timers.Timer BtnTimer
and set the interval to 1000 (1 second)
NOW-
use something like flag (BOOL blDuringClick; ) that will determine whether you are during a 'rapid' click time, on the button's click event set blDuringClick = True and use BtnTimer.stop and then BtnTimer.Start (so each click resets the timer), and on the Elapsed event for the timer set blDuringClick = False
now when you handle click events check if you are during the rapid click by checking blDuringClick 's value.
b.
For checking the character,
there are many ways to do it, maybe the easiest one is to have a string for each button holding something like "2ABCabc" and then cycle through the chars (hold an index, and remember to check bounds).
Fade (Amit BS)
|
|
|
|
|
today i installed VS.Net and after that i downloaded some code samples from microsof's site, and when i try to open the sample project, a message comes and says, "Your project file version is '7.10'. Visual Studio .NET can only load version 7.0 project files".
how can i get the higher version ...? is it available like a patch/update..????
I want to change Myself..Can u help me?
|
|
|
|
|
I guess, you are using visual studio version 2002 (7.0 as it says), and the sample files are for the VS.NET version 2003 (7.1).
renjith_sree wrote:
ow can i get the higher version ...? is it available like a patch/update..????
It comes as separate pack of CDs (6), you may have to buy them as separate package
There is nothing new under the sun, But there are lots of old things we don't know. - Ambrose Bierce
|
|
|
|