示例#1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var scopes = string.Join(", ", OctokitClientFactory.Scopes);

            DescriptionLabel.Text = string.Format("The provided Personal Access Token must allow access to the following scopes: {0}", scopes);

            TokenText.EditingChanged += (sender, args) => ViewModel.Token = TokenText.Text;
            ViewModel.WhenAnyValue(x => x.Token).Subscribe(x => TokenText.Text = x);

            LoginButton.TouchUpInside += (sender, args) => ViewModel.LoginCommand.ExecuteIfCan();
            ViewModel.LoginCommand.CanExecuteObservable.Subscribe(x => LoginButton.Enabled = x);

            View.BackgroundColor = UIColor.FromRGB(239, 239, 244);
            LogoImageView.Image  = Images.Logos.GitHub;

            LoginButton.SetBackgroundImage(Images.Buttons.GreyButton.CreateResizableImage(new UIEdgeInsets(18, 18, 18, 18)), UIControlState.Normal);

            //Set some generic shadowing
            LoginButton.Layer.ShadowColor   = UIColor.Black.CGColor;
            LoginButton.Layer.ShadowOffset  = new CGSize(0, 1);
            LoginButton.Layer.ShadowOpacity = 0.3f;

            TokenText.ShouldReturn = delegate {
                TokenText.ResignFirstResponder();
                LoginButton.SendActionForControlEvents(UIControlEvent.TouchUpInside);
                return(true);
            };

            this.ViewportObservable().Subscribe(x => ScrollView.Frame = x);

            ImageHeight.Constant = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 192 : 86;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var scopes = string.Join(", ", OctokitClientFactory.Scopes);

            DescriptionLabel.Text      = string.Format("The provided Personal Access Token must allow access to the following scopes: {0}", scopes);
            DescriptionLabel.TextColor = ComponentTextColor;

            TokenText.AttributedPlaceholder = new Foundation.NSAttributedString("Token", foregroundColor: ComponentPlaceholderColor);
            TokenText.BackgroundColor       = ComponentBackgroundColor;
            TokenText.TextColor             = ComponentTextColor;

            DomainText.AttributedPlaceholder = new Foundation.NSAttributedString("Domain", foregroundColor: ComponentPlaceholderColor);
            DomainText.BackgroundColor       = ComponentBackgroundColor;
            DomainText.TextColor             = ComponentTextColor;

            View.BackgroundColor = BackgroundColor;
            LogoImageView.Image  = Images.Logos.Enterprise;

            LoginButton.SetTitleColor(ComponentTextColor, UIControlState.Normal);
            LoginButton.SetBackgroundImage(Images.Buttons.BlackButton.CreateResizableImage(new UIEdgeInsets(18, 18, 18, 18)), UIControlState.Normal);

            //Set some generic shadowing
            LoginButton.Layer.ShadowColor   = UIColor.Black.CGColor;
            LoginButton.Layer.ShadowOffset  = new CGSize(0, 1);
            LoginButton.Layer.ShadowOpacity = 0.2f;

            this.ViewportObservable().Subscribe(x => ScrollView.Frame = x);

            ImageHeight.Constant = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 192 : 86;

            OnActivation(d => {
                d(TokenText.GetChangedObservable().Subscribe(x => ViewModel.Token    = x));
                d(ViewModel.WhenAnyValue(x => x.Token).Subscribe(x => TokenText.Text = x));

                d(DomainText.GetChangedObservable().Subscribe(x => ViewModel.Domain    = x));
                d(ViewModel.WhenAnyValue(x => x.Domain).Subscribe(x => DomainText.Text = x));

                d(LoginButton.GetClickedObservable().InvokeCommand(ViewModel.LoginCommand));
                d(ViewModel.LoginCommand.CanExecuteObservable.Subscribe(x => LoginButton.Enabled = x));

                DomainText.ShouldReturn = delegate {
                    TokenText.BecomeFirstResponder();
                    return(true);
                };

                TokenText.ShouldReturn = delegate {
                    TokenText.ResignFirstResponder();
                    LoginButton.SendActionForControlEvents(UIControlEvent.TouchUpInside);
                    return(true);
                };

                d(Disposable.Create(() => {
                    DomainText.ShouldReturn = null;
                    TokenText.ShouldReturn  = null;
                }));
            });
        }
        private void OpenJwtIoButton_Click(object sender, RoutedEventArgs e)
        {
            var token = TokenText.Text;

            TokenText.SelectAll();
            TokenText.Focus();

            Process.Start("https://jwt.io/?value=" + token);
        }
示例#4
0
        private List <byte> ProcessLine(TokenText line)
        {
            List <byte> bytes = new List <byte>();

            foreach (var token in line.Tokens)
            {
                ProcessToken(token, bytes);
            }

            return(bytes);
        }
 void ICompletionWidget.Replace(int offset, int count, string text)
 {
     if (count > 0)
     {
         TokenText = TokenText.Remove(offset, count);
     }
     if (!string.IsNullOrEmpty(text))
     {
         TokenText = TokenText.Insert(offset, text);
     }
 }
示例#6
0
        public void Decompile(TokenText line, bool emitLineEndTag = true)
        {
            foreach (var token in line.Tokens)
            {
                Decompile(token);
            }

            if (emitLineEndTag)
            {
                WriteTag("e");
            }
        }
示例#7
0
        public void TestTokenRenumberOfNonemptyBy3WithoutNewLine()
        {
            var          tokenTextTable = new TokenTextTable();
            var          pathTable      = new PathTable();
            AbsolutePath path           = AbsolutePath.Create(pathTable, A("t", "a.txt"));
            var          token          = new Token(path, 100, 100, TokenText.Create(tokenTextTable, "abc"));
            Token        newToken       = token.UpdateLineInformationForPosition(tokenTextTable, 3);

            XAssert.AreEqual(path, newToken.Path);
            XAssert.AreEqual(100, newToken.Line);
            XAssert.AreEqual(102, newToken.Position);
            XAssert.AreEqual("abc", token.Text.ToString(tokenTextTable));
        }
示例#8
0
        public void TestTokenRenumberOfEmpty()
        {
            var          tokenTextTable = new TokenTextTable();
            var          pathTable      = new PathTable();
            AbsolutePath path           = AbsolutePath.Create(pathTable, A("t", "a.txt"));
            var          token          = new Token(path, 0, 0, TokenText.Create(tokenTextTable, string.Empty));
            Token        newToken       = token.UpdateLineInformationForPosition(tokenTextTable, 0);

            XAssert.AreEqual(path, newToken.Path);
            XAssert.AreEqual(0, newToken.Line);
            XAssert.AreEqual(0, newToken.Position);
            XAssert.AreEqual(string.Empty, token.Text.ToString(tokenTextTable));
        }
示例#9
0
        public void TestTokenRenumberOfBigStringWithMultipleLines()
        {
            var          tokenTextTable = new TokenTextTable();
            var          pathTable      = new PathTable();
            string       txt            = @"abc
de
f
ghi";
            AbsolutePath path           = AbsolutePath.Create(pathTable, A("t", "a.txt"));
            var          token          = new Token(path, 100, 100, TokenText.Create(tokenTextTable, txt));
            Token        newToken       = token.UpdateLineInformationForPosition(tokenTextTable, 13);

            XAssert.AreEqual('h', txt[13]);
            XAssert.AreEqual(path, newToken.Path);
            XAssert.AreEqual(103, newToken.Line);
            XAssert.AreEqual(1, newToken.Position);
        }
示例#10
0
        static void WriteLine(TokenText line, bool writeNewLine = true)
        {
            if (line == null)
            {
                return;
            }

            foreach (var token in line.Tokens)
            {
                WriteToken(token);
            }

            // write newline if the line doesn't contain any
            if (writeNewLine && (!line.Tokens.Any(x => x.Kind == TokenKind.NewLine) || (OutputFunctions && line.Tokens.Last().Kind == TokenKind.Function)))
            {
                Writer.WriteLine();
            }
        }
示例#11
0
 string ICompletionWidget.GetCompletionText(CodeCompletionContext ctx)
 {
     return(TokenText.Substring(ctx.TriggerOffset, ctx.TriggerWordLength));
 }
 private void CopyTokenAndFocusButton_Click(object sender, RoutedEventArgs e)
 {
     Clipboard.SetText(TokenText.Text);
     TokenText.SelectAll();
     TokenText.Focus();
 }