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); } }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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; }); } } }
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); }
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); }
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); }
public void Sync(IJSExecutable handler) { _handler = handler; Sync(); }
public void SyncShared(IJSExecutable handler, object state) { InvokeAsync(SyncSharedCallback, handler, state); }
public void MakeSnapshot(int size, IJSExecutable callback, object state) { MakeSnapshot(Path, size, callback, state); }
public void MakeSnapshot(string path, IJSExecutable callback, object state) { MakeSnapshot(path, Size, callback, state); }
public void MakeSnapshot(string path, int size, IJSExecutable callback) { MakeSnapshot(path, size, callback, null); }
public void MakeSnapshot(int size, IJSExecutable callback) { MakeSnapshot(Path, size, callback, null); }
public void UploadPrivate(IJSExecutable handler) { UploadPrivate(handler, null); }
public void UploadPrivate(IJSExecutable handler, object state) { InvokeAsync(UploadPrivateCallback, handler, state); }
public void Copy(string destinationPath, IJSExecutable handler) { Copy(destinationPath, handler, null); }
public void Ask(object message, IJSExecutable positiveHandler, object positiveValue, IJSExecutable negativeHandler) { Ask(message, positiveHandler, positiveValue, negativeHandler, null); }
public void Ask(object message, IJSExecutable positiveHandler) { Ask(message, positiveHandler, null, null, null); }
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); } }
public void Scan(IJSExecutable handler) { Scan(handler, null); }
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; }); } }
public void Sync(IJSExecutable handler, object state) { _state = state; Sync(handler); }
public void ShowTime(string caption, DateTime current, IJSExecutable handler) { ShowTime(caption, current, handler, null); }
public void ShowTime(string caption, IJSExecutable handler, object value) { ShowTime(caption, System.DateTime.Now, handler, value); }
public void SyncShared(IJSExecutable handler) { SyncShared(handler, null); }
public void Select(string caption, object items, IJSExecutable handler) { Select(caption, items, handler, null); }