Ejemplo n.º 1
0
        private void verbergToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Activiteit actCurr = tcActLijst.SelectedTab.Tag as Activiteit;

            actCurr.visible = false;
            m_invisTabPages.Insert(m_invisTabPages.Count, tcActLijst.SelectedTab);
            HideTabPage(tcActLijst.SelectedTab);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Remove activity
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void verwijderActiviteit(object sender, EventArgs e)
        {
            Activiteit actCurr = tcActLijst.SelectedTab.Tag as Activiteit;

            if (MessageBox.Show("Verwijder activiteit '" + actCurr.m_sDesc + "'?", "Bevestig keuze",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                tcActLijst.TabPages.Remove(tcActLijst.SelectedTab);
                if (tcActLijst.TabCount == 1 && timer1.Enabled)
                {
                    btPausestart.Enabled = false;
                    btPausestart_Click(sender, e);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create new activity
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btNewAct_Click(object sender, EventArgs e)
        {
            Activiteit pAct;

            pAct         = new Activiteit();
            pAct.sGUID   = Guid.NewGuid().ToString();
            pAct.m_sDesc = "Nieuwe activiteit";
            pAct.SetTimespent(0L);

            TabPage tpNew = new TabPage(pAct.m_sDesc);

            tpNew.ToolTipText = pAct.m_sDesc;
            tcActLijst.TabPages.Add(tpNew);

            tpNew.Tag = pAct;
            // tpNew.ContextMenuStrip = cmActiviteit;
            // tcActLijst.ContextMenuStrip = cmActiviteit;

            TreeView tvNew = new TreeView();

            tpNew.Controls.Add(tvNew);

            resizeInner();
            btPausestart.Enabled = true;

            tvNew.CheckBoxes      = true;
            tvNew.LabelEdit       = true;
            tvNew.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.tvTaskLijst_RenameAct);
            tvNew.MouseDown      += new System.Windows.Forms.MouseEventHandler(this.tvActLijst_MouseDown);

            TreeNode tnNew = new TreeNode("*");

            tvNew.Nodes.Add(tnNew);

            tnNew.BeginEdit();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// load configuration from XML
        /// </summary>
        private void OpenConfig()
        {
            TreeNode        tnNew;
            XmlNodeList     nodes, tnodes, dnodes;
            XmlDocument     ActReg = new XmlDocument();
            Activiteit      actCurr;
            ScheduledAction saCurr;
            ICollection     coll;
            XmlNode         tmpNode;
            bool            loadCompleted;

            RegistryKey regKey;

            regKey = Registry.CurrentUser.OpenSubKey(@"Software\ToDo");
            if (regKey == null)
            {
                regKey = Registry.CurrentUser.CreateSubKey(@"Software\ToDo", RegistryKeyPermissionCheck.ReadWriteSubTree);
                regKey.SetValue("LoadCompleted", "False");
            }
            loadCompleted = Convert.ToBoolean(regKey.GetValue("LoadCompleted"));

            try
            {
                ActReg.Load(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ActivityRegistration.xml");
            }
            catch
            {
                return;
            }

            tcActLijst.ContextMenuStrip = cmActiviteit;

            nodes = ActReg.SelectNodes("/ACTIVITIES/ACTIVITY");
            foreach (XmlNode node in nodes)
            {
                actCurr         = new Activiteit();
                actCurr.sGUID   = node.Attributes["id"].Value;
                actCurr.m_sDesc = node.SelectSingleNode("DESCRIPTION").InnerText;

                tmpNode = node.SelectSingleNode("AVAILABLETIME");
                if (tmpNode != null)
                {
                    actCurr.totalAvailable = Convert.ToInt64(tmpNode.InnerText);
                }

                coll   = actCurr.m_Hash.Keys;
                dnodes = node.SelectNodes("TIMESPENT/DAY");

                foreach (XmlNode dnode in dnodes)
                {
                    actCurr.m_Hash.Add(dnode.Attributes["day"].Value, System.Convert.ToInt64(dnode.InnerText));
                }

                string  str   = actCurr.m_sDesc;
                TabPage tpNew = new TabPage(str.Substring(0, Math.Min(str.Length, nchars)));
                tpNew.ToolTipText = str;

                if (node.Attributes["visible"] != null)
                {
                    actCurr.visible = Convert.ToBoolean(node.Attributes["visible"].Value);
                }
                else
                {
                    actCurr.visible = true;
                }
                if (actCurr.visible)
                {
                    tcActLijst.TabPages.Add(tpNew);
                }
                else
                {
                    m_invisTabPages.Insert(m_invisTabPages.Count, tpNew);
                }

                tpNew.Tag = actCurr;
                // tpNew.ContextMenuStrip = cmActiviteit;
                // tcActLijst.ContextMenuStrip = cmActiviteit;

                TreeView tvNew = new TreeView();
                tpNew.Controls.Add(tvNew);

                tvNew.CheckBoxes      = true;
                tvNew.LabelEdit       = true;
                tvNew.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.tvTaskLijst_RenameAct);
                tvNew.MouseDown      += new System.Windows.Forms.MouseEventHandler(this.tvActLijst_MouseDown);

                tnodes = node.SelectNodes("TASKS/TASK");
                foreach (XmlNode tnode in tnodes)
                {
                    if (loadCompleted || !System.Convert.ToBoolean(tnode.Attributes["completed"].Value))
                    {
                        tnNew = new TreeNode(tnode.Attributes["description"].Value);
                        tvNew.Nodes.Add(tnNew);
                        tnNew.ContextMenuStrip = cmTaak;
                        tnNew.Checked          = System.Convert.ToBoolean(tnode.Attributes["completed"].Value);
                    }
                }
                tnNew = new TreeNode("*");
                tvNew.Nodes.Add(tnNew);
                btPausestart.Enabled = true;
            }

            nodes = ActReg.SelectNodes("/ACTIVITIES/SCHEDULEDACTION");
            foreach (XmlNode node in nodes)
            {
                saCurr              = new ScheduledAction();
                saCurr.sGUID        = node.Attributes["id"].Value;
                saCurr.hasbeenfired = Convert.ToBoolean(node.Attributes["hasbeenfired"].Value);
                saCurr.fire         = Convert.ToInt64(node.SelectSingleNode("FIRE").InnerText);
                saCurr.alertmsg     = node.SelectSingleNode("ALERTMSG").InnerText;
                tmpNode             = node.SelectSingleNode("REPEAT");
                if (tmpNode != null)
                {
                    saCurr.repeat     = true;
                    saCurr.repeattype = tmpNode.Attributes["type"].Value;
                    saCurr.times      = Convert.ToInt32(tmpNode.Attributes["times"].Value);
                    saCurr.period     = tmpNode.InnerText;
                }
                else
                {
                    saCurr.repeat = false;
                }

                int    k = 1;
                string key;
                do
                {
                    key = saCurr.fire.ToString() + "_" + k.ToString();
                    k++;
                } while (m_frmScheduledAction.m_scheduledActions.ContainsKey(key));
                m_frmScheduledAction.m_scheduledActions.Add(key, saCurr);
            }

            resizeInner();
        }