Exemplo n.º 1
0
        void dlgLogin_FormClosing(object sender, FormClosingEventArgs e)
        {
            m_dlgLogin.FormClosing -= dlgLogin_FormClosing;

            if (!m_dlgLogin.IsFilledOut)
            {
                m_pPerson = new Person("unknown", "unknown");
                return;
            }
            if (m_dlgLogin.RememberMe)
            {
                AppSettings.Instance.loginName = m_dlgLogin.UserName;
                AppSettings.Instance.loginPassword = m_dlgLogin.Password;
                AppSettings.Instance.rememberLastLogin = true;
            }
            m_pPerson = new Person(m_dlgLogin.UserName, m_dlgLogin.Password);
            try
            {
                m_pPerson.Load();
            }
            catch (System.Exception)
            {
                m_pPerson = new Person("unknown", "unknown");
            }

            this.Text = "Time Assist [" + m_pPerson.Name + "]";

            UpdateForm(m_pPerson);
        }
Exemplo n.º 2
0
        private void UpdateForm(Person p)
        {
            // TODO: Add the ability to update both the today element and
            //      the record stack of elements.

            if (p.Records.Count > 0)
            {
                // Handle all records.
                treeViewRecords.Nodes.Clear();
                TreeNode node;
                TreeNode record = new TreeNode();
                foreach (var key in p.Records.Keys)
                {
                    node = treeViewRecords.Nodes.Add(key.ToString());
                    List<Record> sorted = new List<Record>(p.Records[key].ToArray());
                    sorted.Sort((Record a, Record b) =>
                    {
                        return a.Start.CompareTo(b.Start);
                    });
                    foreach (var task in sorted)
                    {
                        record = new TreeNode();
                        record.Text = task.Duration.ToString("F2") + " - " + task.Task;
                        foreach (var item in task.properties)
                        {
                            record.Nodes.Add(item.GetType().Name + " - " + item.Data.ToString());
                        }
                        node.Nodes.Add(record);
                    }
                }
                if (record != null) treeViewRecords.SelectedNode = record;
            }
        }
Exemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //LoadRecordsBinary("test.xml.bin");
            //LoadRecordsSoap("SoapTest.xml");
            if (AppSettings.Instance.rememberLastLogin)
            {
                m_pPerson = new Person(AppSettings.Instance.loginName, AppSettings.Instance.loginPassword);
                try
                {
                    m_pPerson.Load();
                }
                catch (System.Exception)
                {
                    m_pPerson = new Person("unknown", "unknown");
                }

                this.Text = "Time Assist [" + m_pPerson.Name + "]";

                UpdateForm(m_pPerson);
            }
            else
            {
                ShowLoginDialog();
            }
        }