/// <summary>
        /// a slice filter is used to hide some slices.
        /// </summary>
        /// <remarks> this will set up a filter even if you do not specify a filter path, since
        /// some filtering is done by the FDO classes (CmObject.IsFieldRelevant)
        /// </remarks>
        /// <example>
        ///		to set up a slice filter,kids the relative path in the filterPath attribute of the parameters:
        ///		<control assemblyPath="xWorks.dll" class="SIL.FieldWorks.XWorks.RecordEditView">
        ///			<parameters field="Entries" templatePath="LexEd\XDEs" filterPath="LexEd\basicFilter.xml">
        ///			...
        ///</example>
        private void SetupSliceFilter()
        {
            try
            {
                string filterPath = XmlUtils.GetOptionalAttributeValue(m_configurationParameters, "filterPath");
                if (filterPath != null)
                {
#if __MonoCS__
                    // TODO-Linux: fix the data
                    filterPath = filterPath.Replace(@"\", "/");
#endif
                    var document = new XmlDocument();
                    document.Load(DirectoryFinder.GetFWCodeFile(filterPath));
                    m_dataEntryForm.SliceFilter = new SliceFilter(document);
                }
                else                 //just set up a minimal filter
                {
                    m_dataEntryForm.SliceFilter = new SliceFilter();
                }
            }
            catch (Exception e)
            {
                throw new ConfigurationException("Could not load the filter.", m_configurationParameters, e);
            }
        }
示例#2
0
        private static void EnsureWindowConfiguration(Mediator mediator)
        {
            XmlNode xnWindow = (XmlNode)mediator.PropertyTable.GetValue("WindowConfiguration");

            if (xnWindow == null)
            {
                string configFile = DirectoryFinder.GetFWCodeFile("Language Explorer\\Configuration\\Main.xml");
                // This can be called from TE...in that case, we don't complain about missing include
                // files (true argument) but just trust that we put enough in the installer to make it work.
                XmlDocument configuration           = XmlUtils.LoadConfigurationWithIncludes(configFile, true);
                XmlNode     windowConfigurationNode = configuration.SelectSingleNode("window");
                mediator.PropertyTable.SetProperty("WindowConfiguration", windowConfigurationNode);
                mediator.PropertyTable.SetPropertyPersistence("WindowConfiguration", false);
            }
        }
示例#3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of the main X window
        /// </summary>
        /// <param name="progressDlg">The progress dialog to use, if needed (can be null).</param>
        /// <param name="isNewCache">Flag indicating whether one-time, application-specific
        /// initialization should be done for this cache.</param>
        /// <param name="wndCopyFrom">Must be null for creating the original app window.
        /// Otherwise, a reference to the main window whose settings we are copying.</param>
        /// <param name="fOpeningNewProject"><c>true</c> if opening a brand spankin' new
        /// project</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public override Form NewMainAppWnd(IProgress progressDlg, bool isNewCache,
                                           Form wndCopyFrom, bool fOpeningNewProject)
        {
            if (isNewCache)
            {
                // TODO: Do any needed initialization here.
            }
            Stream iconStream = ApplicationIconStream;

            Debug.Assert(iconStream != null, "Couldn't find the specified application icon as a resource.");
            string configFile;

            if (m_appArgs.ConfigFile != string.Empty)
            {
                configFile = m_appArgs.ConfigFile;
            }
            else
            {
                configFile = DirectoryFinder.GetFWCodeFile(DefaultConfigurationPathname);
                //					configFile = (string)SettingsKey.GetValue("LatestConfigurationFile",
                //						Path.Combine(DirectoryFinder.FWCodeDirectory,
                //						DefaultConfigurationPathname));
                if (!File.Exists(configFile))
                {
                    configFile = null;
                }
            }
            if (configFile == null)             // try to load from stream
            {
                return(new FwXWindow(this, wndCopyFrom, iconStream, ConfigurationStream));
            }

            // We pass a copy of the link information because it doesn't get used until after the following line
            // removes the information we need.
            FwXWindow result = new FwXWindow(this, wndCopyFrom, iconStream, configFile,
                                             m_appArgs.HasLinkInformation ? m_appArgs.CopyLinkArgs() : null, false);

            m_appArgs.ClearLinkInformation();             // Make sure the next window that is opened doesn't default to the same place
            return(result);
        }
示例#4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of the main X window
        /// </summary>
        ///
        /// <param name="cache">Instance of the FW Data Objects cache that the new main window
        /// will use for accessing the database.</param>
        /// <param name="isNewCache">Flag indicating whether one-time, application-specific
        /// initialization should be done for this cache.</param>
        /// <param name="wndCopyFrom"> Must be null for creating the original app window.
        /// Otherwise, a reference to the main window whose settings we are copying.</param>
        /// <param name="fOpeningNewProject"><c>true</c> if opening a brand spankin' new
        /// project</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        protected override Form NewMainAppWnd(FdoCache cache, bool isNewCache, Form wndCopyFrom,
                                              bool fOpeningNewProject)
        {
            // Review: I put in this exception catching block because
            // the exception handler is not been invoked...until we figure out why
            // not, this is better than just having the raw exception in the users face.
            try
            {
                if (isNewCache)
                {
                    // TODO: Do any needed initialization here.
                }
                Stream iconStream = ApplicationIconStream;
                Debug.Assert(iconStream != null, "Couldn't find the specified application icon as a resource.");
                string configFile;
                if (m_commandLineArgs.ContainsKey("x"))
                {
                    configFile = m_commandLineArgs["x"][0];
                }
                else
                {
                    configFile = DirectoryFinder.GetFWCodeFile(DefaultConfigurationPathname);
                    //					configFile = (string)SettingsKey.GetValue("LatestConfigurationFile",
                    //						Path.Combine(DirectoryFinder.FWCodeDirectory,
                    //						DefaultConfigurationPathname));
                    if (!File.Exists(configFile))
                    {
                        configFile = null;
                    }
                }
                FwXWindow result;
                if (configFile != null)
                {
                    result = new FwXWindow(cache, wndCopyFrom, iconStream, configFile, false);
                }
                else
                {
                    // try to load from stream
                    return(new FwXWindow(cache, wndCopyFrom, iconStream, ConfigurationStream));
                }
                if (isNewCache)
                {
                    // Must be done after reading properties from init table.
                    if (result.PropertyTable.GetBoolProperty("SendSync", false) && SyncGuid != Guid.Empty)
                    {
                        cache.MakeDbSyncRecords(SyncGuid);
                    }
                }

                if (m_commandLineArgs.ContainsKey("link"))
                {
                    result.StartupAtURL(m_commandLineArgs["link"][0]);
                }

                return(result);
            }
            catch (Exception error)
            {
                HandleTopLevelError(this, new System.Threading.ThreadExceptionEventArgs(error));
                return(null);
            }
        }