Example #1
0
        /// <summary>
        /// ��ʼ������
        /// </summary>
        /// <param name="subject">�������</param>
        /// <param name="plus">�������(1,2,3,4�ֱ��ʾ���ϣ��ң���)</param>
        public TitleSubject(SubjectBase subject, int plus)
        {
            if (subject.GetType() == typeof(CenterSubject))
            {
                if (viewMode == MapViewModel.ExpandTwoSides)
                {
                    this.Direction = plus == 1 ? -1 : 1;
                }
                this.ParentSubject = subject;
            }
            else if (subject.GetType() == typeof(TitleSubject))
            {
                //�Ƿ�������
                bool bAddChild = true;
                int insertPos = 0; //�����

                if (viewMode == MapViewModel.Structure)
                {
                    bAddChild = plus == 2 || plus == 4; //�������������
                    insertPos = plus == 1 ? 0 : 1;
                }
                else
                {
                    bAddChild = plus == 1 || plus == 3; //�������������
                    insertPos = plus == 2 ? 0 : 1;

                }

                if (bAddChild)  //������
                {
                    this.ParentSubject = subject;
                }
                else  //�ֵ�����
                {
                    SubjectBase brotherSubject = subject;
                    SubjectBase fatherSubject = brotherSubject.ParentSubject;
                    if (fatherSubject == null)
                    {
                        return;
                    }
                    if (fatherSubject.GetType() == typeof(CenterSubject))
                    {
                        this.Direction = brotherSubject.Direction;
                    }

                    int index = fatherSubject.ChildSubjects.IndexOf(brotherSubject);
                    fatherSubject.InsertSubject(this, index + insertPos);
                }
            }
        }
Example #2
0
        private void RenderSubjectTitle(Graphics g, Rectangle r, SubjectBase subject)
        {
            string title = subject.Title;
            Font f = subject.Font;
            Pen p = new Pen(subject.BorderColor, 1.0f);
            Rectangle sr = subject.RectAreas;
            g.Clip = new Region(new Rectangle(sr.Left - (int)(10 * SubjectBase.zoomValue), sr.Top - (int)(10 * SubjectBase.zoomValue), sr.Width + (int)(20 * SubjectBase.zoomValue) + subject.BranchLinkWidth, sr.Height + (int)(20 * SubjectBase.zoomValue)));

            int radius = subject.Height / 6;
            if (selectedSubject == subject)  //����ѡ��߿����չ
            {
                Rectangle activeArea = new Rectangle(sr.Left - (int)(3 * SubjectBase.zoomValue), sr.Top - (int)(6 * SubjectBase.zoomValue), sr.Width + (int)(7 * SubjectBase.zoomValue), sr.Height + (int)(10 * SubjectBase.zoomValue));

                //������չ
                RenderPlus(g, activeArea, subject);

                //���Ʊ߿�ͱ���
                FillRoundRectangle(g, new SolidBrush(subject.SelectColor), activeArea, radius);
                g.FillRectangle(Brushes.White, sr.Left - 1, sr.Top - 1, sr.Width + 2, sr.Height + 2);

            }
            else if (activeSubject == subject) //����ѡ�б߿�
            {
                Rectangle activeArea = new Rectangle(sr.Left - (int)(3 * SubjectBase.zoomValue), sr.Top - (int)(6 * SubjectBase.zoomValue), sr.Width + (int)(7 * SubjectBase.zoomValue), sr.Height + (int)(10 * SubjectBase.zoomValue));

                FillRoundRectangle(g, new SolidBrush(subject.ActiveColor), activeArea, radius);
                g.FillRectangle(Brushes.White, sr.Left - 1, sr.Top - 1, sr.Width + 2, sr.Height + 2);
            }

            if (subject.GetType() == typeof(AttachSubject))
            {
                FillAttachRectangle(g, new SolidBrush(subject.BackColor), sr, radius);
                DrawAttachRectangle(g, p, sr, radius);
            }
            else
            {
                if (theme == MapTheme.Bubble && subject.GetType() == typeof(CenterSubject))
                {
                    g.FillEllipse(new SolidBrush(subject.BackColor), sr);
                    g.DrawEllipse(p, sr);
                }
                else
                {
                    FillRoundRectangle(g, new SolidBrush(subject.BackColor), sr, radius);
                    DrawRoundRectangle(g, p, sr, radius);
                }
            }

            //����ͼ��
            int lb = subject.MarginWidth;
            for (int i = 0; i < subject.SubjectPictures.Count; i++)
            {
                Image img = subject.SubjectPictures[i].SubjectImage;

                g.DrawImage(img, (float)(sr.Left + lb), (float)(sr.Top + sr.Height / 2 - img.Height / 2 + 1));
                lb += (img.Width + subject.ImageSplitWidth);
            }

            SizeF size = g.MeasureString(title, f);
            //�����ı�
            float x_title = (float)(sr.Left + sr.Width / 2 - size.Width / 2); //�����
            float y_title = (float)(sr.Top + sr.Height / 2 - Math.Floor(size.Height) / 2 + 1);
            if (lb != subject.MarginWidth)
            {
                x_title = (float)(sr.Left + lb);//��ͼ������
            }

            g.DrawString(title, f, new SolidBrush(subject.ForeColor), x_title, y_title);
            Rectangle srTitle = new Rectangle((int)x_title, (int)y_title, (int)size.Width, (int)size.Height);
            subject.RectTitle = srTitle;
        }
Example #3
0
        /// <summary>
        /// ���Ʒ�֧�ߺ��۵���ť
        /// </summary>
        private void RenderSubjectBranchLink(Graphics g, Rectangle r, SubjectBase subject)
        {
            if (subject.ChildSubjects.Count == 0) return;

            if (theme != MapTheme.Default && subject.GetType() == typeof(CenterSubject)) return;

            g.Clip = new System.Drawing.Region(r);

            //�Ȼ�������ķ�֧�����ߺ��۵���ť���ٻ�������������ʾ��ǰ
            int x1 = 0;
            int y1 = 0;
            int x2 = 0;
            int y2 = 0;
            if (ViewModel == MapViewModel.ExpandTwoSides)
            {
                bool bDrawRight = false;
                bool bDrawLeft = false;
                if (subject.GetType() == typeof(CenterSubject))
                {
                    foreach (SubjectBase childSubject in subject.ChildSubjects)
                    {
                        if (childSubject.Direction == 1)
                        {
                            bDrawRight = true;
                        }
                        if (childSubject.Direction == -1)
                        {
                            bDrawLeft = true;
                        }
                        if (bDrawRight && bDrawLeft) break;
                    }
                }
                else
                {
                    bDrawRight = subject.Direction == 1;
                    bDrawLeft = subject.Direction == -1;
                }

                if (bDrawRight)
                {
                    x1 = subject.RectAreas.Left + subject.RectAreas.Width;
                    y1 = subject.RectAreas.Top + subject.RectAreas.Height / 2;

                    x2 = x1 + subject.BranchLinkWidth;
                    y2 = y1;

                    RendrBranchLink(g, r, subject, x1, y1, x2, y2);
                }
                if (bDrawLeft)
                {
                    x1 = subject.RectAreas.Left;
                    y1 = subject.RectAreas.Top + subject.RectAreas.Height / 2;

                    x2 = x1 - subject.BranchLinkWidth;
                    y2 = y1;

                    RendrBranchLink(g, r, subject, x1, y1, x2, y2);
                }
                return;
            }

            if (ViewModel == MapViewModel.ExpandRightSide)
            {
                x1 = subject.RectAreas.Left + subject.RectAreas.Width;
                y1 = subject.RectAreas.Top + subject.RectAreas.Height / 2;

                x2 = x1 + subject.BranchLinkWidth;
                y2 = y1;
            }
            else if (ViewModel == MapViewModel.TreeMap)
            {
                x1 = subject.RectAreas.Left + subject.BranchLinkWidth / 2;
                y1 = subject.RectAreas.Top + subject.RectAreas.Height;

                x2 = x1;
                y2 = y1 + subject.BranchLinkWidth;
            }
            else if (ViewModel == MapViewModel.Structure)
            {
                if (subject.Level == 0)
                {
                    x1 = subject.RectAreas.Left + subject.Width / 2;
                    y1 = subject.RectAreas.Top + subject.RectAreas.Height;

                    x2 = x1;
                    y2 = y1 + subject.BranchLinkWidth;
                }
                else
                {
                    x1 = subject.RectAreas.Left + subject.BranchLinkWidth / 2;
                    y1 = subject.RectAreas.Top + subject.RectAreas.Height;

                    x2 = x1;
                    y2 = y1 + subject.BranchLinkWidth;
                }
            }
            RendrBranchLink(g, r, subject, x1, y1, x2, y2);
        }
Example #4
0
        private void RenderSubjectParentLink(Graphics g, Rectangle r, SubjectBase subject)
        {
            if (subject.ParentSubject == null) return;
            g.Clip = new System.Drawing.Region(r);

            if (subject.GetType() == typeof(AttachSubject))
            {
                RenderLinkAttach(g, r, subject);
            }
            else
            {
                RenderLinkBranch(g, r, subject);
            }
        }
Example #5
0
        /// <summary>
        /// ����������ʽ
        /// </summary>
        public void SetThemeStyle(SubjectBase subject)
        {
            if (subject.GetType() == typeof(CenterSubject))
            {
                SetCenterSubjectStyle(subject);
                return;
            }

            switch (subject.Level)
            {
                case 0:
                    SetTitleStyleLevel0(subject);
                    break;
                case 1:
                    SetTitleStyleLevel1(subject);
                    break;
                case 2:
                    SetTitleStyleLevel2(subject);
                    break;
                case 3:
                    SetTitleStyleLevel3(subject);
                    break;
            }
        }