示例#1
0
        public void RemoveFrame(_frameName fn)
        {
            bool bRemove = false;

            if ((fn.source == FrameSource.List) && (frameList != null))
            {
                frameList.Remove(fn.name);
                if (frameList.Count == 0)
                {
                    frameList = null;
                }
                bRemove = true;
            }
            else if ((fn.source == FrameSource.Name) && (frameGrid != null) && (frameGrid.names != null))
            {
                for (int i = 0; i < frameGrid.names.Count; i++)
                {
                    for (int j = 0; j < frameGrid.names[i].Count; j++)
                    {
                        if (frameGrid.names[i][j] == fn.name)
                        {
                            frameGrid.names[i][j] = null;
                            bRemove = true;
                            break;
                        }
                    }

                    if (bRemove)
                    {
                        break;
                    }
                }
            }
            else if ((fn.source == FrameSource.Alias) && (aliases != null))
            {
                aliases.Remove(fn.name);
                if (aliases.Count == 0)
                {
                    aliases = null;
                }
                bRemove = true;
            }

            if (bRemove)
            {
                _frameItem fi = GetFrameItemOf(fn);
                if (fi != null)
                {
                    fi.RemoveName(fn.name);
                    if (fi.names.Count == 0)
                    {
                        ListFrameItems.Remove(fi);
                    }
                    LookupFrameItems.Remove(fn.name);
                }
            }
        }
示例#2
0
        void btnRemoveFrame_Clicked(object sender, EventArgs e)
        {
            if (WorkingFrameItem == null)
            {
                btnRemoveFrame.Enabled = false;
                return;
            }

            List <_frameName> fns;
            DialogResult      dr;
            _frameName        curFrame = WorkingFrameItem.names[cbFrameNames.SelectedIndex];

            if (curFrame.source == FrameSource.Grid)
            {
                // not normally able to delete default frames. only solution is to copy all default frames to the frameList set and then remove the frameGrid
            }
            else
            {
                fns = Globals.WorkingFrames.GetAliasesFor(curFrame.name);
                bool bDelete = false;
                if (fns.Count > 0)
                {
                    dr = MessageBox.Show("Deleting the frame '" + curFrame.name + "' will delete " + fns.Count + " aliases. Do you want to move them to a different frame instead?", "Dependancy Check", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        // build exclude list
                        List <string> excludes = new List <string>();
                        excludes.Add(curFrame.name);
                        foreach (_frameName fn in fns)
                        {
                            excludes.Add(fn.name);
                        }
                        FrameSelectForm fsf = new FrameSelectForm();
                        fsf.InitFor(Globals.WorkingFrames, excludes);
                        dr = fsf.ShowDialog();
                        if (dr == DialogResult.OK)
                        {
                            string nn = fsf.Value;
                            if (nn != null)
                            {
                                foreach (_frameName fn in fns)
                                {
                                    fn.aliasof = nn;
                                    WorkingFrameItem.RemoveName(fn.name);
                                    _frameItem fi = Globals.WorkingFrames.ListFrameItems.Find(f => f.names.Exists(n => n.name == nn));
                                    if (fi != null)
                                    {
                                        fi.names.Add(fn);
                                    }
                                    Globals.WorkingFrames.aliases[fn.name] = nn;
                                }

                                bDelete = true;
                            }
                        }
                    }
                    else if (dr == DialogResult.No)
                    {
                        foreach (_frameName fn in fns)
                        {
                            RemoveFrame(fn);
                        }

                        bDelete = true;
                    }
                }
                else
                {
                    dr = MessageBox.Show("Are you sure you want to delete the frame '" + curFrame.name + "'?", "Deletion Check", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        bDelete = true;
                    }
                }

                if (bDelete)
                {
                    RemoveFrame(curFrame);

                    WorkingFrameItem = null;
                    cbFrameNames.Items.Clear();

                    if (Globals.WorkingFrames.aliases == null)
                    {
                        cbShowAliases.Checked = false;
                        cbShowAliases.Enabled = false;
                    }
                    if (Globals.WorkingFrames.frameList == null)
                    {
                        cbShowList.Checked = false;
                        cbShowList.Enabled = false;
                    }

                    Invalidate();
                }
            }
        }