GetValue() public méthode

get the value of the best property (i.e. tries local first, then global).
public GetValue ( string name ) : object
name string
Résultat object
Exemple #1
0
 private void Init(LcmCache cache, Mediator mediator, XCore.PropertyTable propertyTable, ICmPossibilityList list, int ws, bool useAbbr, Form parent)
 {
     m_mediator      = mediator;
     m_propertyTable = propertyTable;
     if (parent == null)
     {
         if (m_propertyTable != null)
         {
             IApp app = m_propertyTable.GetValue <IApp>("App");
             if (app != null)
             {
                 parent = app.ActiveMainWindow;
             }
             if (parent == null)
             {
                 parent = m_propertyTable.GetValue <Form>("window");
             }
         }
         if (parent == null)
         {
             parent = Form.ActiveForm;                     // desperate for something...
         }
     }
     m_cache   = cache;
     m_useAbbr = useAbbr;
     m_parent  = parent;
     m_list    = list;
     m_ws      = ws;
 }
Exemple #2
0
        /// <summary>
        /// We have to set the checkbox here because the mediator (needed to get the App)
        /// is not set yet in the dialog's constructor.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            m_autoOpenCheckBox.Checked = AutoOpenLastProject;
            var appSettings = m_propertyTable.GetValue <FwApplicationSettingsBase>("AppSettings");

            m_okToPingCheckBox.Checked = appSettings.Reporting.OkToPingBasicUsageData;
        }
Exemple #3
0
 private void ResetWindowLocationAndSize()
 {
     // Get location to the stored values, if any.
     if (m_propertyTable.PropertyExists(m_sWindowKeyLocation) &&
         m_propertyTable.PropertyExists(m_sWindowKeySize))
     {
         var       locWnd = m_propertyTable.GetValue <Point>(m_sWindowKeyLocation);
         var       szWnd  = m_propertyTable.GetValue <Size>(m_sWindowKeySize);
         Rectangle rect   = new Rectangle(locWnd, szWnd);
         ScreenHelper.EnsureVisibleRect(ref rect);
         DesktopBounds = rect;
         StartPosition = FormStartPosition.Manual;
     }
 }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="featSys"></param>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        /// <param name="launchedFromInsertMenu"></param>
        /// <param name="sWindowKey">used to store location and size of dialog window</param>
        /// <param name="sXmlFile">file containing the XML form of the gloss list</param>
        public void SetDlginfo(IFsFeatureSystem featSys, Mediator mediator, XCore.PropertyTable propertyTable, bool launchedFromInsertMenu, string sWindowKey, string sXmlFile)
        {
            CheckDisposed();

            m_featureSystem          = featSys;
            m_featureList            = featSys.FeaturesOC;
            m_launchedFromInsertMenu = launchedFromInsertMenu;
            m_mediator      = mediator;
            m_propertyTable = propertyTable;
            if (m_propertyTable != null)
            {
                m_sWindowKeyLocation = sWindowKey + "Location";
                m_sWindowKeySize     = sWindowKey + "Size";

                ResetWindowLocationAndSize();

                m_helpTopicProvider        = m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider");
                helpProvider               = new HelpProvider();
                helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic));
                helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            }
            m_cache = featSys.Cache;
            LoadMasterFeatures(sXmlFile);
            m_tvMasterList.Cache = m_cache;
        }
Exemple #5
0
        void IFwExtension.Init(LcmCache cache, Mediator mediator, PropertyTable propertyTable)
        {
            m_mediator          = mediator;
            m_propertyTable     = propertyTable;
            m_cache             = cache;
            m_helpTopicProvider = m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider");
            m_sUserWs           = m_cache.ServiceLocator.WritingSystemManager.UserWritingSystem.Id;
            m_sNewUserWs        = m_sUserWs;
            m_userInterfaceChooser.Init(m_sUserWs);

            // Populate Plugins tab page list.
            var baseConfigPath = FwDirectoryFinder.GetCodeSubDirectory(
                Path.Combine("Language Explorer", "Configuration"));
            string basePluginPath = Path.Combine(baseConfigPath, "Available Plugins");
            // The extension XML files should be stored in the data area, not in the code area.
            // This reduces the need for users to have administrative privileges.
            string baseExtensionPath = Path.Combine(FwDirectoryFinder.DataDirectory,
                                                    Path.Combine("Language Explorer", "Configuration"));

            foreach (string dir in Directory.GetDirectories(basePluginPath))
            {
                Debug.WriteLine(dir);
                // Currently not offering Concorder plugin in FW7, therefore, we
                // can remove the feature until we need to implement. (FWNX-755)
                if (Platform.IsUnix && dir == Path.Combine(basePluginPath, "Concorder"))
                {
                    continue;
                }
                string managerPath = Path.Combine(dir, "ExtensionManager.xml");
                if (File.Exists(managerPath))
                {
                    XmlDocument managerDoc = new XmlDocument();
                    managerDoc.Load(managerPath);
                    XmlNode managerNode = managerDoc.SelectSingleNode("/manager");
                    m_lvPlugins.SuspendLayout();
                    ListViewItem lvi = new ListViewItem();
                    lvi.Tag  = managerDoc;
                    lvi.Text = managerNode.Attributes["name"].Value;
                    lvi.SubItems.Add(managerNode.Attributes["description"].Value);
                    // See if it is installed and check the lvi if it is.
                    XmlNode configfilesNode = managerNode.SelectSingleNode("configfiles");
                    string  extensionPath   = Path.Combine(baseExtensionPath, configfilesNode.Attributes["targetdir"].Value);
                    lvi.Checked = Directory.Exists(extensionPath);
                    m_plugins.Add(lvi.Text, lvi.Checked);                     // Remember original installed state.
                    m_lvPlugins.Items.Add(lvi);
                    m_lvPlugins.ResumeLayout();
                }
            }

            if (m_helpTopicProvider != null)             // Will be null when running tests
            {
                helpProvider = new HelpProvider();
                helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic));
                helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            }
        }
Exemple #6
0
        /// <summary/>
        public void SetDlginfo(ICmPossibilityList posList, Mediator mediator, XCore.PropertyTable propertyTable, bool launchedFromInsertMenu, IPartOfSpeech subItemOwner)
        {
            CheckDisposed();

            m_subItemOwner           = subItemOwner;   // May be null, which is fine.
            m_posList                = posList;
            m_launchedFromInsertMenu = launchedFromInsertMenu;
            m_mediator               = mediator;
            m_propertyTable          = propertyTable;
            if (m_propertyTable != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                if (m_propertyTable.PropertyExists("masterCatListDlgLocation") &&
                    m_propertyTable.PropertyExists("masterCatListDlgSize"))
                {
                    var       locWnd = m_propertyTable.GetValue <Point>("masterCatListDlgLocation");
                    var       szWnd  = m_propertyTable.GetValue <Size>("masterCatListDlgSize");
                    Rectangle rect   = new Rectangle(locWnd, szWnd);
                    ScreenHelper.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }
                m_helpTopicProvider = m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider");
                if (m_helpTopicProvider != null)
                {
                    helpProvider = new HelpProvider();
                    helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                    helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic));
                    helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
                }
            }
            m_bnHelp.Enabled = (m_helpTopicProvider != null);

            Debug.Assert(posList != null);
            m_cache = posList.Cache;
            var posSet = new HashSet <IPartOfSpeech>();

            foreach (IPartOfSpeech pos in posList.ReallyReallyAllPossibilities)
            {
                posSet.Add(pos);
            }
            LoadMasterCategories(posSet);
        }
Exemple #7
0
        private void MoveWindowToPreviousPosition()
        {
            // Get location to the stored values, if any.
            object locWnd = m_propertyTable.GetValue <object>("mergeDlgLocation");
            // JohnT: this dialog can't be resized. So it doesn't make sense to
            // remember a size. If we do, we need to override OnLoad (as in SimpleListChooser)
            // to prevent the dialog growing every time at 120 dpi. But such an override
            // makes it too small to show all the controls at the default size.
            // It's better just to use the default size until it's resizeable for some reason.
            //m_mediator.PropertyTable.GetValue("msaCreatorDlgSize");
            object szWnd = Size;

            if (locWnd != null)
            {
                Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                ScreenHelper.EnsureVisibleRect(ref rect);
                DesktopBounds = rect;
                StartPosition = FormStartPosition.Manual;
            }
        }
Exemple #8
0
        private void SetDlgInfo(LcmCache cache, Mediator mediator, XCore.PropertyTable propertyTable, int hvoOwner, int owningFlid, IFsFeatStruc fs, IPhRegularRule rule, IPhSimpleContextNC ctxt)
        {
            m_fs            = fs;
            m_owningFlid    = owningFlid;
            m_hvoOwner      = hvoOwner;
            m_rule          = rule;
            m_ctxt          = ctxt;
            m_mediator      = mediator;
            m_propertyTable = propertyTable;
            if (m_propertyTable != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                if (m_propertyTable.PropertyExists("phonFeatListDlgLocation") &&
                    m_propertyTable.PropertyExists("phonFeatListDlgSize"))
                {
                    var locWnd = m_propertyTable.GetValue <Point>("phonFeatListDlgLocation");
                    var szWnd  = m_propertyTable.GetValue <Size>("phonFeatListDlgSize");
                    var rect   = new Rectangle(locWnd, szWnd);
                    ScreenHelper.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }

                var helpTopicProvider = (m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider"));
                if (helpTopicProvider != null)                 // Will be null when running tests
                {
                    m_helpProvider.HelpNamespace = helpTopicProvider.HelpFile;
                    m_helpProvider.SetHelpKeyword(this, helpTopicProvider.GetHelpString(m_helpTopic));
                    m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
                }
            }
            m_cache = cache;
            m_valuesCombo.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_valuesCombo.StyleSheet           = FontHeightAdjuster.StyleSheetFromPropertyTable(m_propertyTable);

            LoadPhonFeats(m_fs);
            BuildInitialBrowseView();
        }
Exemple #9
0
        protected IPaneBar CreatePaneBar()
        {
            string   preferredLibrary = m_propertyTable.GetValue("PreferredUILibrary", "xCoreOpenSourceAdapter.dll");
            Assembly adaptorAssembly  = AdapterAssemblyFactory.GetAdapterAssembly(preferredLibrary);
            IPaneBar paneBar          = adaptorAssembly.CreateInstance("XCore.PaneBar") as IPaneBar;
            Control  pb = paneBar as Control;

            if (pb.AccessibleName == null)
            {
                pb.AccessibleName = "XCore.PaneBar";
            }
            pb.Dock = DockStyle.Top;
            return(paneBar);
        }
Exemple #10
0
        public void SetDlgInfo(LcmCache cache, Mediator mediator, XCore.PropertyTable propertyTable, ICmObject owner)
        {
            CheckDisposed();

            m_cache = cache;
            m_owner = owner;

            m_helpTopic = "khtpDataNotebook-InsertRecordDlg";

            m_helpTopicProvider = propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider");
            if (m_helpTopicProvider != null)             // Will be null when running tests
            {
                m_helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                m_helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(m_helpTopic));
                m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            }

            IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromPropertyTable(propertyTable);

            m_titleTextBox.StyleSheet           = stylesheet;
            m_titleTextBox.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_titleTextBox.WritingSystemCode    = m_cache.DefaultAnalWs;
            AdjustControlAndDialogHeight(m_titleTextBox, m_titleTextBox.PreferredHeight);

            m_typeCombo.StyleSheet           = stylesheet;
            m_typeCombo.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_typeCombo.WritingSystemCode    = m_cache.DefaultAnalWs;
            AdjustControlAndDialogHeight(m_typeCombo, m_typeCombo.PreferredHeight);

            ICmPossibilityList recTypes = m_cache.LanguageProject.ResearchNotebookOA.RecTypesOA;

            m_typePopupTreeManager = new PossibilityListPopupTreeManager(m_typeCombo, m_cache, mediator, propertyTable,
                                                                         recTypes, cache.DefaultAnalWs, false, this);
            m_typePopupTreeManager.LoadPopupTree(m_cache.ServiceLocator.GetObject(RnResearchNbkTags.kguidRecObservation).Hvo);
            // Ensure that we start out focused in the Title text box.  See FWR-2731.
            m_titleTextBox.Select();
        }
Exemple #11
0
        /// <summary/>
        public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters)
        {
            CheckDisposed();
            m_mediator      = mediator;
            m_propertyTable = propertyTable;
            mediator.AddColleague(this);
            m_propertyTable.SetProperty("ContextHelper", this, false);
            m_propertyTable.SetPropertyPersistence("ContextHelper", false);

            ParentControl = m_propertyTable.GetValue <Control>("window");
            m_document    = new XmlDocument();

            //we use the  directory of the file which held are parameters as the starting point
            //of the path we were given.
            string path = XmlUtils.GetMandatoryAttributeValue(configurationParameters,
                                                              "contextHelpPath");
            var configParamatersBasePath = FileUtils.StripFilePrefix(configurationParameters.BaseURI);

            path = Path.Combine(Path.GetDirectoryName(configParamatersBasePath), path);
            m_document.Load(path);
            //m_items = m_document.SelectNodes("strings/item");

            ShowAlways = m_propertyTable.GetBoolProperty("ShowBalloonHelp", true);
        }
Exemple #12
0
        /// <summary></summary>
        public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters)
        {
            CheckDisposed();

            SuspendLayout();

            m_mediator                = mediator;
            m_propertyTable           = propertyTable;
            m_configurationParameters = configurationParameters;

            // Make the IPaneBar.
            IPaneBar paneBar = CreatePaneBar();
            // initialize the panebar
            string groupId = XmlUtils.GetOptionalAttributeValue(m_configurationParameters, "PaneBarGroupId", null);

            if (groupId != null)
            {
                XWindow         window = m_propertyTable.GetValue <XWindow>("window");
                ImageCollection small  = m_propertyTable.GetValue <ImageCollection>("smallImages");
                paneBar.Init(small, (IUIMenuAdapter)window.MenuAdapter, m_mediator);
            }
            ReloadPaneBar(paneBar);
            m_paneBar = paneBar;
            Controls.Add(paneBar as Control);

            // Make the main control.
            XmlNode mainControlNode = m_configurationParameters.SelectSingleNode("control");
            Control mainControl     = DynamicLoader.CreateObjectUsingLoaderNode(mainControlNode) as Control;

            if (mainControl == null)
            {
                throw new ApplicationException("Soemthing went wrong trying to create the main control.");
            }

            if (!(mainControl is IxCoreContentControl))
            {
                throw new ApplicationException("A PaneBarContainer can only handle controls which implement IxCoreContentControl.");
            }

            mainControl.SuspendLayout();
            m_mainControl    = mainControl;
            mainControl.Dock = DockStyle.Fill;
            if (mainControl is IPaneBarUser)
            {
                (mainControl as IPaneBarUser).MainPaneBar = paneBar;
            }

            /*
             * if (mainControl is MultiPane)
             * {
             *      MultiPane mp = mainControl as MultiPane;
             *      mp.DefaultPrintPaneId = DefaultPrintPaneId;
             *      mp.ParentSizeHint = ParentSizeHint;
             * }*/
            (mainControl as IxCoreColleague).Init(m_mediator, m_propertyTable, mainControlNode.SelectSingleNode("parameters"));
            if (Platform.IsMono)
            {
                // At least one IPaneBarUser main control disposes of its MainPaneBar.  This can
                // cause the program to hang later on.  See FWNX-1036 for details.
                if ((m_paneBar as Control).IsDisposed)
                {
                    Controls.Remove(m_paneBar as Control);
                    m_paneBar = null;
                }
            }

            Controls.Add(mainControl);
            if (mainControl is MultiPane)
            {
                MultiPane mp = mainControl as MultiPane;
                mp.DefaultPrintPaneId = DefaultPrintPaneId;
                mp.ParentSizeHint     = ParentSizeHint;
                if (mp.FirstControl is IPaneBarUser)
                {
                    (mp.FirstControl as IPaneBarUser).MainPaneBar = paneBar;
                }
            }
            mainControl.BringToFront();
            mainControl.ResumeLayout(false);
            ResumeLayout(false);
        }
Exemple #13
0
 protected object Get(string id, string label)
 {
     return(m_propertyTable.GetValue(GetPrefix(id) + "-" + label));
 }
Exemple #14
0
        /// <summary>
        /// Initialize the dialog before showing it.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        /// <param name="entry"></param>
        /// <param name="useForEdit"></param>
        /// <param name="titleForEdit">Edit title appropriate to the button's context.</param>
        /// <param name="persistProvider"></param>
        /// <param name="sandboxMsa"></param>
        /// <param name="hvoOriginalMsa"></param>
        public void SetDlgInfo(LcmCache cache, IPersistenceProvider persistProvider,
                               Mediator mediator, XCore.PropertyTable propertyTable, ILexEntry entry, SandboxGenericMSA sandboxMsa, int hvoOriginalMsa,
                               bool useForEdit, string titleForEdit)
        {
            CheckDisposed();

            Debug.Assert(m_cache == null);
            MsaType msaType = sandboxMsa.MsaType;

            m_cache         = cache;
            m_mediator      = mediator;
            m_propertyTable = propertyTable;

            if (useForEdit)
            {
                // Change the window title and the OK button text.
                Text        = titleForEdit;
                s_helpTopic = "khtpEditGrammaticalFunction";
                btnOk.Text  = LexText.Controls.LexTextControls.ks_OK;
            }
            var helpTopicProvider = m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider");

            helpProvider.HelpNamespace = helpTopicProvider.HelpFile;
            helpProvider.SetHelpKeyword(this, helpTopicProvider.GetHelpString(s_helpTopic));
            helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);

            // Set font, writing system factory, and code for the edit box.
            float fntSize = label1.Font.Size * 2.0F;
            CoreWritingSystemDefinition defVernWs = m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem;

            m_fwtbCitationForm.Font = new Font(defVernWs.DefaultFontName, fntSize);
            m_fwtbCitationForm.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_fwtbCitationForm.WritingSystemCode    = defVernWs.Handle;
            m_fwtbCitationForm.AdjustForStyleSheet(this, null, m_propertyTable);
            m_fwtbCitationForm.AdjustStringHeight = false;
            m_fwtbCitationForm.Tss       = entry.HeadWord;
            m_fwtbCitationForm.HasBorder = false;

            m_fwtbSenses.Font = new Font(defVernWs.DefaultFontName, fntSize);
            m_fwtbSenses.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_fwtbSenses.WritingSystemCode    = defVernWs.Handle;
            m_fwtbSenses.AdjustForStyleSheet(this, null, m_propertyTable);
            m_fwtbSenses.AdjustStringHeight = false;

            ITsIncStrBldr tisb = TsStringUtils.MakeIncStrBldr();

            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_cache.DefaultAnalWs);
            var msaRepository = m_cache.ServiceLocator.GetInstance <IMoMorphSynAnalysisRepository>();

            if (hvoOriginalMsa != 0)
            {
                foreach (var sense in entry.AllSenses)
                {
                    if (sense.MorphoSyntaxAnalysisRA != null)
                    {
                        if (sense.MorphoSyntaxAnalysisRA == msaRepository.GetObject(hvoOriginalMsa))
                        {
                            if (tisb.Text != null)
                            {
                                tisb.Append(", ");                                      // REVIEW: IS LOCALIZATION NEEDED FOR BUILDING THIS LIST?
                            }
                            tisb.AppendTsString(sense.ShortNameTSS);
                        }
                    }
                }
            }
            m_fwtbSenses.Tss       = tisb.GetString();
            m_fwtbSenses.HasBorder = false;

            m_msaGroupBox.Initialize(m_cache, m_mediator, m_propertyTable, this, sandboxMsa);
            int oldHeight = m_msaGroupBox.Height;
            int newHeight = Math.Max(oldHeight, m_msaGroupBox.PreferredHeight);
            int delta     = newHeight - oldHeight;

            if (delta > 0)
            {
                m_msaGroupBox.AdjustInternalControlsAndGrow();
                Debug.Assert(m_msaGroupBox.Height == m_msaGroupBox.PreferredHeight);
                FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, m_msaGroupBox);
            }

            // Reset window location.
            // Get location to the stored values, if any.
            if (m_propertyTable.PropertyExists("msaCreatorDlgLocation"))
            {
                var locWnd = m_propertyTable.GetValue <Point>("msaCreatorDlgLocation");
                // JohnT: this dialog can't be resized. So it doesn't make sense to
                // remember a size. If we do, we need to override OnLoad (as in SimpleListChooser)
                // to prevent the dialog growing every time at 120 dpi. But such an override
                // makes it too small to show all the controls at the default size.
                // It's better just to use the default size until it's resizeable for some reason.
                //m_mediator.XCore.PropertyTable.GetValue("msaCreatorDlgSize");
                Rectangle rect = new Rectangle(locWnd, Size);
                ScreenHelper.EnsureVisibleRect(ref rect);
                DesktopBounds = rect;
                StartPosition = FormStartPosition.Manual;
            }
        }
Exemple #15
0
        /// <summary>
        /// Initialize this has an IxCoreColleague
        /// </summary>
        public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters)
        {
            CheckDisposed();

            SuspendLayout();
            Panel1.SuspendLayout();
            Panel2.SuspendLayout();
            IsInitializing = true;

            m_configurationParameters = configurationParameters;
            m_mediator      = mediator;
            m_propertyTable = propertyTable;
            var toolNode = configurationParameters.SelectSingleNode("ancestor::tool");

            toolName = toolNode == null ? "" : toolNode.Attributes["value"].Value;
//			m_fDontCollapseFillPane = XmlUtils.GetOptionalBooleanAttributeValue(
//				m_configurationParameters, "dontCollapseFillPane", false);

            XmlNodeList nodes = configurationParameters.SelectNodes("control");

            if (nodes.Count != 2)
            {
                throw new ConfigurationException(
                          "Was expecting 2 controls to be defined in the parameters of the Multipane.",
                          configurationParameters);
            }

            string id = XmlUtils.GetAttributeValue(configurationParameters, "id", "");

            m_propertyControllingVisibilityOfFirstPane = GetPropertyControllingVisibilityOfFirstPane(nodes[0]);
            if (m_propertyControllingVisibilityOfFirstPane == null)
            {
                m_showingFirstPane = false;
            }
            else
            {
                m_showingFirstPane = true;                 // default
                // NOTE: we don't actually want to create and persist this property if it's not already loaded.
                if (m_propertyTable.PropertyExists(m_propertyControllingVisibilityOfFirstPane, PropertyTable.SettingsGroup.LocalSettings))
                {
                    m_showingFirstPane = m_propertyTable.GetValue <bool>(m_propertyControllingVisibilityOfFirstPane, PropertyTable.SettingsGroup.LocalSettings);
                }
            }

            SplitterWidth = 5;
            if (id != "")             //must have an id if we're going to persist the value of the splitter
            {
                this.Name = id;       //for debugging
            }
            FirstLabel  = XmlUtils.GetOptionalAttributeValue(configurationParameters, "firstLabel", "");
            SecondLabel = XmlUtils.GetOptionalAttributeValue(configurationParameters, "secondLabel", "");
            SetFirstCollapseZone(nodes[0]);
            SetSecondCollapseZone(nodes[1]);

            string orientation = XmlUtils.GetOptionalAttributeValue(configurationParameters, "splitterBarOrientation", "vertical");

            if (orientation.ToLowerInvariant() == "horizontal" && Orientation != Orientation.Horizontal)
            {
                Orientation = Orientation.Horizontal;
            }
            else if (Orientation != Orientation.Vertical)
            {
                Orientation = Orientation.Vertical;
            }

            m_prioritySecond = XmlUtils.GetOptionalBooleanAttributeValue(configurationParameters,
                                                                         "prioritySecond", false);
            string defaultPrintPaneId = XmlUtils.GetOptionalAttributeValue(configurationParameters,
                                                                           "defaultPrintPane", "");
            string defaultFocusControl = XmlUtils.GetOptionalAttributeValue(configurationParameters,
                                                                            "defaultFocusControl", "");

            // If we are a subcontrol of a MultiPane, our DefaultPrintPane property may already be set.
            // we don't want to change it, unless it's not an empty string.
            if (!String.IsNullOrEmpty(defaultPrintPaneId))
            {
                m_defaultPrintPaneId = defaultPrintPaneId;
            }
            if (!String.IsNullOrEmpty(defaultFocusControl))
            {
                m_defaultFocusControl = defaultFocusControl;
            }
            MakeSubControl(nodes[0], Size, true);
            Panel1Collapsed = !m_showingFirstPane;
            MakeSubControl(nodes[1], Size, false);

            // Attempt to focus the default child control if there is one configured
            // TODO: Things are not yet in a suitable state, hooking onto a later event should work
            // TODO: But if you switch between tools in an area there is sometimes an extra
            // TODO: WM_LBUTTON_DOWN event which steals focus back into the ListViewItemArea
            SetFocusInDefaultControl();

            IsInitializing = false;
            Panel2.ResumeLayout(false);
            Panel1.ResumeLayout(false);
            ResumeLayout(false);

            //it's important to do this last, so that we don't go generating property change
            //notifications that we then go trying to cope with before we are ready
            mediator.AddColleague(this);
            m_fOkToPersistSplit = true;
        }
Exemple #16
0
        private void MakeSubControl(XmlNode configuration, Size parentSizeHint, bool isFirst)
        {
            XmlNode dynLoaderNode = configuration.SelectSingleNode("dynamicloaderinfo");

            if (dynLoaderNode == null)
            {
                throw new ArgumentException("Required 'dynamicloaderinfo' XML node not found, while trying to make control for MultiPane.", "configuration");
            }

            string contentAssemblyPath = XmlUtils.GetMandatoryAttributeValue(dynLoaderNode, "assemblyPath");
            string contentClass        = XmlUtils.GetMandatoryAttributeValue(dynLoaderNode, "class");

            try
            {
                Control subControl = (Control)DynamicLoader.CreateObject(contentAssemblyPath, contentClass);
                if (subControl.AccessibleName == null)
                {
                    subControl.AccessibleName = contentClass;
                }
                if (!(subControl is IxCoreColleague))
                {
                    throw new ApplicationException(
                              "XCore can only handle controls which implement IxCoreColleague. " +
                              contentClass + " does not.");
                }
                if (!(subControl is IXCoreUserControl))
                {
                    throw new ApplicationException(
                              "XCore can only handle controls which implement IXCoreUserControl. " +
                              contentClass + " does not.");
                }

                subControl.SuspendLayout();

                subControl.Dock = DockStyle.Fill;

                // we add this before Initializing so that this child control will have access
                // to its eventual height and width, in case it needs to make initialization
                // decisions based on that.  for example, if the child is another multipane, it
                // will use this to come up with a reasonable default location for its splitter.
                if (subControl is MultiPane)
                {
                    MultiPane mpSubControl = subControl as MultiPane;
                    mpSubControl.ParentSizeHint = parentSizeHint;
                    // cause our subcontrol to inherit our DefaultPrintPane property.
                    mpSubControl.DefaultPrintPaneId = m_defaultPrintPaneId;
                }
                // we add this before Initializing so that this child control will have access
                // to its eventual height and width, in case it needs to make initialization
                // decisions based on that.  for example, if the child is another multipane, it
                // will use this to come up with a reasonable default location for its splitter.
                if (subControl is PaneBarContainer)
                {
                    PaneBarContainer mpSubControl = subControl as PaneBarContainer;
                    mpSubControl.ParentSizeHint = parentSizeHint;
                    // cause our subcontrol to inherit our DefaultPrintPane property.
                    mpSubControl.DefaultPrintPaneId = m_defaultPrintPaneId;
                }


                XmlNode parameters = null;
                if (configuration != null)
                {
                    parameters = configuration.SelectSingleNode("parameters");
                }
                ((IxCoreColleague)subControl).Init(m_mediator, m_propertyTable, parameters);

                // in normal situations, colleagues add themselves to the mediator when
                // initialized.  in this case, we don't want this colleague to add itself
                // because we want it to be subservient to this "papa" control.  however, since
                // this control is only experimental, I'm loathe to change the interfaces in
                // such a way as to tell a colleague that it should not add itself to the
                // mediator.  so, for now, we will just do this hack and remove the colleague
                // from the mediator.
                m_mediator.RemoveColleague((IxCoreColleague)subControl);

                if (isFirst)
                {
                    subControl.AccessibleName += ".First";
                    FirstControl = subControl;
                }
                else
                {
                    subControl.AccessibleName += ".Second";
                    SecondControl              = subControl;
                }
                subControl.ResumeLayout(false);
            }
            catch (Exception error)
            {
                string  s      = "Something went wrong trying to create a " + contentClass + ".";
                XWindow window = m_propertyTable.GetValue <XWindow>("window");
                ErrorReporter.ReportException(new ApplicationException(s, error),
                                              window.ApplicationRegistryKey, m_propertyTable.GetValue <IFeedbackInfoProvider>("FeedbackInfoProvider").SupportEmailAddress);
            }
        }
Exemple #17
0
 private void m_bnHelp_Click(object sender, EventArgs e)
 {
     ShowHelp.ShowHelpTopic(m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider"), m_helpTopic);
 }
Exemple #18
0
 private void btnBackup_Click(object sender, EventArgs e)
 {
     using (var dlg = new BackupProjectDlg(m_cache, m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider")))
         dlg.ShowDialog(this);
 }
Exemple #19
0
        protected virtual void SetDlgInfo(LcmCache cache, WindowParams wp, Mediator mediator, XCore.PropertyTable propertyTable, int ws)
        {
            CheckDisposed();

            Debug.Assert(cache != null);
            m_cache = cache;

            m_mediator      = mediator;
            m_propertyTable = propertyTable;

            if (m_propertyTable != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                if (m_propertyTable.PropertyExists(PersistenceLabel + "DlgLocation") &&
                    m_propertyTable.PropertyExists(PersistenceLabel + "DlgSize"))
                {
                    var locWnd = m_propertyTable.GetValue <Point>(PersistenceLabel + "DlgLocation");
                    var szWnd  = m_propertyTable.GetValue <Size>(PersistenceLabel + "DlgSize");
                    var rect   = new Rectangle(locWnd, szWnd);

                    //grow it if it's too small.  This will happen when we add new controls to the dialog box.
                    if (rect.Width < m_btnHelp.Left + m_btnHelp.Width + 30)
                    {
                        rect.Width = m_btnHelp.Left + m_btnHelp.Width + 30;
                    }

                    if (rect.Height < m_btnHelp.Top + m_btnHelp.Height + 50)
                    {
                        rect.Height = m_btnHelp.Top + m_btnHelp.Height + 50;
                    }

                    ScreenHelper.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }

                m_helpTopicProvider = m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider");
                if (m_helpTopicProvider != null)
                {
                    m_helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                    SetHelpButtonEnabled();
                }
            }

            SetupBasicTextProperties(wp);

            IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromPropertyTable(m_propertyTable);

            // Set font, writing system factory, and writing system code for the Lexical Form
            // edit box.  Also set an empty string with the proper writing system.
            m_tbForm.Font = new Font(cache.ServiceLocator.WritingSystemManager.Get(ws).DefaultFontName, 10);
            m_tbForm.WritingSystemFactory = cache.WritingSystemFactory;
            m_tbForm.WritingSystemCode    = ws;
            m_tbForm.AdjustStringHeight   = false;
            m_tbForm.Tss        = TsStringUtils.EmptyString(ws);
            m_tbForm.StyleSheet = stylesheet;

            // Setup the fancy message text box.
            // Note: at 120DPI (only), it seems to be essential to set at least the WSF of the
            // bottom message even if not using it.
            SetupBottomMsg();
            SetBottomMessage();
            m_fwTextBoxBottomMsg.BorderStyle = BorderStyle.None;

            m_analHvos.UnionWith(cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Select(wsObj => wsObj.Handle));
            List <int> vernList = cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Select(wsObj => wsObj.Handle).ToList();

            m_vernHvos.UnionWith(vernList);
            LoadWritingSystemCombo();
            int iWs = vernList.IndexOf(ws);
            CoreWritingSystemDefinition currentWs;

            if (iWs < 0)
            {
                List <int> analList = cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Select(wsObj => wsObj.Handle).ToList();
                iWs = analList.IndexOf(ws);
                if (iWs < 0)
                {
                    currentWs = cache.ServiceLocator.WritingSystemManager.Get(ws);
                    m_cbWritingSystems.Items.Add(currentWs);
                    SetCbWritingSystemsSize();
                }
                else
                {
                    currentWs = cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems[iWs];
                }
            }
            else
            {
                currentWs = cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems[iWs];
            }
            Debug.Assert(currentWs != null && currentWs.Handle == ws);

            m_skipCheck = true;
            m_cbWritingSystems.SelectedItem = currentWs;
            m_skipCheck = false;
            // Don't hook this up until AFTER we've initialized it; otherwise, it can
            // modify the contents of the form as a side effect of initialization.
            // Also, doing that triggers laying out the dialog prematurely, before
            // we've set WSF on all the controls.
            m_cbWritingSystems.SelectedIndexChanged += m_cbWritingSystems_SelectedIndexChanged;

            InitializeMatchingObjects(cache);

            // Adjust things if the form box needs to grow to accommodate its style.
            int oldHeight = m_tbForm.Height;
            int newHeight = Math.Max(oldHeight, m_tbForm.PreferredHeight);
            int delta     = newHeight - oldHeight;

            if (delta != 0)
            {
                m_tbForm.Height  = newHeight;
                m_panel1.Height += delta;
                GrowDialogAndAdjustControls(delta, m_panel1);
            }
        }
Exemple #20
0
 public T GetValue <T>(string activeclerk)
 {
     return(m_propertyTable.GetValue <T>(activeclerk));
 }