示例#1
0
        /// <summary>
        /// Gets a rich text box that show the syntax highlighted source code of the example.
        /// </summary>
        /// <returns></returns>
        protected virtual NWidget GetExampleSource()
        {
            NRichTextView richText = new NRichTextView();

            richText.HRuler.Visibility = ENVisibility.Collapsed;
            richText.VRuler.Visibility = ENVisibility.Collapsed;
            richText.ReadOnly          = true;

            try
            {
                // Decompress the source code of the example
                Type exampleType = Schema.DomType.Type;
                NSourceCodeDecompressor decompressor = new NSourceCodeDecompressor(exampleType);
                SourceCodeStream.Position = 0;
                NCompression.DecompressZip(SourceCodeStream, decompressor);

                // Highlight the decompressed source code
                NSyntaxHighlighter syntaxHighlighter = new NSyntaxHighlighter();

                MemoryStream decompressedStream = decompressor.GetSourceCodeStream();
                if (decompressedStream != null)
                {
                    Stream htmlStream = syntaxHighlighter.Highlight(decompressedStream);

                    // Load the colorized source code in the source code rich text view
                    richText.LoadFromStream(htmlStream, new NHtmlTextFormat());
                }
            }
            catch (Exception ex)
            {
                NTrace.WriteException("Failed to get example source.", ex);
            }

            return(richText);
        }
示例#2
0
        private void DecompressZip(Stream stream)
        {
            m_TreeView.SelectedItem = null;
            m_TreeView.Items.Clear();

            ZipDecompressor decompressor = new ZipDecompressor(m_TreeView);

            NCompression.DecompressZip(stream, decompressor);
        }
示例#3
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public NExamplesHomePage()
        {
            // Apply a Windows 8 theme
            Document.InheritStyleSheets = false;
            NUITheme theme = new NWindows8Theme();

            Document.StyleSheets.ApplyTheme(theme);
            m_ExamplesMap = null;

            // Add some custom styles
            Document.StyleSheets.Add(CreateCustomStyleSheet(theme));

            // Load the metafile images
            Stream emfStream = NResources.Instance.GetResourceStream("RBIN_HomePageEmfs_zip");

            m_EmfDecompressor = new NEmfDecompressor();
            NCompression.DecompressZip(emfStream, m_EmfDecompressor);

            // Create the main dock panel
            m_MainPanel = new NDockPanel();
            m_MainPanel.HorizontalSpacing   = GroupHorizontalSpacing;
            m_MainPanel.VerticalSpacing     = GroupVerticalSpacing;
            m_MainPanel.Padding             = new NMargins(GroupHorizontalSpacing, GroupVerticalSpacing);
            m_MainPanel.HorizontalPlacement = ENHorizontalPlacement.Center;
            m_MainPanel.VerticalPlacement   = ENVerticalPlacement.Center;

            // Create the contacts and the header labels
            m_MainPanel.Add(CreateSearchAndContacts(), ENDockArea.Top);
            m_HeaderLabel = CreateHeader();
            m_MainPanel.Add(m_HeaderLabel, ENDockArea.Top);

            // Create the page panel
            m_PagePanel = new NSingleVisiblePanel();
            m_PagePanel.Add(CreateWelcomePanel());
            m_MainPanel.Add(m_PagePanel, ENDockArea.Center);

            // Place the main panel in a scroll content
            NScrollContent scrollContent = new NScrollContent(m_MainPanel);

            scrollContent.WindowBackgroundFill = new NColorFill(BackgroundColor);
            scrollContent.NoScrollHAlign       = ENNoScrollHAlign.Center;
            scrollContent.NoScrollVAlign       = ENNoScrollVAlign.Center;
            scrollContent.HorizontalPlacement  = ENHorizontalPlacement.Fit;
            scrollContent.VerticalPlacement    = ENVerticalPlacement.Fit;
            scrollContent.Border          = null;
            scrollContent.BorderThickness = NMargins.Zero;

            // Place the scroll content in a document box surface to prevent theme style inheritance
            NDocumentBoxSurface surface = new NDocumentBoxSurface(scrollContent);

            surface.TextFill = new NColorFill(TextColor);
            Document.Content = surface;
        }