Esempio n. 1
0
        public static int CompareTasks(Task x, Task y, Kanban kanban, string parameter, bool desc)
        {
            int num;

            switch (parameter)
            {
            case "Text":
                num = string.CompareOrdinal(x.Text, y.Text);
                if (desc)
                {
                    return(-num);
                }
                return(num);

            case "Topic":
            {
                Topic topic  = kanban.FindTopicById(x.TopicId);
                Topic topic2 = kanban.FindTopicById(y.TopicId);
                if ((topic == null) || (topic2 != null))
                {
                    if ((topic == null) && (topic2 != null))
                    {
                        num = -1;
                        if (!desc)
                        {
                            return(num);
                        }
                        return(-num);
                    }
                    if ((topic == null))
                    {
                        return(0);
                    }
                    if (topic.Id == topic2.Id)
                    {
                        return(0);
                    }
                    num = string.CompareOrdinal(topic.Name, topic2.Name);
                    if (!desc)
                    {
                        return(num);
                    }
                    return(-num);
                }
                num = 1;
                if (desc)
                {
                    return(-num);
                }
                return(num);
            }
            }
            return(0);
        }
Esempio n. 2
0
        private static Kanban Load()
        {
            Kanban       kanban     = null;
            StreamReader textReader = null;

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Kanban));
                textReader = new StreamReader(DataPath, Encoding.UTF8);
                kanban     = (Kanban)serializer.Deserialize(textReader);
                textReader.Close();
                kanban.CheckConsistency();
            }
            catch (Exception exception)
            {
                MessageBox.Show(@"Failed to load data from file: """ + DataPath + "\"\n\n" + exception.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                if (textReader != null)
                {
                    textReader.Close();
                }
            }
            return(kanban);
        }