Ejemplo n.º 1
0
        private void OpenCard(TreeNode selectedNode)
        {
            //打开卡片
            FormCollection collection = Application.OpenForms;
            bool           isOpened   = false;

            foreach (Form form in collection)
            {
                int    splitIndex = selectedNode.Tag.ToString().IndexOf("@");
                string typicalid  = string.Empty;
                string cardid     = string.Empty;

                if (splitIndex > 0)
                {
                    typicalid = selectedNode.Tag.ToString().Substring(0, splitIndex);
                    cardid    = selectedNode.Tag.ToString().Substring(splitIndex + 1);
                }
                else
                {
                    cardid = selectedNode.Tag.ToString();
                }

                if (form.Name.EndsWith(cardid))
                {
                    isOpened = true;
                    ((ProcessCardFrm)form).TabText = selectedNode.Text;
                    ((ProcessCardFrm)form).OpenCard(null, cardid, false, true);
                    form.Select();
                }
            }

            if (!isOpened)
            {
                ProcessCardFrm frm = new ProcessCardFrm();
                frm.TabText = selectedNode.Text;

                int    splitIndex = selectedNode.Tag.ToString().IndexOf("@");
                string typicalid  = string.Empty;
                string cardid     = string.Empty;

                if (splitIndex > 0)
                {
                    typicalid = selectedNode.Tag.ToString().Substring(0, splitIndex);
                    cardid    = selectedNode.Tag.ToString().Substring(splitIndex + 1);
                }
                else
                {
                    cardid = selectedNode.Tag.ToString();
                }

                frm.Name = string.Format("ProcessCardFrm-{0}", cardid);
                MainFrm.mainFrm.OpenModule(frm);
                bool result = frm.OpenCard(null, cardid, false, true);
                if (!result)
                {
                    MainFrm.mainFrm.CloseModule(frm);
                }
            }
        }
Ejemplo n.º 2
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            Dictionary<string, string> cardIds = GetSelectedCardIds();
            if (cardIds == null || cardIds.Count == 0)
            {
                MessageBox.Show("请选择一个卡片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (cardIds.Count > 1)
            {
                MessageBox.Show("请选择单个卡片打开", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            string cardName = string.Empty;
            string cardId = string.Empty;
            foreach (string key in cardIds.Keys)
            {
                cardId = key;
                cardName = cardIds[key];
            }

            //打开卡片
            FormCollection collection = Application.OpenForms;
            bool isOpened = false;
            foreach (Form form in collection)
            {
                if (form.Name.EndsWith(cardId))
                {
                    isOpened = true;
                    ((ProcessCardFrm)form).TabText = cardName;
                    ((ProcessCardFrm)form).OpenCard(null, cardId, false, true);
                    form.Select();
                }
            }

            if (!isOpened)
            {
                ProcessCardFrm frm = new ProcessCardFrm();
                frm.TabText = cardName;
                frm.Name = string.Format("ProcessCardFrm-{0}", cardId);
                MainFrm.mainFrm.OpenModule(frm);
                bool result = frm.OpenCard(null, cardId, false, true);
                if (!result)
                {
                    MainFrm.mainFrm.CloseModule(frm);
                }
            }

            this.Close();
        }
Ejemplo n.º 3
0
        private void tvProcessCard_MouseDown(object sender, MouseEventArgs e)
        {
            p = new Point(e.X, e.Y);
            TreeNode selectedNode = tvProcessCard.GetNodeAt(p);
            if (selectedNode == null) return;
            tvProcessCard.SelectedNode = selectedNode;
            selectedNode.SelectedImageKey = selectedNode.ImageKey;

            if (selectedNode.SelectedImageKey == "folder" || selectedNode.SelectedImageKey == "folder_o")
            {
                tsmnuDeleteCard.Visible = false;
                tsmnuChangeToTypical.Visible = false;
            }
            else if (selectedNode.SelectedImageKey == "card")
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    //打开卡片
                    FormCollection collection = Application.OpenForms;
                    bool isOpened = false;
                    foreach (Form form in collection)
                    {
                        if (form.Name.EndsWith(selectedNode.Tag.ToString()))
                        {
                            isOpened = true;
                            ((ProcessCardFrm)form).TabText = selectedNode.Text;
                            ((ProcessCardFrm)form).OpenCard(null, selectedNode.Tag.ToString(), false, true);
                            form.Select();
                        }
                    }

                    if (!isOpened)
                    {
                        ProcessCardFrm frm = new ProcessCardFrm();
                        frm.TabText = selectedNode.Text;
                        frm.Name = string.Format("ProcessCardFrm-{0}", selectedNode.Tag.ToString());
                        MainFrm.mainFrm.OpenModule(frm);
                        bool result = frm.OpenCard(null, selectedNode.Tag.ToString(), false, true);
                        if (!result)
                        {
                            MainFrm.mainFrm.CloseModule(frm);
                        }
                    }
                }

                tsmnuDeleteCard.Visible = true;
                tsmnuChangeToTypical.Visible = true;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 导入本地卡片到典型工艺
        /// </summary>
        private void tsmnuImportCard_Click(object sender, EventArgs e)
        {
            ProcessCardFrm frm = new ProcessCardFrm();

            frm.Name = string.Format("ProcessCardFrm-{0}", Guid.NewGuid().ToString());

            if (frm != null)
            {
                string path = string.Empty;

                OpenFileDialog of = new OpenFileDialog();
                of.Filter = "CARD files (*.card)|*.card";
                if (of.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    path = of.FileName;
                }


                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                #region 设置新增卡片Tab的TabText及Name

                string     cardName  = Path.GetFileNameWithoutExtension(path);
                int        tag       = 1;
                int        index     = 1;
                List <int> listIndex = new List <int>();
                foreach (WeifenLuo.WinFormsUI.Docking.DockContent form in this.MdiChildren)
                {
                    if (form.Name.StartsWith("ProcessCardFrm") &&
                        form.TabText.StartsWith(cardName))
                    {
                        int start = form.TabText.IndexOf("-") + 1;
                        tag = int.Parse(form.TabText.Substring(start));
                        listIndex.Add(tag);
                    }
                }
                listIndex.Sort();
                foreach (var i in listIndex)
                {
                    if (i > 1 && index == 1)
                    {
                        index = 1;
                        break;
                    }

                    if (index > 1)
                    {
                        if (i - listIndex[index - 2] > 1)
                        {
                            index = listIndex[index - 2] + 1;
                            break;
                        }
                    }
                    index++;
                }
                frm.TabText = string.Format("{0}-{1}", cardName, index);

                #endregion

                MainFrm.mainFrm.OpenModule(frm);
                frm.OpenCard(path, null, false, true);
                processCardInfo = frm.SaveCardIntoDatabaseWithName(cardName);

                if (processCardInfo != null)
                {
                    AddTypicalOrFolder(BusinessType.Card);
                }
            }
        }