Example #1
0
        void SyncComplete(object sender, SyncEventArgs e)
        {
            ActionHandler.Busy   = false;
            ActionHandlerEx.Busy = false;

            CommonData common = (CommonData)_context.ValueStack.Values["common"];

            common.SyncIsOK = e.OK;

            DbEngine.Database.Current.SyncComplete(e.OK);

            if (_handler != null)
            {
                _context.InvokeOnMainThread(() =>
                {
                    _handler.ExecuteStandalone(_scriptEngine.Visitor, new object[] { _state });
                    _state   = null;
                    _handler = null;
                });
            }

            if (!e.OK)
            {
                LastError = e.Exception.Message;
                _context.HandleException(e.Exception);
            }
        }
Example #2
0
        public void Choose(object caption, object items, object startKey
                           , IJSExecutable positiveHandler, object positiveValue, IJSExecutable negativeHandler, object negativeValue)
        {
            KeyValuePair <object, string>[] rows = PrepareSelection(items);
            int index = 0;

            for (int i = 0; i < rows.Length; i++)
            {
                if (rows[i].Key.Equals(startKey))
                {
                    index = i;
                    break;
                }
            }

            string capt = ObjToString(caption);

            var ok = new DialogButton <object>(D.OK, (state, result) =>
            {
                if (positiveHandler != null)
                {
                    positiveHandler.ExecuteCallback(_scriptEngine.Visitor, state, new DialogArgs <object>(result));
                }
            }, positiveValue);

            var cancel = new DialogButton <object>(D.CANCEL, (state, result) =>
            {
                if (negativeHandler != null)
                {
                    negativeHandler.ExecuteCallback(_scriptEngine.Visitor, state, new DialogArgs <object>(result));
                }
            }, negativeValue);

            _context.DialogProvider.Choose(capt, rows, index, ok, cancel);
        }
Example #3
0
        public void Time(object caption, DateTime current
                         , IJSExecutable positiveHandler, object positiveValue, IJSExecutable negativeHandler, object negativeValue)
        {
            DialogButton <DateTime> ok;
            DialogButton <DateTime> cancel;
            var capt = PrepareDateTime(caption, positiveHandler, positiveValue, negativeHandler, negativeValue, out ok, out cancel);

            _context.DialogProvider.Time(capt, current, ok, cancel);
        }
Example #4
0
        public void Scan(IJSExecutable handler, object value)
        {
            Action<object> callback = result =>
                {
                    object[] p = { result, value };
                    if (handler != null)
                        handler.ExecuteStandalone(_scriptEngine.Visitor, p);
                };

            _context.ScanBarcode(callback);
        }
Example #5
0
        public void Copy(string destinationPath, IJSExecutable callback, object state)
        {
            string path = FileSystemProvider.TranslatePath(_context.LocalStorage, destinationPath);

            Action<object, CallbackArgs> handler;
            if (callback != null)
                handler = (s, args) =>
                    callback.ExecuteStandalone(_scriptEngine.Visitor, s, args);
            else
                handler = (s, args) => { };

            _context.GalleryProvider.Copy(path, Size, handler, state);
        }
Example #6
0
        public void Scan(IJSExecutable handler, object value)
        {
            Action <object> callback = result =>
            {
                object[] p = { result, value };
                if (handler != null)
                {
                    handler.ExecuteStandalone(_scriptEngine.Visitor, p);
                }
            };

            _context.ScanBarcode(callback);
        }
Example #7
0
        public void MakeSnapshot(string path, int size, IJSExecutable callback, object state)
        {
            string p = FileSystemProvider.TranslatePath(_context.LocalStorage, path);

            Action<object, CallbackArgs> handler;
            if (callback != null)
                handler = (s, args) =>
                    callback.ExecuteStandalone(_scriptEngine.Visitor, new[] { s, args });
            else
                handler = (s, args) => { };

            _context.CameraProvider.MakeSnapshot(p, size, handler, state);
        }
Example #8
0
        public void Message(object message, IJSExecutable handler, object value)
        {
            string msg = ObjToString(message);

            var close = new DialogButton <object>(D.CLOSE, (state, result) =>
            {
                if (handler != null)
                {
                    handler.ExecuteCallback(_scriptEngine.Visitor, state, new DialogArgs <object>(null));
                }
            }, value);

            _context.DialogProvider.Message(msg, close);
        }
Example #9
0
        public void ShowTime(string caption, DateTime current, IJSExecutable handler, object value)
        {
            caption = _context.DAL.TranslateString(caption);

            var ok = new DialogButton <DateTime>(D.OK, (state, result) =>
            {
                if (handler != null)
                {
                    handler.ExecuteStandalone(_scriptEngine.Visitor, result, state);
                }
            }, value);

            var cancel = new DialogButton <DateTime>(D.CANCEL);

            _context.DialogProvider.Time(caption, current, ok, cancel);
        }
Example #10
0
        public void Copy(string destinationPath, IJSExecutable callback, object state)
        {
            string path = FileSystemProvider.TranslatePath(_context.LocalStorage, destinationPath);

            Action <object, CallbackArgs> handler;

            if (callback != null)
            {
                handler = (s, args) =>
                          callback.ExecuteStandalone(_scriptEngine.Visitor, s, args);
            }
            else
            {
                handler = (s, args) => { }
            };

            _context.GalleryProvider.Copy(path, Size, handler, state);
        }
Example #11
0
        public void Select(string caption, object items, IJSExecutable handler, object value)
        {
            KeyValuePair <object, string>[] rows = PrepareSelection(items);

            caption = _context.DAL.TranslateString(caption);

            var ok = new DialogButton <object>(D.OK, (state, result) =>
            {
                if (handler != null)
                {
                    handler.ExecuteStandalone(_scriptEngine.Visitor, result, state);
                }
            }, value);

            var cancel = new DialogButton <object>(D.CANCEL);

            _context.DialogProvider.Choose(caption, rows, 0, ok, cancel);
        }
Example #12
0
        public void MakeSnapshot(string path, int size, IJSExecutable callback, object state)
        {
            string p = FileSystemProvider.TranslatePath(_context.LocalStorage, path);

            Action <object, CallbackArgs> handler;

            if (callback != null)
            {
                handler = (s, args) =>
                          callback.ExecuteStandalone(_scriptEngine.Visitor, new[] { s, args });
            }
            else
            {
                handler = (s, args) => { }
            };

            _context.CameraProvider.MakeSnapshot(p, size, handler, state);
        }
Example #13
0
        public void Alert(object message, IJSExecutable handler, object value, object positiveText, object negativeText,
                          object neutralText)
        {
            string msg = ObjToString(message);

            var positiveButtonText = ObjToString(positiveText);
            var positive           = new DialogButton <int>(positiveButtonText, (state, result) =>
            {
                if (handler != null)
                {
                    handler.ExecuteCallback(_scriptEngine.Visitor, state, new DialogArgs <int>(0));
                }
            }, value);

            DialogButton <int> negative = null;

            if (negativeText != null)
            {
                negative = new DialogButton <int>(_context.DAL.TranslateString(negativeText.ToString()), (state, result) =>
                {
                    if (handler != null)
                    {
                        handler.ExecuteCallback(_scriptEngine.Visitor, state, new DialogArgs <int>(1));
                    }
                }, value);
            }

            DialogButton <int> neutral = null;

            if (neutralText != null)
            {
                neutral = new DialogButton <int>(_context.DAL.TranslateString(neutralText.ToString()), (state, result) =>
                {
                    if (handler != null)
                    {
                        handler.ExecuteCallback(_scriptEngine.Visitor, state, new DialogArgs <int>(2));
                    }
                }, value);
            }

            _context.DialogProvider.Alert(msg, positive, negative, neutral);
        }
Example #14
0
        async void InvokeAsync(Action callback, IJSExecutable handler, object state)
        {
            ActionHandler.Busy   = true;
            ActionHandlerEx.Busy = true;

            _lastException = null;

            try
            {
                await Task.Run(callback);

                SuccessSync = true;
            }
            catch (Exception e)
            {
                _lastException = e;
                SuccessSync    = false;
            }
            finally
            {
                LastSyncTime = DateTime.Now;
                WriteFsLog();

                ActionHandler.Busy   = false;
                ActionHandlerEx.Busy = false;

                if (handler != null)
                {
                    _context.InvokeOnMainThread(() =>
                    {
                        var args = new EventArgs {
                            State = state, Result = _lastException == null
                        };
                        handler.ExecuteStandalone(_scriptEngine.Visitor, new object[] { args });

                        handler = null;
                        state   = null;
                    });
                }
            }
        }
Example #15
0
        public void Ask(object message
                        , IJSExecutable positiveHandler, object positiveValue, IJSExecutable negativeHandler, object negativeValue)
        {
            string msg = ObjToString(message);
            var    yes = new DialogButton <object>(D.YES, (state, result) =>
            {
                if (positiveHandler != null)
                {
                    positiveHandler.ExecuteCallback(_scriptEngine.Visitor, state, new DialogArgs <Result>(Result.Yes));
                }
            }, positiveValue);

            var no = new DialogButton <object>(D.NO, (state, result) =>
            {
                if (negativeHandler != null)
                {
                    negativeHandler.ExecuteCallback(_scriptEngine.Visitor, state, new DialogArgs <Result>(Result.No));
                }
            }, negativeValue);

            _context.DialogProvider.Ask(msg, yes, no);
        }
Example #16
0
        private string PrepareDateTime(object caption, IJSExecutable positiveHandler, object positiveValue,
                                       IJSExecutable negativeHandler, object negativeValue, out DialogButton <DateTime> ok, out DialogButton <DateTime> cancel)
        {
            string capt = ObjToString(caption);

            ok = new DialogButton <DateTime>(D.OK, (state, result) =>
            {
                if (positiveHandler != null)
                {
                    positiveHandler.ExecuteCallback(_scriptEngine.Visitor, state, new DialogArgs <DateTime>(result));
                }
            }, positiveValue);

            cancel = new DialogButton <DateTime>(D.CANCEL, (state, result) =>
            {
                if (negativeHandler != null)
                {
                    negativeHandler.ExecuteCallback(_scriptEngine.Visitor, state, new DialogArgs <DateTime>(result));
                }
            }, negativeValue);
            return(capt);
        }
Example #17
0
        public void Question(string message, IJSExecutable handler, object value)
        {
            message = _context.DAL.TranslateString(message);

            var yes = new DialogButton <object>(D.YES, (state, result) =>
            {
                if (handler != null)
                {
                    handler.ExecuteStandalone(_scriptEngine.Visitor, Result.Yes, state);
                }
            }, value);

            var no = new DialogButton <object>(D.NO, (state, result) =>
            {
                if (handler != null)
                {
                    handler.ExecuteStandalone(_scriptEngine.Visitor, Result.No, state);
                }
            }, value);

            _context.DialogProvider.Ask(message, yes, no);
        }
Example #18
0
 public void Sync(IJSExecutable handler)
 {
     _handler = handler;
     Sync();
 }
Example #19
0
 public void SyncShared(IJSExecutable handler, object state)
 {
     InvokeAsync(SyncSharedCallback, handler, state);
 }
Example #20
0
 public void MakeSnapshot(int size, IJSExecutable callback, object state)
 {
     MakeSnapshot(Path, size, callback, state);
 }
Example #21
0
 public void MakeSnapshot(string path, IJSExecutable callback, object state)
 {
     MakeSnapshot(path, Size, callback, state);
 }
Example #22
0
 public void MakeSnapshot(string path, int size, IJSExecutable callback)
 {
     MakeSnapshot(path, size, callback, null);
 }
Example #23
0
 public void MakeSnapshot(int size, IJSExecutable callback)
 {
     MakeSnapshot(Path, size, callback, null);
 }
Example #24
0
 public void UploadPrivate(IJSExecutable handler)
 {
     UploadPrivate(handler, null);
 }
Example #25
0
 public void UploadPrivate(IJSExecutable handler, object state)
 {
     InvokeAsync(UploadPrivateCallback, handler, state);
 }
Example #26
0
 public void Copy(string destinationPath, IJSExecutable handler)
 {
     Copy(destinationPath, handler, null);
 }
Example #27
0
 public void Ask(object message, IJSExecutable positiveHandler, object positiveValue, IJSExecutable negativeHandler)
 {
     Ask(message, positiveHandler, positiveValue, negativeHandler, null);
 }
Example #28
0
 public void Ask(object message, IJSExecutable positiveHandler)
 {
     Ask(message, positiveHandler, null, null, null);
 }
Example #29
0
        void SyncComplete(object sender, SyncEventArgs e)
        {
            ActionHandler.Busy = false;
            ActionHandlerEx.Busy = false;

            CommonData common = (CommonData)_context.ValueStack.Values["common"];
            common.SyncIsOK = e.OK;

            DbEngine.Database.Current.SyncComplete(e.OK);

            if (_handler != null)
                _context.InvokeOnMainThread(() =>
                {
                    _handler.ExecuteStandalone(_scriptEngine.Visitor, new object[] { _state });
                    _state = null;
                    _handler = null;
                });

            if (!e.OK)
            {
                LastError = e.Exception.Message;
                _context.HandleException(e.Exception);
            }
        }
Example #30
0
 public void Scan(IJSExecutable handler)
 {
     Scan(handler, null);
 }
Example #31
0
        async void InvokeAsync(Action callback, IJSExecutable handler, object state)
        {
            ActionHandler.Busy = true;
            ActionHandlerEx.Busy = true;

            _lastException = null;

            try
            {
                await Task.Run(callback);
                SuccessSync = true;
            }
            catch (Exception e)
            {
                _lastException = e;
                SuccessSync = false;
            }
            finally
            {
                LastSyncTime = DateTime.Now;
                WriteFsLog();

                ActionHandler.Busy = false;
                ActionHandlerEx.Busy = false;

                if (handler != null)
                    _context.InvokeOnMainThread(() =>
                    {
                        var args = new EventArgs { State = state, Result = _lastException == null };
                        handler.ExecuteStandalone(_scriptEngine.Visitor, new object[] { args });

                        handler = null;
                        state = null;
                    });
            }
        }
Example #32
0
 public void MakeSnapshot(string path, IJSExecutable callback, object state)
 {
     MakeSnapshot(path, Size, callback, state);
 }
Example #33
0
 public void Sync(IJSExecutable handler, object state)
 {
     _state = state;
     Sync(handler);
 }
Example #34
0
 public void MakeSnapshot(int size, IJSExecutable callback, object state)
 {
     MakeSnapshot(Path, size, callback, state);
 }
Example #35
0
 public void UploadPrivate(IJSExecutable handler)
 {
     UploadPrivate(handler, null);
 }
Example #36
0
 public void ShowTime(string caption, DateTime current, IJSExecutable handler)
 {
     ShowTime(caption, current, handler, null);
 }
Example #37
0
 public void UploadPrivate(IJSExecutable handler, object state)
 {
     InvokeAsync(UploadPrivateCallback, handler, state);
 }
Example #38
0
 public void MakeSnapshot(int size, IJSExecutable callback)
 {
     MakeSnapshot(Path, size, callback, null);
 }
Example #39
0
 public void Scan(IJSExecutable handler)
 {
     Scan(handler, null);
 }
Example #40
0
 public void MakeSnapshot(string path, int size, IJSExecutable callback)
 {
     MakeSnapshot(path, size, callback, null);
 }
Example #41
0
 public void ShowTime(string caption, IJSExecutable handler, object value)
 {
     ShowTime(caption, System.DateTime.Now, handler, value);
 }
Example #42
0
 public void SyncShared(IJSExecutable handler)
 {
     SyncShared(handler, null);
 }
Example #43
0
 public void SyncShared(IJSExecutable handler, object state)
 {
     InvokeAsync(SyncSharedCallback, handler, state);
 }
Example #44
0
 public void Sync(IJSExecutable handler, object state)
 {
     _state = state;
     Sync(handler);
 }
Example #45
0
 public void Select(string caption, object items, IJSExecutable handler)
 {
     Select(caption, items, handler, null);
 }
Example #46
0
 public void Sync(IJSExecutable handler)
 {
     _handler = handler;
     Sync();
 }
Example #47
0
 public void SyncShared(IJSExecutable handler)
 {
     SyncShared(handler, null);
 }