예제 #1
0
 private void ClickAddDynCom(object sender, RoutedEventArgs e)
 {
     Models.Dynamic.IDynItems    item = (sender as MenuItem).DataContext as Models.Dynamic.IDynItems;
     Models.Dynamic.DynComObject para = new Models.Dynamic.DynComObject()
     {
         Parent = item
     };
     if ((VersionList.SelectedItem as Models.AppVersion).IsComObjectRefAuto)
     {
         Models.ComObjectRef oref = new Models.ComObjectRef()
         {
             Name = "Ref" + (new Random().Next(0, 10000))
         };
         (VersionList.SelectedItem as Models.AppVersion).ComObjectRefs.Add(oref);
         para.ComObjectRefObject = oref;
     }
     item.Items.Add(para);
 }
예제 #2
0
        private void LoadSubDyn(Models.Dynamic.IDynItems dyn, List <Models.ParameterRef> paras, List <Models.ComObjectRef> coms)
        {
            foreach (Models.Dynamic.IDynItems item in dyn.Items)
            {
                item.Parent = dyn;

                if (item is Models.Dynamic.DynParameter)
                {
                    Models.Dynamic.DynParameter para = item as Models.Dynamic.DynParameter;
                    if (!string.IsNullOrEmpty(para._parameter))
                    {
                        Models.ParameterRef pr = paras.Single(p => p.Name == para._parameter);
                        para.ParameterRefObject = pr;
                    }
                }
                else if (item is Models.Dynamic.DynChoose)
                {
                    Models.Dynamic.DynChoose ch = item as Models.Dynamic.DynChoose;
                    if (!string.IsNullOrEmpty(ch._parameterRef))
                    {
                        Models.ParameterRef pr = paras.Single(p => p.Name == ch._parameterRef);
                        ch.ParameterRefObject = pr;
                    }
                }
                else if (item is Models.Dynamic.DynComObject)
                {
                    Models.Dynamic.DynComObject dc = item as Models.Dynamic.DynComObject;
                    if (!string.IsNullOrEmpty(dc._comObjectRef))
                    {
                        Models.ComObjectRef cr = coms.Single(c => c.Name == dc._comObjectRef);
                        dc.ComObjectRefObject = cr;
                    }
                }

                if (!(item is Models.Dynamic.DynParameter) && item.Items != null)
                {
                    LoadSubDyn(item, paras, coms);
                }
            }
        }