Ejemplo n.º 1
0
 public Tomato_listDetail(TomatoWork tomatoWork,string id)
 {
     InitializeComponent();
     _NowTask = GetTaskList("config/tomato_list.xml", "/list/task[id=" + id + "]");
     base.Text = _NowTask.Title;
     this._tomatoWork = tomatoWork;
     txt_datetime.Text = _NowTask.Datetime;
     txt_title.Text=_NowTask.Title;
     txt_content.Text = _NowTask.Content;
     //处理子列表
     _NowTask.Sublist=string.IsNullOrEmpty(_NowTask.Sublist)?"":_NowTask.Sublist;
     txt_sublist.Text = _NowTask.Sublist;
     ch_showList.Checked = _tomatoWork.CfgShowDetailList;
     ReloadSubList();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            TomatoTask task=new TomatoTask();
            task.Id = _NowTask.Id;
            task.Datetime = txt_datetime.Text;
            task.Title = txt_title.Text;
            task.Content = txt_content.Text;
            task.State = _NowTask.State;

            _NowTask.Sublist=txt_sublist.Text ;
            string subliststring = "";
            if (_NowTask.Sublist.Split("\r\n".ToCharArray()).Length > 0)
            {
                foreach (string a in _NowTask.Sublist.Split("\r\n".ToCharArray()))
                {
                    if (a.Length > 0)
                    {
                        if (!a.StartsWith("(o)") && !a.StartsWith("(x)"))
                        {
                            subliststring += "(x)" + a + "\r\n";
                        }
                        else
                        {
                            subliststring += a + "\r\n";
                        }
                    }
                }
            }
            if (ch_showList.Checked)
            {
                txt_sublist.Text = subliststring;
                _NowTask.Sublist = subliststring;
            }
            else
            {
                _NowTask.Sublist = subliststring;
            }

            task.Sublist = _NowTask.Sublist;
            SetTaskList("config/tomato_list.xml", "/list/task[id=" + _NowTask.Id + "]",task);
            _tomatoWork.ReloadList(true);

            this.Close();
            this.Dispose();
        }
Ejemplo n.º 3
0
 private ArrayList GetXmlConfigList(string filename,string xpath)
 {
     XmlDocument doc = new XmlDocument();
     doc.Load(filename);
     XmlNodeList nodes=doc.SelectNodes(xpath);
     ArrayList list = new ArrayList();
     foreach (XmlNode node in nodes)
     {
         TomatoTask task=new TomatoTask();
         var n1 = node.SelectSingleNode("id");
         if (n1 != null)
             task.Id = Convert.ToInt32(n1.InnerText.Trim());
         var n2 = node.SelectSingleNode("title");
         if (n2 != null)
             task.Title = n2.InnerText.Trim();
         var n3 = node.SelectSingleNode("content");
         if (n3 != null)
             task.Content = n3.InnerText.Trim();
         var n4 = node.SelectSingleNode("datetime");
         if (n4 != null)
             task.Datetime = n4.InnerText.Trim();
         var n5 = node.SelectSingleNode("state");
         if (n5 != null)
             task.State = n5.InnerText.Trim();
         var n6 = node.SelectSingleNode("sublist");
         if (n6 != null)
             task.Sublist = n6.InnerText.Trim();
         list.Add(task);
     }
     list.Reverse();
     return list;
 }
Ejemplo n.º 4
0
        /*
         * 新建任务按钮
         */
        private void btn_AddTask_Click(object sender, EventArgs e)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("config/tomato_list.xml");
            XmlNode listnode=doc.SelectSingleNode("/list");
            TomatoTask task = new TomatoTask();
            task.Id = Convert.ToInt32(GetXmlConfig("config/tomato_list.xml","/list/maxid")) + 1;

            task.Title = txt_title.Text;
            task.Content = txt_content.Text;
            task.Datetime = txt_time.Text;
            task.State = "0";
            XmlElement nodeTask = doc.CreateElement("task");
            XmlElement nodeId = doc.CreateElement("id");
            nodeId.InnerText = Convert.ToString(task.Id);
            XmlElement nodeTitle = doc.CreateElement("title");
            nodeTitle.InnerText = task.Title;
            XmlElement nodeContent = doc.CreateElement("content");
            nodeContent.InnerText = task.Content;
            XmlElement nodeDatetime = doc.CreateElement("datetime");
            nodeDatetime.InnerText = task.Datetime;
            XmlElement nodeState = doc.CreateElement("state");
            nodeState.InnerText = task.State;
            XmlElement nodeSublist = doc.CreateElement("sublist");
            nodeSublist.InnerText = task.Sublist;
            nodeTask.AppendChild(nodeId);
            nodeTask.AppendChild(nodeTitle);
            nodeTask.AppendChild(nodeContent);
            nodeTask.AppendChild(nodeDatetime);
            nodeTask.AppendChild(nodeState);
            nodeTask.AppendChild(nodeSublist);
            listnode.AppendChild(nodeTask);
            Tasklist.Insert(0,task);
            doc.Save("config/tomato_list.xml");
            txt_title.Text = "";
            txt_content.Text="";
            txt_time.Text="";

            SetXmlConfig("config/tomato_list.xml", "/list/maxid", task.Id.ToString());
            ReloadList(true);
        }
Ejemplo n.º 5
0
 private void SetTaskList(string filename, string xpath,TomatoTask task)
 {
     XmlDocument doc = new XmlDocument();
     doc.Load(filename);
     XmlNode node = doc.SelectSingleNode(xpath);
     if (node != null)
     {
         var n1 = node.SelectSingleNode("id");
         if (n1 != null)
             n1.InnerText = task.Id.ToString().Trim();
         else
         {
             XmlElement ele=doc.CreateElement("id");
             ele.InnerText = task.Id.ToString().Trim();
             node.AppendChild(ele);
         }
         var n2 = node.SelectSingleNode("title");
         if (n2 != null)
             n2.InnerText=task.Title.Trim();
         else{
             XmlElement ele = doc.CreateElement("title");
             ele.InnerText = task.Title.ToString().Trim();
             node.AppendChild(ele);
         }
         var n3 = node.SelectSingleNode("content");
         if (n3 != null)
             n3.InnerText=task.Content.Trim();
         else
         {
             XmlElement ele = doc.CreateElement("content");
             ele.InnerText = task.Content.ToString().Trim();
             node.AppendChild(ele);
         }
         var n4 = node.SelectSingleNode("datetime");
         if (n4 != null)
             n4.InnerText=task.Datetime.Trim();
         else
         {
             XmlElement ele = doc.CreateElement("datetime");
             ele.InnerText = task.Datetime.ToString().Trim();
             node.AppendChild(ele);
         }
         var n5 = node.SelectSingleNode("state");
         if (n5 != null)
             n5.InnerText=task.State.Trim();
         else
         {
             XmlElement ele = doc.CreateElement("state");
             ele.InnerText = task.State.ToString().Trim();
             node.AppendChild(ele);
         }
         var n6 = node.SelectSingleNode("sublist");
         if (n6 != null){
             if (string.IsNullOrEmpty(task.Sublist))
             {
                 task.Sublist = "";
             }
             n6.InnerText = task.Sublist.Trim();
         }
         else
         {
             XmlElement ele = doc.CreateElement("sublist");
             ele.InnerText = task.Sublist.ToString().Trim();
             node.AppendChild(ele);
         }
     }
     doc.Save(filename);
 }
Ejemplo n.º 6
0
 private TomatoTask GetTaskList(string filename, string xpath)
 {
     XmlDocument doc = new XmlDocument();
     doc.Load(filename);
     XmlNode node = doc.SelectSingleNode(xpath);
     TomatoTask task = new TomatoTask();
     if (node != null)
     {
         var n1 = node.SelectSingleNode("id");
         if (n1 != null)
             task.Id = Convert.ToInt32(n1.InnerText.Trim());
         var n2 = node.SelectSingleNode("title");
         if (n2 != null)
             task.Title = n2.InnerText.Trim();
         var n3 = node.SelectSingleNode("content");
         if (n3 != null)
             task.Content = n3.InnerText.Trim();
         var n4 = node.SelectSingleNode("datetime");
         if (n4 != null)
             task.Datetime = n4.InnerText.Trim();
         var n5 = node.SelectSingleNode("state");
         if (n5 != null)
             task.State = n5.InnerText.Trim();
         var n6 = node.SelectSingleNode("sublist");
         if (n6 != null)
             task.Sublist = n6.InnerText.Trim();
     }
     return task;
 }