PropertyExists() public method

Test whether a property exists, tries local first and then global.
public PropertyExists ( string name ) : bool
name string
return bool
Ejemplo n.º 1
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;
     }
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
 public bool PropertyExists(string name)
 {
     return(m_propertyTable.PropertyExists(name));
 }
Ejemplo n.º 6
0
        private void SetSplitterDistance()
        {
            int sizeOfSharedDimension = Orientation == Orientation.Vertical ? Width : Height;
            // If the default size is specified in the XML file, use that,
            // otherwise compute something reasonable.
            string defaultLoc = XmlUtils.GetOptionalAttributeValue(m_configurationParameters,
                                                                   "defaultFixedPaneSizePoints",
                                                                   "50%");
            int defaultLocation;

            // Find 'total', which will be the height or width,
            // depending on the orientation of the multi pane.
            bool proportional = defaultLoc.EndsWith("%");
            int  total;
            Size size = Size;

            if (m_parentSizeHint.Width != 0 && !proportional)
            {
                size = m_parentSizeHint;
            }
            if (Orientation == Orientation.Vertical)
            {
                total = size.Width;
            }
            else
            {
                total = size.Height;
            }

            if (proportional)
            {
                string percentStr = defaultLoc.Substring(0, defaultLoc.Length - 1);
                int    percent    = Int32.Parse(percentStr);
                float  loc        = (total * (((float)percent) / 100));
                double locD       = Math.Round(loc);
                defaultLocation = (int)locD;
            }
            else
            {
                defaultLocation = Int32.Parse(defaultLoc);
            }

            if (m_mediator != null)
            {
                // NB GetIntProperty RECORDS the default as if it had really been set by the user.
                // This behavior is disastrous here, where if we haven't truly persisted something,
                // we want to stick to computing the percent whenever the parent resizes.
                // So, first see whether there is a value in the property table at all.
                if (m_propertyTable.PropertyExists(SplitterDistancePropertyName))
                {
                    defaultLocation = m_propertyTable.GetIntProperty(SplitterDistancePropertyName, defaultLocation);
                }
            }
            if (defaultLocation < kCollapsedSize)
            {
                defaultLocation = kCollapsedSize;
            }

            if (SplitterDistance != defaultLocation)
            {
                int originalSD = SplitterDistance;
                try
                {
                    // Msg: SplitterDistance (aka: defaultLocation) must be between Panel1MinSize and Width - Panel2MinSize.
                    if (defaultLocation >= Panel1MinSize && defaultLocation <= (sizeOfSharedDimension - Panel2MinSize))
                    {
                        // We do NOT want to persist this computed position!
                        bool old = m_fOkToPersistSplit;
                        m_fOkToPersistSplit = false;
                        SplitterDistance    = defaultLocation;
                        m_fOkToPersistSplit = old;
                    }
                }
                catch (Exception err)
                {
                    Debug.WriteLine(err.Message);
                    string msg = string.Format("Orientation: {0} Width: {1} Height: {2} Original SD: {3} New SD: {4} Panel1MinSize: {5} Panel2MinSize: {6} ID: {7} Panel1Collapsed: {8} Panel2Collapsed: {9}",
                                               Orientation.ToString(), Width, Height, originalSD, defaultLocation,
                                               Panel1MinSize, Panel2MinSize,
                                               XmlUtils.GetAttributeValue(m_configurationParameters, "id", "NOID"),
                                               Panel1Collapsed, Panel2Collapsed);
                    throw new ArgumentOutOfRangeException(msg, err);
                }
            }
        }
Ejemplo n.º 7
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;
        }
Ejemplo n.º 8
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;
            }
        }