This class describes the header of the XML configured script options form.
Наследование: ObservableObject
		/// <summary>
		/// Gets the editor to use to edit <see cref="HeaderInfo"/>.
		/// </summary>
		/// <param name="p_hdrHeader">The header to edit.</param>
		/// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
		/// being edited belongs.</param>
		/// <returns>The editor to use to edit <see cref="HeaderInfo"/>. <c>null</c> is returned if the
		/// current <see cref="XmlScript"/> does not support editing the <see cref="HeaderInfo"/>.</returns>
		public override NodeEditor GetHeaderEditor(HeaderInfo p_hdrHeader, IList<VirtualFileSystemItem> p_lstModFiles)
		{
			HeaderEditorVM vmlHeaderEditor = new HeaderEditorVM(p_hdrHeader, p_lstModFiles, HeaderProperties.Title | HeaderProperties.TextColour | HeaderProperties.TextPosition | HeaderProperties.Image | HeaderProperties.Height);
			return new HeaderEditor(vmlHeaderEditor);
		}
		/// <summary>
		/// Gets the editor to use to edit <see cref="HeaderInfo"/>.
		/// </summary>
		/// <param name="p_hdrHeader">The header to edit.</param>
		/// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/>
		/// being edited belongs.</param>
		/// <returns>The editor to use to edit <see cref="HeaderInfo"/>. <c>null</c> is returned if the
		/// current <see cref="XmlScript"/> does not support editing the <see cref="HeaderInfo"/>.</returns>
		public virtual NodeEditor GetHeaderEditor(HeaderInfo p_hdrHeader, IList<VirtualFileSystemItem> p_lstModFiles)
		{
			HeaderEditorVM vmlHeaderEditor = new HeaderEditorVM(p_hdrHeader, p_lstModFiles, HeaderProperties.Title);
			return new HeaderEditor(vmlHeaderEditor);
		}
Пример #3
0
        /// <summary>
        /// Executes the script.
        /// </summary>
        /// <param name="p_scpScript">The XMl Script to execute.</param>
        /// <returns><c>true</c> if the script completes successfully;
        /// <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentException">Thrown if <paramref name="p_scpScript"/> is not an
        /// <see cref="XmlScript"/>.</exception>
        public override bool DoExecute(IScript p_scpScript)
        {
            if (!(p_scpScript is XmlScript))
            {
                throw new ArgumentException("The given script must be of type XmlScript.", "p_scpScript");
            }

            XmlScript xscScript = (XmlScript)p_scpScript;

            ConditionStateManager csmStateManager = ((XmlScriptType)xscScript.Type).CreateConditionStateManager(Mod, GameMode, Installers.PluginManager, EnvironmentInfo);

            if ((xscScript.ModPrerequisites != null) && !xscScript.ModPrerequisites.GetIsFulfilled(csmStateManager))
            {
                throw new DependencyException(xscScript.ModPrerequisites.GetMessage(csmStateManager));
            }

            IList <InstallStep> lstSteps      = xscScript.InstallSteps;
            HeaderInfo          hifHeaderInfo = xscScript.HeaderInfo;

            if (String.IsNullOrEmpty(hifHeaderInfo.ImagePath))
            {
                hifHeaderInfo.ImagePath = Mod.ScreenshotPath;
            }
            if ((hifHeaderInfo.Height < 0) && hifHeaderInfo.ShowImage)
            {
                hifHeaderInfo.Height = 75;
            }
            OptionsForm ofmOptions = null;

            if (m_scxSyncContext == null)
            {
                ofmOptions = new OptionsForm(xscScript, hifHeaderInfo, csmStateManager, lstSteps);
            }
            else
            {
                m_scxSyncContext.Send(x => ofmOptions = new OptionsForm(xscScript, hifHeaderInfo, csmStateManager, lstSteps), null);
            }
            ofmOptions.Name = "OptionForm";
            bool booPerformInstall = false;

            if (lstSteps.Count == 0)
            {
                booPerformInstall = true;
            }
            else
            {
                if (m_scxSyncContext == null)
                {
                    booPerformInstall = (ofmOptions.ShowDialog() == DialogResult.OK);
                }
                else
                {
                    m_scxSyncContext.Send(x => booPerformInstall = (ofmOptions.ShowDialog() == DialogResult.OK), null);
                }
            }

            if (booPerformInstall)
            {
                XmlScriptInstaller xsiInstaller = new XmlScriptInstaller(Mod, GameMode, Installers);
                OnTaskStarted(xsiInstaller);
                return(xsiInstaller.Install(hifHeaderInfo.Title, xscScript, csmStateManager, ofmOptions.FilesToInstall, ofmOptions.PluginsToActivate));
            }
            return(false);
        }