|
I think it might help if you rephrase this as a question - asking something specific, perhaps about some code, and showing what you've done so far .. if you dont have a place to start, you may have to google a bit first
.. as it is, its likely only to get disdainful responses
'g'
|
|
|
|
|
I have an application with crystal reports. while loading the reports its prompting for the database login entities. How to disable the login prompt in crystal reports???
|
|
|
|
|
Google Results[^] This has been asked and answered thousands of time over the years. All it takes is a little research...
|
|
|
|
|
Hi,
I have a class 'C1' with lot of properties with different retun type, and those are set using another class's method 'C2.m1'.
i am searching for a technic to get those values using iteration mathod and display in a datagrid, Instead of directly accessing those properties like 'C1.property1'.
Could you one please help me..?
Thank you
Venu.
|
|
|
|
|
Seemed like a prefect case for using "Reflection".
Try seraching "get property by reflection c#"
berlus
|
|
|
|
|
Sounds like you want a PropertyGrid then.
|
|
|
|
|
Well a DataGridView control does reflection automatically.
If you have a collection of 'C1' objects that implements the IList interface, then any public property will automatically be extracted and used to populate the cells in the apropriate column.
Does this help?
Harry.
|
|
|
|
|
Hello everybody!
I want to create a slideshow program like powerpoint.
Hope every body guide to me!
Thanks!!
|
|
|
|
|
So, what have you tried so far? Google, maybe?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
First, you'll need to assemble a team of programmers....
|
|
|
|
|
kienhv_87 wrote: Hope every body guide to me!
If 7 million people guide you, you will get lost in your inbox without getting any coding done.
|
|
|
|
|
I have a form with border none, so I had to manually enable the system menu(appears when right click on taskbar). But I want to disable 'Move' item as well. Searched everywhere but didn't find anything about that one.
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style |= 0x80000 | 0x20000;
return cp;
}
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I think I have to keep use this way
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_SYSCOMMAND)
{
if (m.WParam == (IntPtr)61456)
return;
}
base.WndProc(ref m);
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hello all,
To demonstrate the decorator pattern, many articles gives as an example the ability to extend user controls (e.g. a window) with another ability (e.g. scrollable bar).
I'm trying to use it in winforms and extend the ProgressBar.
I'm building a utility function that copy some files from one network drive to another network drive, and I would like to supply also a progress bar that will show (as accurate as possible) the progress of the copy.
In order to that I want to extend the progress bar with a full amount property, and a sniffing method (supplied by the user, e.g. querying the network adapter), and thus the progress bar would display the size so far divided by the known full amount.
Decorator pattern seems the perfect choice but i can't seems to implement in winforms.
Thanks,
Berlus.
|
|
|
|
|
While you would normally use the File.Copy method to copy files in Windows using the File.OpenRead method will allow you to manually copy using streams and have the file size and stream location immediately available and thus negate the need for a custom progress bar that uses a sniffer. Just remember, never load the full stream in memory.
|
|
|
|
|
Thanks for your answer.
The problem is that the file copying is in 3rd party Dll, and I'm aware only to the side effects of the copying process.
And, I would like to use this opportunity to exercise the decorator pattern.
thanks anyway,
Berlus
|
|
|
|
|
Patterns are suggestions when problems arise that they are suited for. Using a pattern for a given problem because you want to use the pattern is not a recipe for success. Sometimes the problem is not with the answer but with the desired approach.
Since a progress bar is inheritable this is the simplest method. Note, BeginCopyNotifyChange will call your third party tool and poll. However, keep in mind, that you cannot technically know when the transfer is finished unless you poll the locks placed on the file for copying nor will you know the size, assuming the file copy tool is a third party tool.
public class FileCopyProgressBar : System.Windows.Forms.ProgressBar {
public void BeginCopyNotifyChange(string source, string destination);
}
|
|
|
|
|
Where are you getting your information about patterns? Decorator involves changing the behaviour of a class on the fly at runtime. The stuff you want to do can and probably should be done at compile time. AJAX extenders are good examples of decorator. They add functionality. But what you are wanting to do is more of a change in how the progress bar works than an addition of a feature. You want to change how it calculates progress. That sounds more like a subclass to me.
|
|
|
|
|
Thanks for your answer, it is execatly what I was aiming for, beacause I need some help understanding the pattern.
I've looked up decorator pattern in wikipedia, and i quote:
http://en.wikipedia.org/wiki/Decorator_pattern
"In object-oriented programming, the decorator pattern is a design pattern that allows new/additional behaviour to be added to an existing object dynamically."
dynamically, as you said.
but in the motivation part:
"As an example, consider a window in a windowing system. To allow scrolling of the window's contents, we may wish to add horizontal or vertical scrollbars to it, as appropriate. Assume windows are represented by instances of the Window class, and assume this class has no functionality for adding scrollbars. We could create a subclass ScrollingWindow that provides them, or we could create a ScrollingWindowDecorator that adds this functionality to existing Window objects. At this point, either solution would be fine."
which seemed like what i'm trying to do.
Thanks, Berlus
|
|
|
|
|
After rereading the article i'm attaching a sample class:
public abstract class ProgressBarDecorator : ProgressBar
{
protected ProgressBar m_decoratedProgressBar;
public ProgressBarDecorator()
{
}
public ProgressBarDecorator(ProgressBar p_decoratedProgressBar)
{
this.m_decoratedProgressBar = p_decoratedProgressBar;
}
}
public class NotifiableProgressBarDecorator : ProgressBarDecorator
{
public NotifiableProgressBarDecorator()
{
}
public NotifiableProgressBarDecorator(ProgressBar p_decoratedProgressBar)
: base(p_decoratedProgressBar)
{
}
protected override void OnCreateControl()
{
base.OnCreateControl();
this.BackColor = Color.Green;
this.Value = 50;
}
}
}
It is the base design fot my implementation, if it will be any good, i might consider posting as an article.
Your thoughts ans suggestions are most welcome.
Thanks,
Belrus
modified on Friday, June 18, 2010 5:17 PM
|
|
|
|
|
First thought is to use the 'code block' widget above the edit box when posting so your code is surrounded by <pre></pre> tags so the code is legible.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
|
Right.
|
|
|
|
|
That isn't what you are trying to do. Adding a scrollbar to a window doesn't change anything about the underlying functionality of the window. How the window is closed, moved, z-ordered etc. all remain intact. Changing the methodology a progress bar uses to determine the amount of progress is a fundamental change to the existing underlying functionality, not an addition. Adding a user preference for the color of the progress bar would be more of a decorator.
I see from one of your other responses that it is a 3rd party control you are dealing with. Decorator pattern seems to be what you want only because you can't do it with subclassing because you don't have the source to do it. You are shoehorning your design requirement into a pattern based on other external factors.
Why are you using a control that doesn't do what you want it to?
|
|
|
|
|
T M Gray wrote: Why are you using a control that doesn't do what you want it to?
Form where do i get such control ?
anyway, here is the first version of the class, I hope i'm not abusing this forum ...
using System;
using System.Drawing;
using System.Net.NetworkInformation;
using System.Windows.Forms;
namespace TestProgressBar
{
public abstract class ProgressBarDecorator : ProgressBar
{
protected ProgressBar m_decoratedProgressBar;
public ProgressBarDecorator()
{
}
public ProgressBarDecorator(ProgressBar p_decoratedProgressBar)
{
this.m_decoratedProgressBar = p_decoratedProgressBar;
}
}
public class NotifiableProgressBarDecorator : ProgressBarDecorator
{
public long FullAmount;
public void InformOnNewData(long p_newDelta)
{
float normalizedSize = Maximum - Minimum;
if (FullAmount != 0)
{
int newValue = Value + (int) (p_newDelta/(float) FullAmount*normalizedSize);
if ((Value + newValue) <= Maximum)
{
Value += newValue;
}
else
{
Value = Maximum;
}
}
}
public void Clear()
{
FullAmount = 0;
}
public NotifiableProgressBarDecorator()
{
}
public NotifiableProgressBarDecorator(ProgressBar p_decoratedProgressBar)
: base(p_decoratedProgressBar)
{
}
}
public class NetworkNotifiableProgressBarDecorator : NotifiableProgressBarDecorator
{
private NetworkInterface adapter;
private Timer m_timer = new Timer();
private long m_lastSentBytes;
public NetworkNotifiableProgressBarDecorator()
{
adapter = NetworkInterface.GetAllNetworkInterfaces()[1];
m_timer.Interval = 500;
m_timer.Tick += onTimerTick;
}
public void Init(int p_totalNofBytes)
{
FullAmount = p_totalNofBytes;
m_lastSentBytes = adapter.GetIPv4Statistics().BytesSent;
m_timer.Start();
}
private void onTimerTick(object p_sender, EventArgs p_args)
{
long sentBytes = adapter.GetIPv4Statistics().BytesSent;
if ( sentBytes - m_lastSentBytes > 0)
{
InformOnNewData(sentBytes - m_lastSentBytes);
}
m_lastSentBytes = sentBytes;
}
public void Stop()
{
m_timer.Stop();
}
}
}
|
|
|
|