I have some code activities.
public class baseAct: CodeActivity
{
}
public sealed class C1: baseAct
{
}
public sealed class C2: baseAct
{
}
public sealed class C3: baseAct
{
}
And i use a custom wf desinger.
I would like set same icon to activites C1,C2,C3 without define activity designer.
There are something (AttributeTableBuilder or similar) to set icon?.
Add the icon to your solution, set its Build Action to Resoruce
In your Activity, set the ActivityDesigner.Icon to this image
Hardest part about this is getting the Uri right. If you have problems, just dump the image into the same folder as the designer.
<sap:ActivityDesigner.Icon>
<DrawingBrush>
<DrawingBrush.Drawing>
<ImageDrawing>
<ImageDrawing.Rect>
<Rect
Location="0,0"
Size="16,16"></Rect>
</ImageDrawing.Rect>
<ImageDrawing.ImageSource>
<BitmapImage
UriSource="RelativeUriToTheImage.bmp" />
</ImageDrawing.ImageSource>
</ImageDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
</sap:ActivityDesigner.Icon>
I have a sample that illustrates exactly what you need to do. How to create a Custom Activity Designer with Windows Workflow Foundation (WF4)
Related
I would ultimately like to make .nativePath bindable or fire an event when it changes in Adobe Air. I figured I'd just extend the File class and be good.
But I cant find its source anywhere (so I know how to extend it). I've dug through http://opensource.adobe.com/svn/opensource/flex/sdk/ quite a bit and didnt see anything.
Is there a way to make .nativePath bindable or extend File?
alxx, your code was definitely close. Thank you - it gave me an idea on how to extend it. Working code:
public class FileEx extends File
{
public function FileEx(path:String=null)
{
super(path);
}
[Bindable("nativePathChanged")]
override public function get nativePath():String
{
return super.nativePath;
}
override public function set nativePath(value:String):void
{
super.nativePath=value;
dispatchEvent(new Event("nativePathChanged"));
}
}
The File Class is part of the Flash package, so it is not open source and you won't be able to get your hands on the code (unless you're deep in the inner circle of Adobe developers).
In theory you can extend the class, as it is not marked as final, and make the nativePath Bindable that way, but I'm not sure of the benefit. You'd have to expand on your use case to evaluate that.
You don't need source to subclass something. As long as it's not final, just extend it and override something you need:
public class BindableFile extends File {
[Bindable(event="nativePathChanged")]
override public function get nativePath():String {
return super.nativePath;
}
override public function set nativePath(value:String):void {
super.nativePath = value;
dispatchEvent("nativePathChanged");
}
}
Not tested, but looks realistic :)
I find out how to replace the busy cursor here: http://livedocs.adobe.com/flex/3/html/cursormgr_3.html
However, how do you animate an image for the cursor?
Use an animated asset created in the Flash IDE and embed it within your Flex app.
You can also create them programmatically, e.g. by extending flash.display.Sprite:
Class SampleCursor:
public class SampleCursor extends Sprite
public function SampleCursor() {
addEventListener(Event.ENTER_FRAME, drawCursor);
}
public function drawCursor(e:Event):void {
// Draw cursor using graphics context
// ...
}
{
And in your Application you just register this class as a cursor (same for other types of cursors like bitmap or flash assets):
cursorManager.removeAllCursors();
cursorManager.setCursor(SampleCursor);
Hope that helps.
I created a few styles into a CSSResource and it works well whether I use
GWT.<MyResources>create(MyResources.class).myStyles().ensureInjected();
or not.
Could anyone shed a light on this and explain when to use ensureInjected or not?
Thank you!
Daniel
As Christian said, inside the UiBinder ui.xml file you don't have to worry about invoking ensureInjected(), the following XML statements do the job:
<ui:with field='myStyle' type='com...MyStyle'/>
<div class='{myStyle.redBorder}'/>
Of course this is assuming that there is somewhere a MyStyle interface defined:
public interface MyStyle {
public String redBorder();
}
Now I agree with you that things get annoying when you need to manipulate the CssResource extension outside of UiBinder templates. Precisely because you have to take care of invoking ensureInjected() somewhere before using the MyStyle instance with your widgets.
I personally use GIN to inject instances of extensions of CssResource whenever I need them.That way you can implement a custom GIN provider ensuring that ensureInjected() is called on the CssResource before injecting it.
There are three steps involved there:
Create an interface for MyStyle alongside with a CSS file.
MyStyle.java
public interface MyStyle {
public String redBorder();
}
MyStyle.css
.redBorder { border: 1px solid red; }
Expose it through a ClientBundle extension.
Resources.java
public interface Resources extends ClientBundle {
#Source("MyStyle.css")
public MyStyle style();
}
Configure a GIN provider method to inject your instances of MyStyle.
ClientModule.java
public class ClientModule extends AbstractGinModule {
#Override
protected void configure() {
//...
}
#Provides MyStyle createStyle(final Resources resources) {
MyStyle style = resources.style();
style.ensureInjected();
return style;
}
}
We smoothly inject the Resources instance here above, which means no more hassle of a static accessor calling GWT.<Resources>create(Resources.class) anywhere, it just all happens through the GIN injection.
Having done that you can inject your instances of MyStyle when you need them.
For example (in some MVP context):
private Widget widget;
#Inject
public SomeView(final MyStyle style) {
//...
widget = uiBinder.createAndBindUi(this);
widget.addStyleName(style.redBorder());
}
Good question - one situation that comes to my mind is when you want to use styles from some global stylesheet in a UiBinder template - then you need to call ensureInjected to... ensure the styles are indeed injected when you are referencing them (the "local" UiBinder styles, that you define in xml are automagically injected).
You can see this used as such in the Mail example:
public void onModuleLoad() {
// Inject global styles.
GWT.<GlobalResources>create(GlobalResources.class).css().ensureInjected();
// Create the UI defined in Mail.ui.xml.
DockLayoutPanel outer = binder.createAndBindUi(this);
// ...rest of the code
}
Note how ensureInjected is called before binding the UI.
This is the only situation I know that warrants using ensureInjected, but maybe I missed something.
The rule is easy: you have to call ensureInjected() explicitly, unless the CssResource is being generated from an <ui:style> in a UiBinder template (because most of the time you won't have a handle on the generated CssResource.
Specifically, <ui:with> provides no special treatment for CssResources.
Also, a few widgets take a specific ClientBundle as argument to a constructor (such as CellTable), they will then call ensureInjected() on the CssResource they use.
If you use UiBinder the call to ensureInjected is provided by the tag ui:with. For any other css you are using in a client bundle (i.e. legacy css excluded) and that are not declared in a ui:with block, you have to call ensureInjected explicitly.
I am going to aplogize in advance because I am really at the limits of my understanding on this so if I do not explain this well....well sorry...
Anyway I am trying to create an asp.net server control that has complex properties which can be set using intellisense. So as an example I will use cars, so the server control might be called car and when I actually implement the control on a webform I want to set complex, hierarchical properties so for example:
<Control:Car Color="Paint.Metalic.CandyRed"
Wheels="Forged.Aluminun.FiveSpoke.GunMetal" />
or
<Control:Car Color="Paint.Matte.Yellow"
Wheels="Forged.Steel.SevenSpoke.BareMetal" />
I have tried creating public properties in the server control that are just types/classes that point to the base class but intellisense doesn't come up with anything. I can use a straight forward enum and that will show up but I can't do anything hierarchical that way. I've been looking for examples but I can't seem to find anything. Any help would be greatly appreciated!!!!
Thank you!
How about a different example as it seems the relationship between items or their intended value, although completely unimportant, seems to be an issue.
Let's take the relationships between continent/ country / state / city / etc.... By this example, if my custom server control is called "Location" then I would like to be able to ...
<Control:Location CurrentLocation="UnitedStates.Nebraska.Lincoln" />
or
<Control:Location CurrentLocation="Europe.Italy.Napoli" />
Your problem is worse than the previous two answers suggest: you don't know what you're doing.
Sorry to sound so harsh, but where did you ever see something like "Paint.Metalic.CandyRed", and what did it mean there? Or "Forged.Aluminun.FiveSpoke.GunMetal"? What do you even want that to mean?
First, figure out what you want to represent. Then, create a class that can represent it. Then, add a property of that class to the server control. You may have to add a TypeConverter or other designer support in order for ASP.NET to convert your preferred textual representation into an instance of the class. Otherwise, you'll be able to get something like the properties of a Font.
I'm going to make a guess about what some of these values represent, and try to show you how to deal with them in a control. My guess could be far off, though.
I'll work with "Paint.Metalic.CandyRed". I'll assume this applies to the domain of automobile customization, and that the Color property is meant to represent the finish given to the car as a whole. In that case, "Paint" would probably be an enum referring to the type of finish (though I don't know what other sorts of finish apply to a car!). I know from building model cars when I was a kid that paints may be metallic, or gloss, or flat, so those three would be enum values of one enum. "CandyRed" would be one of many colors. This would give something like this:
public enum FinishType
{
Paint,
NotPaint // _I_ don't know!
}
public enum PaintFinish
{
Metallic,
Gloss,
Flat
}
public enum CarColor
{
CandyRed,
SilverMist,
DesertSandMica,
MagneticGray,
// etc.
}
public class CarFinish
{
public FinishType FinishType {get;set;}
public PaintFinish PaintFinish {get;set;}
public CarColor CarColor {get;set;}
}
public class Car : WebControl
{
public CarFinish Color {get;set;}
}
This would allow for something like this:
<Control:Car Color-FinishType="Paint"
Color-PaintFinish="Metallic"
Color-CarColor="CandyRed" .../>
or this:
<Control:Car ...>
<Color FinishType="Paint" PaintFinish="Metallic" CarColor="CandyRed"/>
</Control:Car>
These items would need to be enums as that is the only way that it is supported at least in everything I have seen. now, you can accomplish what you want with a few enums.
namespace Paint
{
public enum Metalic
{
CandyRed
}
public enum Matte
{
Yellow
}
}
Granted, not perfect, but easy to document and understand!
As Mitchel Sellers posted, they will need to be either Enum or Constants/Statics.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace Paint
{
public class Metallic
{
public static Color CandyRed
{
get { return Color.Red; }
}
public static Color CandyGreen
{
get { return Color.Green; }
}
}
public class Matte
{
public static Color Red
{
get { return Color.Red; }
}
public static Color Green
{
get { return Color.Green; }
}
}
}
I want to make a custom ASP.NET control that is a subclasse of System.Web.UI.WebControls.Calendar. I need it to add a few data members and set up a few event handlers in it's constructor.
Is this possible? If so How?
So far I have tried using add new item to add a default web user control and tried editing in Calendar in a few different places. None have worked so far.
Edit: it seems I'm totally missing how this stuff is supposed to work.
Does anyone known of a demo project that I can look at? Something that already exists. (Unless you are really board, don't go out and make one for me.)
Unless I'm misunderstanding the question, you can just create a new class file and inherit from Calendar. Add in the properties you need, and the event handlers you want to set up.
public class MyCalendar : System.Web.UI.WebControls.Calendar
{
public MyCalendar()
{
// set up handlers/properties
}
}
Then anywhere you'd like to add a Calendar to your pages, you can simply create a MyCalendar instead. If you need to do so in the designer, you can look at several good tutorials about how to make your inherited controls show their new properties in the designer, like this one.
In a new class file you need to inherit from System.Web.UI.WebControls.Calendar instead of System.Web.UI.UserControl.
namespace MyNamespace
{
[ToolboxData("<{0}:UserCalendar runat=\"server\" />")]
public class UserCalendar : System.Web.UI.WebControls.Calendar
{
private string property1;
public UserCalendar() { }
public string Property1 { get { return property1;} set { property1 = value; } }
}
}
Then on your .aspx page (or in another control .ascx):
<%# Register TagPrefix="userControl" namespace="MyNamespace" assembly="MyProjectAssembly" %>
<userControl:UserCalendar runat="server" ID="myCalendar" property1="some value" />
Stuff to read: Developing Custom ASP.NET Server Controls.