protected virtual void CreateDragFeedbackImages(IList <Activity> draggedActivities) { Bitmap draggedImage = null; if (draggedActivities.Count > 0) { Bitmap image = null; String description = String.Empty; if (draggedActivities.Count > 1) { image = DR.GetImage(DR.Activities) as Bitmap; description = DR.GetString(DR.ActivitiesDesc); } else { ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)TypeDescriptor.GetAttributes(draggedActivities[0].GetType())[typeof(ToolboxBitmapAttribute)]; image = toolboxBitmapAttribute.GetImage(draggedActivities[0].GetType()) as Bitmap; description = draggedActivities[0].GetType().Name; } if (image != null && description.Length > 0) { //Start creating a bitmap WorkflowView parentView = ParentView; Rectangle imageRectangle = (image != null) ? new Rectangle(Point.Empty, image.Size) : Rectangle.Empty; Rectangle descriptionRectangle = (description.Length > 0) ? new Rectangle(Point.Empty, new Size(AmbientTheme.DragImageTextSize.Width, parentView.Font.Height + 2)) : Rectangle.Empty; if (!imageRectangle.IsEmpty) { descriptionRectangle.Offset(imageRectangle.Width + AmbientTheme.DragImageMargins.Width, 0); } Size draggedImageSize = parentView.LogicalSizeToClient(new Size(imageRectangle.Width + descriptionRectangle.Width, Math.Max(imageRectangle.Height, descriptionRectangle.Height))); draggedImage = new Bitmap(draggedImageSize.Width, draggedImageSize.Height, PixelFormat.Format32bppArgb); using (Graphics draggedImageGraphics = Graphics.FromImage(draggedImage)) using (Brush backgroundBrush = new SolidBrush(Color.FromArgb(0, 255, 0, 255))) { draggedImageGraphics.ScaleTransform(ScaleZoomFactor, ScaleZoomFactor); draggedImageGraphics.FillRectangle(backgroundBrush, new Rectangle(0, 0, draggedImage.Width, draggedImage.Height)); if (image != null) { draggedImageGraphics.DrawImage(image, new Rectangle(Point.Empty, image.Size)); } if (description.Length > 0) { StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Near; stringFormat.Trimming = StringTrimming.EllipsisCharacter; stringFormat.LineAlignment = StringAlignment.Center; draggedImageGraphics.DrawString(description, parentView.Font, SystemBrushes.WindowText, descriptionRectangle, stringFormat); } } } } this.dragImage = draggedImage; }
protected virtual void CreateDragFeedbackImages(IList <Activity> draggedActivities) { Bitmap image = null; if (draggedActivities.Count > 0) { Bitmap bitmap2 = null; string s = string.Empty; if (draggedActivities.Count > 1) { bitmap2 = DR.GetImage("Activities") as Bitmap; s = DR.GetString("ActivitiesDesc", new object[0]); } else { ToolboxBitmapAttribute attribute = (ToolboxBitmapAttribute)TypeDescriptor.GetAttributes(draggedActivities[0].GetType())[typeof(ToolboxBitmapAttribute)]; bitmap2 = attribute.GetImage(draggedActivities[0].GetType()) as Bitmap; s = draggedActivities[0].GetType().Name; } if ((bitmap2 != null) && (s.Length > 0)) { WorkflowView parentView = base.ParentView; Rectangle rectangle = (bitmap2 != null) ? new Rectangle(Point.Empty, bitmap2.Size) : Rectangle.Empty; Rectangle layoutRectangle = (s.Length > 0) ? new Rectangle(Point.Empty, new Size(AmbientTheme.DragImageTextSize.Width, parentView.Font.Height + 2)) : Rectangle.Empty; if (!rectangle.IsEmpty) { layoutRectangle.Offset(rectangle.Width + AmbientTheme.DragImageMargins.Width, 0); } Size size = parentView.LogicalSizeToClient(new Size(rectangle.Width + layoutRectangle.Width, Math.Max(rectangle.Height, layoutRectangle.Height))); image = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb); using (Graphics graphics = Graphics.FromImage(image)) { using (Brush brush = new SolidBrush(Color.FromArgb(0, 0xff, 0, 0xff))) { graphics.ScaleTransform(this.ScaleZoomFactor, this.ScaleZoomFactor); graphics.FillRectangle(brush, new Rectangle(0, 0, image.Width, image.Height)); if (bitmap2 != null) { graphics.DrawImage(bitmap2, new Rectangle(Point.Empty, bitmap2.Size)); } if (s.Length > 0) { StringFormat format = new StringFormat { Alignment = StringAlignment.Near, Trimming = StringTrimming.EllipsisCharacter, LineAlignment = StringAlignment.Center }; graphics.DrawString(s, parentView.Font, SystemBrushes.WindowText, layoutRectangle, format); } } } } } this.dragImage = image; }
private void OnPropertyGridAdornments(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList) { IComponent component = null; IReferenceService referenceService = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService; if (referenceService != null) { component = referenceService.GetComponent(context.Instance); } string fullAliasName = string.Empty; //this attribue is set to overcome issue with the TypedVariableDeclarationTypeConverter //not returning Name property at all. we alias that property to the VariableDeclaration itself DefaultPropertyAttribute aliasPropertyNameAttribute = propDesc.Attributes[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute; if (aliasPropertyNameAttribute != null && aliasPropertyNameAttribute.Name != null && aliasPropertyNameAttribute.Name.Length > 0) { fullAliasName = propDesc.Name + "." + aliasPropertyNameAttribute.Name; } if (component != null) { ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(component as Activity); if (activityDesigner != null) { if (!activityDesigner.IsLocked && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc) && !propDesc.IsReadOnly) { valueUIItemList.Add(new PropertyValueUIItem(DR.GetImage(DR.Bind), OnBindProperty, DR.GetString(DR.BindProperty))); } string fullComponentName = referenceService.GetName(component); //schedule1.send1 string fullPropertyName = referenceService.GetName(context.Instance); //schedule1.send1.message fullPropertyName = (fullPropertyName.Length > fullComponentName.Length) ? fullPropertyName.Substring(fullComponentName.Length + 1, fullPropertyName.Length - fullComponentName.Length - 1) + "." + propDesc.Name : string.Empty; foreach (DesignerAction action in activityDesigner.DesignerActions) { string actionPropertyName = action.PropertyName as string; if (actionPropertyName == null || actionPropertyName.Length == 0) { continue; } if (actionPropertyName == propDesc.Name || (actionPropertyName == fullPropertyName) || (actionPropertyName == fullAliasName)) { PropertyValueUIItemHandler propValueUIItemhandler = new PropertyValueUIItemHandler(action); valueUIItemList.Add(new PropertyValueUIItem(action.Image, propValueUIItemhandler.OnFixPropertyError, action.Text)); break; } } } } }
private void OnPropertyGridAdornments(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList) { IComponent reference = null; IReferenceService service = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService; if (service != null) { reference = service.GetComponent(context.Instance); } string str = string.Empty; DefaultPropertyAttribute attribute = propDesc.Attributes[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute; if (((attribute != null) && (attribute.Name != null)) && (attribute.Name.Length > 0)) { str = propDesc.Name + "." + attribute.Name; } if (reference != null) { ActivityDesigner designer = ActivityDesigner.GetDesigner(reference as Activity); if (designer != null) { if ((!designer.IsLocked && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc)) && !propDesc.IsReadOnly) { valueUIItemList.Add(new PropertyValueUIItem(DR.GetImage("Bind"), new PropertyValueUIItemInvokeHandler(this.OnBindProperty), DR.GetString("BindProperty", new object[0]))); } string name = service.GetName(reference); string str3 = service.GetName(context.Instance); str3 = (str3.Length > name.Length) ? (str3.Substring(name.Length + 1, (str3.Length - name.Length) - 1) + "." + propDesc.Name) : string.Empty; foreach (DesignerAction action in designer.DesignerActions) { string propertyName = action.PropertyName; if (((propertyName != null) && (propertyName.Length != 0)) && (((propertyName == propDesc.Name) || (propertyName == str3)) || (propertyName == str))) { PropertyValueUIItemHandler handler = new PropertyValueUIItemHandler(action); valueUIItemList.Add(new PropertyValueUIItem(action.Image, new PropertyValueUIItemInvokeHandler(handler.OnFixPropertyError), action.Text)); break; } } } } }