Ejemplo n.º 1
0
    public MainWindow(string url) : base(Gtk.WindowType.Toplevel)
    {
        Build();
        Url = url;

        _pbkdfHandler  = new PbkdfHandler();
        _hmacGenerator = new HmacGenerator();
        _sqrlSigner    = new SqrlSigner();
        _sqrlClient    = new SqrlClient(_pbkdfHandler, _hmacGenerator, _sqrlSigner);

        this.domainLabel.Text = string.Format("Do you want to log in to {0}", _sqrlClient.GetDomainFromUrl(url));

        _identities = GetIdentities();

        if (_identities.Count() <= 0)
        {
            var newIdentity = CreateNewIdentity();
            _identities.Add(newIdentity);
            SaveIdentities(_identities);
        }

        var comboList    = new ListStore(typeof(int), typeof(string));
        var textRenderer = new CellRendererText();

        identityCombo.PackStart(textRenderer, false);
        identityCombo.AddAttribute(textRenderer, "text", 1);

        var identitiesArray = _identities.ToArray();

        for (var i = 0; i < identitiesArray.Length; i++)
        {
            comboList.AppendValues(i, identitiesArray[i].Name);
        }

        identityCombo.Model = comboList;
    }
Ejemplo n.º 2
0
    public MainWindow(string url)
        : base(Gtk.WindowType.Toplevel)
    {
        Build();
        Url = url;

        _pbkdfHandler = new PbkdfHandler();
        _hmacGenerator = new HmacGenerator();
        _sqrlSigner = new SqrlSigner();
        _sqrlClient = new SqrlClient(_pbkdfHandler, _hmacGenerator, _sqrlSigner);

        this.domainLabel.Text = string.Format("Do you want to log in to {0}", _sqrlClient.GetDomainFromUrl(url));

        _identities = GetIdentities();

        if(_identities.Count() <= 0)
        {
            var newIdentity = CreateNewIdentity();
            _identities.Add(newIdentity);
            SaveIdentities(_identities);
        }

        var comboList = new ListStore(typeof(int), typeof(string));
        var textRenderer = new CellRendererText();
        identityCombo.PackStart(textRenderer, false);
        identityCombo.AddAttribute(textRenderer, "text", 1);

        var identitiesArray = _identities.ToArray();

        for(var i = 0; i < identitiesArray.Length; i++)
        {
            comboList.AppendValues(i, identitiesArray[i].Name);
        }

        identityCombo.Model = comboList;
    }