コード例 #1
0
        private bool CanChangeFile()
        {
            RequestFileChangeResult r = this.displayControls.CanUpdatePicture();

            if (r == RequestFileChangeResult.DoNotClose)
            {
                return(false);
            }

            if (r == RequestFileChangeResult.CloseAndSave)
            {
                this.displayControls.CurrentPicture.SaveChanges();
            }

            return(true);
        }
コード例 #2
0
        public RequestFileChangeResult CanUpdatePicture()
        {
            int countDoNotClose   = 0;
            int countCloseAndSave = 0;
            int countClose        = 0;

            foreach (IPictureDetailControllerBase c in this)
            {
                RequestFileChangeResult r = c.RequestFileChange();
                switch (r)
                {
                case RequestFileChangeResult.Close:
                    countClose++;
                    break;

                case RequestFileChangeResult.CloseAndSave:
                    countCloseAndSave++;
                    break;

                case RequestFileChangeResult.DoNotClose:
                    countDoNotClose++;
                    break;
                }
            }

            int count = this.Count;

            // one say dont close
            if (countDoNotClose > 0)
            {
                return(RequestFileChangeResult.DoNotClose);
            }

            // all say close
            if (countClose == count)
            {
                return(RequestFileChangeResult.Close);
            }

            // none say dont close and one or more say save
            return(RequestFileChangeResult.CloseAndSave);
        }