Exemple #1
0
        private void AddPipelineComponent(IPipelineComponent toRealize, PipelineComponentRole role)
        {
            Exception exConstruction;

            //create the pipeline realization (might fail
            var value = _pipelineFactory.TryCreateComponent(toRealize, out exConstruction);

            if (role != PipelineComponentRole.Source)
            {
                AddDividerIfReorderingAvailable();
            }

            //create the visualization
            var component = new PipelineComponentVisualisation(toRealize, role, value, exConstruction, component_shouldAllowDrop);

            component.DragDrop += component_DragDrop;
            flpPipelineDiagram.Controls.Add(component);//add the component

            //try to initialize the realization (we do this after creating visualization so that when the events come in we can record where on UI the consumption events happen and also because later on it might be that initialization takes ages and we want to use a Thread)
            if (value != null)
            {
                try
                {
                    if (!_useCase.IsDesignTime)
                    {
                        _useCase.GetContext().PreInitializeGeneric(new ThrowImmediatelyDataLoadEventListener(), value, _useCase.GetInitializationObjects().ToArray());
                        component.Check();
                    }

                    component.CheckMandatoryProperties();
                }
                catch (Exception exInit)
                {
                    //initialization failed
                    component.ExInitialization = exInit;
                }
            }

            component.AllowDrag = AllowReOrdering;

            if (AllowSelection)
            {
                component.AllowSelection     = true;
                component.ComponentSelected += component_Selected;
            }


            //PipelineComponents can never be locked because they are user setup things
            component.IsLocked = false;
        }
Exemple #2
0
        public DataFlowComponentVisualisation(PipelineComponentRole role, object value, Func <DragEventArgs, DataFlowComponentVisualisation, DragDropEffects> shouldAllowDrop)
        {
            Value            = value;
            _role            = role;
            _shouldAllowDrop = shouldAllowDrop;
            InitializeComponent();

            _fullPen.Width        = 2;
            _emptyPen.Width       = 2;
            _emptyPen.DashPattern = new float[] { 4.0F, 2.0F, 1.0F, 3.0F };

            if (value == null)
            {
                IsLocked     = false;//cannot be locked AND empty!
                _isEmpty     = true;
                lblText.Text = "Empty";
                AllowDrop    = _shouldAllowDrop != null;
            }
            else
            {
                _checkable        = value as ICheckable;
                _mandatoryChecker = new MandatoryPropertyChecker(value);
                lblText.Text      = value.ToString();//.GetType().Name;
                GenerateToolTipBasedOnProperties(value);
            }

            switch (role)
            {
            case PipelineComponentRole.Source:
                prongLeft1.Visible = false;
                prongLeft2.Visible = false;
                break;

            case PipelineComponentRole.Middle:
                break;

            case PipelineComponentRole.Destination:
                prongRight1.Visible = false;
                prongRight2.Visible = false;
                break;

            default:
                throw new ArgumentOutOfRangeException("role");
            }


            this.Width = lblText.PreferredWidth + 80;
        }
Exemple #3
0
        public PipelineComponentVisualisation(IPipelineComponent component, PipelineComponentRole role, object valueOrNullIfBroken, Exception constructionExceptionIfAny, Func <DragEventArgs, DataFlowComponentVisualisation, DragDropEffects> shouldAllowDrop)
            : base(role, valueOrNullIfBroken, shouldAllowDrop)
        {
            PipelineComponent = component;

            if (constructionExceptionIfAny != null)
            {
                ragSmiley1.OnCheckPerformed(new CheckEventArgs("Failed to construct component", CheckResult.Fail, constructionExceptionIfAny));
            }

            _origFullPen = _fullPen;

            if (component == null)
            {
                return;
            }

            lblText.Text = component.GetClassNameLastPart();

            if (valueOrNullIfBroken == null)
            {
                ragSmiley1.OnCheckPerformed(new CheckEventArgs("Could not construct object", CheckResult.Fail));
            }

            this.Width = lblText.PreferredWidth + 85;

            _isEmpty = false;

            MouseDown             += Anywhere_MouseDown;
            lblText.MouseDown     += Anywhere_MouseDown;
            prongRight1.MouseDown += Anywhere_MouseDown;
            prongRight2.MouseDown += Anywhere_MouseDown;
            prongLeft1.MouseDown  += Anywhere_MouseDown;
            prongLeft2.MouseDown  += Anywhere_MouseDown;
            pComponent.MouseDown  += Anywhere_MouseDown;
        }
Exemple #4
0
 //by ID overload
 private void AddPipelineComponent(int componentID, PipelineComponentRole role, IRepository repository)
 {
     AddPipelineComponent(repository.GetObjectByID <PipelineComponent>(componentID), role);
 }