public void Dispose()
        {
            m_Model.StreamReadAvailable   -= LoadFromStream;
            m_Model.StreamWriteAvailable  -= SaveToStream;
            m_Model.StorageReadAvailable  -= LoadFromStorage;
            m_Model.StorageWriteAvailable -= SaveToStorage;

            m_App.ShowMessageBox($"Closed {m_Model.Title}");
        }
Beispiel #2
0
        public void Init(IXApplication app, IXDocument model)
        {
            m_App   = app;
            m_Model = model;

            m_Model.StreamReadAvailable   += LoadFromStream;
            m_Model.StreamWriteAvailable  += SaveToStream;
            m_Model.StorageReadAvailable  += LoadFromStorage;
            m_Model.StorageWriteAvailable += SaveToStorage;

            m_App.ShowMessageBox($"Opened {model.Title}");
        }
Beispiel #3
0
        private async void StartStopProgress()
        {
            try
            {
                m_IsStarted = !m_IsStarted;

                if (m_IsStarted)
                {
                    m_CurrentJobCancellationTokenSource = new CancellationTokenSource();
                    var token = m_CurrentJobCancellationTokenSource.Token;

                    using (var appPrg = m_App.CreateProgress())
                    {
                        appPrg.SetStatus("Doing work...");

                        for (int i = 0; i < 100; i++)
                        {
                            await Task.Delay(TimeSpan.FromSeconds(0.5), token);

                            token.ThrowIfCancellationRequested();

                            var prg = (i + 1) / 100d;
                            Progress.Progress = prg;
                            appPrg.Report(prg);
                        }
                    }
                }
                else
                {
                    m_CurrentJobCancellationTokenSource.Cancel();
                }
            }
            catch (TaskCanceledException)
            {
                m_App.ShowMessageBox("Work cancelled", MessageBoxIcon_e.Info);
            }
            catch (Exception)
            {
                //handling as this function is async void and exception will be swallowed
            }
            finally
            {
                Progress.Progress = 0.0;
            }
        }
Beispiel #4
0
        private bool?ShowMessage(string question, MessageBoxIcon_e img, MessageBoxButtons_e btns)
        {
            var res = m_App.ShowMessageBox(question, img, btns);

            switch (res)
            {
            case MessageBoxResult_e.Yes:
            case MessageBoxResult_e.Ok:
                return(true);

            case MessageBoxResult_e.No:
                return(false);

            case MessageBoxResult_e.Cancel:
                return(null);

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #5
0
        public void ShowMessage(string message, MessageType_e type)
        {
            var icon = MessageBoxIcon_e.Info;

            switch (type)
            {
            case MessageType_e.Info:
                icon = MessageBoxIcon_e.Info;
                break;

            case MessageType_e.Warning:
                icon = MessageBoxIcon_e.Warning;
                break;

            case MessageType_e.Error:
                icon = MessageBoxIcon_e.Error;
                break;
            }

            m_App.ShowMessageBox(message, icon, MessageBoxButtons_e.Ok);
        }
 public void ShowError(string error)
 => m_App.ShowMessageBox(error, MessageBoxIcon_e.Error, MessageBoxButtons_e.Ok);