|
Not if you write your expression properly.
We'd need to see a sample of the file.
|
|
|
|
|
Pseudo code
open the file (System.IO)
read line (System.Text)
test that it contains the YearStarting pattern in the text (System.Text or regex)
extract the first date after pattern (System.Text or regex)
store the details (System.Data)
repeat test if it is possible to have more than 1 date per line
repeat line 2 until end of file
close file
Fairly simple really
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Use a StreamReader to read the file into a List<string> or some other “collection”.
Iterate over the list looking for page start / end (e.g. form feeds or whatever).
Since you know the x,y of the date in question, count “y” lines from the top / bottom of a “page”.
Once you have the line in question, use “string” functions to get date at “x”; e.g.
// Assumes x relative to 0 and date in mm/dd/yyyy format
String strDate = line.SubString( x, 10 );
Then just convert the “string date” to a suitable format for further processing using Parse or whatever.
|
|
|
|
|
hii........plz help
by use asp.net .... if i hve one image...if i click on some color(i take as buton click event like btngreen_click) i need to change that total image to that green color..
thanqu fnds...
~@nisha~
"The work will teach you how to do it.....!!"
|
|
|
|
|
Why fiddle with the image, why not just replace the image with a green rectangle.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hummmm.....i need 2 fill with color to that total image.... bye just click on button...
|
|
|
|
|
I'm writing an application that started fine as a Windows Application using Visual c# 2008. I had problems with my PC and had to restart. Now when I try to run the program in the editor it thinks that the ouptput is a Class Library even though it is set to Windows Application under project preperties. How can I fix this?
|
|
|
|
|
Maybe your solution contains several projects and the one that you want isn't the startup project any more?
|
|
|
|
|
hello all,
i have a windows application program contains a dll and i need to decomplie this dll to modify some functions.
can any one advice me how i can do it?
please reply me quickly
best regards
Abdullah
|
|
|
|
|
As you posted this in c# forum, I assume that it's a .NET dll, and you can decompile it with Reflector: http://www.red-gate.com/products/reflector/[^]
Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
|
|
|
|
|
Member 4528123 wrote: please reply me quickly
Quickly? Ok, here are some quick options.
1) Contact the company that wrote it, and ask them to change it
2) Teach yourself how to reverse engineer (This might take a few years or more)
3) Figure out another way to solve your problem that doesn't involve decompiling someone else's code.
|
|
|
|
|
If those methods are virtual, you could always override them.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I would usually try opening it in Reflector ( + ReflexIL plugin) and then just edit the function at the IL level. Much easier that way - if you have the Reflector decompile it completely it will almost always make some mistakes, which you'd have to fix.
If someone was so silly as to use "Reflector breakers" I'd probably first try the tools from NTCore (eg using Rebel.NET to replace the function)
|
|
|
|
|
Hi Guys
Hope you can help. I'm writing a program to do a record count within an XML file
The XML file is structured as per below:
<WEBRequest>
<Request>
<BlockA>
<REC>
<CustomerNumber></CustomerNumber>
<FirstName></FirstName>
<LastName></LastName>
<Email></Email>
</REC>
</BlockA>
<BlockB>
<REC>
<FirstName></FirstName>
<LastName></LastName>
<OrderDetail></OrderDetail>
<PartType></PartType>
</REC>
<REC>
<FirstName></FirstName>
<LastName></LastName>
<OrderDetail></OrderDetail>
<PartType></PartType>
</REC>
<REC>
<FirstName></FirstName>
<LastName></LastName>
<OrderDetail></OrderDetail>
<PartType></PartType>
</REC>
</BlockB>
<BlockC>
....
....
....
....
</BlockC>
....
....
....
</Request>
What I need to do is count and output number of <REC>'s for each <Block> element and output to a cell within excel (Excel Automation is working).
E.g.
BlockA = 1 REC
BlockB = 3 REC
.
.
.
BlockM = 32 REC
I have the excel automated correctly, however, I'm afraid that my inexperience with XML is quite telling, so I dont have a clear idea on how to do the record count.
Thanks in advance!!!
Grg!
|
|
|
|
|
Using XDocument it's quite easy:
XDocument doc = XDocument.Load("YourXMLHere.xml");
var distinctBlocks = from rec in doc.Descendants()
where rec.Name.ToString().StartsWith("Block")
select rec;
var results = from rec in distinctBlocks.Descendants("REC")
select rec;
var output = (from rec in results
group rec by rec.Parent.Name into g
select new {Block = g.Key, Count = g.Count()}).ToList();
modified on Tuesday, April 27, 2010 3:55 PM
|
|
|
|
|
Thanks for Info!
I don't suppose you have the c# code?
|
|
|
|
|
GrgBalden wrote: I don't suppose you have the c# code?
That was C#(3) code.
Using XLinq => Linq to XML.
modified on Wednesday, April 28, 2010 10:33 AM
|
|
|
|
|
Hi can anyone else help with this, I'm somewhat limited to c#2 (using VS2005)??
|
|
|
|
|
here you go.
I created a dummy class that holds the Block name and the rec count:
public class BlockCount
{
private int count = 0;
public int Count
{
get { return count; }
set { count = value; }
}
private string block;
public string Block
{
get { return block; }
set { block = value; }
}
}
private void button1_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load("Abs.xml");
XmlNodeList requests = doc.GetElementsByTagName("Request");
if (requests != null && requests.Count > 0)
{
blocks = new List<BlockCount>();
foreach (XmlNode nd in requests)
{
foreach (XmlNode blck in nd.ChildNodes)
{
BlockCount c = new BlockCount();
c.Block = blck.Name;
foreach (XmlNode rec in blck.ChildNodes)
{
c.Count++;
}
blocks.Add(c);
}
}
}
dataGridView1.DataSource = blocks;
}
}
modified on Wednesday, April 28, 2010 2:11 PM
|
|
|
|
|
Thank you kindly!!!
Will give this a go tommorow!
|
|
|
|
|
i would like to achieve a checkbox on a ColumnHeader in a listview.
i have been trying for days.
i have achieved a checkbox on the right spot in the listview by virtual placing it on top.
<br />
[DllImport("user32")]<br />
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);<br />
<br />
protected override void OnHandleCreated(EventArgs e)<br />
{<br />
SetParent(_cCehckBox.Handle, Handle);<br />
base.OnHandleCreated(e);<br />
}<br />
but the visual style/effect of the header causes the checkbox to fall in the background if you hover the mouse of the header.
the Header class doesn't provide anu usefull stuff, atleast i don't see any usefull stuff.
i have bene reading alot about it and viewed many things regarding headers.
i have also been using ...
<br />
protected override void WndProc(ref Message message)<br />
{<br />
....<br />
}<br />
filtering on WM_NOTIFY for 'HDN_ITEMCHANGINGA', 'HDN_ITEMCHANGEDA', 'HDN_BEGINTRACKA', 'HDN_BEGINTRACKW'.
i used a piece of code from a project here on codeproject, virtually unchanged.
but i only get the windows handle, the other things are empty.
[StructLayout(LayoutKind.Sequential)]
private struct NMHDR
{
public IntPtr hwndFrom;
public int idFrom;
public int code;
}
base.WndProc(ref message);
*/
const int WM_NOTIFY = 0x004E;
const int HDN_FIRST = (0 - 300);
const int HDN_BEGINTRACKA = (HDN_FIRST - 6);
const int HDN_BEGINTRACKW = (HDN_FIRST - 26);
bool callBase = true;
switch (message.Msg)
{
case WM_NOTIFY:
NMHDR nmhdr = (NMHDR)message.GetLParam(typeof(NMHDR));
OnMessageNeedsSending("WM_NOTIFY " + message, Color.Black);
OnMessageNeedsSending("code: " + nmhdr.code + ", hwndFrom: " + nmhdr.hwndFrom + ", idFrom: " + nmhdr.idFrom, Color.Black);
switch (nmhdr.code)
{
case HDN_BEGINTRACKA:
OnMessageNeedsSending("HDN_BEGINTRACKA " + message, Color.Black);
break;
case HDN_BEGINTRACKW:
OnMessageNeedsSending("HDN_BEGINTRACKW " + message, Color.Black);
break;
}
break;
}
if (callBase)
{
base.WndProc(ref message);
}
}
http://www.codeguru.com/forum/showthread.php?t=352366[^]
http://www.codeguru.com/cpp/controls/listview/headercontrol/comments.php/c1057/?thread=12184[^]
A Much Easier to Use ListView[^]
is there is a why to add properties, like Controls 'xxx.Add(checkbox); ?.
Bad = knowing 2 much
modified on Tuesday, April 27, 2010 11:04 AM
|
|
|
|
|
i extented ...
[StructLayout(LayoutKind.Sequential)]
private struct NMHDR
{
public IntPtr hwndFrom;
public int idFrom;
public int code;
}
to ...
[StructLayout(LayoutKind.Sequential)]
private struct NMHDR2
{
public IntPtr hwndFrom;
public int idFrom;
public int code;
public int coder;
}
this new variable 'coder' contains numbers, like: -12, -16, -23 -320, -321, -326 -327, -530
-12 and -530 seam to be mouseover and mouseleave.
-16 and -326 seam to be mouseclick / down and mouse release.
i posted a logoutput.
http://pastebin.com/HuCk5cac[^]
anyone experienced with this?
Bad = knowing 2 much
modified on Tuesday, April 27, 2010 2:47 PM
|
|
|
|
|
this is the entire code to create a listview with a checkbox in the left upper corner of the ListView.
NM_CUSTOMDRAW seams to be the message when the mouse hover over the headers.
but i fail to keep the checkBox visible / ontop @ all time.
if you slightly hoover of the first header, the headers mousehover effect draws over the check.
anyone an idea how to prevent this?
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Listview_Colum_header_checkbox
{
class CCehckBox2 : CheckBox
{
public CCehckBox2()
{
Width = 14;
Height = 14;
}
}
class CustomChechBox2 : Control
{
readonly CCehckBox2 _chb = new CCehckBox2();
public CustomChechBox2()
{
Size = new Size(16, 16);
_chb.Location = new Point(0, 0);
Controls.Add(_chb);
}
}
class CListview2 : ListView
{
public delegate void MessageNeedsSendingCallback(string message, Color color);
public event MessageNeedsSendingCallback OnMessageNeedsSending;
private readonly CustomChechBox2 _cCehckBox = new CustomChechBox2();
private readonly ColumnHeader _header1, _header2, _header3 = new ColumnHeader();
#region PInvoke Declarations
[DllImport("User32", CallingConvention = CallingConvention.Cdecl)]
private static extern uint RealGetWindowClass(IntPtr hwnd, System.Text.StringBuilder pszType, int cchType);
[DllImport("user32")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
#endregion
public CListview2()
{
View = View.Details;
_header1 = Columns.Add("");
_header1.Width = (Location.X + 5) + 12;
_header1.Name = "CheckBox";
_header1.DisplayIndex = 0;
_header2 = Columns.Add("bah");
_header2.Width = 50;
_header3 = Columns.Add("boh");
_header3.Width = 50;
var wijd = _cCehckBox.Width;
var hoog = _cCehckBox.Height;
_cCehckBox.Location = new Point((Location.X + 5), (Location.Y + 5));
}
protected override void OnHandleCreated(EventArgs e)
{
SetParent(_cCehckBox.Handle, Handle);
base.OnHandleCreated(e);
}
[StructLayout(LayoutKind.Sequential)]
private struct NMHDR
{
public IntPtr hwndFrom;
public int idFrom;
public int code;
public int coder;
}
private const int WM_NOTIFY = 0x4E;
private const int CCM_FIRST = 8192;
private const int CCM_SETBKCOLOR = (CCM_FIRST + 1);
private const int CCM_SETCOLORSCHEME = (CCM_FIRST + 2);
private const int CCM_GETCOLORSCHEME = (CCM_FIRST + 3);
private const int CCM_GETDROPTARGET = (CCM_FIRST + 4);
private const int CCM_SETUNICODEFORMAT = (CCM_FIRST + 5);
private const int CCM_GETUNICODEFORMAT = (CCM_FIRST + 6);
private const int HDN_FIRST = (0 - 300);
private const int HDM_FIRST = 4608;
private const int HDM_HITTEST = (HDM_FIRST + 6);
private const int HDM_GETITEMRECT = (HDM_FIRST + 7);
private const int HDM_SETIMAGELIST = (HDM_FIRST + 8);
private const int HDM_GETIMAGELIST = (HDM_FIRST + 9);
private const int HDM_ORDERTOINDEX = (HDM_FIRST + 15);
private const int HDM_CREATEDRAGIMAGE = (HDM_FIRST + 16);
private const int HDM_GETORDERARRAY = (HDM_FIRST + 17);
private const int HDM_SETORDERARRAY = (HDM_FIRST + 18);
private const int HDM_SETHOTDIVIDER = (HDM_FIRST + 19);
private const int HDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
private const int HDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
private const int HDN_ITEMCHANGINGA = (HDN_FIRST - 0);
private const int HDN_ITEMCHANGINGW = (HDN_FIRST - 20);
private const int HDN_ITEMCHANGEDA = (HDN_FIRST - 1);
private const int HDN_ITEMCHANGEDW = (HDN_FIRST - 21);
private const int HDN_ITEMCLICKA = (HDN_FIRST - 2);
private const int HDN_ITEMCLICKW = (HDN_FIRST - 22);
private const int HDN_ITEMDBLCLICKA = (HDN_FIRST - 3);
private const int HDN_ITEMDBLCLICKW = (HDN_FIRST - 23);
private const int HDN_DIVIDERDBLCLICKA = (HDN_FIRST - 5);
private const int HDN_DIVIDERDBLCLICKW = (HDN_FIRST - 25);
private const int HDN_BEGINTRACKA = (HDN_FIRST - 6);
private const int HDN_BEGINTRACKW = (HDN_FIRST - 26);
private const int HDN_ENDTRACKA = (HDN_FIRST - 7);
private const int HDN_ENDTRACKW = (HDN_FIRST - 27);
private const int HDN_TRACKA = (HDN_FIRST - 8);
private const int HDN_TRACKW = (HDN_FIRST - 28);
private const int HDN_GETDISPINFOA = (HDN_FIRST - 9);
private const int HDN_GETDISPINFOW = (HDN_FIRST - 29);
private const int HDN_BEGINDRAG = (HDN_FIRST - 10);
private const int HDN_ENDDRAG = (HDN_FIRST - 11);
private const int HDN_ITEMCHANGING = HDN_ITEMCHANGINGA;
private const int HDN_ITEMCHANGED = HDN_ITEMCHANGEDA;
private const int HDN_ITEMCLICK = HDN_ITEMCLICKA;
private const int HDN_ITEMDBLCLICK = HDN_ITEMDBLCLICKA;
private const int HDN_DIVIDERDBLCLICK = HDN_DIVIDERDBLCLICKA;
private const int HDN_BEGINTRACK = HDN_BEGINTRACKA;
private const int HDN_ENDTRACK = HDN_ENDTRACKA;
private const int HDN_TRACK = HDN_TRACKA;
private const int HDN_GETDISPINFO = HDN_GETDISPINFOA;
private const int NM_FIRST = 0;
private const int NM_OUTOFMEMORY = (NM_FIRST - 1);
private const int NM_CLICK = (NM_FIRST - 2);
private const int NM_DBLCLK = (NM_FIRST - 3);
private const int NM_RETURN = (NM_FIRST - 4);
private const int NM_RCLICK = (NM_FIRST - 5);
private const int NM_RDBLCLK = (NM_FIRST - 6);
private const int NM_SETFOCUS = (NM_FIRST - 7);
private const int NM_KILLFOCUS = (NM_FIRST - 8);
private const int NM_CUSTOMDRAW = (NM_FIRST - 12);
private const int NM_HOVER = (NM_FIRST - 13);
private const int NM_NCHITTEST = (NM_FIRST - 14);
private const int NM_KEYDOWN = (NM_FIRST - 15);
private const int NM_RELEASEDCAPTURE = (NM_FIRST - 16);
private const int NM_SETCURSOR = (NM_FIRST - 17);
private const int NM_CHAR = (NM_FIRST - 18);
protected override void WndProc(ref Message message)
{
bool callBase = true;
switch (message.Msg)
{
case WM_NOTIFY:
NMHDR nmhdr = (NMHDR)message.GetLParam(typeof(NMHDR));
OnMessageNeedsSending("code: " + nmhdr.code + ", hwndFrom: " + nmhdr.hwndFrom + ", idFrom: " + nmhdr.idFrom + ", coder: " + nmhdr.coder, Color.Black);
switch (nmhdr.coder)
{
case HDN_BEGINTRACKA:
OnMessageNeedsSending("HDN_BEGINTRACKA " + message, Color.Black);
break;
case HDN_BEGINTRACKW:
OnMessageNeedsSending("HDN_BEGINTRACKW " + message, Color.Black);
break;
case HDN_ENDTRACKW:
OnMessageNeedsSending("HDN_ENDTRACKW " + message, Color.Black);
break;
case HDN_ITEMCLICKA:
OnMessageNeedsSending("HDN_ITEMCLICKA " + message, Color.Black);
break;
case HDN_ITEMDBLCLICKW:
OnMessageNeedsSending("HDN_ITEMDBLCLICKW " + message, Color.Black);
break;
case HDN_ITEMCLICKW:
OnMessageNeedsSending("HDN_ITEMCLICKW " + message, Color.Black);
break;
case HDN_ITEMCHANGINGW:
OnMessageNeedsSending("HDN_ITEMCHANGINGW " + message, Color.Black);
break;
case HDN_ITEMCHANGEDA:
OnMessageNeedsSending("HDN_ITEMCHANGEDA " + message, Color.Black);
break;
case HDN_ITEMCHANGEDW:
OnMessageNeedsSending("HDN_ITEMCHANGEDW " + message, Color.Black);
break;
case NM_HOVER:
OnMessageNeedsSending("NM_HOVER " + message, Color.Black);
break;
case NM_RELEASEDCAPTURE:
OnMessageNeedsSending("NM_RELEASEDCAPTURE" + message, Color.Black);
break;
case NM_CUSTOMDRAW:
callBase = false;
OnMessageNeedsSending("NM_CUSTOMDRAW" + message, Color.Black);
_cCehckBox.BringToFront();
_cCehckBox.Invalidate();
break;
default:
OnMessageNeedsSending("code: " + nmhdr.code + ", hwndFrom: " + nmhdr.hwndFrom + ", idFrom: " + nmhdr.idFrom + ", coder: " + nmhdr.coder, Color.Black);
break;
}
break;
}
if (callBase)
{
base.WndProc(ref message);
}
}
}
}
Bad = knowing 2 much
|
|
|
|
|
So the deeper I get into my first Windows Forms application the more I'm questioning myself. In the VB6 days I would distribute my apps with a password protected MS Access db (not very secure) and hope nobody hacked into it.
In this app. I created my MDF in MS SQL 2008, copied the mdf and ldf to my VS 2008 application directory and set up a datasource connection to it. When I view the db in VS 2008 I see all of my tables, views and sproc's but I do not see a security node or users. So does my mdf get distributed with no security? Can anyone just attach it to their local MSSQL version and open the db? If it is in fact wide open, can it be locked down or do I need a different solution?
|
|
|
|
|
It's wide open. (SQL Server 2008 R2 has an encryption option, but probably not in the express edition).
The problem is that you cannot encrypt these files, because they will be opened by the SQLServer service, running under Userid that has probably no access to the encryption keys.
If you want to encrypt your database, distribute an SQL Server Compact 3.5 database, and attach a password to it (which of course will be known to your program, and suitably obfuscated in the executable)
|
|
|
|