Пример #1
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;
            }
        }
Пример #2
0
        private void OnMultiselectOpenFileDialogClosed(NOpenFileDialogResult result)
        {
            switch (result.Result)
            {
            case ENCommonDialogResult.OK:
                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < result.Files.Length; i++)
                {
                    sb.AppendLine(result.Files[i].Name);
                }

                m_TextBox.Text = sb.ToString();

                m_EventsLog.LogEvent("Multiple files selected");
                break;

            case ENCommonDialogResult.Cancel:
                m_EventsLog.LogEvent("File not selected");
                break;

            case ENCommonDialogResult.Error:
                m_EventsLog.LogEvent("Error message: " + result.ErrorException.Message);
                break;
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
        private void OnOpenFileDialogClosed(NOpenFileDialogResult result)
        {
            switch (result.Result)
            {
            case ENCommonDialogResult.OK:
                string fileName = result.Files[0].Name;
                using (StreamReader reader = new StreamReader(result.Files[0].OpenRead()))
                {
                    m_TextBox.Text = reader.ReadToEnd();
                }

                m_EventsLog.LogEvent("File opened: " + fileName);
                break;

            case ENCommonDialogResult.Cancel:
                m_EventsLog.LogEvent("File not selected");
                break;

            case ENCommonDialogResult.Error:
                m_EventsLog.LogEvent("Error message: " + result.ErrorException.Message);
                break;
            }
        }
Пример #5
0
        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");
            }
        }