Example #1
0
 public void OpenRequest(SHTarget ReqTarget)
 {
     var j = Dispatcher.RunIdleAsync(x =>
     {
         ControlFrame.Instance.SubNavigateTo(this, () => new HSRequestView(BindItem, Crypt, ReqTarget, AccessToken));
     });
 }
Example #2
0
 public void PlaceRequest(SHTarget Target)
 {
     ControlFrame.Instance.SubNavigateTo(this, () => {
         HSRequestView HSRV = new HSRequestView(BindItem, Crypt, Target, AccessToken);
         HSRV.PlaceRequest();
         return(HSRV);
     });
 }
Example #3
0
        private void NewReply(object sender, RoutedEventArgs e)
        {
            HSComment       HSC = ( HSComment )(( FrameworkElement )sender).DataContext;
            StringResources stx = StringResources.Load("AppBar");

            CCTarget = SHTarget.COMMENT;
            CCId     = HSC.Id;
            NewComment(stx.Text("Reply"));
        }
Example #4
0
        public HSRequestView(HubScriptItem HSI, CryptAES Crypt, SHTarget ReqTarget, string AccessToken)
            : this()
        {
            BindItem         = HSI;
            this.Crypt       = Crypt;
            this.ReqTarget   = ReqTarget;
            this.AccessToken = AccessToken;

            XGrant.SetParameter(BindItem.Id, CustomAnchor.TimeKey);
            ShowRequest(ReqTarget);
        }
Example #5
0
        private void ShowRequest(SHTarget Target)
        {
            // User have the thing. So he / she can grant requests for this script
            if ((Target & SHTarget.KEY) != 0)
            {
                RequestList.Tag = BindItem.Encrypted && Crypt != null;
            }
            else
            {
                // Default Targeted to TOKEN
                Target          = SHTarget.TOKEN;
                RequestList.Tag = AccessToken;
            }

            ReloadRequests(Target);
        }
Example #6
0
        public PlaceRequest( SHTarget Target, HubScriptItem HSI, string Placeholder )
        {
            this.InitializeComponent();

            StringResources stx = new StringResources( "Message" );

            PrimaryButtonText = stx.Str( "OK" );
            SecondaryButtonText = stx.Str( "Cancel" );

            this.Target = Target;

            Canceled = true;
            BindItem = HSI;
            RemarksPlaceholder = Placeholder;

            SetTemplate();
        }
Example #7
0
        public PlaceRequest(SHTarget Target, HubScriptItem HSI, string Placeholder)
        {
            this.InitializeComponent();

            StringResources stx = StringResources.Load("Message");

            PrimaryButtonText   = stx.Str("OK");
            SecondaryButtonText = stx.Str("Cancel");

            this.Target = Target;

            Canceled           = true;
            BindItem           = HSI;
            RemarksPlaceholder = Placeholder;

            SetTemplate();
        }
Example #8
0
        private async void ReloadRequests(SHTarget Target)
        {
            if (0 < LoadLevel)
            {
                return;
            }

            ReqTarget = Target;
            MarkLoading();
            HSLoader <SHRequest> CLoader = new HSLoader <SHRequest>(
                BindItem.Id
                , Target
                , (_Target, _Skip, _Limit, _Ids) => Shared.ShRequest.GetRequests(_Target, _Ids[0], _Skip, _Limit)
                );

            CLoader.ConvertResult = xs =>
            {
                XParameter XParam = XGrant.Parameter(BindItem.Id);
                if (XParam != null)
                {
                    foreach (SHRequest x in xs)
                    {
                        x.Granted = XParam.FindParameter(x.Id) != null;
                    }
                }
                return(xs.ToArray());
            };

            IList <SHRequest> FirstPage = await CLoader.NextPage();

            MarkNotLoading();

            RequestsSource = new Observables <SHRequest, SHRequest>(FirstPage);
            RequestsSource.ConnectLoader(CLoader);

            RequestsSource.LoadStart += (x, y) => MarkLoading();
            RequestsSource.LoadEnd   += (x, y) => MarkNotLoading();
            RequestList.ItemsSource   = RequestsSource;
        }
Example #9
0
        private void InitAppBar()
        {
            StringResources stx = StringResources.Load("AppBar", "AppResources");

            AddBtn        = UIAliases.CreateAppBarBtn(Symbol.Add, stx.Str("AddComment"));
            AddBtn.Click += (sender, e) =>
            {
                CCTarget = SHTarget.SCRIPT;
                CCId     = BindItem.Id;
                NewComment(AddBtn.Label);
            };

            SubmitBtn        = UIAliases.CreateAppBarBtn(Symbol.Send, stx.Text("Button_Post", "AppResources"));
            SubmitBtn.Click += (s, e) => SubmitComment();

            DiscardBtn        = UIAliases.CreateAppBarBtn(Symbol.Delete, "Discard");
            DiscardBtn.Click += (sender, e) => DiscardComment();

            CommentControls = new AppBarButton[] { AddBtn };

            MajorControls = CommentControls;
        }
Example #10
0
        private void NewReply( object sender, RoutedEventArgs e )
        {
            HSComment HSC = ( HSComment ) ( ( FrameworkElement ) sender ).DataContext;
            StringResources stx = new StringResources( "AppBar" );

            CCTarget = SHTarget.COMMENT;
            CCId = HSC.Id;
            NewComment( stx.Text( "Reply" ) );
        }
Example #11
0
        private async void ReloadRequests( SHTarget Target )
        {
            if ( LoadingRing.IsActive ) return;

            ReqTarget = Target;
            MarkLoading();
            HSLoader<SHRequest> CLoader = new HSLoader<SHRequest>(
                BindItem.Id
                , Target
                , ( _Target, _Skip, _Limit, _Ids ) => Shared.ShRequest.GetRequests( _Target, _Ids[0], _Skip, _Limit )
            );
            CLoader.ConvertResult = xs =>
            {
                XParameter XParam = XGrant.Parameter( BindItem.Id );
                if ( XParam != null )
                {
                    foreach ( SHRequest x in xs )
                    {
                        x.Granted = XParam.FindParameter( x.Id ) != null;
                    }
                }
                return xs.ToArray();
            };

            IList<SHRequest> FirstPage = await CLoader.NextPage();
            MarkNotLoading();

            RequestsSource = new Observables<SHRequest, SHRequest>( FirstPage );
            RequestsSource.ConnectLoader( CLoader );

            RequestsSource.LoadStart += ( x, y ) => MarkLoading();
            RequestsSource.LoadEnd += ( x, y ) => MarkNotLoading();
            RequestList.ItemsSource = RequestsSource;
        }
Example #12
0
        private void ShowRequest( SHTarget Target )
        {
            // User have the thing. So he / she can grant requests for this script
            if ( ( Target & SHTarget.KEY ) != 0 )
            {
                ControlsList.SelectedIndex = 0;
                RequestList.Tag = BindItem.Encrypted && Crypt != null;
            }
            else
            {
                // Default Targeted to TOKEN
                Target = SHTarget.TOKEN;
                ControlsList.SelectedIndex = Crypt != null ? 1 : 0;
                RequestList.Tag = AccessToken;
            }

            ReloadRequests( Target );
        }
Example #13
0
 public void OpenRequest( SHTarget Target )
 {
     if ( RequestsOpened )
     {
         ShowRequest( Target );
     }
     else
     {
         ReqTarget = Target;
         ToggleRequests();
     }
 }
Example #14
0
        public async void PlaceRequest( SHTarget Target, HubScriptItem HSI )
        {
            StringResources stx = new StringResources();

            PlaceRequest RequestBox = new PlaceRequest(
                Target, HSI
                , stx.Text( ( Target & SHTarget.KEY ) != 0 ? "KeyRequest" : "TokenRequest" )
            );

            await Popups.ShowDialog( RequestBox );
            if ( !RequestBox.Canceled ) OpenRequest( Target );
        }
Example #15
0
        private void SetTemplate()
        {
            LayoutRoot.DataContext = BindItem;

            if( BindItem.Encrypted )
            {
                ReqTarget = SHTarget.KEY;
                Crypt = ( CryptAES ) new AESManager().GetAuthById( BindItem.Id );
            }

            BottomControls = new ObservableCollection<PaneNavButton>();
            AccessToken = ( string ) new TokenManager().GetAuthById( BindItem.Id )?.Value;
            XGrant.SetParameter( BindItem.Id, BookStorage.TimeKey );

            if ( !string.IsNullOrEmpty( AccessToken ) )
            {
                TransitionDisplay.SetState( AccessControls, TransitionState.Active );
            }

            AvailControls = new Dictionary<string, PaneNavButton>()
            {
                { "Download", new PaneNavButton( new IconLogin() { AutoScale = true, Direction = Direction.Rotate270 }, Download ) }
                , { "Comment", new PaneNavButton( new IconComment() { AutoScale = true }, ToggleComments ) }
                , { "HideComment", new PaneNavButton( new IconNavigateArrow() { AutoScale = true, Direction = Direction.MirrorHorizontal }, ToggleComments ) }
                , { "NewComment", new PaneNavButton( new IconPlusSign() { AutoScale = true }, () => {
                    StringResources stx = new StringResources( "AppBar" );
                    CCTarget = SHTarget.SCRIPT;
                    CCId = BindItem.Id;
                    NewComment( stx.Str( "AddComment" ) );
                } ) }
                , { "OpenRequest", new PaneNavButton( new IconKeyRequest() { AutoScale = true }, ToggleRequests ) }
                , { "KeyRequest", new PaneNavButton( new IconRawDocument() { AutoScale = true }, () => { ShowRequest( SHTarget.KEY ); } ) }
                , { "TokenRequest", new PaneNavButton( new IconMasterKey() { AutoScale = true }, () => { ShowRequest( SHTarget.TOKEN ); } ) }
                , { "CloseRequest", new PaneNavButton( new IconNavigateArrow() { AutoScale = true, Direction = Direction.MirrorHorizontal }, ToggleRequests ) }
                , { "Submit", new PaneNavButton( new IconTick() { AutoScale = true }, SubmitComment ) }
                , { "Discard", new PaneNavButton( new IconCross() { AutoScale = true }, DiscardComment ) }
            };

            DisplayControls( HomeControls );

            ControlsList.ItemsSource = BottomControls;

            CommentStory = new Storyboard();
            CommentStory.Completed += CommentStory_Completed;

            RequestStory = new Storyboard();
            RequestStory.Completed += RequestStory_Completed;

            Member = X.Singleton<IMember>( XProto.SHMember );
            Unloaded += ScriptDetails_Unloaded;
        }
Example #16
0
 public void OpenRequest(SHTarget Target)
 {
     ShowRequest(Target);
 }