Esempio n. 1
0
        private void OpenFileCmd(string fileName)
        {
            if (String.IsNullOrEmpty(fileName) || !File.Exists(fileName))
            {
                return;
            }

            curDoc = AppBase.LoadFile(fileName);
            if (curDoc == null)
            {
                MessageBox.Show("Failed to load seleted file, check file format.");
            }
            else
            {
                rTBDoc.Clear();
                rTBDoc.Text = curDoc.content;
                if (!String.IsNullOrEmpty(curDoc.intent))
                {
                    cbIntent.Text = curDoc.intent;
                }
                if (!String.IsNullOrEmpty(curDoc.type))
                {
                    cBType.Text = curDoc.type;
                }
                lbMessage.Text = String.Format("Message:\n Tilte:{0}\n Author:{1}\n URL:{2}\n ID:{3}", curDoc.title, curDoc.author, curDoc.url, curDoc.id);
                RefreshRichTextBox(-1, -1);
                curDocFileName = Path.GetFileNameWithoutExtension(fileName);
                if (curDocFileName.EndsWith(".xml"))
                {
                    curDocFileName = curDocFileName.Substring(0, curDocFileName.Length - 4);
                }
            }
        }
Esempio n. 2
0
        private void tSbtOpen_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog ofDlg = new OpenFileDialog())
            {
                ofDlg.DefaultExt  = ".xml";
                ofDlg.Filter      = "XML File|*.xml|Work State File|*.ws|All File|*.*";
                ofDlg.Multiselect = false;

                if (ofDlg.ShowDialog() == DialogResult.OK)
                {
                    curDoc = AppBase.LoadFile(ofDlg.FileName);
                    if (curDoc == null)
                    {
                        MessageBox.Show("Failed to load seleted file, check file format.");
                    }
                    else
                    {
                        rTBDoc.Clear();
                        rTBDoc.Text = curDoc.content;
                        if (!String.IsNullOrEmpty(curDoc.intent))
                        {
                            cbIntent.Text = curDoc.intent;
                        }
                        if (!String.IsNullOrEmpty(curDoc.type))
                        {
                            cBType.Text = curDoc.type;
                        }
                        lbMessage.Text = String.Format("Message:\n Tilte:{0}\n Author:{1}\n URL:{2}\n ID:{3}", curDoc.title, curDoc.author, curDoc.url, curDoc.id);
                        RefreshRichTextBox(-1, -1);
                        curDocFileName = Path.GetFileNameWithoutExtension(ofDlg.FileName);
                        if (curDocFileName.EndsWith(".xml"))
                        {
                            curDocFileName = curDocFileName.Substring(0, curDocFileName.Length - 4);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        private void tSbtSave_Click(object sender, EventArgs e)
        {
            curDoc.type   = cBType.Text;
            curDoc.intent = cbIntent.Text;

            using (SaveFileDialog sfDlg = new SaveFileDialog())
            {
                sfDlg.FileName   = curDocFileName + "_result";
                sfDlg.DefaultExt = "*.xml";
                sfDlg.Filter     = "XML File|*.xml|All File|*.*";

                if (sfDlg.ShowDialog() == DialogResult.OK)
                {
                    if (AppBase.SaveFile(sfDlg.FileName, curDoc))
                    {
                        MessageBox.Show("Save successful", "Save file", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Save failed", "Save file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }