コード例 #1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            _client = new ZenfolioClient();

            // try to login
            Boolean loggedIn = _client.Login("", "");
            //Boolean loggedIn = _client.LoginPlain("", "");

            // load own profile
            User user = _client.LoadPrivateProfile();

            // load and wrap Groups hierarchy
            Group rootGroup = _client.LoadGroupHierarchy(user.LoginName);
            //TreeNode rootNode = CreateGroupNode(rootGroup);

            //// fix-up the root node of the Group hierarchy
            //rootNode.ImageIndex = (int)NodeType.Root;
            //rootNode.SelectedImageIndex = rootNode.ImageIndex;
            //rootNode.Text = user.DisplayName;
            //_tvGroups.Nodes.Add(rootNode);

            //// initialize browser pane
            //_axWebBrowser.Navigate("about:blank");
            //_axWebBrowser.TheaterMode = true;
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: danrichardson/ZenSync
        /// <summary>
        /// Occurs before a form is displayed for the first time.
        /// Makes all necessary initializations.
        /// </summary>
        private void OnLoad(object sender, EventArgs e)
        {
            _client = new ZenfolioClient();

            LoginDialog loginDialog = new LoginDialog();

            // try to login in a loop until successfully logged in or
            // cancelled by the user
            bool loggedIn = false;
            while (!loggedIn)
            {
                // ask for username and password
                DialogResult res = loginDialog.ShowDialog(this);

                // exit if the user doesn't want to enter credentials
                if (res != DialogResult.OK)
                {
                    Application.Exit();
                    return;
                }

                // try to login
                loggedIn = _client.Login(loginDialog.UserName,
                                         loginDialog.Password);
            }

            // load own profile
            User user = _client.LoadPrivateProfile();

            // load and wrap Groups hierarchy
            Group rootGroup = _client.LoadGroupHierarchy(user.LoginName);
            TreeNode rootNode = CreateGroupNode(rootGroup);

            // fix-up the root node of the Group hierarchy
            rootNode.ImageIndex = (int)NodeType.Root;
            rootNode.SelectedImageIndex = rootNode.ImageIndex;
            rootNode.Text = user.DisplayName;
            _tvGroups.Nodes.Add(rootNode);

            // initialize browser pane
            _axWebBrowser.Navigate("about:blank");
            _axWebBrowser.TheaterMode = true;
        }