Exemplo n.º 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);
        }
Exemplo n.º 2
0
        private void LoadExample(NXmlElement element)
        {
            string groupNamespace = NExamplesHomePage.GetNamespace(element);
            string name           = element.GetAttributeValue("name");
            string type           = groupNamespace + "." + element.GetAttributeValue("type");

            try
            {
                type = "Nevron.Nov.Examples." + type;
                Type exampleType = Type.GetType(type);
                if (exampleType != null)
                {
                    NDomType domType = NDomType.FromType(exampleType);
                    NDebug.Assert(domType != null, "The example type:" + type + " is not a valid type");

                    // Create the example
                    DateTime     start   = DateTime.Now;
                    NExampleBase example = domType.CreateInstance() as NExampleBase;
                    example.Title = name;
                    example.Initialize();
                    m_Splitter.Pane2.Content = example;

                    string stats = "Example created in: " + (DateTime.Now - start).TotalSeconds + " seconds, ";

                    // Evaluate the example
                    start = DateTime.Now;
                    OwnerDocument.Evaluate();
                    stats += " evaluated in: " + (DateTime.Now - start).TotalSeconds + " seconds";

                    m_StatusLabel.Text = stats;
                }

                // Set the breadcrumb
                CreateBreadcrumb(element);
            }
            catch (Exception ex)
            {
                NTrace.WriteException("Failed to load example", ex);
                m_Splitter.Pane2.Content = new NErrorPanel("Failed to load example. Exception was: " + ex.Message);
            }
        }
Exemplo n.º 3
0
        static void Main()
        {
            try
            {
                // install Nevron Open Vision for WPF
                NNovApplicationInstaller.Install(
                    NTextModule.Instance,
                    NChartModule.Instance,
                    NDiagramModule.Instance,
                    NScheduleModule.Instance,
                    NGridModule.Instance,
                    NBarcodeModule.Instance);

                // show the main window
                Window window = new Window();
                window.Title       = "Nevron Open Vision Examples for WPF";
                window.WindowState = WindowState.Maximized;

                // load icon from stream
                using (Stream stream = typeof(Program).Assembly.GetManifestResourceStream("Nevron.Nov.Examples.Wpf.Resources.NevronOpenVision.ico"))
                {
                    // Decode the icon from the stream and set the first frame to the BitmapSource
                    BitmapDecoder decoder = IconBitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.None);
                    BitmapSource  source  = decoder.Frames[1];

                    // set image source
                    window.Icon = source;
                }

                // place a NOV UI Element that contains an NExampleContent widget
                window.Content = new NNovWidgetHost <NExamplesContent>();

                // show the window
                Application app = new Application();
                app.Run(window);
            }
            catch (Exception ex)
            {
                NTrace.WriteException("Exception in Main", ex);
            }
        }
Exemplo n.º 4
0
        private void OnShowDesignerClick(NEventArgs args)
        {
            try
            {
                NNode         node         = (NNode)args.TargetNode.Tag;
                NEditorWindow editorWindow = NEditorWindow.CreateForInstance(
                    node,
                    null,
                    OwnerWindow,
                    null);

                if (node is NStyleNodeCollectionTree)
                {
                    editorWindow.PreferredSize = new NSize(500, 360);
                }

                editorWindow.Open();
            }
            catch (Exception ex)
            {
                NTrace.WriteException("OnShowDesignerClick failed.", ex);
            }
        }
Exemplo n.º 5
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // install Nevron Open Vision for Windows Forms
                NNovApplicationInstaller.Install(
                    NTextModule.Instance,
                    NChartModule.Instance,
                    NDiagramModule.Instance,
                    NScheduleModule.Instance,
                    NGridModule.Instance,
                    NBarcodeModule.Instance);

                // show the main form
                bool startWithNovWindow = false;
                if (startWithNovWindow)
                {
                    // create a NOV top level window
                    NTopLevelWindow window = NApplication.CreateTopLevelWindow();
                    window.BackgroundFill = new NColorFill(NColor.White);
                    window.Content        = new NExamplesContent();
                    window.Closed        += OnWindowClosed;
                    window.Title          = "Nevron Open Vision Examples for Windows Forms";
                    window.AllowXResize   = true;
                    window.AllowYResize   = true;
                    window.ShowInTaskbar  = true;
                    window.Modal          = true;
                    window.PreferredSize  = new NSize(500, 500);
                    window.StartPosition  = ENWindowStartPosition.CenterScreen;
                    window.Open();

                    // run the application
                    ApplicationContext context = new ApplicationContext();
                    Application.Run(context);
                }
                else
                {
                    // create a WinForms form
                    Form form = new Form();

                    // set form icon
                    using (Stream stream = typeof(Program).Assembly.GetManifestResourceStream("Nevron.Nov.Examples.WinForm.Resources.NevronOpenVision.ico"))
                    {
                        Icon icon = new Icon(stream);
                        form.Icon = icon;
                    }

                    // set form title and state
                    form.Text        = "Nevron Open Vision Examples for Windows Forms";
                    form.WindowState = FormWindowState.Maximized;

                    // place a NOV WinForms Control that contains an NExampleContent widget
                    NNovWidgetHost <NExamplesContent> host = new NNovWidgetHost <NExamplesContent>();
                    host.Dock = DockStyle.Fill;
                    form.Controls.Add(host);

                    // run the form
                    Application.Run(form);
                }
            }
            catch (Exception ex)
            {
                NTrace.WriteException("Exception in Main", ex);
            }
        }