|
Could you post some code ??? so we can see what your trying to do. ?
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
I do not want that deserialization call formatter.Deserialize(ms); will result in Exception. Thus I need to check that MemoryStream ms; contains valid header which is used internally in BinaryFormatter.Deserialize() call.
Чесноков
|
|
|
|
|
Its not that simple. please provide an sample code from where you get the error. else im unable to help you.
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
It is very simple, MemoryStream contains your data for deserialization.
With MemoryStream.GetBuffer(); you may get access to underlying byte[] array.
It needs to check that in that array first bytes are valid BinaryHeader structure used inernally by BinaryFormatter during deserialization call.
If there is garbage in the MemoryStream then BinaryFormatter will throw exception. I need to avoid that exception and make sure correct data will be passed for deserialization.
Finally I found that link that resolves the issue http://primates.ximian.com/~lluis/dist/binary_serialization_format.htm[^]
Чесноков
|
|
|
|
|
dose anyone one know how to change the opacity of a picture box or anything like a buttons opacity? and still keep the background of the form at 100%?
|
|
|
|
|
It depends what you are trying to do. Are you just trying to make a control transparent? If so, take a look at this[^] article.
|
|
|
|
|
Hi In my system i has Visual Studio Team System(2008), i don't have sharepoint. My system o/s is Windows XP. I want to use SPFarm commands in my code. Here my question is without installing sharepoint is it possible to use SpFarm commands by adding the reference? will it work? Please help me. I'm very new to Sharepoint.
Very urgent for me.
Thanks in advance.
|
|
|
|
|
Please do not post your question in multiple forums.
It's time for a new signature.
|
|
|
|
|
OK, This is driving me insane. Yes I am a beginner and I am trying but this is confusing me so much.
I have the following classes...(This is a patient simulation program)
1) Form (my main form which displays an ecg etc)
2) ecg class
I would like the ecg class to be able to draw itself (ecg.Draw())
Now, I tried to create a custom panel class derived from panel, and overide the onpaint method.
But I cannot seem to initialise it with a panal control on my main form, and nothing hapens.
Am I even doing this right in the first place.
Should I pass a panel object into the constructor og my ecg class, or should i set a static member of ecg in the form control and invoke paint from here?
I am so confused!
Thank you
Steve
|
|
|
|
|
Message Closed
modified 23-Nov-14 5:56am.
|
|
|
|
|
Hi.
Thats what I am trying to do, but the onpaint method never gets called
Steve
Also,
If I do it that way, how do I add custom functions to the control?
Thank you
Steve
|
|
|
|
|
It works fine for me, so try recreating the steps I used:
1) In solution explorer, right click your project, and add a user control. Call it something sensible.
2) Highlight the new control, and open the code.
3) Change the derivation from "UserControl" to "Panel" - you don't need to do this, but WTF. If you do, compile the program, and delete the line the compiler complains about (AuoScaleMode)
4) In your new control class, add the following:
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Green, e.ClipRectangle);
}
Now, when you add your new control, it will fill itself with Green - this shows OnPaint in being called.
I would then add a Paint method to my ECG class, and hand it either e.Graphics so it can draw itself.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Hello
"I would then add a Paint method to my ECG class, and hand it either e.Graphics so it can draw itself."
Forgive, but, it is this part I am strugling with.
So do I create a class called ECGMachine, and give it a method called OnPaint()?
And how do I pass in e.graphics etc?
I am learning but still strugling with this part.
Thank you for your time,
Steve
|
|
|
|
|
Don't call it "OnPaint" - that has a specific meaning, you will find out later and don't need to worry about that now.
using System.Drawing;
using System.Windows.Forms;
public partial class ECGMachine
{
...
public void Paint(Graphics g)
{
g.FillRectangle(Brushes.Red, g.ClipBounds);
}
...
}
Replace the FillRectangle with your code...
Then in to OnPaint method for your user control / panel as previously:
...
myECGMachineINstance.Paint(e.Graphics);
...
[edit]I forgot to tell you how to call it... blame lack of coffee.[/edit]
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
OK I got that to work, however...
Once I have created the control, instead of coding its position, size etc I would like to manualy draw a panal object on the form, so how would I then "atach" the new panal to my control?
Thank you
Steve
|
|
|
|
|
Sorry for the delay - bloody work gets in the way sometimes: I mean, just because they pay you...
I'm not exactly sure what you mean. Why do you want to:
stephen.darling wrote: manualy draw a panal object on the form
and then
stephen.darling wrote: how would I then "atach" the new panal to my control
If you mean "I want to put a new panel on my form in software, rather than the designer, and then put my new control on that panel" then:
Panel p = new Panel();
p.Location = pointIWantMyPanel;
p.Size = sizeIWantMyPanel;
Controls.Add(p);
MyECGDisplayControl myECG = new MyECGDisplayControl();
myECG.Location = pointIWantMyECG;
myECG.Size = sizeIWantMyECG;
p.Controls.Add(myECG);
But to be honest you don't need the panel for that - your control can act as the panel if it is derived from Panel or UserControl.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Dear All,
I have list of date ranges (Start Date and End Date). I want to find the gap between the each item. ie;
My date range list
#. Start Date End Date
1. 1-Jan-2010 2-Jan-2010
2. 1-Jan-2010 8-Jan-2010
3. 4-Jan-2010 4-Jan-2010
4. 6-Jan-2010 8-Jan-2010
5. 9-Jan-2010 10-Jan-2010
6. 10-Jan-2010 14-Jan-2010
7. 10-Jan-2010 15-Jan-2010
8. 17-Jan-2010 18-Jan-2010
Actually i want to get the gap between adjacent items.
Expected output
GapStart GapEnd
16-Jan-2010 16-Jan-2010
But i get the following
GapStart GapEnd
05-Jan-2010 05-Jan-2010 (Not need this gap because many other items include this date range)
16-Jan-2010 16-Jan-2010
How can i filter the resultant list?
Regards,
Lalk
|
|
|
|
|
And how are you doing it right now?
I would create a dictionary (Dictionary<DateTime, bool> dates ) and fill it with all dates, that are available (in your example I would put there all dates between 1-Jan-2010 and 18-Jan-2010). Next there would be a loop over all ranges, and in this loop second loop over all dates in range. And I would set dates[currentDate] to true (where currentDate is date, that is pointed by double loop.
After those loops you have a dictionary, where false is set on dates, that aren't in any of the ranges.
Hope you get the idea.
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.
|
|
|
|
|
If u don't mind, could u please post the code scrap here.
I am using two loops and finding the difference between each date range (currentItem.StartDate - prevItem.EndDate). Then checking it with all the date renages.
|
|
|
|
|
<code>Dictionary<DateTime, bool> dates = new Dictionary<DateTime, bool>();
for(DateTime loop = Min(ranges); loop < Max(ranges); loop = loop.AddDays(1))
{
dates.Add(loop, false);
}
for(int i = 0; i < ranges.count; i++)
{
for(DateTime loop = ranges[i].Start; loop < ranges[i].End; loop = loop.AddDays(1))
{
dates[loop] = true;
}
}
Min(ranges) and Max(ranges) give minimal and maximal range start (you must create them yourself). Rest of the code should compile and work, but I didn't check them.
You will find gaps, where dates[some date] is false.
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.
|
|
|
|
|
Thanks Nowakowski. Its working fine..
|
|
|
|
|
I have simple list with point.
I need to return new list with all point that their X value is 50 -
The code :
The compile error that i get is
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<System.Drawing.Point>' to 'System.Collections.Generic.List<System.Drawing.Point>'. An explicit conversion exists (are you missing a cast?)
public static List<Point> SelectX<T>( this List<Point> PointCollection)
{
List<Point> pointCollectionSelected = new List<Point>();
pointCollectionSelected = from i in PointCollection
where i.X == 50
select i;
return pointCollectionSelected;
}
What i did wrong ?
|
|
|
|
|
Yanshof wrote: pointCollectionSelected = from i in PointCollection where i.X == 50
select i;
pointCollectionSelected = (from i in PointCollection
where i.X == 50
select i).ToList();
I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Onyx
modified on Tuesday, September 21, 2010 4:25 AM
|
|
|
|
|
Not that it answers your question, but...
0) What are you doing with the generic parameter (T)?
1) Why are you initializing pointCollectionSelected?
|
|
|
|
|
Hi All,
I need to add rows to a datagridview programaticcaly. The data in the datagridview is loaded from an xml file. I could find out by googling that, for adding data to gridview we need to add data to the dataset and refresh the datagridview. But how can I get the data from the datagridview into a dataset? how to accomplish this. Please help.
Thanks in adavance.
modified on Wednesday, September 29, 2010 8:20 AM
|
|
|
|