473,225 Members | 1,232 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

What is C#'s analogue of Delphi's TAction ?

What is C#'s analogue of Delphi's TAction ?

If there is no one, how to implement the same functionality >

Oleg Subachev
Jan 13 '06 #1
7 8854
Oleg Subachev wrote:
What is C#'s analogue of Delphi's TAction ?

If there is no one, how to implement the same functionality


It would help if you could say what TAction does - otherwise you've
limited yourself to those who know both Delphi and C#.

Joanna? :)

Jon

Jan 13 '06 #2
> It would help if you could say what TAction does

TAction is a class that mainly has two events:
OnExecute - where some real job may be done
and
OnUpdate - where the instance may be enabled/disabled.

Then the TAction instance may be assigned to the special
property of different controls, such as menu item, button,
speed button etc. So that all these controls will perform
the same job on clicking. Also these controls will be
simultaneously enabled/disabled and may share common
Caption, Hint and other properties.

Oleg Subachev
Jan 13 '06 #3
Oleg Subachev wrote:
It would help if you could say what TAction does


TAction is a class that mainly has two events:
OnExecute - where some real job may be done
and
OnUpdate - where the instance may be enabled/disabled.

Then the TAction instance may be assigned to the special
property of different controls, such as menu item, button,
speed button etc. So that all these controls will perform
the same job on clicking. Also these controls will be
simultaneously enabled/disabled and may share common
Caption, Hint and other properties.


I don't believe there's anything similar in the .NET framework.
However, you could create a class which aggregated a list of controls,
and allowed you to manipulate them (enable/disable etc) as a group
(just by looping through the list when you asked the instance to do
something).

Jon

Jan 13 '06 #4
"Jon Skeet [C# MVP]" <sk***@pobox.com> a écrit dans le message de news:
11**********************@o13g2000cwo.googlegroups. com...

| It would help if you could say what TAction does - otherwise you've
| limited yourself to those who know both Delphi and C#.
|
| Joanna? :)

You rang ?

TAction is a non-visual component that can be added to a TActionList using a
component editor. Basically, controls like buttons and menu items have an
Action property and a TAction provides a RAD way of specifying what happens
when button or menu item is clicked. It provides an OnHint event where the
Hint value can be supplied as an when required and an OnExecute and OnUpdate
where you can specify what happens when the control is clicked and what how
to alter the client controls' state when things like Enabled or Checked
change. A TAction can be attached to several controls so that there is a
single place where code for a single "Action" like Copy, Cut or Paste, etc
can react to a button, popup menu and main menu for the same action.

To set up a TAction, place a TActionList on a form and then use the
component editor to add TActions to it. Add code to the event handlers and
then hook up whatever controls need to call that Action by setting the
Action property of those controls to one of the Actions in the list.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jan 13 '06 #5
"Jon Skeet [C# MVP]" <sk***@pobox.com> a écrit dans le message de news:
11**********************@g14g2000cwa.googlegroups. com...

| I don't believe there's anything similar in the .NET framework.
| However, you could create a class which aggregated a list of controls,
| and allowed you to manipulate them (enable/disable etc) as a group
| (just by looping through the list when you asked the instance to do
| something).

Oleg, take a look at creating a Component derivative that implements
IExtenderProvider. Make sure that it is capable of capturing the Click event
of Control. This will set you in a similar direction; I suggest that you
look at the source for TControl, TActionLink and TActionList to see how
Delphi works, and then simplify what you see.

Here's a starter :

[ProvideProperty("InvokeAction", typeof(Control))]
public class ActionProvider : Component, IExtenderProvider
{
private class Properties
{
private bool invokeAction = false;

public bool InvokeAction
{
get { return invokeAction; }
set { invokeAction = value; }
}
}

private Hashtable properties = new Hashtable();

private EventHandler execute;

public event EventHandler Execute
{
add { execute += value; }
remove { execute -= value; }
}

public ActionProvider(IContainer parent)
{
parent.Add(this);
}

bool IExtenderProvider.CanExtend(object obj)
{
return obj is Control;
}

private Properties EnsurePropertiesExists(object key)
{
Properties p = (Properties) properties[key];

if (p == null)
{
p = new Properties();

properties[key] = p;
}

return p;
}

[Category("Behaviour")]
[Description("Calls centralised event handler for Click event of linked
controls")]
[DefaultValue(false)]
public bool GetInvokeAction(Control c)
{
return EnsurePropertiesExists(c).InvokeAction;
}

public void SetInvokeAction(Control c, bool value)
{
EnsurePropertiesExists(c).InvokeAction = value;

if (value)
c.Click += HandleClick;
else
c.Click -= HandleClick;
}

private void HandleClick(object sender, EventArgs args)
{
if (!DesignMode)
{
Control control = (Control) sender;
if (control != null && execute != null)
{
execute(this, EventArgs.Empty);
}
}
}
}
Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jan 13 '06 #6
>TAction is a non-visual component that can be added to a TActionList using a
component editor. Basically, controls like buttons and menu items have an
Action property and a TAction provides a RAD way of specifying what happens
when button or menu item is clicked.


Very convenient way of doing things, which is - unfortunately - sorely
lacking from the .NET framework. Makes you wonder why.....

There are a number of free and commercial "replacements" for this
annoyance.

There are a number of pretty straightforward "Delphi-to-C#"
translations up on CodeProject - see these for instance:

Simplifying GUI development with Actions
http://www.codeproject.com/csharp/ac...stprovider.asp

ActionLists for Windows.Forms
http://www.codeproject.com/cs/miscctrl/actionlist.asp

Or there's the commercial package by some former Delphites called
"CommandMaster" which can be found here:
http://www.componentscience.net/Prod...3/Default.aspx

No personal experience with any of those, though.

Marc
Jan 14 '06 #7
Sergio
2
nxSharp Actions for .NET - fully functional analog of Delphi ActionList with additional features.

http://nxsharp.com/
Mar 22 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: achrist | last post by:
I'm aving some trouble getting callbacks from a Delphi DLL back to python working through ctypes. The call from python to the DLL works fine. In the Delphi(5) code: type TCallbackFunc =...
29
by: noid droid | last post by:
Hi. I've not used C# yet but just ran across a premonition from 2 years ago saying that C# would render C++ obsolete by this time. Has it? Have most corporate developers migrated to C#? Is...
6
by: Erva | last post by:
Hi, Is there someone who has moved from Delphi to VS.NET? I'am using Delphi currently but seriously considering to moving VS.NET. I would like to hear if someone has already done that, is it...
1
by: BlackTiger | last post by:
How to create analogue of Delphi's 'DataModule'? DataModule is non-visual form, which contains connections to DB, queries, tables, field definitions and relations between tables. All this...
10
by: Arda Han | last post by:
I am migrating my some applications from Delphi to C#. But... Yes But I don't know C# professionally. I am using DLL in delphi like this : ..... const RFID_103_485IO = 'Cihaz.dll'; ...
9
by: Chazza | last post by:
I would like to override a method from an inherited class, but the new method has a different signature to the inherited class. Example: class A { private void Init() { // code } } class B...
3
by: lukeharpin | last post by:
Currently I have been developing applications in Delphi 7. Recently I meet up with a friend of mine who previously developed in Delphi, from version 1 - 7. When Delphi 8 .net was release he found...
7
by: ray | last post by:
Ah well, it had to happen. Create a new form, minimum size 14cm by 14cm. Anywhere on the form, place 3 lines of any length called scrLineSecond, scrLineMinute and scrLineHour. Set the form's...
184
by: jim | last post by:
In a thread about wrapping .Net applications using Thinstall and Xenocode, it was pointed out that there may be better programming languages/IDEs to use for the purpose of creating standalone,...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.