Esempio n. 1
0
        public ClosingState CheckForChanges()
        {
            IFlowSharpCanvasService canvasService = ServiceManager.Get <IFlowSharpCanvasService>();
            bool         changed = canvasService.Controllers.Any(c => GetSavePoint(c) != c.UndoStack.UndoStackSize);
            ClosingState ret     = ClosingState.NoChanges;

            if (changed)
            {
                DialogResult res = MessageBox.Show("Do you wish to save changes to this drawing?", "Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                switch (res)
                {
                case DialogResult.Cancel:
                    ret = ClosingState.CancelClose;
                    break;

                case DialogResult.Yes:
                    ret = ClosingState.SaveChanges;
                    break;

                case DialogResult.No:
                    ret = ClosingState.ExitWithoutSaving;
                    break;
                }
            }

            return(ret);
        }
Esempio n. 2
0
 public CloseWindowController(IAppWindow win, IIOPortHandler[] portHandlers)
 {
     _win = win;
     _state = ClosingState.NoClosing;
     _portHandlers = portHandlers;
     _portHandlerClosedStates = new Dictionary<IIOPortHandler, bool>();
     foreach (IIOPortHandler handler in portHandlers)
         _portHandlerClosedStates[handler] = false;
 }
Esempio n. 3
0
        public StateBankAccount()
        {
            confirmingIdentityState = new ConfirmingIdentityState(this);
            activeState             = new ActiveState(this);
            frozenState             = new FrozenState(this);
            closingState            = new ClosingState(this);
            closedState             = new ClosedState(this);

            state   = confirmingIdentityState;
            balance = 0.0;
        }
Esempio n. 4
0
        /// <summary>
        /// Return true if operation should be cancelled.
        /// </summary>
        protected bool CheckForChanges()
        {
            bool ret = true;

            ClosingState state = serviceManager.Get <IFlowSharpEditService>().CheckForChanges();

            if (state == ClosingState.SaveChanges)
            {
                ret = !SaveOrSaveAs();   // override because of possible cancel in save operation.
            }
            else if (state != ClosingState.CancelClose)
            {
                BaseController canvasController = serviceManager.Get <IFlowSharpCanvasService>().ActiveController;
                canvasController.UndoStack.ClearStacks();       // Prevents second "are you sure" when exiting with Ctrl+X
                ret = false;
            }

            return(ret);
        }
Esempio n. 5
0
        protected void OnFormClosing(object sender, FormClosingEventArgs e)
        {
            ClosingState state = ServiceManager.Get <IFlowSharpEditService>().CheckForChanges();

            if (state == ClosingState.SaveChanges)
            {
                if (!ServiceManager.Get <IFlowSharpMenuService>().SaveOrSaveAs())
                {
                    e.Cancel = true;
                }
            }
            else
            {
                e.Cancel = state == ClosingState.CancelClose;
            }

            if (!e.Cancel)
            {
                dockingService.SaveLayout("layout.xml");
            }
        }
Esempio n. 6
0
        protected void Close(Exception exception)
        {
            if (!this.TryClose())
            {
                return;
            }

            var closingState = new ClosingState();

            if (exception != null)
            {
                closingState.RegisterException(exception);
            }

            // Closing logic should be executed on the loop thread
            if (this.Worker != null && Thread.CurrentThread.ManagedThreadId != this.BaseSocket.ThreadId)
            {
                this.Worker.EnqueueFinalJob(this.CloseCallback, closingState);
            }
            else
            {
                this.CloseCallback(closingState);
            }
        }
Esempio n. 7
0
 public void closePortHandlers()
 {
     _state = ClosingState.ClosingResources;
     foreach (IIOPortHandler handler in _portHandlers)
         handler.terminate();
 }