Esempio n. 1
0
        private async void AnyDateTimeDialog(DateTimeDialog func, object caption, DateTime current
                                             , IJsExecutable positiveHandler, object positiveValue, IJsExecutable negativeHandler, object negativeValue)
        {
            ControlsContext.Current.ActionHandlerLocker.Acquire();
            try
            {
                string capt = ObjToString(caption);

                var ok     = new DialogButton(D.OK);
                var cancel = new DialogButton(D.CANCEL);

                IDialogAnswer <DateTime> answer = await func(capt, current, ok, cancel);

                IJsExecutable handler = answer.Positive ? positiveHandler : negativeHandler;
                object        value   = answer.Positive ? positiveValue : negativeValue;

                if (handler != null)
                {
                    handler.ExecuteCallback(_scriptEngine.Visitor, value, new Args <DateTime>(answer.Result));
                }
            }
            finally
            {
                ControlsContext.Current.ActionHandlerLocker.Release();
            }
        }
Esempio n. 2
0
        public async void ShowTime(string caption, DateTime current, IJsExecutable handler, object value)
        {
            caption = _context.Dal.TranslateString(caption);

            var ok     = new DialogButton(D.OK);
            var cancel = new DialogButton(D.CANCEL);

            IDialogAnswer <DateTime> answer = await _context.DialogProvider.Time(caption, current, ok, cancel);

            if (handler != null)
            {
                handler.ExecuteCallback(_scriptEngine.Visitor, answer.Result, value);
            }
        }
Esempio n. 3
0
        public async 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(D.OK);

            var cancel = new DialogButton(D.CANCEL);

            IDialogAnswer <object> answer = await _context.DialogProvider.Choose(caption, rows, 0, ok, cancel);

            if (handler != null)
            {
                handler.ExecuteCallback(_scriptEngine.Visitor, answer.Result, value);
            }
        }
Esempio n. 4
0
        public async void Choose(object caption, object items, object startKey
                                 , IJsExecutable positiveHandler, object positiveValue, IJsExecutable negativeHandler, object negativeValue)
        {
            ControlsContext.Current.ActionHandlerLocker.Acquire();
            try
            {
                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(D.OK);
                var cancel = new DialogButton(D.CANCEL);

                IDialogAnswer <object> answer = await _context.DialogProvider.Choose(capt, rows, index, ok, cancel);

                IJsExecutable handler = answer.Positive ? positiveHandler : negativeHandler;
                object        value   = answer.Positive ? positiveValue : negativeValue;

                if (handler != null)
                {
                    handler.ExecuteCallback(_scriptEngine.Visitor, value, new KeyValueArgs <object, string>(answer.Result, rows));
                }
            }
            finally
            {
                ControlsContext.Current.ActionHandlerLocker.Release();
            }
        }