示例#1
0
        public CalendarView()
            : base()
        {
            virtualParent = new TreeListNode();

            nodes = virtualParent.Nodes;
            nodes.Owner = virtualParent;
            nodes.MouseDown += new MouseEventHandler(OnSubControlMouseDown);
            nodes.NodesChanged += new EventHandler(OnNodesChanged);

            taskEventNodes = new List<TaskEventNode>();
            selectedNodes = new TreeListNodeCollection();

            nodeRowRects = new ListDictionary();
            pmRects = new ListDictionary();

            txtNode = new TextBox();
            txtNode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            txtNode.MouseDown += txtNode_MouseDown;
            txtNode.MouseUp += txtNode_MouseUp;
            txtNode.MouseMove += txtNode_MouseMove;
            txtNode.KeyDown += txtNode_KeyDown;
            txtNode.Leave += txtNode_Leave;

            timerTxt = new Timer();
            timerTxt.Interval = 1000;
            timerTxt.Enabled = false;
            timerTxt.Tick += timerTxt_Tick;

            currentTime = DateTime.Now;
            // Use reflection to load the
            // embedded bitmaps for the
            // styles plus and minus icons
            Assembly myAssembly = Assembly.GetAssembly(Type.GetType("JsmCalendar.CalendarView"));
            ////string filename = Application.StartupPath + @"\Image\tv_minus.bmp";
            ////bmpMinus = new Bitmap(filename);  yixun
            ////bmpMinus = new Bitmap(Application.StartupPath + @"\Image\tv_plus.bmp");
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CalendarView));
               //// bmpMinus = ((System.Drawing.Bitmap)(resources.GetObject("tv_minus.bmp")));
        }
示例#2
0
        public TreeListNode()
        {
            subitems = new ContainerSubListViewItemCollection();
            subitems.ItemsChanged += new ItemsChangedEventHandler(OnSubItemsChanged);

            nodes = new TreeListNodeCollection();
            nodes.Owner = this;
            nodes.MouseDown += new MouseEventHandler(OnSubNodeMouseDown);
        }
示例#3
0
 public TreeListNodeCollection GetAllSelectNodes()
 {
     alSelectNodes = new TreeListNodeCollection();
     foreach (TreeListNode node in nodes)
     {
         if (node.Selected) alSelectNodes.Add(node, false);
         GetAllSelectNodes(node);
     }
     return alSelectNodes;
 }
示例#4
0
        public TreeListNode(DateTime dt)
        {
            date = dt;
            week = Convert.ToInt32(dt.DayOfWeek.ToString("d"));
            year = dt.Year;
            month = dt.Month;
            day = dt.Day;
            if (year == DateTime.Now.Year && month == DateTime.Now.Month && day == DateTime.Now.Day)
            {
                isToday = true;
            }
            chinesDate = new ChineseDate(dt);
            backcolor = Color.Honeydew;
            nodes = new TreeListNodeCollection();
            relateTasks = new List<TaskEventNode>();
            nodes.Owner = this;
            nodes.MouseDown += new MouseEventHandler(OnSubNodeMouseDown);

            subitems = new ContainerSubListViewItemCollection();
            subitems.ItemsChanged += new ItemsChangedEventHandler(OnSubItemsChanged);
        }
示例#5
0
 private void UnselectNodes(TreeListNodeCollection nodecol)
 {
     for (int i=0; i<nodecol.Count; i++)
     {
         UnselectNodes(nodecol[i].Nodes);
         nodecol[i].Focused = false;
         nodecol[i].Selected = false;
     }
 }
示例#6
0
        private void SortNodes(TreeListNodeCollection lstNodes, int i)
        {
            foreach (TreeListNode treelistNode in lstNodes)
            {
                if (treelistNode.Nodes.Count > 0) SortNodes(treelistNode.Nodes, i);
            }

            //�����ڵ���������
            TreeListNode[] arrayNode = new TreeListNode[lstNodes.Count];
            for (int row = 0; row < lstNodes.Count; row++)
            {
                arrayNode[row] = lstNodes[row];
            }

            if (i == 0)
            {
                Array.Sort(arrayNode, delegate(TreeListNode node1, TreeListNode node2)
                {

                    if (sortAsc)
                    {
                        //����
                        if (regNumber.IsMatch(node1.Text) && regNumber.IsMatch(node2.Text))
                        {
                            return decimal.Parse(node1.Text).CompareTo(decimal.Parse(node2.Text));
                        }
                        else
                        {
                            return node1.Text.CompareTo(node2.Text);
                        }
                    }
                    else
                    {
                        //����
                        if (regNumber.IsMatch(node1.Text) && regNumber.IsMatch(node2.Text))
                        {
                            return decimal.Parse(node2.Text).CompareTo(decimal.Parse(node1.Text));
                        }
                        else
                        {
                            return node2.Text.CompareTo(node1.Text);
                        }
                    }
                });
            }
            else  //�Ƚϵ�subitems
            {
                Array.Sort(arrayNode, delegate(TreeListNode node1, TreeListNode node2)
                {
                    string text1 = "";
                    string text2 = "";
                    if (node1.SubItems.Count > i - 1)
                    {
                        text1 = node1.SubItems[i - 1].Text;
                    }
                    if (node2.SubItems.Count > i - 1)
                    {
                        text2 = node2.SubItems[i - 1].Text;
                    }

                    if (sortAsc)
                    {
                        //����
                        if (regNumber.IsMatch(text1) && regNumber.IsMatch(text2))
                        {
                            return decimal.Parse(text1).CompareTo(decimal.Parse(text2));
                        }
                        else
                        {
                            return text1.CompareTo(text2);
                        }
                    }
                    else
                    {
                        //����
                        if (regNumber.IsMatch(text1) && regNumber.IsMatch(text2))
                        {
                            return decimal.Parse(text2).CompareTo(decimal.Parse(text1));
                        }
                        else
                        {
                            return text2.CompareTo(text1);
                        }
                    }

                });  //�Զ�������ʽ
            }

            //�������Ľڵ�������ӵ�������
            for (int c = lstNodes.Count - 1; c >= 0; c--)
            {
                lstNodes.RemoveAt(c);
            }

            for (int c = 0; c < arrayNode.Length; c++)
            {
                lstNodes.Add(arrayNode[c]);
            }
        }
示例#7
0
        private TreeListNodeCollection GetSelectedNodes(TreeListNode node)
        {
            TreeListNodeCollection list = new TreeListNodeCollection();

            for (int i=0; i<node.Nodes.Count; i++)
            {
                // check if current node is selected
                if (node.Nodes[i].Selected)
                {
                    list.Add(node.Nodes[i]);
                }

                // chech if node is expanded and has
                // selected children
                if (node.Nodes[i].IsExpanded)
                {
                    TreeListNodeCollection list2 = GetSelectedNodes(node.Nodes[i]);
                    for (int j=0; j<list2.Count; j++)
                    {
                        list.Add(list2[i]);
                    }
                }
            }

            return list;
        }
示例#8
0
        private void AutoSetColWidth(TreeListNodeCollection nodes, ref int mwid, ref int twid, int i)
        {
            for (int j=0; j<nodes.Count; j++)
            {
                if (i > 0)
                    twid = GetStringWidth(nodes[j].SubItems[i-1].Text);
                else
                    twid = GetStringWidth(nodes[j].Text);
                twid += 5;
                if (twid > mwid)
                    mwid = twid;

                if (nodes[j].Nodes.Count > 0)
                {
                    AutoSetColWidth(nodes[j].Nodes, ref mwid, ref twid, i);
                }
            }
        }