/// <summary>
        /// Sets the selected file
        /// </summary>
        /// <param name="filename">The name of the file</param>
        public void SetSelectedFile(string filename)
        {
            if (!(DataContext is FileListControlViewModel viewModel) || string.IsNullOrEmpty(filename))
            {
                return;
            }

            viewModel.SetSelectedFile(filename);
            NodeTreeView.BringIntoView();
        }
예제 #2
0
        private void NodeTreeView_MouseDown(object sender, MouseEventArgs e)
        {
            TreeNode nodeClicked = NodeTreeView.GetNodeAt(e.X, e.Y);

            if (nodeClicked != null)
            {
                IModule module = nodeClicked.Tag as IModule;
                if (module != null)
                {
                    this.DoDragDrop(module.CreateNode(), DragDropEffects.Copy);
                }
            }
        }
예제 #3
0
        public void AddModuleToTree(IModule module)
        {
            string[] catPath = module.GetCategoryPath().Split('/');
            if (catPath.Count() <= 0)
            {
                return;
            }
            NodeTreeView.BeginUpdate();
            TreeNode currentNode;

            if (NodeTreeView.Nodes.ContainsKey(catPath[0]))
            {
                currentNode = NodeTreeView.Nodes[catPath[0]];
            }
            else
            {
                currentNode      = NodeTreeView.Nodes.Add(catPath[0]);
                currentNode.Name = catPath[0];
            }

            for (int i = 1; i < catPath.Count(); i++)
            {
                if (currentNode.Nodes.ContainsKey(catPath[i]))
                {
                    currentNode = currentNode.Nodes[catPath[i]];
                    continue;
                }
                else
                {
                    currentNode      = NodeTreeView.Nodes.Add(catPath[i]);
                    currentNode.Name = catPath[0];
                }
            }
            TreeNode newNode = currentNode.Nodes.Add(module.GetNodeName());

            newNode.Tag  = module;
            newNode.Name = module.GetNodeName();
            NodeTreeView.EndUpdate();
        }
예제 #4
0
        /// <summary>
        /// Save Limit Times.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                var node = NodeTreeView.SelectedNode;
                if (node == null)
                {
                    MessageBox.Show("请选择需要应用参数的设备", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                var devIds = new List <Int32>();
                var tag    = (IDValuePair <Int32, EnmNodeType>)node.Tag;
                if (tag.Value == EnmNodeType.Dev)
                {
                    devIds.Add(tag.ID);
                }
                else
                {
                    CheckDevTreeView(node.Nodes, devIds);
                    if (devIds.Count == 0)
                    {
                        MessageBox.Show(String.Format("请勾选[{0}]节点下需要应用参数的设备", node.Text), "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        NodeTreeView.Focus();
                        return;
                    }
                }

                var limitIds = new List <EnmLimitID>();
                if (AllCB.Checked || RightTabControl.SelectedIndex == 0)
                {
                    limitIds.Add(EnmLimitID.DTM);
                    limitIds.Add(EnmLimitID.NDTM);
                }

                if (AllCB.Checked || RightTabControl.SelectedIndex == 1)
                {
                    limitIds.Add(EnmLimitID.WTMG);
                }

                if (AllCB.Checked || RightTabControl.SelectedIndex == 2)
                {
                    limitIds.Add(EnmLimitID.IRTM);
                }

                if (AllCB.Checked || RightTabControl.SelectedIndex == 3)
                {
                    limitIds.Add(EnmLimitID.SHD);
                }

                if (AllCB.Checked || RightTabControl.SelectedIndex == 4)
                {
                    limitIds.Add(EnmLimitID.SWD);
                }

                var times = CurTimes.FindAll(t => limitIds.Any(l => t.LimitId == l));
                if (times.Count == 0)
                {
                    MessageBox.Show("未设置任何参数,请先设置参数。", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!AllCB.Checked || MessageBox.Show("您确定要对设备应用全部时段吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                {
                    var result = Common.ShowWait(() => {
                        new LimitTime().SaveLimitTimes(devIds, limitIds, times);
                    }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                    if (result == DialogResult.OK)
                    {
                        foreach (var devId in devIds)
                        {
                            foreach (var limitId in limitIds)
                            {
                                Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SetLimitTimeForm.SaveBtn.Click", String.Format("配置设备[ID:{0}]准进时段[{1}]", devId, ComUtility.GetLimitIDText(limitId)), null);
                            }
                        }
                        MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SetLimitTimeForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }