예제 #1
0
        internal void menuEditSubFunction_Click(object sender, EventArgs e)
        {
            var node = treeView.SelectedNode;

            if (node != null)
            {
                if (node.Tag is SubFunction subFunction)
                {
                    using (var dlg = new SubFunctionDialog(SubFunctionDialog.Operation.Update,
                                                           dcmDocument.VdfDocument))
                    {
                        dlg.SubFunctionName  = subFunction.Name;
                        dlg.PrefixData       = subFunction.Prefix;
                        dlg.DataLen          = subFunction.DataLen;
                        dlg.AddressType      = subFunction.CanAddressType;
                        dlg.Message          = subFunction.Message;
                        dlg.ParsingDirection = subFunction.ParsingDirection;

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            subFunction.Name           = dlg.SubFunctionName;
                            subFunction.Prefix         = dlg.PrefixData;
                            subFunction.DataLen        = dlg.DataLen;
                            subFunction.CanAddressType = dlg.AddressType;

                            subFunction.Message    = dlg.Message;
                            subFunction.VdfMessage =
                                dcmDocument.VdfDocument.Message(subFunction.Message);

                            subFunction.Data = Utils.NewInitializedList(subFunction.DataLen,
                                                                        subFunction.Data);

                            if (subFunction.ParsingDirection != dlg.ParsingDirection)
                            {
                                subFunction.ParsingDirection = dlg.ParsingDirection;
                                dcmDocument.UpdateReceiveSubFunctionTable();
                            }

                            mainForm.ContentChanged = true;
                            node.Text = string.Format("{0} - {1}",
                                                      Utils.HexArrayToString(subFunction.Prefix), subFunction.Name);

                            mainForm.UpdateSubFunction(subFunction);
                        }
                    }
                }
            }
        }
예제 #2
0
        // 添加子功能
        internal void menuAddSubFunction_Click(object sender, EventArgs e)
        {
            var node = treeView.SelectedNode;

            if (node != null)
            {
                if (node.Tag is Service service)
                {
                    using (var dlg = new SubFunctionDialog(SubFunctionDialog.Operation.New,
                                                           dcmDocument.VdfDocument))
                    {
                        var subFunction = new SubFunction();
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            subFunction.Name           = dlg.SubFunctionName;
                            subFunction.Prefix         = dlg.PrefixData;
                            subFunction.DataLen        = dlg.DataLen;
                            subFunction.CanAddressType = dlg.AddressType;
                            subFunction.Message        = dlg.Message;

                            subFunction.DataType = DataType.Hex; //这儿属性已经作废了,因为引入Vdf

                            subFunction.Data = Utils.NewInitializedList(subFunction.DataLen,
                                                                        subFunction.Data);

                            if (subFunction.ParsingDirection != dlg.ParsingDirection)
                            {
                                subFunction.ParsingDirection = dlg.ParsingDirection;
                                dcmDocument.UpdateReceiveSubFunctionTable();
                            }


                            mainForm.ContentChanged = true;

                            var subFunctionNode = new TreeNode(string.Format("{0} - {1}",
                                                                             Utils.HexArrayToString(subFunction.Prefix), subFunction.Name),
                                                               ImageIndexSubFunction, ImageIndexSubFunction);
                            service.SubFunctions.Add(subFunction);

                            subFunctionNode.Tag = subFunction;
                            node.Nodes.Add(subFunctionNode);
                            node.Expand();
                        }
                    }
                }
            }
        }