public async Task Init(IEnumerable <T> permittedValues, T currentValue)
        {
            _view.Confirm.State = ActionViewState.CreateIdleOrSuccess();
            await _localValue.DoChange(currentValue, false, this, false);

            _view.Choosen.PermittedValues = permittedValues;
        }
示例#2
0
            public IView <HTMLElement> Create(RemoteFileDescr forFile, Action forceAddOrRemoveToView)
            {
                var widget = InputTypeButtonActionView.CreateFontAwesomeIconedAction(
                    IconFontType.FontAwesomeSolid, FontAwesomeSolid.IconExchangeAlt);

                widget.Widget.Title = I18n.Translate("Replace");
                widget.Triggered   += () => {
                    //HACK due to lack of: on input[file] activated but user declined to select anything
                    _parent._hackOnUploadStarted =
                        () => {
                        widget.State = ActionViewState.CreateOperationRunning();
                        _activatedFor.Add(forFile);
                    };

                    _parent.OnReplace(widget, forFile, forceAddOrRemoveToView);

                    _parent._hackOnUploadEnded = result => {
                        _activatedFor.Remove(forFile);
                        widget.Widget.TextContent = FontAwesomeSolid.IconExchangeAlt;
                        widget.State = result.Success ?
                                       ActionViewState.CreateIdleOrSuccess()
                            :
                                       ActionViewState.CreateOperationFailed(new Exception(result.ErrorMessage));

                        UpdateEnablement(forFile, widget, false); //make action enabled (needed due to hack above)
                    };
                };
                UpdateEnablement(forFile, widget, false);
                _known.Add(forFile, widget);
                return(widget);
            }
示例#3
0
 private void UpdateEnablement(
     RemoteFileDescr forFile, bool isOperationStarted, IView <HTMLElement> senderOrNull)
 {
     _known
     .Where(x => x.Key == forFile)
     .ForEach(x => {
         if (x.Value != senderOrNull)
         {
             //reset former errors if any
             x.Value.State = ActionViewState.CreateIdleOrSuccess();
         }
         UpdateEnablement(x.Key, x.Value, isOperationStarted);
     });
 }
示例#4
0
            public IView <HTMLElement> Create(RemoteFileDescr forFile, Action forceAddOrRemoveToView)
            {
                var widget = InputTypeButtonActionView.CreateFontAwesomeIconedAction(
                    IconFontType.FontAwesomeSolid, FontAwesomeSolid.IconTrashAlt);

                widget.Widget.Title = I18n.Translate("Remove");
                widget.Triggered   += async() => {
                    widget.State = ActionViewState.CreateOperationRunning();
                    var result = await _parent.OnRemove(widget, forFile, forceAddOrRemoveToView);

                    widget.Widget.TextContent = FontAwesomeSolid.IconTrashAlt;
                    widget.State = result.Success ?
                                   ActionViewState.CreateIdleOrSuccess()
                        :
                                   ActionViewState.CreateOperationFailed(new Exception(result.ErrorMessage));
                };

                UpdateEnablement(forFile, widget, false);

                _known.Add(forFile, widget);
                return(widget);
            }
示例#5
0
 public void ResponseStopRecording()
 {
     this.actionViewState = ActionViewState.Idle;
     this.WindowState = WindowState.Normal;
     taskbarInfo.ProgressState = TaskbarItemProgressState.Normal;
     taskbarInfo.ProgressValue = 1;            
     this.HasActions = true;
 }
示例#6
0
 public void ResponseStartRecording()
 {
     this.UpdateNoyifyIconBalloonTipText("开始动作录制。按F10键停止录制!", 5000, this.notifyIcon);
     this.actionViewState = ActionViewState.Busy;
     this.WindowState = WindowState.Minimized;
     taskbarInfo.ProgressState = TaskbarItemProgressState.Paused;
     taskbarInfo.ProgressValue = 1.0;            
 }
示例#7
0
 public void ResponseStartPlayback()
 {
     this.UpdateNoyifyIconBalloonTipText("开始动作录制回放.", 5000, this.notifyIcon);
     this.actionViewState = ActionViewState.Busy;
     this.WindowState = WindowState.Minimized;
 }
 public void OnShown()
 {
     _view.Confirm.State = ActionViewState.CreateIdleOrSuccess(); //don't show former error
 }
 public void Init(IEnumerable <T> permittedValues)
 {
     _view.Confirm.State = ActionViewState.CreateIdleOrSuccess();
     _localValue.Reset(false, this);
     _view.Choosen.PermittedValues = permittedValues;
 }
示例#10
0
            private void UpdateContentImpl(
                RemoteFileDescr forFile, UploadStatus?formerStatus, AnchorBasedActionView widget,
                bool isOperationRunning)
            {
                var enabledVal =
                    _parent.Downloadable &&
                    forFile.Status != UploadStatus.Running &&
                    forFile.FileId != null &&
                    !isOperationRunning;

                Logger.Debug(GetType(),
                             "UpdateContentImpl file={0} formerStatus={1} isOperationRunning={2} enabled={3}",
                             forFile, formerStatus, isOperationRunning, enabledVal);

                widget.Enabled = enabledVal;

                if (formerStatus.HasValue && formerStatus.Value == forFile.Status)
                {
                    //no need to recreate details
                    return;
                }

                switch (forFile.Status)
                {
                case UploadStatus.Running: {
                    widget.State = ActionViewState.CreateOperationRunning();

                    var throbber = new HTMLDivElement {
                        TextContent = FontAwesomeSolid.IconSpinner
                    };
                    throbber.AddClasses(IconFontType.FontAwesomeSolid.ToCssClassName());

                    throbber.Style.FontSize = $"{_parent._cellSize.width/3}px";
                    throbber.Style.SetProperty("animation", "throbberSpin 1.0s linear infinite");

                    widget.Widget.AppendChild(throbber);
                    break;
                }

                case UploadStatus.Failed:
                case UploadStatus.Succeeded:
                    if (formerStatus.HasValue && formerStatus.Value == UploadStatus.Running)
                    {
                        //file just uploaded (succ or fail)
                        SetupOnClick(forFile, widget, false);
                    }

                    if (forFile.UploadErrorMessage != null)
                    {
                        widget.Widget.SetAttribute(
                            Magics.AttrDataErrorsTooltip, forFile.UploadErrorMessage);
                    }

                    if (forFile.ThumbDimensions != null)
                    {
                        var dim = _parent.CalculateDimensionsFittingIntoCell(
                            forFile.ThumbDimensions.Value);
                        var img = new HTMLImageElement {
                            Width  = dim.width,
                            Height = dim.height,
                            Src    = forFile.ThumbnailDataUrl
                        };
                        widget.Widget.AppendChild(img);
                    }
                    else
                    {
                        var icn = new HTMLDivElement {
                            TextContent = FontAwesomeSolid.IconFileAlt
                        };
                        icn.AddClasses(IconFontType.FontAwesomeSolid.ToCssClassName());
                        icn.Style.FontSize = $"{_parent._cellSize.width/3}px";

                        widget.Widget.AppendChild(icn);
                    }
                    break;

                default: throw new Exception("unsupported UploadStatus");
                }
            }