|
|
Show us the code you used.
Jon Sagara
As you may presently yourself be fully made aware of, my grammar sucks.
Sagara.org | Blog | My Articles
J.O.N.S.A.G.A.R.A.: Journeying Operational Neohuman Skilled in Assassination, Galactic Analysis and Rational Astrophysics
|
|
|
|
|
I created a smart document that creates a list of students in word. This information comes from a custom API exposed by a .NET application I made.
All seems ok, except: I can't get the security right for the document, it keeps telling me my security settings are wrong and I don't have the full trust policy on my assembly.
I checked everything:
- I have a zone Office_Projects
- I have a specific zone for my <docname>_bin with execution rights
- I have a specific zone for my <docname>.dll inside the bin folder that has fulltrust.
Still it doesn't work. Anyone have had this problem before and can tell me more about this issue?
WM.<br>
<b>What about weapons of mass-construction?</b>
-- modified at 9:48 Friday 16th September, 2005
|
|
|
|
|
Hi
I want to create a page where someone can view if someone has been seen within a week or not with 2 buttons on the page, 1 to click which will display records of people who were which will show results in a datagrid and another button to show which was not and to show in a datagrid.
The way the system works now is someone fills out an initial form which populates the data in a table below and the date of submission is recorded:
Initial Referral table
RefID int 4 0
Base varchar 150 0
CustNumber int 4
ReasonForAppointment varchar 50
TimeSpent varchar 50
Contact varchar 50 0
CustomerType varchar 50
Comments varchar 2000
DateSubmitted datetime 8
Then someone else will need to follow up the referral from another form and the following is added and date of submission recorded:
Follow up table
FollowUpID int 4
RefID int 4 0
AdditionalInfo varchar 2000
Point1 bit 1
Point2 varchar 2000
DateToBeCompleted datetime 8
ClientSeen bit 1
DateSubmitted datetime 8
I have the form pages all done, it is just this page i am having a problem with so it can calculate if the dates are longer or shorter than the 2 dates from the two tables and fill the datagrid with the right results.
Any hints or points in the right direction will be appreciated.
Cheers
|
|
|
|
|
How do I convert an array of objects to an array of bytes?
I don't know how to do it the old way like in C, get the address of and the size of the object and then save it to a file...
Niklas Ulvinge aka IDK
|
|
|
|
|
If you're just wanting to serialize the array, the following should work (generically, for any binary serializable type):
using System;
using System.Runtime.Serialization.Formatters.Binary;
namespace SomeStuff
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string[] foo = new string[3]{"a", "b", "c"};
byte[] bytes = BinaryConverter.SerializeThis(foo);
string[] newFoo = (string[])BinaryConverter.DeserializeThat(bytes);
foreach(string s in newFoo)
Console.WriteLine(s);
Console.ReadLine();
}
}
class BinaryConverter
{
private BinaryConverter(){}
public static object DeserializeThat(byte[] bytes)
{
object graph = null;
if (bytes != null && bytes.Length > 0)
{
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream stream = new MemoryStream(bytes);
graph = formatter.Deserialize(stream);
stream.Close();
}
return graph;
}
public static byte[] SerializeThis(object graph)
{
byte[] bytes = null;
if (graph != null)
{
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
formatter.Serialize(stream, graph);
bytes = stream.GetBuffer();
stream.Close();
}
return bytes;
}
}
}
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
I don't know what to serilize an array is but you forget to include
using System.IO;
And I got some errors wich I fixed with making the class I used [Serializable]
I really just want to save the data to a file...
And after a little fixing it worked. Thanks
Niklas Ulvinge aka IDK
|
|
|
|
|
I got an error. If I saved an array of 8 objects it loads 9 and the last one is null.
That's bad.
Niklas Ulvinge aka IDK
|
|
|
|
|
That's not a lot to go on. I have no idea what your source code looks like. If you'd like to include it (code that builds the array, serializes it and deserializes it, along with the type you're trying to serialize in the array), I can have a look.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
It's huge... I'll only post some parts of it...
The code for each class is huge, I hope the structure is enough
Item.cs:
namespace NiklasUlvinge.ChipsEater
{
[Serializable]
abstract class Item
[Serializable]
class Void : Item
[Serializable]
class Cord : Item
[Serializable]
class Ground : Item
[Serializable]
class theGround : Item
...
}
form1.cs:
namespace NiklasUlvinge.ChipsEater
{
public partial class Form1 : Form
{
#region FileHandling
private void OpenFile_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog(this);
FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read, FileShare.None);
byte[] data = new byte[fs.Length];
fs.Read(data, 0, (int)fs.Length);
items = (Item[])BinaryConverter.DeserializeThat(data);
fs.Flush();
fs.Close();
SetParent();
PB.Refresh();
}
private void SaveFile_Click(object sender, EventArgs e)
{
saveFileDialog1.ShowDialog(this);
FileStream fs = new FileStream(saveFileDialog1.FileName, FileMode.Create, FileAccess.Write, FileShare.None);
byte[] data = BinaryConverter.SerializeThis(items);
fs.Write(data, 0, data.Length);
fs.Flush();
fs.Close();
}
#endregion
private void toolStripButtonClear_Click(object sender, EventArgs e)
{
items = new Item[1] { new theGround(items) };
SetParent();
PB.Refresh();
}
private void addItem(Item item)
{
Item[] titem = new Item[items.Length + 1];
for (int i = 0; i < items.Length; i++)
{
titem[i] = items[i];
}
titem[items.Length] = item;
items = titem;
SetParent();
if (item.x - PB.Width > hScrollBar1.Maximum)
hScrollBar1.Maximum = item.x - PB.Width;
if (item.y - PB.Height > vScrollBar1.Maximum)
vScrollBar1.Maximum = item.y - PB.Height;
}
private Item getItem(int x, int y)
{
for (int i = 0; i < items.Length; i++)
{
if (Math.Abs(items[i].x - x) < items[i].Width)
if (Math.Abs(items[i].y - y) < items[i].Height)
if (items[i].GetType() != new Cord(-50, -50, items).GetType())
return items[i];
}
return null;
}
public void SetParent()
{
for (int i = 0; i < items.Length; i++)
{
items[i].parent = items;
}
}
}
}
Hope this was enough, I only included the most neccesary parts...
Niklas Ulvinge aka IDK
|
|
|
|
|
I can't really tell for sure, but my guess would be that in your addItem method you're creating an array where the last item (set to the value of the 'item' parameter) is null.
Have you inserted a breakpoint in your code just prior to serialization (in SaveFile_Click ) to inspect your array and ensure that the length is what you expect it to be, and that all the elements in the array are non-null?
If you want, just email the source to me.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
-- modified at 12:42 Saturday 17th September, 2005
|
|
|
|
|
I couldn't find any error in the any of the file funcs...
I then made some UI improvements and now the error is gone!
Thank you for your help.
It's a circuit simulator, but it's not that good yet. It got some foults... It's the Kirchkorvs (or whatever he's called, I can't remember) rule that's not working as it should.
turbochimp wrote:
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
That's funny...
Niklas Ulvinge aka IDK
|
|
|
|
|
I wasn't really aiming at providing you with a completed application - just some sample code.
If you don't know what serialization is, I would suggest reading about it before using it - it's in the MSDN documentation under "Serialization".
Glad to have helped.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi
I'me working on a tapi project with tapi3.dll. I successfully created calls with ITAddress etc. Now I tried to call the method TranslateAddress from the class ITAddressTranslation, which is an abstract class. Unfortunately without success.
Now the question: Does anybody know how I can use this method? How do I have to instantiate the class ITAddressTranslation in order to get this method?
Thanks Fredy
|
|
|
|
|
hi,can anyone tell me a way of voice chat in c#,i will be very thankful to u.
|
|
|
|
|
Hi,
I want to filter the rows of the DataTable using the DataTables's Select() method.
I have a DataTime column in the DataTable. My Search Criteria should check that
DateTime Column's Hour value with the present System Time's Hour value
and
DateTime Column's Minute value with the present System Time's Minute value.
What functions/methods can i specify to extract the Hour, Minute from the DateTime column of the DataTable?
The following is the code:
string lstr = string.Empty;
lstr = "datename(hh,getdate())= datename(hh,schedule_time) and datename(mi,getdate())= datename(mi,schedule_time)";
DataRow[] dr = mds.Tables[0].Select(lstr);
Thanks in advance.
-- modified at 6:50 Friday 16th September, 2005
|
|
|
|
|
hey all,
am getting image using SHGetFileInfo for form Image, but when i put it onto a toolbarbutton i get black where it should be transparent.
i tried to convert to bitmap before putting icon into the imagelist but still no good.
any ideas pls?
<br />
private void CreateNewMDIChild(string path)<br />
{<br />
EditorPane pane = new EditorPane(path);<br />
pane.MdiParent = this;<br />
pane.Show();<br />
<br />
this.documentImageList.Images.Add(pane.Icon);<br />
<br />
ToolBarButton button = new ToolBarButton(pane.FileName);<br />
button.ToolTipText = pane.Path; <br />
button.ImageIndex = MdiChildren.Length - 1;<br />
this.mdiChildrenToolbar.Buttons.Add(button);<br />
<br />
UpdateButtonPushState(button);<br />
}<br />
kind regards,
g00fy
|
|
|
|
|
Hi,
Check for the size of the Image/Icon and the Image Size selected for the ImageList control. Both the size should match inorder to display the icon properly
Best Regards,
|
|
|
|
|
yes they are same => 16, 16, transparentColor = transparent, ColorDepth => Depth8Bit
one thing i have noticed debugging is that the depth of the icon of the form, is 0 which is not same as imagelist.
regards,
g00fy
|
|
|
|
|
Hi!
Could be the rather well-known "32bpp images in an ImageList lose transparency" bug.
You'll find a lot of stuff/suggestions/discussions when you google for "imagelist transparency bug".
Regards,
mav
|
|
|
|
|
Hi
I'm trying to start a timer event from another event. A event is activated from an external button through the parallellport.
This works perfect. I can fire almost anything, but not the timer. I want to start a countdown when i press the external button. The timer starts if I start it from a formbutton.
Please help.
//Nicklas
Here is part of my code:
public delegate void PortDataHandler(object sender, MyDataEventArgs e);
private System.Threading.ThreadStart threadStart;
private System.Threading.Thread thread;
public event PortDataHandler OnPortDataChange;
Timer timer1 = new Timer();
private void Form1_Load(object sender, System.EventArgs e)
{
drive();
}
private void drive()
{
//my timer
timer1.Tick += new EventHandler(Ticker);
timer1.Interval = 1000;
//my event
OnPortDataChange += new PortDataHandler(my_Handler);
this.threadStart = new System.Threading.
ThreadStart(Application_Tick);
this.thread = new System.Threading.Thread(threadStart);
this.thread.Start();
}
public class MyDataEventArgs : EventArgs
{
public readonly int TheNumber;
public MyDataEventArgs(int num)
{
TheNumber = num;
}
}
public void Application_Tick()
{
while ((Input(889)==120))
{
}
OnPortDataChange(this, new MyDataEventArgs(Input(889)));
drive();
}
void Ticker(object sender, EventArgs e)
{
//do something every second
}
public void my_counter()
{
label1.Text="now you are here";
timer1.Start(); //the timer don't start from here
}
public void my_Handler(object sender, MyDataEventArgs e)
{
this.label2.Text="You pressed the button!!";
my_counter();
//PlaySound( "C:/mina mappar/project programming/play2/sound.wav", 0, 1 );
//timer1.start(); //timer dont start here
private void button1_Click(object sender, System.EventArgs e)
{
//label1.Text="vanliga knappen";
this.thread.Abort();
this.Close();
//OnPortDataChange(this, new MyDataEventArgs(Input(889)));
}
private void button2_Click(object sender, System.EventArgs e)
{
timer1.Start(); //the timer start here????????? but not where i want.
}
}
}
|
|
|
|
|
Hi!
It might have to do with the type of timer you use.
You just wrote Timer , but from the Tick event I guess it's the System.Windows.Forms.Timer class.
This kind of timer depends on your UI thread's message pump to work, so this could be the problem (depends on the rest of your program).
Try using System.Timers.Timer instead.
Regards,
mav
|
|
|
|
|
Can anyone explain me more about CLR ??
|
|
|
|
|
|
Hi, I am looking for a way to merge video file together on-the-fly, I have find some demo activeX control doing it, but it's always by recompressing the whole video, so it take ages. I'd like to do it the way most shareware (like "Easy Video Joiner") do it, without decompressing the frame.
Any help or info could help me.
Thansk you a lot in advance.
|
|
|
|