Пример #1
0
        public void Invoke(Object[] invokeArgs)
        {
            if (invokeArgs.Length > 0)
            {
                String xmlStr = invokeArgs[0] as String;

                if (xmlStr != null)
                {
                    XmlSaveOpener.OpenXmlByExployer(xmlStr, m_XmlViewerDef.ViewApp);
                }
            }
        }
Пример #2
0
        public Boolean CanInvoke(Object[] invokeArgs)
        {
            Boolean bCanInvoke = false;

            if (invokeArgs.Length > 0)
            {
                String xmlStr = invokeArgs[0] as String;

                if (xmlStr != null)
                {
                    bCanInvoke = XmlSaveOpener.IsXmlString(xmlStr);
                }
            }

            return(bCanInvoke);
        }
Пример #3
0
        public void Invoke(Object[] invokeArgs)
        {
            if (invokeArgs.Length > 0)
            {
                String xmlStr = invokeArgs[0] as String;

                if (xmlStr != null)
                {
                    StringBuilder xmlFileNameStrB  = new StringBuilder();
                    String        xmlFileName      = String.Empty;
                    Boolean       bXmlFileName     = false;
                    Boolean       bSaveDirectory   = false;
                    Boolean       bDupFileName     = true;
                    String        savedXmlFileName = String.Empty; // The file name of saved xml file.

                    if (!String.IsNullOrEmpty(m_XmlSaverDef.SaveDirectory))
                    {
                        bSaveDirectory = Directory.Exists(m_XmlSaverDef.SaveDirectory);
                    }

                    for (Int32 i = 1; i < invokeArgs.Length; ++i)
                    {
                        xmlFileNameStrB.Append(invokeArgs[i].ToString()).Append('_');
                    }
                    if (xmlFileNameStrB.Length > 0)
                    {
                        xmlFileNameStrB.Remove(xmlFileNameStrB.Length - 1, 1);
                        xmlFileNameStrB.Append(".xml");
                        xmlFileName = xmlFileNameStrB.ToString();

                        if (xmlFileName.IndexOfAny(XmlSaveOpener.GetNonFileNameChars()) < 0)
                        {
                            bXmlFileName = true;
                        }

                        if (bSaveDirectory && bXmlFileName)
                        {
                            bDupFileName = File.Exists(Path.Combine(m_XmlSaverDef.SaveDirectory, xmlFileName));
                        }
                    }

                    if (!bSaveDirectory || !bXmlFileName || bDupFileName)
                    {
                        SaveFileDialog saveFileDlg = new SaveFileDialog();

                        saveFileDlg.DefaultExt = "xml";
                        saveFileDlg.Filter     = "Xml files (*.xml)|*.xml|All files (*.*)|*.*";
                        if (bSaveDirectory)
                        {
                            saveFileDlg.InitialDirectory = m_XmlSaverDef.SaveDirectory;
                        }
                        if (bXmlFileName)
                        {
                            saveFileDlg.FileName = xmlFileName;
                        }

                        if (saveFileDlg.ShowDialog() == DialogResult.OK)
                        {
                            savedXmlFileName = XmlSaveOpener.SaveXmlToFile(xmlStr, saveFileDlg.FileName);
                        }
                    }
                    else
                    {
                        savedXmlFileName = XmlSaveOpener.SaveXmlToFile(xmlStr, Path.Combine(m_XmlSaverDef.SaveDirectory, xmlFileName));
                    }

                    if (!String.IsNullOrEmpty(savedXmlFileName))
                    {
                        DialogResult dlgRet = DialogResult.None;

                        dlgRet = MessageBox.Show("Do you want to open located folder?", "Information", MessageBoxButtons.YesNo);
                        if (dlgRet == DialogResult.Yes)
                        {
                            this.OpenDestDirAndSelectFile(savedXmlFileName);
                        }
                    }
                }
            }
        }