Link to home
Start Free TrialLog in
Avatar of razziel
razziel

asked on

#if design time for swf

Is there a preprocessor define to know if the code is running in design time like  #if NETCFDESIGNTIME in the compact framework??

Thanks
Avatar of RomanPetrenko
RomanPetrenko

I don't think so.
Look here:
http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_fxnetcf/html/23a10364-ea60-4ad6-804b-1afd259bb3d4.asp

===citation===
Adding Controls to the Toolbox
The .NET Compact Framework does not currently provide the capability to add a custom control for design-time access.

Microsoft Visual Studio 2005 does not support adding controls developed with the .NET Compact Framework or customizing the Toolbox with your own controls developed with the .NET Compact Framework. The reason is that the .NET Compact Framework does not currently support designer attributes for its base Windows.Forms.Control class. To have a design-time experience with a custom or derived control, you must compile an alternate design-time version of your assembly using the Windows Control Library project template the full .NET Framework. Then you can add that control to the ToolBox in a smart device application project for your run-time application.

When you compile or deploy your run-time application, the .NET Compact Framework uses the run-time version of your assembly by having determined the value of the RuntimeAssemblyAttribute attribute.

This attribute, exclusive to the .NET Compact Framework, takes the fully qualified name of the run-time assembly as its only argument. The following example specifies an assembly using the RuntimeAssemblyAttribute.

  Copy Code
[assembly: System.CF.Design.RuntimeAssemblyAttribute("SimpleChart, Version=1.0.1.5, Culture=neutral, PublicKeyToken=null")]
 

For more information, see Walkthrough: Authoring a Custom Control for Smart Device Applications.
===end of citation===
Avatar of razziel

ASKER

Im sorry maybe i didnt explain myself correctly, #if NETCFDESIGNTIME is for the .net compact framework and does work, i want a preprocessor directive like that one but for windows from, the full .net framework

thanks for your reply
What problem you want to solve?

If you writing custom designer you can hadle a lot of things.
Avatar of razziel

ASKER

I have a control in wich i connect to a remote server to get some collection of objects, the connection to the remote server is done in the constructor of the control, i just want a way to know if the control is beng created for design time so the designer doesnt throw an error every time i open a form containing it. But the connection to the remote server must stay in the constructor.
There is a way to do what you need:
1. There is DesignMode property for all Component derived classes
class MyClass: Component
{
    public MyClass()
    {
        if (this.DesignMode)
        {
            //Call Design Time code
        }
        else
        {
            // Call Runtime code
        }
    }
}
2.
ASKER CERTIFIED SOLUTION
Avatar of RomanPetrenko
RomanPetrenko

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of razziel

ASKER

Sorry for the late reply.
Heres your points roman, thanks.
May I ask why grade B? The answer wasn't full?