|
void FillRTB(string filepath,long length)
{
byte[] ByteRead = new byte[length];
using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.ReadWrite)) {
fs.Read(ByteRead, 0, ByteRead.Length);
}
MemoryStream memStream = new MemoryStream(ByteRead);
richTextBox1.LoadFile(memStream, RichTextBoxStreamType.PlainText);
}
|
|
|
|
|
Thank you very much. That's work...
N a v a n e e t h wrote: byte[] ByteRead = new byte[length];
I thought we can't declare variables like this. And actually I didn't test that
Thank you again
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Hi all,
I am trying to export image to PDF file using iTextSharp dll.
I created a PDF file(test.pdf) and added image to that pdf file. But the problem is when the image is too large ,its not showing the complete image in pdf file.
when the image height is large, i am automatically getting the vertical scroll bar in pdf file. but for width i am not getting any horizontal scroll bar.
Please suggest me how to export large images to pdf file without resizing the image. I s there any way to get the horizontal and vertical scroll for PDF file.
Thanks in advance
|
|
|
|
|
Hi.
I Build Report In C# Windows Application , and this Report Is Build His Columns By Dynamic Criteria, May be the Number of Columns In it is 5 or 7 or 13 or 20 or other , and I won’t to put this columns in the report as a good way , the all columns is Clear of the User , i add the columns at every number of it , but if the number is more than 7 columns the columns is not show in the Report is Hidden , then I calculate the width of Report and The Width of the max text in every columns and Other Options may be Decrees the Size of Font if the Columns Number is or Increase the Font , these Operation Depend On Number OF Columns .....
The Problem Is in Type of Screen, the Report is good if the Screen 15 but if screen is 17 the Report is Show in Not Good Way.
Who I can solve this Problem, and what is the Unite Of width the text and width of report (Cm, Inch …., Unites).
Thanks for any body help me
Thaer
|
|
|
|
|
Hi
We use an external library with a class with a static event looking like this:
public static event EventHandler ThemeChanged .
I want to clear it's invocation list, is that possible?
Anything that would cause ThemeChanged to not hold references to anything will do
Thanks
modified on Monday, October 20, 2008 3:23 AM
|
|
|
|
|
Try setting that to NULL .
|
|
|
|
|
Unfortunately it's not that easy
error CS0079: The event 'ThemeChanged' can only appear on the left hand side of += or -=.
It would also be easy using reflection if it was non static.
|
|
|
|
|
Ok, how about writing a method which sets this to NULL?
class MyTheme
{
public static event EventHandler ThemeChanged;
public void ClearInvocationList()
{
ThemeChanged = null;
}
} You can implement this in destructor and use dispose pattern and set it to NULL.
|
|
|
|
|
I can't modify the source codes of that external library(I can but it causes other problems)
If I would have the possibility to modify it, I would do this:
public static event EventHandler ThemeChanged
{
add{}
remove{}
}
I don't need that event and it's causing memory leaks.
|
|
|
|
|
induur wrote: I can't modify the source codes of that external library
How about removing the handlers when application exits?
ExternalLibraryClass.ThemeChanged -= Yourhandler
edit
fixed typo
modified on Monday, October 20, 2008 6:48 AM
|
|
|
|
|
I need to do that during the life of my app.
Objects(controls) that subscribe to that event are also defined in the external libraries, I can't change their code.
During debuging VS allows me to look to the invocation list of that event, but from the code I can't get the references to subscribers. I was hoping there is a way to do that using reflection, but I have problems since the event is static. Is there a way to get the invocation list of a static event?
|
|
|
|
|
induur wrote: , but I have problems since the event is static
I think you will have problems even if it is not static. AFAIK, you won't get the invocation list from outside the class where event is declared. I will sit tonight and try to figure this. I will update you if I got something. Nice question though.
|
|
|
|
|
Thanks.
I'm looking forward to your response.
|
|
|
|
|
I think your best bet is to create a proxy class for your external library and route all calls through your proxy. Which means, you should not invoke your external library directly. It should be done via this proxy class.
Mimic the event in your proxy class. When items are added, keep the event handlers in a list. Create a method something like ClearInvocationList() in the proxy class, loop through all the event handlers in the list and unregister the event. Clear the list.
You can implement this cleanup in destructor also. But it is not recommended as finalization is performance costly. Look at implementing IDisposable instead.
Sample code follows, (uncompiled and exceptions not handled)
class ExternalLibraryProxy
{
List<EventHandler> subscriptions = new List<EventHandler>();
public event EventHandler ThemeChanged
{
add
{
ExternalLibrary.ThemeChanged += value;
subscriptions.Add(value);
}
remove
{
ExternalLibrary.ThemeChanged -= value;
subscriptions.Remove(value);
}
}
public void ClearInvocationList()
{
foreach(EventHandler handler in subscriptions)
ExternalLibrary.ThemeChanged -= handler;
subscriptions.Clear();
}
}
Hope this makes sense.
|
|
|
|
|
I think the following will be more neat than the previous one.
As said in the previous post, create a proxy class.
class ExternalLibrayProxy
{
public event EventHandler ThemeChanged;
public ExternalLibrayProxy(){
ExternalLibray.ThemeChanged += EventHandlerMethod;
}
~ExternalLibrayProxy(){
ExternalLibray.ThemeChanged -= EventHandlerMethod;
}
void EventHandlerMethod(object sender,EventArgs args){
if(ThemeChanged != null)
ThemeChanged(sender,args);
}
} In this you don't need to keep the handlers explicitly in a list. When the class destructor is executed, your external library's event will get deregistered. You can implement IDisposable here to avoid overhead of finalization.
|
|
|
|
|
I'm afraid I can't insert a proxy.
As I wrote before the subscribers are also in an external library and subscribe to the ExternalLibrary.ThemeChanged directly.
That is some neat code though, I appreciate your effort.
edit:
typo
modified on Wednesday, October 22, 2008 4:03 AM
|
|
|
|
|
Hello,
I have to use a smoothing algorithm in my COde. I am using Visual C++ .Net 2008 with 3.5 framwork.
I am reading a data through serial port from a target device and this data is store into a XML file. I have to display(plot) this data on the window. For ploting the waveform, i read the data from the XML file, and draw(Plot) the point using "Drawline" function. but the curve generated is not in Smooth shape. It shows some noise(like steps).So in this case I want to use smoothing algorithm but dont know how to use it.So plz can anyone tell me how to use smoothing algorithm? its urgent so plz help me out.
Thanks and Regards,
Abhijit
|
|
|
|
|
How on earth is this a C# or ASP.NET question ?
Christian Graus
Driven to the arms of OSX by Vista.
"Iam doing the browsing center project in vb.net using c# coding" - this is why I don't answer questions much anymore. Oh, and Microsoft doesn't want me to.
|
|
|
|
|
Please post the questions in their appropriate forums. As per ur question you should use Anti-aliasing techniques. That should smooth out the graph a bit. But for complete smoothening, try to search for some free Vector drawing libraries!
-------------------------------------------
It's code that drives you - Shyam
|
|
|
|
|
Thanks for reply.
You say post this questions in their appropriate forums. But there is no Message board for Visual C++ .Net 2008. Which message board, i have to post this question, you suggest me?
|
|
|
|
|
|
Please do help me with the following problem.
In my C# Application Program, I have a DataGridView control. There are several rows and columns without data in it. And I need some type of a control (say, a lable or a button or a textbox - any control of my choice) to be able to dragged and dropped on this DataGridView so that it fits into the cell when I drop the control.
This dragged control in reality is do be drawn (or created) at runtime, but for the time being if I can get a predefined control to get the desired functionality, that would suffice.
Please do help with this. I checked this forum as well as a few others but couldn't find an answer. Also, please do explain how I get the drag-drop functionality to any control as well.
Thanks in advance!
|
|
|
|
|
I haven't tried, but DragEnter and DragDrop events will be the way to get started.
|
|
|
|
|
This is a most unusual requirement, most people just move the data around (there are lots of articles for that) I have never heard of DD a control before. Why do you need to drop a control into a DGV.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Well, yeah it sounded unusual for me too.
I'll give you as much information as I can reveal. This is for some work of professional software. One of our clients wants one of their MIS SW redesigned. It is originally designed by some other company. Now we don't have the original codes but just the interfaces.
In simpler terms imagine that there is a sort of a time table - say for a week, with eight hours being shown for every day - that is the DGV. Now controls are the jobs - lets say so - and whoever assigns the orders should be able to drag them from a list or something and then place on the DGV on the relavent time period. Say, one job is to allocate teh time 10am - 11am on Monday. SO and so.
So they need the exact functionality, and here I am stuck in the middle of it not knowing anything. My PM wants to somehow create it. And he doesn't really care which way. So I'm allowed to use any kind of control I like.
Hope you understood. Please help if you can.
|
|
|
|