public void SetActivity(Engine.Tools.IGraphicActivity activity) { GraphicActivity = activity; GraphicActivity.Initialize(this); OnDrawingBoardActionRequested(WorkflowDrawingBoardRequestType.DetachHandleEndOfProcess); if (GraphicActivity is Engine.Effects.Effect) { // for effects, must disable mouse input in workflow because // they are working on different thread and cause failure in EffectBase.Process() DrawingBoardMode = DrawingBoardModes.Disabled; // DrawingBoardMode can be re-enabled by clicking on "Draw" button in UI // or selecting a new drawing tool. } if (GraphicActivity is Engine.Tools.Tool) { DrawingBoardMode = DrawingBoardModes.None; // will cycle to SuspendDraw and Draw } if (GraphicActivity.HasVisualProperties) { OnPropertyPageActionRequested(WorkflowPropertyPageRequestType.ContentUpdate); } else { OnPropertyPageActionRequested(WorkflowPropertyPageRequestType.ClosePage); } }
private void SetActivity(Engine.Tools.IGraphicActivity activity) { Engine.Workflow w = GetWorkflowForCurrentDrawingBoard(); if (w == null) { return; } w.SetActivity(activity); _app.VisualPropertyPageManager.Show(w); }
/// <summary> /// /// </summary> /// <param name="w"></param> /// <remarks>Called by the VisualPropertyPageManager</remarks> internal void Build(Engine.Workflow w) { Clear(); t_workflow = w; if (w.GraphicActivity == null) { return; } Engine.Tools.IGraphicActivity activity = w.GraphicActivity; Engine.Effects.VisualProperties vp = activity.GetVisualProperties(); // this can happen for tools or effects that have no visual properties if (vp == null) { return; } if (vp.Count == 0) { // ensure no properties are left from a previous workflow-document t_properties = null; t_canAutoApply = false; return; } t_properties = new Engine.Attributes.AttributeCollection(); Dictionary <string, Engine.Effects.VisualPropertyItem> items = vp.GetItems(); foreach (KeyValuePair <string, Engine.Effects.VisualPropertyItem> key in items) { BuildControl(key); } t_canAutoApply = true; }
/// <summary> /// Validates and passes the values to the selected GraphicActivity (tool, effect, animation). /// </summary> /// <returns>Indicates whether or not the validation process raised an error or not.</returns> private bool Apply() { Engine.Tools.IGraphicActivity ga = t_workflow.GraphicActivity; Type gaType = ga.GetType(); bool hasErrors = false; foreach (System.Windows.UIElement uie in FlowPanelContainer.Children) { TPropertyControl ipc = (TPropertyControl)uie; // required when user has entered invalid value, signals are being displayed. when user enters corrected values // the validation process is executed again and in case of success, no signal must be displayed. ipc.ClearSignals(); string propertyActualName = ipc.PropertyName; // i.e.: "Seed" object validatedValue = null; if (ipc.Validators.Count > 0) { foreach (Engine.Validators.Validator v in ipc.Validators) { v.InputValue = (string)ipc.EnteredValue; bool result = v.Validate(); if (!result) { ipc.SignalError(v.ErrorMessage); hasErrors = true; continue; } } if (!hasErrors) { // using the interface IValidated which can return an object; specific validators return a value specific to the control data type validatedValue = ((Engine.Validators.IValidated)ipc.Validators[ipc.Validators.Count - 1]).Validated; // there is a special case where the selected value is an enum, this is being handled by the IntAttribute class t_properties.Get(propertyActualName).SetValue(validatedValue); } } else { // no validator validatedValue = ipc.EnteredValue; } PropertyInfo prop = gaType.GetProperty(propertyActualName, BindingFlags.Public | BindingFlags.Instance); if (prop != null && prop.CanWrite) { prop.SetValue(ga, validatedValue, null); } } ga.CollectedPropertyValues = t_properties; return(hasErrors); }