private ToolStripMenuItem CreateFilterItem(VariableGroup varGroup)
        {
            ToolStripMenuItem item = new ToolStripMenuItem(varGroup.ToString());

            item.Click += (sender, e) => ToggleVarGroupVisibility(varGroup);
            return(item);
        }
Ejemplo n.º 2
0
 public EquationEditorForm(VariableGroup group)
 {
     InitializeComponent();
     m_group = group;
     m_sail = group.Sail;
     if (m_sail != null)
     {
         List<object> autoComplete = m_sail.GetAutoFillData(group);
         List<MouldCurve> curves = m_sail.GetCurves(group);
         //curves.ForEach(cur => { autoComplete.Add(cur); });
         curves.ForEach(curve => CurveListBox.Items.Add(curve));
         availableEqs = m_sail.GetEquations(m_group);
         EquationListBox.Items.Clear();
         foreach (KeyValuePair<string, Equation> entry in availableEqs)
         {
             //autoComplete.Add(entry.Value);
             EquationListBox.Items.Add(entry.Key);
             listView1.Items.Add(entry.Key);
             if (!m_group.ContainsKey(entry.Key))
                 listView1.Items[listView1.Items.Count - 1].Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Italic);
             //else
             //	listView1.Items[listView1.Items.Count - 1].BackColor = Color.White;
             //	EquationListBox.Items[EquationListBox.Items.Count-1]
         }
         autoCompleteTextBox1.Values = autoComplete.ToArray();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 向当前组添加子组
        /// </summary>
        /// <param name="name">子组名称</param>
        /// <param name="absolutePath">要添加的组全路径</param>
        public virtual VariableGroup AddGroup(string name, string absolutePath)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new Exception(Resource1.CVariableGroup_AddGroup_GroupNameIsNull);
            }

            VariableGroup parentVariableGroup = VariableRepository.FindGroupByPath(absolutePath);

            if (parentVariableGroup == null)
            {
                throw new ArgumentNullException(Resource1.UnitofWork_AddGroup_currentVariableGroup);
            }
            var newGroup = new VariableGroup(name, parentVariableGroup);

            if (IsExistName(name, parentVariableGroup))
            {
                throw new Exception(Resource1.CVariableGroup_AddGroup_GroupeNameIsExist);
            }

            parentVariableGroup.ChildGroups.Add(newGroup);
            RealTimeRepositoryBase.RtDbContext.VariableGroupSet.Add(newGroup);
            RealTimeRepositoryBase.RtDbContext.SaveAllChanges();
            return(newGroup);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 复制变量组
        /// </summary>
        /// <param name="sourse">源</param>
        /// <param name="destination">目标</param>
        /// <param name="pasteMode">粘贴模式,0:默认模式,重复则返回,1:如果重复则替换,2:如果重复则两个变量都保留,3:如果重复则放弃</param>
        private void CopyGroup(VariableGroup sourse, VariableGroup destination, uint pasteMode)
        {
            if (sourse == null)
            {
                return;
            }
            string groupName = sourse.Name;

            if ((pasteMode == 2) && IsExistName(sourse.Name, destination))//同时保留两个
            {
                groupName = GetDefaultName(destination, sourse.Name);
            }
            AddGroup(groupName, destination.AbsolutePath);

            VariableGroup var =
                VariableRepository.FindGroupByPath(destination.AbsolutePath == null ? groupName : destination.AbsolutePath + "." + groupName);

            if (var == null)
            {
                throw new ArgumentNullException(Resource1.VariableRepository_CopyGroup_destinationIsNotExist);
            }

            foreach (var childVariable in sourse.ChildVariables)
            {
                var varVariable = new AnalogVariable(var);
                ObjectCopier.CopyProperties(varVariable, childVariable);
                AddVariable(varVariable);
            }

            foreach (var variableGroup in sourse.ChildGroups)
            {
                CopyGroup(variableGroup, var, pasteMode);
            }
        }
 public void ShowOnlyVariableGroup(VariableGroup visibleVarGroup)
 {
     ShowOnlyVariableGroups(new List <VariableGroup>()
     {
         visibleVarGroup
     });
 }
Ejemplo n.º 6
0
        private void TreeViewVariableListMouseDown(object sender, MouseEventArgs e)
        {
            _currentNode = treeView_VariableList.GetNodeAt(e.X, e.Y);

            if (_currentNode == null)
            {
                return;
            }
            treeView_VariableList.SelectedNode = _currentNode;
            VariableGroup varGroup =
                _iVariableDesignRepository.FindGroupByPath(GetVariableGroupPath(_currentNode.FullPath));

            if (varGroup == null)
            {
                return;
            }
            dataGridView_VariableList.Rows.Clear();
            foreach (VariableBase variable in _iVariableDesignRepository.FindVariables(varGroup.AbsolutePath))
            {
                AddVarToListview(variable, dataGridView_VariableList);
            }
            if (dataGridView_VariableList.Rows.Count > 0)
            {
                dataGridView_VariableList.Rows[0].Selected = false;
            }
        }
Ejemplo n.º 7
0
 public EquationEditorForm(VariableGroup group)
 {
     InitializeComponent();
     m_group = group;
     m_sail = group.Sail;
     if (m_sail != null)
     {
         List<IRebuild> watermark = m_sail.Watermark(group);
         //availableEqs = new List<Equation>();
         CurveListBox.Items.Clear();
         EquationListBox.Items.Clear();
         listView1.Items.Clear();
         foreach (IRebuild entry in watermark)
         {
             if (entry is Equation)
             {
             //	availableEqs.Add(entry as Equation);
                 EquationListBox.Items.Add(entry.Label);
                 listView1.Items.Add(entry.Label);
                 if (!m_group.ContainsKey(entry.Label))
                     listView1.Items[listView1.Items.Count - 1].Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Italic);
             }
             else if( entry is MouldCurve )
                 CurveListBox.Items.Add(entry as MouldCurve);
         }
         autoCompleteTextBox1.Values = watermark.ToArray<object>();
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 删除指定变量
        /// </summary>
        /// <param name="name">变量名称</param>
        /// <param name="absolutePath">移除变量所属组全路径</param>
        public virtual void RemoveVariable(string name, string absolutePath)
        {
            VariableGroup currentVariableGroup = VariableRepository.FindGroupByPath(absolutePath);

            if (currentVariableGroup == null)
            {
                throw new ArgumentNullException(Resource1.UnitofWork_AddGroup_currentVariableGroup);
            }
            var curVariable = currentVariableGroup.ChildVariables.FirstOrDefault(p => p.Name == name);

            if (curVariable == null)
            {
                return;
            }
            curVariable.ParentGroup.ChildVariables.Remove(curVariable);
            switch (curVariable.ValueType)
            {
            case VarValuetype.VarBool:
                RealTimeRepositoryBase.RtDbContext.DigitalSet.Remove((DigitalVariable)curVariable);
                break;

            case VarValuetype.VarDouble:
                RealTimeRepositoryBase.RtDbContext.AnalogSet.Remove((AnalogVariable)curVariable);
                break;

            case VarValuetype.VarString:
                RealTimeRepositoryBase.RtDbContext.TextSet.Remove((TextVariable)curVariable);
                break;
            }
            RealTimeRepositoryBase.RtDbContext.SaveAllChanges();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 删除指定组
        /// </summary>
        /// <param name="absolutePath">要移除的组全路径</param>
        public virtual void RemoveGroup(string absolutePath)
        {
            VariableGroup currentVariableGroup = VariableRepository.FindGroupByPath(absolutePath);

            if (currentVariableGroup == null)
            {
                throw new ArgumentNullException(Resource1.UnitofWork_AddGroup_currentVariableGroup);
            }
            //删除该组下面的子组
            while (currentVariableGroup.ChildGroups.Count > 0)
            {
                RemoveGroup(currentVariableGroup.ChildGroups[0].AbsolutePath);
            }

            //删除该组下的变量
            ClearVariable(absolutePath);

            //删除该组
            if (currentVariableGroup.Parent == null)
            {
                //根组不允许
                throw new Exception(Resource1.VariableGroup_RemoveGroup_DeleteGroup_Is_RootGroup);
            }
            currentVariableGroup.Parent.ChildGroups.Remove(currentVariableGroup);
            RealTimeRepositoryBase.RtDbContext.VariableGroupSet.Remove(currentVariableGroup);
            RealTimeRepositoryBase.RtDbContext.SaveAllChanges();
        }
        public override IEnumerable <IVersionable> Build(IEnumerable <IVersionable> ws)
        {
            Collection <IVersionable> allItems = getAllItems();

            var rp  = allItems.OfType <ResourcePackage>().First();
            var qcs = new ControlConstructScheme();

            qcs.ItemName.Add("en-GB", "Topic Question Construct Groups");
            qcs.UserIds.Add(new UserId("closerid", "topics-ccs-000001"));
            var vs = new VariableScheme();

            vs.ItemName.Add("en-GB", "Topic Variable Groups");
            vs.UserIds.Add(new UserId("closerid", "topics-vs-000001"));
            rp.ControlConstructSchemes.Add(qcs);
            rp.VariableSchemes.Add(vs);
            allItems.Add(qcs);
            allItems.Add(vs);

            var concept_lookup_q = new Dictionary <Concept, ControlConstructGroup>();
            var concept_lookup_v = new Dictionary <Concept, VariableGroup>();

            foreach (var concept in allItems.OfType <Concept>().ToList())
            {
                var qcg = new ControlConstructGroup();
                qcg.TypeOfGroup = "ConceptGroup";
                qcg.Concept     = concept;
                qcg.Label.Add("en-GB", concept.Label.Best + " Question Construct Group");
                qcg.ItemName.Add("en-GB", concept.ItemName.Best);
                qcg.UserIds.Add(new UserId("closerid", "topics-qcg-" + concept.ItemName.Best.ToLower()));

                concept_lookup_q[concept] = qcg;

                foreach (var parent_concept in concept.SubclassOf)
                {
                    concept_lookup_q[parent_concept].ChildGroups.Add(qcg);
                }

                qcs.ControlConstructGroups.Add(qcg);
                allItems.Add(qcg);

                var vg = new VariableGroup();
                vg.TypeOfGroup = "ConceptGroup";
                vg.Concept     = concept;
                vg.Label.Add("en-GB", concept.Label.Best + " Variable Group");
                vg.ItemName.Add("en-GB", concept.ItemName.Best);

                concept_lookup_v[concept] = vg;

                foreach (var parent_concept in concept.SubclassOf)
                {
                    concept_lookup_v[parent_concept].ChildGroups.Add(vg);
                }

                vs.VariableGroups.Add(vg);
                allItems.Add(vg);
            }

            return(allItems);
        }
Ejemplo n.º 11
0
 public bool BelongsToGroup(VariableGroup variableGroup)
 {
     if (variableGroup == VariableGroup.NoGroup)
     {
         return(GroupList.Count == 0);
     }
     return(GroupList.Contains(variableGroup));
 }
        public void RemoveVariableGroup(VariableGroup varGroup)
        {
            List <WatchVariableControl> watchVarControls =
                _watchVarControls.FindAll(
                    watchVarControl => watchVarControl.BelongsToGroup(varGroup));

            RemoveVariables(watchVarControls);
        }
Ejemplo n.º 13
0
        /// <summary>
        ///     组节点退出编辑状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TreeViewFunctionTestAfterLabelEdit(object sender,
                                                        NodeLabelEditEventArgs e)
        {
            if (e.Label != null)
            {
                if (e.Label.Length > 0)
                {
                    if (e.Label.IndexOfAny(new[] { '@', '.', ',', '!' }) == -1)
                    {
                        try
                        {
                            VariableGroup varGroup =
                                _iVariableDesignRepository.FindGroupByPath(GetVariableGroupPath(_currentNode.FullPath));
                            _iVariableDesignRepository.RenameGroup(e.Label, GetVariableGroupPath(_currentNode.FullPath));
                            if (varGroup != null)
                            {
                                dataGridView_Avaiable.Rows.Clear();
                                foreach (VariableBase variable in varGroup.ChildVariables)
                                {
                                    AddVarToListview(variable, dataGridView_Avaiable);
                                }
                            }

                            // Stop editing without canceling the label change.
                            e.Node.EndEdit(false);
                        }
                        catch
                        {
                            e.CancelEdit = true;
                            MessageBox.Show(
                                Resources.FunctionTestForm_TreeViewFunctionTestAfterLabelEdit_NodeNameIsExist,
                                Resources.FunctionTestForm_TreeViewFunctionTestAfterLabelEdit_Node_Label_Edit);
                            e.Node.BeginEdit();
                        }
                    }
                    else
                    {
                        /* Cancel the label edit action, inform the user, and
                         * place the node in edit mode again. */
                        e.CancelEdit = true;
                        MessageBox.Show(Resources.FunctionTestForm_TreeViewFunctionTest_AfterLabelEdit_,
                                        Resources.FunctionTestForm_TreeViewFunctionTestAfterLabelEdit_Node_Label_Edit);
                        e.Node.BeginEdit();
                    }
                }
                else
                {
                    /* Cancel the label edit action, inform the user, and
                     * place the node in edit mode again. */
                    e.CancelEdit = true;
                    MessageBox.Show(Resources.FunctionTestForm_TreeViewFunctionTest_AfterLabelEdit_ContentIsBlank,
                                    Resources.FunctionTestForm_TreeViewFunctionTestAfterLabelEdit_Node_Label_Edit);
                    e.Node.BeginEdit();
                }

                treeView_FunctionTest.LabelEdit = true;
            }
        }
Ejemplo n.º 14
0
 public VariableGroupEditor(VariableGroup varGroup)
 {
     InitializeComponent();
     this.DoubleBuffered = true;
     VarGroup = varGroup;
     Count = 0;
     Equations = varGroup.ToArray();
     Label = varGroup.Label;
 }
Ejemplo n.º 15
0
        public VariableGroupTracker(VariableGroup group)
        {
            m_group = group;
            m_eqEditor = new EquationEditorForm(m_group);
            m_eqEditor.OnVariableAdded += m_eqEditor_OnVariableAdded;
            m_eqEditor.OnVariableDeleted += m_eqEditor_OnVariableDeleted;

            m_edit = new VariableGroupEditor(m_group);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 查询组路径下面所有变量
        /// </summary>
        /// <param name="absolutePath">组路径</param>
        /// <returns>所有变量列表</returns>
        public virtual IEnumerable <VariableBase> FindVariables(string absolutePath)
        {
            VariableGroup variableGroup = FindGroupByPath(absolutePath);

            if (variableGroup == null)
            {
                return(null);
            }
            return(variableGroup.ChildVariables);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Add a variable group
        /// </summary>
        /// <param name="variables"></param>
        /// <returns></returns>
        public VariableGroup Group(params Variable[] variables)
        {
            VariableGroup vg = VariableGroup.FromVariables(variables);

            for (int i = 0; i < variables.Length; i++)
            {
                variables[i].AddAttribute(new Models.Attributes.GroupMember(vg, i == 0));
            }
            groups.Add(vg);
            return(vg);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 对变量组进行排序
 /// </summary>
 /// <param name="vGroup">需要排序的组</param>
 private static void SortGroups(VariableGroup vGroup)
 {
     if (vGroup.ChildGroups != null)
     {
         vGroup.ChildGroups.Sort((x, y) => x.CreateTime.CompareTo(y.CreateTime));
         foreach (var childGroups in vGroup.ChildGroups)
         {
             SortGroups(childGroups);
         }
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 粘贴变量
        /// </summary>
        /// <param name="source">需要粘贴的变量</param>
        /// <param name="absolutePath">粘贴变量的目标组</param>
        /// <param name="isCopy">是否为复制,true为复制,false为剪切</param>
        /// <param name="pasteMode">粘贴模式,0:默认模式,重复则返回,1:如果重复则替换,2:如果重复则两个变量都保留,3:如果重复则放弃</param>
        /// <returns>如果默认模式下且有相同变量名称存在返回变量新名称,否则返回粘贴变量名称</returns>
        public virtual string PasteVariable(VariableBase source, string absolutePath, bool isCopy,
                                            uint pasteMode = 0)
        {
            if (source == null)
            {
                throw new ArgumentNullException(Resource1.VariableRepository_PasteVariable_sourceVariable);
            }

            VariableGroup desGroup = VariableRepository.FindGroupByPath(absolutePath);

            if (desGroup == null)
            {
                throw new ArgumentNullException(Resource1.VariableRepository_PasteVariable_desGroup);
            }

            if (IsExistName(source.Name, desGroup) && (pasteMode == 0))
            {
                return(GetDefaultName(desGroup, source.Name)); //保留两个变量后新的变量名
            }

            if (pasteMode <= 2)
            {
                if (pasteMode == 1) //替换
                {
                    //如果变量的位置与目标位置相同,无需替换,直接返回
                    if (source.ParentGroup.AbsolutePath == absolutePath)
                    {
                        return(source.Name);
                    }
                    RemoveVariable(source.Name, desGroup.AbsolutePath);
                }
                if (isCopy)
                {
                    VariableBase var = ObjectCopier.Clone(source);
                    var.ParentGroup = desGroup;

                    if (pasteMode == 2) //同时保留两个
                    {
                        var.Name = GetDefaultName(desGroup, source.Name);
                    }
                    AddVariable(var);
                }
                else
                {
                    if (pasteMode == 2) //同时保留两个
                    {
                        source.Name = GetDefaultName(desGroup, source.Name);
                    }
                    MoveVariable(source.AbsolutePath, desGroup.AbsolutePath);
                }
            }
            return(source.Name);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// 递归查找组内部方法
 /// </summary>
 /// <param name="group"></param>
 /// <param name="absolutePath"></param>
 /// <returns></returns>
 private VariableGroup findRecursion(VariableGroup group, string absolutePath)
 {
     if (group == null)
     {
         return(null);
     }
     if (!absolutePath.Contains('.'))
     {
         return(group.ChildGroups.FirstOrDefault(m => m.Name == absolutePath));
     }
     return(findRecursion(group.ChildGroups.FirstOrDefault(m => m.Name == absolutePath.Split('.')[0]),
                          absolutePath.Substring(absolutePath.IndexOf('.') + 1)));
 }
Ejemplo n.º 21
0
        public void AddGroupTest()
        {
            RepositoryConfig           variableRepositoryConfig = null;                                   // TODO: 初始化为适当的值
            EfVariableDesignRepository target = new EfVariableDesignRepository(variableRepositoryConfig); // TODO: 初始化为适当的值
            string        name         = string.Empty;                                                    // TODO: 初始化为适当的值
            string        absolutePath = string.Empty;                                                    // TODO: 初始化为适当的值
            VariableGroup expected     = null;                                                            // TODO: 初始化为适当的值
            VariableGroup actual;

            actual = target.AddGroup(name, absolutePath);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Ejemplo n.º 22
0
 /// <summary>
 /// 判断组或者变量的名称name是否在currentVariableGroup中存在
 /// </summary>
 /// <param name="name">组名称</param>
 /// <param name="group">组对象</param>
 /// <returns>true:存在,false:不存在</returns>
 private bool IsExistName(string name, VariableGroup group)
 {
     if (name == null)
     {
         throw new ArgumentNullException(Resource1.VariableUnitOfWork_IsExistName_nameIsNullOrEmpty);
     }
     if (group == null)
     {
         throw new ArgumentNullException(Resource1.UnitofWork_AddGroup_currentVariableGroup);
     }
     //如果父组包含groupName相同的组或者相同的变量,则返回不添加
     return(group.ChildGroups.Any(curGroup => curGroup.Name == name) ||
            group.ChildVariables.Any(curVariable => curVariable.Name == name));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// 删除当前组的所有变量
        /// </summary>
        /// <param name="absolutePath">要清空的组全路径</param>
        public virtual void ClearVariable(string absolutePath)
        {
            VariableGroup currentVariableGroup = VariableRepository.FindGroupByPath(absolutePath);

            if (currentVariableGroup == null)
            {
                throw new ArgumentNullException(Resource1.UnitofWork_AddGroup_currentVariableGroup);
            }
            //删除该组下的变量
            while (currentVariableGroup.ChildVariables.Count > 0)
            {
                RemoveVariable(currentVariableGroup.ChildVariables[0].Name, absolutePath);
            }
        }
        public async Task AddVariableGroups(BuildDefinition definition,
                                            CustomBuildDefinitionPayload payload)
        {
            if (payload.VariableGroups == null ||
                payload.VariableGroups.Length == 0)
            {
                return;
            }

            var client = await _client.GetTaskAgentAsync();

            foreach (var variableGroup in payload.VariableGroups)
            {
                var groups = await client.GetVariableGroupsAsync(project : payload.Project, groupName : variableGroup);

                if (groups == null ||
                    !groups.Any())
                {
                    throw new Exception($"Could not find any variablegroup with name: {variableGroup}");
                }

                if (groups.Count() > 1)
                {
                    throw new Exception($"There are more thant one variable group in the same project ({payload.Project}) with the same : {variableGroup}");
                }

                var group = groups.FirstOrDefault();

                if (group != null)
                {
                    var g = new VariableGroup
                    {
                        Name        = group.Name,
                        Description = group.Description,
                        Id          = group.Id,
                        Type        = group.Type
                    };

                    foreach (var(key, value) in group.Variables)
                    {
                        g.Variables[key] = new BuildDefinitionVariable
                        {
                            Value    = value.Value,
                            IsSecret = value.IsSecret
                        };
                    }
                    definition.VariableGroups.Add(g);
                }
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 由变量组集合生成树
        /// </summary>
        /// <param name="treeNode">树</param>
        /// <param name="variableGroup">树节点所属组</param>
        protected void RefreshTreeView(TreeView treeNode, VariableGroup variableGroup)
        {
            treeNode.Nodes.Clear();
            var node = new TreeNode(variableGroup.Name)
            {
                ContextMenuStrip = _ContextMenuStrip
            };

            treeNode.Nodes.Add(node);
            foreach (var variable in variableGroup.ChildGroups)
            {
                RefreshTreeView(node, variable);
            }
        }
Ejemplo n.º 26
0
        private static string GetVariableValue(VariableGroup group, string key)
        {
            if (key == null)
            {
                return(null);
            }
            if (!group.Variables.Any())
            {
                return(null);
            }

            return(group.Variables.Any(v => v.Key.Equals(key))
                ? group.Variables[key].Value
                : null);
        }
Ejemplo n.º 27
0
        private void RefreshDataGridView()
        {
            switch (_displayState)
            {
            case Displaytype.Alarm:
                dataGridView_Avaiable.Rows.Clear();
                foreach (AlarmBase alarmBase in _iAalarmDesignRepository.FindAlarms())
                {
                    var alarmGridViewRow = new DataGridViewRow();
                    alarmGridViewRow.CreateCells(dataGridView_Avaiable);
                    alarmGridViewRow.Cells[0].Value = alarmBase.Name;
                    alarmGridViewRow.Cells[1].Value = alarmBase.Variable == null ? null : alarmBase.Variable.Name;
                    alarmGridViewRow.Cells[2].Value = alarmBase;
                    alarmGridViewRow.Cells[3].Value = alarm_Level.Items[alarmBase.Level];
                    alarmGridViewRow.Cells[4].Value = alarmBase.Group == null ? null : alarmBase.Group.Name;
                    alarmGridViewRow.Cells[5].Value = alarmBase.Description;
                    dataGridView_Avaiable.Rows.Add(alarmGridViewRow);
                }
                break;

            case Displaytype.AlarmGroup:
                dataGridView_Avaiable.Rows.Clear();
                foreach (AlarmGroup alarmGroup in _iAalarmDesignRepository.FindAlarmGroups())
                {
                    var alarmGridViewRow = new DataGridViewRow();
                    alarmGridViewRow.CreateCells(dataGridView_Avaiable);
                    alarmGridViewRow.Cells[0].Value = alarmGroup.Name;
                    alarmGridViewRow.Cells[1].Value = alarmGroup.Description;
                    dataGridView_Avaiable.Rows.Add(alarmGridViewRow);
                }
                break;

            case Displaytype.Variable:
                treeView_FunctionTest.SelectedNode = _currentNode;
                VariableGroup varGroup =
                    _iVariableDesignRepository.FindGroupByPath(GetVariableGroupPath(_currentNode.FullPath));
                if (varGroup == null)
                {
                    return;
                }
                dataGridView_Avaiable.Rows.Clear();
                foreach (VariableBase variable in _iVariableDesignRepository.FindVariables(varGroup.AbsolutePath))
                {
                    AddVarToListview(variable, dataGridView_Avaiable);
                }
                break;
            }
        }
Ejemplo n.º 28
0
    public void Set(string groupName, string variableName, object value)
    {
        VariableGroup set = GetVariableSetByName(groupName);

        if (set == null)
        {
            return;
        }
        VariablePair pair = set.GetPairByName(variableName);

        if (pair == null)
        {
            return;
        }
        pair.SetValue(value);
    }
        private void ToggleVarGroupVisibility(VariableGroup varGroup, bool?newVisibilityNullable = null)
        {
            // Toggle visibility if no visibility is provided
            bool newVisibility = newVisibilityNullable ?? !_visibleGroups.Contains(varGroup);

            if (newVisibility) // change to visible
            {
                _visibleGroups.Add(varGroup);
            }
            else // change to hidden
            {
                _visibleGroups.Remove(varGroup);
            }
            UpdateControlsBasedOnFilters();
            UpdateFilterItemCheckedStatuses();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 由变量组集合生成树
        /// </summary>
        /// <param name="treeNode">树节点</param>
        /// <param name="variableGroup">树节点所属组</param>
        private void RefreshTreeView(TreeNode treeNode, VariableGroup variableGroup)
        {
            var node = new TreeNode(variableGroup.Name)
            {
                ContextMenuStrip = _ContextMenuStrip
            };

            if (treeNode != null)
            {
                treeNode.Nodes.Add(node);
            }
            foreach (var variable in variableGroup.ChildGroups)
            {
                RefreshTreeView(node, variable);
            }
        }
Ejemplo n.º 31
0
        /// <summary>
        ///     剪切变量组
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CmsCutVariableGroupClick(object sender, EventArgs e)
        {
            _groupPasteBoard = null;
            if (_currentNode == null)
            {
                return;
            }
            _groupPasteBoard = _iVariableDesignRepository.FindGroupByPath(GetVariableGroupPath(_currentNode.FullPath));

            if (_groupPasteBoard == null)
            {
                return;
            }
            _iscopy = false;
            CMS_PasteVariableGroup.Enabled = true;
        }
Ejemplo n.º 32
0
    public T Get <T>(string owner, string name)
    {
        VariableGroup set = GetVariableSetByName(owner);

        if (set == null)
        {
            return(default(T));
        }
        VariablePair pair = set.GetPairByName(name);

        if (pair == null)
        {
            return(default(T));
        }

        return((T)pair.GetValue());
    }
Ejemplo n.º 33
0
        /// <summary>
        ///     粘贴变量组
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CmsPasteVariableGroupClick(object sender, EventArgs e)
        {
            if (_groupPasteBoard == null)
            {
                return;
            }
            try
            {
                string str = _iVariableDesignRepository.PasteGroup(_groupPasteBoard,
                                                                   GetVariableGroupPath(_currentNode.FullPath),
                                                                   _iscopy);

                if (str != _groupPasteBoard.Name)
                {
                    switch ((new PasteMessage(str)).ShowDialog())
                    {
                    case DialogResult.Yes:     //移动并替换
                        _iVariableDesignRepository.PasteGroup(_groupPasteBoard,
                                                              GetVariableGroupPath(_currentNode.FullPath),
                                                              _iscopy, 1);
                        break;

                    case DialogResult.OK:     //移动,但保留两个文件
                        _iVariableDesignRepository.PasteGroup(_groupPasteBoard,
                                                              GetVariableGroupPath(_currentNode.FullPath),
                                                              _iscopy, 2);
                        break;
                    }
                }
                RefreshTree();
                if (_iscopy == false)
                {
                    _groupPasteBoard = null;
                }
                if (_groupPasteBoard == null)
                {
                    CMS_PasteVariableGroup.Enabled = false;
                }
                RefreshDataGridView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void Add(string project, string name, VariableGroup group)
        {
            AssertCorrectLocation(project);

            var writer = new StringWriter();

            _jsonSerializer.Serialize(writer, group);

            // Ensure folder exists
            var folder = Path.GetDirectoryName(name);

            if (folder != null)
            {
                Directory.CreateDirectory(folder);
            }

            File.WriteAllText(name, writer.ToString());
        }
Ejemplo n.º 35
0
        private void helpToolStripButton_Click(object sender, EventArgs e)
        {
            if (ActiveSail == null)
                return;

            if (Tree.SelectedTag != null)
            {
                IRebuild tag = Tree.SelectedTag as IRebuild;
                List<IRebuild> rebuilds = new List<IRebuild>();
                if (tag != null)
                    tag.GetParents(ActiveSail, rebuilds);

                StringBuilder sb = new StringBuilder();
                foreach (IRebuild rb in rebuilds)
                    sb.AppendLine(rb.Label);
                MessageBox.Show(sb.ToString());
                return;
            }

            VariableGroup varGroup = new VariableGroup("Vars", ActiveSail);
            varGroup.Add(new Equation("yarScale", 1.0));
            varGroup.Add(new Equation("yarnDPI", "yarScale * 12780"));
            varGroup.Add(new Equation("targetScale", 1.0));
            varGroup.Add(new Equation("targetDPI", "targetScale * 14416"));
            ActiveSail.Add(varGroup);

            UpdateViews(ActiveSail.CreateOuterCurves());

            //Geodesic geo = new Geodesic("Geo", ActiveSail, new IFitPoint[] { new FixedPoint(.1, .1), new FixedPoint(.1, .9) });
            MouldCurve v1 = new MouldCurve("v1", ActiveSail, new IFitPoint[] { new FixedPoint(1, 0), new FixedPoint(.3, .4), new FixedPoint(.1, .8), new FixedPoint(0, 1) });

            MouldCurve v2 = new MouldCurve("v2", ActiveSail, new IFitPoint[] { new FixedPoint(1, 0), new FixedPoint(0, 1) });

            MouldCurve v3 = new MouldCurve("v3", ActiveSail, new IFitPoint[] { new FixedPoint(1, 0), new FixedPoint(.95, .25), new FixedPoint(.9, .55), new FixedPoint(.65, .85), new FixedPoint(0, 1) });
            //MouldCurve v4 = new MouldCurve("v4", ActiveSail, new IFitPoint[] { new FixedPoint(1, 0), new FixedPoint(.8, .5), new FixedPoint(1, 1) });
            //MouldCurve v5 = new MouldCurve("v5", ActiveSail, new IFitPoint[] { new FixedPoint(1, 0), new FixedPoint(1, 1) });
            CurveGroup grp = new CurveGroup("Warps", ActiveSail);
            grp.Add(v1);
            grp.Add(v2);
            grp.Add(v3);
            grp.Add(new MouldCurve("g3", ActiveSail,
                new IFitPoint[] {
                    new FixedPoint(0,0),
                    new SlidePoint(v1, 0),
                    new FixedPoint(1,.5) }));
            grp.Add(new MouldCurve("g4", ActiveSail,
                new IFitPoint[] {
                    new FixedPoint(1, 0),
                    new FixedPoint(.4, .4),
                    new FixedPoint(.3, .7),
                    new FixedPoint(0,1)}));
            //grp.Add(v4);
            //grp.Add(v5);
            //grp.Add(guide);

            CurveGroup guides = new CurveGroup("Guides", ActiveSail);
            GuideComb guide = new GuideComb("Guide", ActiveSail,
                new IFitPoint[] {
                    new FixedPoint(0, .5),
                    new SlidePoint(v2, .5),
                    new FixedPoint(1, .5) },
                new Vect2[] {
                    new Vect2(0, 1),
                    new Vect2(.3, .55),
                    new Vect2(.5, .5),
                    new Vect2(.7, .55),
                    new Vect2(1, 1) });
            guides.Add(guide);

            YarnGroup yar = new YarnGroup("yar1", ActiveSail, varGroup["yarnDPI"], varGroup["targetDPI"]);
            yar.Warps.Add((ActiveSail.FindGroup("Outer") as CurveGroup)[0]);
            yar.Warps.Add((ActiveSail.FindGroup("Outer") as CurveGroup)[1]);
            yar.Guide = guide;
            yar.DensityPos = new List<double>() { 0.2, 0.8 };
            ActiveSail.Add(grp);
            ActiveSail.Add(guides);
            ActiveSail.Add(yar);
            UpdateViews(grp);
            UpdateViews(guides);

            //YarnGroup LuYar = new YarnGroup("LuYar", ActiveSail, 12780);
            //LuYar.DensityPos.AddRange(new double[] { 0.25, 0.5, 0.75 });
            //LuYar.YarnsUpdated += LuYar_YarnsUpdated;
            ////if (LuYar.LayoutYarns(new List<MouldCurve>() { lu, mi, le }, guide, 14416) > 0)
            ////DateTime now = DateTime.Now;
            ////LuYar.LayoutYarns(grp, guide, 14416, LuYar.SpreadYarnsAlongGuide);
            ////TimeSpan gde = DateTime.Now - now;
            ////now = DateTime.Now;

            ////LuYar.LayoutYarns(grp, guide, 14416, LuYar.SpreadYarnsAcrossWarps);
            ////TimeSpan wrps = DateTime.Now - now;
            ////now = DateTime.Now;
            ////MessageBox.Show(string.Format("AcrossWarps: {0}\nAlongGuide: {1}", wrps.TotalMilliseconds, gde.TotalMilliseconds));

            UpdateViews(guides);
            UpdateViews(grp);
            yar.Update(ActiveSail);
            UpdateViews(yar);
            //if (LuYar.LayoutYarns(grp, guide, 14416) > 0
            //	|| MessageBox.Show(String.Format("Failed to match Target Dpi\nTarget: {0}\nAchieved: {1}\nContinue Anyway?", LuYar.TargetDpi, LuYar.AchievedDpi), "Yarn Generation Failed", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes )
            //	ActiveSail.Add(LuYar);

            ////Yarns.YarnGroup LeYar = new Yarns.YarnGroup("LeYar", ActiveSail, 12780);
            ////if (LeYar.LayoutYarns(new List<MouldCurve>() { mi, le }, guide, 14416) > 0)
            ////	ActiveSail.Add(LeYar);

            ////Rebuild(null);

            //UpdateViews(LuYar);
            //Rebuild(grp);
            //Rebuild(grp);
            //Rebuild(guides);
            //Rebuild(LuYar);
            View.Refresh();
            ActiveSail.Rebuild(null);
        }
Ejemplo n.º 36
0
        private void CreateVariableGroups()
        {
            //Get concepts that are used, add the implicit ones and except for "0" create variable groups from them in the relevant variable scheme and put into the working set
             this.usedConcepts = variablesConcepts.Values.Distinct().ToList();

             //add implicit level-1 groups that are parents of level-2 groups
             var implicits = new List<string>();
             foreach (var uc in this.usedConcepts)
             {
                 if (uc.Length == 1 + 2 + 2)
                 {
                     if (!usedConcepts.Contains(uc.Substring(0, 3)))
                     {
                         implicits.Add(uc.Substring(0,3));
                     }
                 }
             }
             this.usedConcepts.AddRange(implicits.Distinct());

            //get the concept scheme from the repository
            //I assume there is only one
            //if there is none, get concepts from the working set
            ConceptScheme vgConceptScheme = new ConceptScheme();
            var client = Utility.GetClient();
            var facet = new SearchFacet();
            facet.ItemTypes.Add(DdiItemType.ConceptScheme);
            SearchResponse response = client.Search(facet);
            bool fromRepo = false;
            if (response.ReturnedResults > 0)
            {
                fromRepo = true;
                vgConceptScheme = client.GetItem(response.Results[0].CompositeId, ChildReferenceProcessing.Populate) as ConceptScheme;
            }

             var variableScheme = WorkingSet.OfType<VariableScheme>().Where(x => string.Compare(x.ItemName.Best, this.vsName, ignoreCase: true) == 0).First();
             foreach (var uc in this.usedConcepts)
             {
                 if (uc != "0")
                 {
                     VariableGroup vg = new VariableGroup();
                     vg.TypeOfGroup = "ConceptGroup";
                     Concept vgConcept = new Concept();
                     if (fromRepo)
                     {
                         vgConcept = vgConceptScheme.Concepts.Where(x => string.Compare(x.ItemName.Best, uc, ignoreCase: true) == 0).First();
                     }
                     else    //from working set
                     {
                         vgConcept = WorkingSet.OfType<Concept>().Where(x => string.Compare(x.ItemName.Best, uc, ignoreCase: true) == 0).First();
                     }

                     vg.Concept = vgConcept;
                     vg.ItemName.Add("en-GB", "Variable Group - " + vgConcept.Label.Best);
                     //Trace.WriteLine("   " + vg.ItemName.Best);
                     variableScheme.VariableGroups.Add(vg);
                 }
             }
             WorkingSet.AddRange(variableScheme.VariableGroups);
             Trace.WriteLine("  concept groups: " + variableScheme.VariableGroups.Count().ToString() + " for " + this.vsName);
        }