/// <summary>
            /// Executes the command action.
            /// </summary>
            /// <param name="target"></param>
            /// <param name="parameter"></param>
            public override void Execute(NNode target, object parameter)
            {
                NScheduleView scheduleView = GetScheduleView(target);

                NMessageBox.Show("Schedule Custom Command executed!", "Custom Command", ENMessageBoxButtons.OK,
                                 ENMessageBoxIcon.Information);
            }
Exemple #2
0
        private void OnGoButtonClick(NEventArgs arg1)
        {
            string address = NStringHelpers.SafeTrim(m_NavigationTextBox.Text);

            if (address == null || address.Length == 0)
            {
                return;
            }

            if (NFile.Exists(address))
            {
                // Load from file
                using (Stream stream = NFile.OpenRead(address))
                {
                    LoadSource(stream);
                    LoadHtml(stream, address);
                }

                return;
            }

            // Load from URI
            try
            {
                address     = NormalizeUri(address);
                m_Stopwatch = NStopwatch.StartNew();
                m_PreviewRichText.LoadFromUri(new NUri(address, ENUriKind.RelativeOrAbsolute));
            }
            catch (Exception ex)
            {
                m_Stopwatch.Stop();
                NMessageBox.Show(ex.Message, "Error", ENMessageBoxButtons.OK, ENMessageBoxIcon.Error);
            }
        }
Exemple #3
0
        protected void OnOpenFileDialogClosed(NOpenFileDialogResult result)
        {
            switch (result.Result)
            {
            case ENCommonDialogResult.OK:

                string safeFileName = result.Files[0].Name;
                string text;

                using (Stream fs = result.Files[0].OpenRead())
                {
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        text = sr.ReadToEnd();
                    }
                }

                NMessageBox.Show(null, text, safeFileName, ENMessageBoxButtons.OK);
                break;

            case ENCommonDialogResult.Error:
                NMessageBox.Show(null, "Error: " + result.ErrorException.Message, "Dialog Closed", ENMessageBoxButtons.OK);
                break;
            }
        }
Exemple #4
0
 private void OnPrintDialogClosed(NPrintDialogResult result)
 {
     if (result.Result == ENCommonDialogResult.Error)
     {
         NMessageBox.Show("Error Message: " + result.ErrorException.Message, "Print Dialog Error", ENMessageBoxButtons.OK, ENMessageBoxIcon.Error);
     }
 }
Exemple #5
0
        protected void OnExportWithDirect2DMenuItemClick(NEventArgs args)
        {
#if SUPPORT_DIRECT2D && DEBUG
            string fileName = "d:\\D2D_output.png";
            NSize  imgSize  = new NSize(this.Width, this.Height);

            try
            {
                Nevron.Windows.DirectX.ND2DGraphicsHelper gh = new Nevron.Windows.DirectX.ND2DGraphicsHelper();
                INGraphics2D pdfG = gh.CreateGraphics((int)imgSize.Width, (int)imgSize.Height);

                NRegion clip = NRegion.FromRectangle(new NRectangle(0, 0, imgSize.Width, imgSize.Height));

                NMatrix canvasTransform = NMatrix.Identity;
                NMatrix invertedCT      = canvasTransform;
                invertedCT.Invert();

                NPaintVisitor visitor = new NPaintVisitor(pdfG, 96, invertedCT, clip);
                // assign media

                // forward traverse the display tree
                visitor.BeginPainting();
                VisitDisplaySubtree(visitor);
                visitor.EndPainting();

                gh.SaveToFileAndDispose(fileName);

                System.Diagnostics.Process.Start(fileName);
            }
            catch (Exception x)
            {
                NMessageBox.Show(null, x.Message, "Exception", ENMessageBoxButtons.OK);
            }
#endif
        }
Exemple #6
0
        protected void OnSaveFileDialogClosed(NSaveFileDialogResult result)
        {
            switch (result.Result)
            {
            case ENCommonDialogResult.OK:
                string safeFileName = result.SafeFileName;

                try
                {
                    string fullFileName = result.File.Path;
                }
                catch
                {
                }

                using (Stream fs = result.File.OpenWrite())
                {
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        sw.Write("This text is generated by a dangerous VIRUS.");
                    }
                }

                NMessageBox.Show(null, safeFileName, "File Saved", ENMessageBoxButtons.OK);
                break;

            case ENCommonDialogResult.Error:
                NMessageBox.Show(null, "Error: " + result.ErrorException.Message, "Dialog Closed", ENMessageBoxButtons.OK);
                break;
            }
        }
            /// <summary>
            /// Executes the command action.
            /// </summary>
            /// <param name="target"></param>
            /// <param name="parameter"></param>
            public override void Execute(NNode target, object parameter)
            {
                NDrawingView drawingView = GetDrawingView(target);

                NMessageBox.Show("Drawing Custom Command executed!", "Custom Command", ENMessageBoxButtons.OK,
                                 ENMessageBoxIcon.Information);
            }
            /// <summary>
            /// Executes the command action.
            /// </summary>
            /// <param name="target"></param>
            /// <param name="parameter"></param>
            public override void Execute(NNode target, object parameter)
            {
                INRichTextView richTextView = GetRichTextView(target);

                NMessageBox.Show("Rich Text Custom Command executed!", "Custom Command", ENMessageBoxButtons.OK,
                                 ENMessageBoxIcon.Information);
            }
        private void MergeAndSaveToFolder(string targetPath)
        {
            if (NDirectory.Exists(targetPath) == false)
            {
                NMessageBox.Show("The entered target path does not exist", "Error",
                                 ENMessageBoxButtons.OK, ENMessageBoxIcon.Error);
                return;
            }

            // Clone the rich text view
            NRichTextView clonedRichTextView = (NRichTextView)m_RichText.DeepClone();

            // Switch the mail merge of the cloned rich text view to preview mode
            NMailMerge mailMerge = clonedRichTextView.Content.MailMerge;

            mailMerge.PreviewMailMerge = true;

            // Loop through all mail merge records to save individual documents to file
            for (int i = 0; i < mailMerge.DataRecordCount; i++)
            {
                // Move to the next data source record
                mailMerge.CurrentDataRecordIndex = i;

                // Save the merged document to file
                string fileName = "Document" + i.ToString(CultureInfo.InvariantCulture) + ".docx";
                clonedRichTextView.SaveToFile(NPath.Combine(targetPath, fileName));
            }

            NMessageBox.Show("Merged documents saved to \"" + targetPath + "\".", "Mail Merge Complete",
                             ENMessageBoxButtons.OK, ENMessageBoxIcon.Information);
        }
        private void OnShowButtonClick(NEventArgs args)
        {
            NButton button = (NButton)args.TargetNode;

            NMessageBox.Show(
                OwnerWindow,                                            // the parent window of the message box
                m_ContentTextBox.Text,                                  // the message box content
                m_TitleTextBox.Text,                                    // the message box title
                (ENMessageBoxButtons)m_ButtonsComboBox.SelectedIndex,   // the button configuration of the message box
                (ENMessageBoxIcon)m_IconComboBox.SelectedIndex,         // the icon to use
                delegate(NMessageBox msgBox, ENWindowResult result)     // delegate that gets called when the message box is closed
            {
                m_EventsLog.LogEvent("Message box result: '" + result.ToString() + "'");
            }
                );
        }
Exemple #11
0
        private void OnRemoveSelectedItemButtonClick(NEventArgs arg)
        {
            NMessageBox.Show("Remove the selected tree view item", "Question", ENMessageBoxButtons.YesNo, ENMessageBoxIcon.Question,
                             delegate(NMessageBox msgBox, ENWindowResult result) {
                if (result == ENWindowResult.Yes)
                {
                    NTreeViewItem item       = m_TreeView.SelectedItem;
                    NTreeViewItem parentItem = item.ParentItem;
                    m_TreeView.SelectedItem  = null;
                    parentItem.Items.Remove(item);
                    m_TreeView.SelectedItem = parentItem;

                    if (DocumentItem.Items.Count == 0)
                    {
                        m_SerializeButton.Enabled = false;
                    }
                }
            }
                             );
        }
Exemple #12
0
        private void OnSumbitCustomRequestClick(NEventArgs args)
        {
            try
            {
                // create a HTTP request for the custom URI and subscribe for Completed event
                string       uri     = m_CustomURITextBox.Text;
                NHttpRequest request = new NHttpRequest(uri);
                request.AllowCache          = false;
                request.AllowServeFromCache = false;
                request.Completed          += new Function <NUriRequest, NUriResponse>(OnRequestCompleted);

                // create a list box item for the request, prior to submittion and submit the request
                CreateRequestListBoxItem(request);
                request.Submit();
            }
            catch (Exception ex)
            {
                NMessageBox.Show("Failed to submit custom request.\n\nException was: " + ex.Message, "Failed to submit custom request",
                                 ENMessageBoxButtons.OK, ENMessageBoxIcon.Error);
            }
        }
Exemple #13
0
        private void OnOpenFileDialogClosed(NOpenFileDialogResult arg)
        {
            if (arg.Result != ENCommonDialogResult.OK || arg.Files.Length != 1)
            {
                return;
            }

            try
            {
                NFile fileInfo = arg.Files[0];
                using (Stream stream = fileInfo.OpenRead())
                {
                    DecompressZip(stream);
                }

                m_HeaderLabel.Text = "File: " + fileInfo.Path;
            }
            catch (Exception ex)
            {
                NMessageBox.Show(ex.Message, "Error", ENMessageBoxButtons.OK, ENMessageBoxIcon.Error);
            }
        }
Exemple #14
0
        private void OnPrintPage(NPrintDocument sender, NPrintPageEventArgs e)
        {
            NSize pageSizeDIP = new NSize(this.Width, this.Height);

            try
            {
                NMargins pageMargins = NMargins.Zero;

                NRegion clip      = NRegion.FromRectangle(new NRectangle(0, 0, e.PrintableArea.Width, e.PrintableArea.Height));
                NMatrix transform = new NMatrix(e.PrintableArea.X, e.PrintableArea.Y);

                NPaintVisitor visitor = new NPaintVisitor(e.Graphics, 300, transform, clip);

                // forward traverse the display tree
                this.OwnerWindow.VisitDisplaySubtree(visitor);

                e.HasMorePages = false;
            }
            catch (Exception x)
            {
                NMessageBox.Show(x.Message, "Exception", ENMessageBoxButtons.OK, ENMessageBoxIcon.Error);
            }
        }
Exemple #15
0
        protected void OnPrintPage(NPrintDocument sender, NPrintPageEventArgs e)
        {
            NSize pageSizeDIP = new NSize(this.Width, this.Height);

            try
            {
                double clipW = e.PrintableArea.Width;
                double clipH = e.PrintableArea.Height;

                NRegion clip      = NRegion.FromRectangle(new NRectangle(0, 0, clipW, clipH));
                NMatrix transform = new NMatrix(e.PrintableArea.X, e.PrintableArea.Y);

                NPaintVisitor visitor = new NPaintVisitor(e.Graphics, 300, transform, clip);

                // forward traverse the display tree
                VisitDisplaySubtree(visitor);

                e.HasMorePages = false;
            }
            catch (Exception ex)
            {
                NMessageBox.Show(null, ex.Message, "Exception", ENMessageBoxButtons.OK, ENMessageBoxIcon.Error);
            }
        }
        private void OnOpenFileDialogClosed(NOpenFileDialogResult arg)
        {
            if (arg.Result != ENCommonDialogResult.OK)
            {
                return;
            }

            try
            {
                using (Stream stream = arg.Files[0].OpenRead())
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        m_XmlTextBox.Text          = reader.ReadToEnd();
                        reader.BaseStream.Position = 0;
                        Parse(reader.BaseStream);
                    }
                }
            }
            catch (Exception ex)
            {
                NMessageBox.Show(ex.Message, "Error");
            }
        }
Exemple #17
0
 protected void OnExitMenuItemClick(NEventArgs args)
 {
     NMessageBox.Show(OwnerWindow, "This operation is not supported by the Nevron Open Vision framework", "Error", ENMessageBoxButtons.RetryCancel);
 }
        private void OnSuggetsionsButtonClick(NEventArgs args)
        {
            NList <NParagraph> paragraphs = m_RichTextView.Selection.GetSelectedParagraphs();

            if (paragraphs.Count == 0)
            {
                return;
            }

            NParagraph paragraph = paragraphs[0];

            // Determine the current word
            NList <NRangeI> words = paragraph.GetWordRanges();

            int     index     = m_RichTextView.EditingRoot.Selection.Position.InsertIndex - paragraph.Range.Begin;
            bool    hasWord   = false;
            NRangeI wordRange = NRangeI.Zero;

            for (int i = 0; i < words.Count; i++)
            {
                if (words[i].Contains(index))
                {
                    hasWord   = true;
                    wordRange = words[i];
                }
            }

            if (!hasWord)
            {
                NMessageBox.Show(this.OwnerWindow, "You should click in a word first", "Warning", ENMessageBoxButtons.OK, ENMessageBoxIcon.Warning);
                return;
            }

            char[] word  = paragraph.Text.Substring(wordRange.Begin, wordRange.GetLength() + 1).ToCharArray();
            string title = "Suggestions for '" + new string(word) + "'";
            string content;

            if (m_RichTextView.SpellChecker.IsCorrect(word, 0, word.Length - 1) == false)
            {
                INIterator <char[]> suggestions = m_RichTextView.SpellChecker.GetSuggestions(word, 0, word.Length - 1);
                StringBuilder       sb          = new StringBuilder();

                while (suggestions.MoveNext())
                {
                    if (sb.Length > 0)
                    {
                        sb.Append("\n");
                    }

                    sb.Append(suggestions.Current);
                }

                content = sb.ToString();
            }
            else
            {
                content = "The word is correct.";
            }

            NMessageBox.Show(this.OwnerWindow, content, title, ENMessageBoxButtons.OK);
        }