コード例 #1
0
ファイル: LingTree.cs プロジェクト: cdyangupenn/CarlaLegacy
        public LingTreeApp(string strInitFileName)
        {
            BackColor = SystemColors.Window;
            if (BackColor.ToArgb() == 0)
                BackColor = Color.White;
            if (m_clrTreeBackgroundColor.ToArgb() == 0)
                m_clrTreeBackgroundColor = Color.White;
            ForeColor = SystemColors.WindowText;
            ResizeRedraw = true;

            try
            {
                RegistryKey regkey = Registry.CurrentUser.OpenSubKey(m_strRegKey);
                if (regkey != null)
                {
                    retrieveRegistryInfo(regkey);
                    regkey.Close();
                }
            }
            catch
            {
            }

            // Allow handling of user closing the form
            this.Closing += new CancelEventHandler(LingTreeAppOnClosing);

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            pnlForTree = new Panel();
            pnlForTree.Parent = this;
            pnlForTree.Dock = DockStyle.Fill;
            pnlForTree.AutoScroll = true;
            #if TreeNotControl
            pnlTree = new Panel();
            pnlTree.Parent = pnlForTree;
            pnlTree.Dock = DockStyle.None;
            pnlTree.AutoScroll = true;
            pnlTree.Paint += new PaintEventHandler(TreePanelOnPaint);
            pnlTree.Size = new Size(10, 10);  // give it an initial size
            pnlTree.Location = new Point(0, 0);
            #else
            pnlForTree.Paint += new PaintEventHandler(TreePanelOnPaint);
            #endif
            Splitter split = new Splitter();
            split.Parent = this;
            split.Dock = DockStyle.Top;
            split.BackColor = SystemColors.ScrollBar;

            rtbTreeDescription = new RichTextBox();
            rtbTreeDescription.Parent = this;
            rtbTreeDescription.Dock = DockStyle.Top;
            rtbTreeDescription.Height = m_iDescriptionBoxHeight;
            rtbTreeDescription.BorderStyle = BorderStyle.Fixed3D;
            rtbTreeDescription.KeyUp += new KeyEventHandler(DescriptionOnKeyUp);
            rtbTreeDescription.TextChanged += new EventHandler(DescriptionOnTextChanged);

            InitMenu();
            InitToolBar();
            InitStatusBar();
            AutoScroll = true;

            // create the tree with all the right parameters
            tree = new LingTreeTree(Application.ProductVersion);
            tree.GlossColor = Color.Green;
            tree.NTColor = Color.Red;
            tree.LexColor = Color.Blue;
            #if !TreeNotControl
            tree.Parent = pnlForTree;
            //			tree.Paint += new PaintEventHandler(TreePanelOnPaint);
            tree.m_LingTreeNodeClickedEvent += new LingTreeNodeClickedEventHandler(OnNodeClicked);
            pnlForTree.Controls.Add(tree);
            #endif

            if (strInitFileName != null)
            {
                m_strTreeFile = strInitFileName;
            }
            if (File.Exists(m_strTreeFile))
            {
                loadTree();
                rtbTreeDescription.Text = tree.Description;
                ParseTreeDescription();
                setFontsInTreeDescription();
            #if !TryToFixSVGColors
                CreateSVG();
            #else
                m_strSVG = tree.CreateSVG(CreateGraphics(), m_clrTreeLinesColor.Name);
            #endif
            }
            else
            {
                if ((strInitFileName != null) &&
                    (DialogResult.OK == MessageBox.Show(m_strTreeFile + " could not be found!  Please navigate to where it is located or click on Cancel to start a new tree description.", "Initial File Not Found!", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)))
                {
                    MenuFileOpenOnClick(null, null);
                }
                else
                {
                    rtbTreeDescription.Text = m_strNewDescriptionMessage;
                    rtbTreeDescription.SelectAll();
                }
            }
            setIsDirty(false);
            // also allocate the temporary/work RichTextBox
            rtbTemp = new RichTextBox();
            // set position on screen
            m_RectNormal = DesktopBounds;
        }