Exemple #1
0
        void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            _diagramViewModel = new DiagramViewModel();

            //SetupStatesDiagram(_diagramViewModel);

            SetupExpressionsDiagram(_diagramViewModel);

            diagram.DataContext = _diagramViewModel;
            palette.DataContext = _diagramViewModel;
        }
 public void PropertiesTests()
 {
     var vm = new DiagramViewModel();
     TestsHelper.TestPublicDeclaredPropertiesGetSet(vm, true);
 }
Exemple #3
0
        //private static List<IExpressionField> GetCRFields(IExpressionField f, SourceFieldList sourceNodeList)
        //{
        //    Func<IExpressionField, ICollection<IExpressionField>> sfRetriever = srf => GetCRFields(f, sourceNodeList);
        //    return new List<IExpressionField>
        //    {
        //        new SourceField(sourceNodeList)
        //            {
        //                DataType = NodeDataType.String, 
        //                Name = "Name", 
        //                SetName = SourceFieldSetNames.Item, 
        //                SystemName = f.Name + ".Name", 
        //                ConnectorOut = { DataType = NodeDataType.String, Name = f.Name + ".Name" },
        //            },
        //        new SourceField(sourceNodeList)
        //            {
        //                DataType = NodeDataType.String, 
        //                Name = "Author", 
        //                SetName = SourceFieldSetNames.Item, 
        //                SystemName = f.Name + ".Author", 
        //                ConnectorOut = { DataType = NodeDataType.String, Name = f.Name + ".Author" },
        //                SubfieldsRetriever = sfRetriever
        //            }
        //    };
        //}

        #region States
        private static void SetupStatesDiagram(DiagramViewModel vm)
        {
            vm.Palette.Add(new NodeGroup("Common States", new List<NodeViewModel<StateNode, StateConnection>>
                                                              {
                                                                  new NodeViewModel<StateNode, StateConnection>(
                                                                      new StateNode
                                                                          {
                                                                              Name = "Default",
                                                                              Description = "Default",
                                                                              Width = 135,
                                                                              Height = 60
                                                                          }, vm),
                                                                  new NodeViewModel<StateNode, StateConnection>(
                                                                      new StateNode
                                                                          {
                                                                              Name = "Approved",
                                                                              Description = "Approved",
                                                                              Width = 135,
                                                                              Height = 60
                                                                          }, vm),
                                                                  new NodeViewModel<StateNode, StateConnection>(
                                                                      new StateNode
                                                                          {
                                                                              Name = "Rejected",
                                                                              Description = "Rejected",
                                                                              Width = 135,
                                                                              Height = 60
                                                                          }, vm),
                                                                  new NodeViewModel<StateNode, StateConnection>(
                                                                      new StateNode
                                                                          {
                                                                              Name = "ReadyToApprove",
                                                                              Description = "ReadyToApprove",
                                                                              Width = 135,
                                                                              Height = 60
                                                                          }, vm)
                                                              }));

            var defaultNode = new StateNode
                                  {Name = "Default", Description = "Default", Width = 135, Height = 60, Left = 10, Top = 10};
            var approvedNode = new StateNode
                                   {
                                       Name = "Approved",
                                       Description = "Approved",
                                       Width = 135,
                                       Height = 60,
                                       Left = 200,
                                       Top = 200
                                   };
            var rejectedNode = new StateNode
                                   {Name = "Rejected", Description = "Rejected", Width = 135, Height = 60, Left = 10, Top = 200};

            var defaultNodeVM = new NodeViewModel<StateNode, StateConnection>(defaultNode, vm);
            var approvedNodeVM = new NodeViewModel<StateNode, StateConnection>(approvedNode, vm);
            var rejectedNodeVM = new NodeViewModel<StateNode, StateConnection>(rejectedNode, vm);

            vm.Items.Add(defaultNodeVM);
            vm.Items.Add(approvedNodeVM);
            vm.Items.Add(rejectedNodeVM);

            var defaultToApprovedConnection = new StateConnection
                                                  {
                                                      SourceItem = defaultNode,
                                                      DestinationItem = approvedNode,
                                                      IsSecurityMode = true,
                                                      IsUnlocked = true
                                                  };
            var defaultToRejectedConnection = new StateConnection {SourceItem = defaultNode, DestinationItem = rejectedNode};
            var rejectedToDefaultConnection = new StateConnection {SourceItem = rejectedNode, DestinationItem = defaultNode};

            vm.Items.Add(new ConnectionViewModel<StateConnection>(defaultToApprovedConnection, defaultNodeVM, approvedNodeVM, vm));
            vm.Items.Add(new ConnectionViewModel<StateConnection>(defaultToRejectedConnection, defaultNodeVM, rejectedNodeVM, vm));
            vm.Items.Add(new ConnectionViewModel<StateConnection>(rejectedToDefaultConnection, rejectedNodeVM, defaultNodeVM, vm));
        }
Exemple #4
0
        private static void SetupExpressionsDiagram(DiagramViewModel vm)
        {
            vm.Palette.Add(new NodeGroup("String Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.ToUpper)
                                                        {
                                                            ExpressionName = "Uppercase",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.ToLower)
                                                        {
                                                            ExpressionName = "Lowercase",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.Trim)
                                                        {
                                                            ExpressionName = "Trim",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Concat)
                                                        {
                                                            ExpressionName = "Concat",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Left)
                                                        {
                                                            ExpressionName = "Left",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } 
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Right)
                                                        {
                                                            ExpressionName = "Right",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    )
                                                }));

            vm.Palette.Add(new NodeGroup("Date Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.AddDays)
                                                        {
                                                            ExpressionName = "Add Days",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Days Count" },
                                                            ConnectorOut = { DataType = NodeDataType.DateTime, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.DateDiffDays)
                                                        {
                                                            ExpressionName = "DateDiff Days",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date 1" },
                                                            Connector2In = { DataType = NodeDataType.DateTime, Name = "Date 2" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.DateDiffHours)
                                                        {
                                                            ExpressionName = "DateDiff Hours",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date 1" },
                                                            Connector2In = { DataType = NodeDataType.DateTime, Name = "Date 2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FunctionExpressionNode, ExpressionConnection>(
                                                        new FunctionExpressionNode(vm, new FunctionExpression(ExpressionNodeType.CustomFunction)
                                                        {
                                                            ExpressionName = "Current Date",
                                                            FunctionName = "DateTime.Now",
                                                            ConnectorOut = { DataType = NodeDataType.DateTime, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateYear)
                                                        {
                                                            ExpressionName = "Date Year",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Year" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateQuarter)
                                                        {
                                                            ExpressionName = "Date Quarter",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Quarter" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateMonth)
                                                        {
                                                            ExpressionName = "Date Month",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Month" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateMonthName)
                                                        {
                                                            ExpressionName = "Date Month Name",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Month Name" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateWeek)
                                                        {
                                                            ExpressionName = "Date Week",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Week" }
                                                        }),
                                                        vm
                                                    ),

                                                }));

            vm.Palette.Add(new NodeGroup("Logical Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.IsLess)
                                                        {
                                                            ExpressionName = "Less",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.IsGreater)
                                                        {
                                                            ExpressionName = "Greater",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.AreEqual)
                                                        {
                                                            ExpressionName = "Equals",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<ThreeInOneOutExpressionNode, ExpressionConnection>(
                                                        new ThreeInOneOutExpressionNode(vm, new ThreeInOneOutExpression(ExpressionNodeType.If)
                                                        {
                                                            ExpressionName = "Condition",
                                                            Connector1In = { DataType = NodeDataType.Boolean, Name = "Condition" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "When True"  },
                                                            Connector3In = { DataType = NodeDataType.String, Name = "When False" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("Aggregate Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Add)
                                                        {
                                                            ExpressionName = "Add", 
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1"},
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2"},
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Subtract)
                                                        { 
                                                            ExpressionName = "Subtract",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Multiply)
                                                        {
                                                            ExpressionName = "Multiply",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Divide)
                                                        {
                                                            ExpressionName = "Divide",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.CustomFunction)
                                                        {
                                                            ExpressionName = "Custom Multiply",
                                                            FunctionName = "?1 * ?2",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("SPC Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.AboveCenterLine)
                                                        {
                                                            ExpressionName = "Above Center Line", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.BelowCenterLine)
                                                        {
                                                            ExpressionName = "Below Center Line", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.GoingDown)
                                                        {
                                                            ExpressionName = "Going Down", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.GoingUp)
                                                        {
                                                            ExpressionName = "Going Up", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.AlternatingUpAndDown)
                                                        {
                                                            ExpressionName = "Alternating Up and Down", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.LessThanLowerLimits)
                                                        {
                                                            ExpressionName = "Less Than LCL/LSL", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "LCL/LSL"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector5In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.GreaterThanUpperLimits)
                                                        {
                                                            ExpressionName = "Greater Than UCL/USL", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "UCL/USL"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector5In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.Same)
                                                        {
                                                            ExpressionName = "Same", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.Between)
                                                        {
                                                            ExpressionName = "Between", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Double, Name = "Low Value"},
                                                            Connector5In = { DataType = NodeDataType.Double, Name = "High Value"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneAorBeyond)
                                                        {
                                                            ExpressionName = "Zone A or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneBorBeyond)
                                                        {
                                                            ExpressionName = "Zone B or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneCorBeyond)
                                                        {
                                                            ExpressionName = "Zone C or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.FailedNumber)
                                                        {
                                                            ExpressionName = "Failed Number (attribute)", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Number of samples"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.FailedPercent)
                                                        {
                                                            ExpressionName = "Failed Percent (attribute)", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Number of samples"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("Constants",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<ConstantExpressionNode, ExpressionConnection>(
                                                        new ConstantExpressionNode(vm, new ConstantExpression()
                                                        {
                                                            ExpressionName = "Constant",
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    )
                                                }));


            var uis = new SourceFieldList {ExpressionName = "Current User Information", Left = 10, Top = 400};
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "User Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserName", ConnectorOut = { DataType = NodeDataType.String, Name = "User Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Full Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserFullName", ConnectorOut = { DataType = NodeDataType.String, Name = "Full Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.Int, Name = "Person ID", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserPersonId", ConnectorOut = { DataType = NodeDataType.String, Name = "Person ID" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Email Address", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserEmailAddress", ConnectorOut = { DataType = NodeDataType.String, Name = "Email Address" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Last Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserLastName", ConnectorOut = { DataType = NodeDataType.String, Name = "Last Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Business Unit", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserBusinessUnitId", ConnectorOut = { DataType = NodeDataType.String, Name = "Business Unit" } });

            // source
            //var fieldList = new Dictionary<string, object>();
            //fieldList["Name"] = "Name";
            //fieldList["Title"] = "Title";
            //fieldList["PublishDate"] = DateTime.Now;
            //fieldList["Author"] = "Author";

            var sourceNodeList = new SourceFieldList();

            //Func<IExpressionField, ICollection<IExpressionField>> sfRetriever = f => GetCRFields(f, sourceNodeList);
            
            sourceNodeList.ExpressionName = "Album";
            sourceNodeList.Top = 10;
            sourceNodeList.Left = 10;
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Name", SetName = SourceFieldSetNames.Item, SystemName = "Name", ConnectorOut = { DataType = NodeDataType.String, Name = "Name" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Title", SetName = SourceFieldSetNames.Item, SystemName = "Title", ConnectorOut = { DataType = NodeDataType.String, Name = "Title" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "PublishDate", SetName = SourceFieldSetNames.Item, SystemName = "PublishDate", ConnectorOut = { DataType = NodeDataType.String, Name = "PublishDate" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList)
                                          {
                                              DataType = NodeDataType.String, 
                                              Name = "Author", 
                                              SetName = SourceFieldSetNames.Item, 
                                              SystemName = "Author", 
                                              ConnectorOut = { DataType = NodeDataType.String, Name = "Author" },
                                              SubfieldsRetriever = new CRSubfieldsRetriever()
                                          });



            //var sourceNodes = SourceNodeFactory.ConvertToSource("Album", fieldList, SourceFieldSetNames.Item);
            //sourceNodes.Top = 10;
            //sourceNodes.Left = 10;
            //sourceNodes.Width = 200;

            // destination
            var destinationNodes = DestinationNodeFactory.ConvertToSource(typeof(ExpressionResult));
            destinationNodes.Top = 200;
            destinationNodes.Left = 600 ;

            var expressions = new List<IExpressionObjectBase>();
            expressions.Add(sourceNodeList);
            //expressions.Add(uis);
            expressions.Add(destinationNodes);

            // connection
            var connection = new Connection
                                 {
                                     Id = Guid.NewGuid(),
                                     Source = new ConnectorOut(null) { Id = sourceNodeList.ConnectorsOut[0].Id },
                                     Sink = new ConnectorIn(null) { Id = destinationNodes.ConnectorsIn[0].Id }
                                 };
            //expressions.Add(connection);

            // constant
            var constantExpr = new ConstantExpression { ExpressionName = "Constant", Top = 10, Left = 250, Value = 10,
                                                        ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            //expressions.Add(constantExpr);

            // oneinoneout
            var oneinoneoutExpr = new OneInOneOutExpression(ExpressionNodeType.ToUpper)
                                      { ExpressionName = "Uppercase", Top = 60, Left = 250, 
                                        ConnectorIn = {DataType = NodeDataType.String, Name = "String"},
                                        ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                      };
            //expressions.Add(oneinoneoutExpr);

            // twoinoneout
            var twoinoneoutExpr = new TwoInOneOutExpression(ExpressionNodeType.Concat)
            {
                ExpressionName = "Concat",
                Top = 110,
                Left = 250,
                Connector1In = { DataType = NodeDataType.String, Name = "String" },
                Connector2In = { DataType = NodeDataType.String, Name = "String" },
                ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            //expressions.Add(twoinoneoutExpr);

            // threeinoneout
            var threeinoneoutExpr = new ThreeInOneOutExpression(ExpressionNodeType.If)
            {
                ExpressionName = "Condition",
                Top = 180,
                Left = 250,
                Connector1In = { DataType = NodeDataType.Boolean, Name = "Condition" },
                Connector2In = { DataType = NodeDataType.String, Name = "If True" },
                Connector3In = { DataType = NodeDataType.String, Name = "If False" },
                ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            expressions.Add(threeinoneoutExpr);

            // function
            var functionExpr = new FunctionExpression(ExpressionNodeType.CustomFunction) { ExpressionName = "Current Date", Top = 280, Left = 250, Width = 100, Height = 45, FunctionName = "DateTime.Now",
                                ConnectorOut = {DataType = NodeDataType.DateTime, Name="Result"}};
            //expressions.Add(functionExpr);

            ExpressionTranslator.TranslateToDiagram(expressions, vm);
        }