SetProperty() public method

set the value of the best property (try finding local first, then global) and broadcast the change.
public SetProperty ( string name, object newValue ) : void
name string
newValue object
return void
Exemplo n.º 1
0
        /// <summary>
        /// set the value of a property to a node of a list. Also sets the corresponding parameters property.
        /// </summary>
        /// <remarks> this is static so that it can be called by the XCore initializationcode and set from the contents of the XML configuration file</remarks>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        /// <param name="choiceValue"></param>
        /// <param name="choiceParameters"></param>
        /// <param name="propertyName"></param>
        /// <param name="settingsGroup"></param>
        static public void ChooseSinglePropertyAtomicValue(Mediator mediator, PropertyTable propertyTable, string choiceValue,
                                                           XmlNode choiceParameters, string propertyName, PropertyTable.SettingsGroup settingsGroup)
        {
            //a hack (that may be we could live with)
            //	if(choiceParameters !=null)
            //	{
            propertyTable.SetProperty(propertyName + "Parameters", choiceParameters, settingsGroup, true);
            //it is possible that we would like to persist these parameters
            //however, as a practical matter, you cannot have XmlNodes witch do not belong to a document.
            //therefore, they could not be deserialize if we did save them.
            //unless, of course, we convert them to a string before serializing.
            //However, when de-serializing, what document would we attach the new xmlnode to?
            propertyTable.SetPropertyPersistence(propertyName + "Parameters", false, settingsGroup);
            //}


            //remember, each of these calls to SetProperty() generate a broadcast, so the order of these two calls
            //is relevant.
            propertyTable.SetProperty(propertyName, choiceValue, settingsGroup, true);

            if (choiceParameters != null)
            {
                //since we cannot persist the parameters, it's safer to not persist the choice either.
                propertyTable.SetPropertyPersistence(propertyName, false, settingsGroup);
            }
        }
Exemplo n.º 2
0
 private void MergeObjectDlg_Closed(object sender, EventArgs e)
 {
     if (m_propertyTable != null)
     {
         m_propertyTable.SetProperty("mergeDlgLocation", Location, true);
         m_propertyTable.SetProperty("mergeDlgSize", Size, true);
     }
 }
Exemplo n.º 3
0
 private void BaseGoDlg_Closed(object sender, EventArgs e)
 {
     // Save location.
     if (m_mediator != null)
     {
         var propName = PersistenceLabel + "DlgLocation";
         m_propertyTable.SetProperty(propName, Location, true);
         var sz = new Size(0, m_delta);
         propName = PersistenceLabel + "DlgSize";
         m_propertyTable.SetProperty(propName, Size - sz, true);
     }
 }
Exemplo n.º 4
0
        static public void ChooseSinglePropertySequenceValue(Mediator mediator, PropertyTable propertyTable, string choiceValue,
                                                             XmlNode choiceParameterNode, string propertyName, bool fEmptyAllowed, PropertyTable.SettingsGroup settingsGroup)
        {
            propertyTable.SetProperty(propertyName + "Parameters", choiceParameterNode, settingsGroup, true);
            propertyTable.SetPropertyPersistence(propertyName + "Parameters", false, settingsGroup);
            string sValue = propertyTable.GetStringProperty(propertyName, "", settingsGroup);

            string[] rgsValues = sValue.Split(',');
            int      idx       = -1;

            if (sValue == choiceValue)
            {
                if (fEmptyAllowed)
                {
                    sValue = "";
                }
            }
            else if ((idx = IndexOf(rgsValues, choiceValue)) != -1)
            {
                // remove the choiceValue from the string.
                Debug.Assert(rgsValues.Length > 1);
                System.Text.StringBuilder sbValues = new System.Text.StringBuilder(sValue.Length);
                for (int i = 0; i < rgsValues.Length; ++i)
                {
                    if (idx != i)
                    {
                        if (sbValues.Length > 0)
                        {
                            sbValues.Append(",");
                        }
                        sbValues.Append(rgsValues[i]);
                    }
                }
                sValue = sbValues.ToString();
            }
            else
            {
                if (sValue.Length == 0)
                {
                    sValue = choiceValue;
                }
                else
                {
                    sValue = sValue + "," + choiceValue;
                }
            }
            propertyTable.SetProperty(propertyName, sValue, settingsGroup, true);
            propertyTable.SetPropertyPersistence(propertyName, false, settingsGroup);
        }
Exemplo n.º 5
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK != openFileDialog1.ShowDialog())
            {
                return;
            }

            tbPath.Text = openFileDialog1.FileName;
            UpdateButtons();
            if (btnOK.Enabled)
            {
                m_propertyTable.SetProperty(FilePropertyName, tbPath.Text, true);
                m_propertyTable.SetPropertyPersistence(FilePropertyName, true);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            // Must not be run more than once.
            if (m_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_mediator != null)
                {
                    m_mediator.RemoveColleague(this);
                    m_propertyTable.SetProperty("ContextHelper", null, false);
                    m_propertyTable.SetPropertyPersistence("ContextHelper", false);
                }
                if (m_helpIdToElt != null)
                {
                    m_helpIdToElt.Clear();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_mediator    = null;
            m_helpIdToElt = null;
            m_document    = null;

            m_isDisposed = true;
        }
Exemplo n.º 7
0
        /// <summary>
        /// If OK, then add relevant POSes to DB.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MasterCategoryListDlg_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            switch (DialogResult)
            {
            default:
                m_selPOS = null;
                break;

            case DialogResult.OK:
            {
                // Closing with normal selection(s).
                foreach (TreeNode tn in m_nodes)
                {
                    MasterCategory mc = tn.Tag as MasterCategory;
                    Debug.Assert(mc != null);
                    if ((tn.Checked || (tn == m_tvMasterList.SelectedNode)) &&
                        !mc.InDatabase)
                    {
                        // if this.m_subItemOwner != null, it indicates where to put the newly chosed POS
                        mc.AddToDatabase(m_cache,
                                         m_posList,
                                         (tn.Parent == null) ? null : tn.Parent.Tag as MasterCategory,
                                         m_subItemOwner);
                    }
                }
                MasterCategory mc2 = m_tvMasterList.SelectedNode.Tag as MasterCategory;
                Debug.Assert(mc2 != null);
                m_selPOS = mc2.POS;
                Debug.Assert(m_selPOS != null);
                break;
            }

            case DialogResult.Yes:
            {
                // Closing via the hotlink.
                // Do nothing special, except avoid setting m_selPOS to null, as in the default case.
                break;
            }
            }

            if (m_mediator != null)
            {
                m_propertyTable.SetProperty("masterCatListDlgLocation", Location, true);
                m_propertyTable.SetProperty("masterCatListDlgSize", Size, true);
            }
        }
Exemplo n.º 8
0
 private void MsaCreatorDlg_Closed(object sender, System.EventArgs e)
 {
     if (m_propertyTable != null)
     {
         m_propertyTable.SetProperty("msaCreatorDlgLocation", Location, true);
         //No need, since the dlg isnt; resizable. m_mediator.XCore.PropertyTable.SetProperty("msaCreatorDlgSize", Size);
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// If OK, then add relevant inflection features to DB.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MasterListDlg_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            switch (DialogResult)
            {
            default:
                m_selFeatDefn = null;
                break;

            case DialogResult.OK:
            {
                using (new WaitCursor(this))
                {
                    if (m_tvMasterList.TerminalsUseCheckBoxes)
                    {
                        UpdateAllCheckedItems(m_tvMasterList.Nodes);
                    }
                    else
                    {
                        MasterItem mi = m_tvMasterList.SelectedNode.Tag as MasterItem;
                        if (mi != null)
                        {
                            mi.AddToDatabase(m_cache);
                            m_selFeatDefn = mi.FeatureDefn;
                        }
                    }
                }
                break;
            }

            case DialogResult.Yes:
            {
                // Closing via the hotlink.
                // Do nothing special, except avoid setting m_selFeatDefn to null, as in the default case.
                break;
            }
            }

            if (m_propertyTable != null)
            {
                m_propertyTable.SetProperty(m_sWindowKeyLocation, Location, true);
                m_propertyTable.SetProperty(m_sWindowKeySize, Size, true);
            }
        }
Exemplo n.º 10
0
        protected override void OnSplitterMoved(object sender, SplitterEventArgs e)
        {
            if (InSplitterMovedMethod)
            {
                return;
            }

            base.OnSplitterMoved(sender, e);

            // Persist new position.
            if (m_mediator != null && m_fOkToPersistSplit)
            {
                m_propertyTable.SetProperty(SplitterDistancePropertyName, SplitterDistance, false);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 12
0
        /// <summary>
        /// If OK, then make FS have the selected feature value(s).
        /// JohnT: This is a really ugly kludge, which I have only partly repaired.
        /// We need the dialog to return with m_fs set to an FsFeatStruc (if OK was clicked),
        /// since that is what the bulk edit bar wants to copy to MoStemMsas for any items
        /// it is asked to modify. Also, the new FsFeatStruc needs to be in the ReferenceForms
        /// (which is what m_owningFlid apparently always is, currently) so that it will become
        /// one of the items in the combo list and can be selected. However, Andy says this is
        /// not the intended use of ReferenceForms at all.
        /// A further ugliness is that we always make a new FsFeatStruc (unless one was passed
        /// in to one of the SegDlgInfo methods, but AFAIK that override is never used), but
        /// we then delete it if it turns out to be a duplicate. There is no other straightforward
        /// way to detect that the current choices in the dialog correspond to an existing item.
        /// This may cause problems in the new world, where we can't do this "suppress sub tasks"
        /// trick without losing our Undo stack.
        /// It may be possible in the new world to create an object without initially giving it an
        /// owner, and only persist it if it is NOT a duplicate. But even that we don't really want
        /// to be undoable, nor should it clear the undo stack. Really the list of possible choices
        /// for the combo should not be separately persisted as model data, but it should be persisted
        /// somehow...
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MsaInflectionFeatureListDlg_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                // making and maybe then deleting the new item for the combo is not undoable
                NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor,
                                               () =>
                {
                    if (m_fs == null)
                    {
                        // Didn't have one to begin with. See whether we want to create one.
                        if (CheckFeatureStructure(m_tvMsaFeatureList.Nodes))
                        {
                            var repo = m_cache.ServiceLocator.GetInstance <IFsFeatStrucRepository>();
                            // FsFeatStruc may be owned atomically or in a colllection. See which fake insertion index we need.
                            int where  = m_cache.MetaDataCacheAccessor.GetFieldType(m_owningFlid) == (int)CellarPropertyType.OwningAtomic ? -2: -1;
                            int hvoNew = m_cache.DomainDataByFlid.MakeNewObject(FsFeatStrucTags.kClassId, m_hvoOwner,
                                                                                m_owningFlid, where);
                            m_fs = repo.GetObject(hvoNew);
                        }
                        else
                        {
                            return;                                             // leave it null.
                        }
                    }
                    // clean out any extant features in the feature structure
                    foreach (var spec in m_fs.FeatureSpecsOC)
                    {
                        m_fs.FeatureSpecsOC.Remove(spec);
                    }
                    UpdateFeatureStructure(m_tvMsaFeatureList.Nodes);
                    // The (usually) newly created one may be a duplicate. If we find a duplicate
                    // delete the one we just made (or were passed) and return the duplicate.
                    int cpt = m_cache.MetaDataCacheAccessor.GetFieldType(m_owningFlid);
                    if (m_hvoOwner != 0 && cpt != (int)CellarPropertyType.OwningAtomic)
                    {
                        int chvo = m_cache.DomainDataByFlid.get_VecSize(m_hvoOwner, m_owningFlid);
                        for (int ihvo = 0; ihvo < chvo; ihvo++)
                        {
                            int hvo = m_cache.DomainDataByFlid.get_VecItem(m_hvoOwner, m_owningFlid, ihvo);
                            if (hvo == m_fs.Hvo)
                            {
                                continue;
                            }
                            IFsFeatStruc fs = m_cache.ServiceLocator.GetInstance <IFsFeatStrucRepository>().GetObject(hvo);
                            if (DomainObjectServices.AreEquivalent(fs, m_fs))
                            {
                                m_cache.DomainDataByFlid.DeleteObj(m_fs.Hvo);
                                m_fs = fs;
                                break;
                            }
                        }
                    }
                    // If the user emptied all the FeatureSpecs (i.e. chose "None of the above" in each area),
                    // then we need to delete the FsFeatStruc. (LT-13596)
                    if (FS.FeatureSpecsOC.Count == 0)
                    {
                        if (m_fs.CanDelete)
                        {
                            m_fs.Delete();
                        }
                        m_fs = null;
                    }
                });
            }

            if (m_propertyTable != null)
            {
                m_propertyTable.SetProperty("msaInflFeatListDlgLocation", Location, true);
                m_propertyTable.SetProperty("msaInflFeatListDlgSize", Size, true);
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Save any appropriate settings to the property table
 /// </summary>
 public static void SaveSettings(IFdoServiceLocator services, PropertyTable propertyTable)
 {
     var hc = services.GetInstance<HomographConfiguration>();
     propertyTable.SetProperty(khomographconfiguration, hc.PersistData);
 }
Exemplo n.º 14
0
		/// <summary>
		/// Store this virtual property's settings to the property table so they can be persisted in local settings.
		/// </summary>
		/// <param name="pt"></param>
		internal void StoreSettings(PropertyTable pt)
		{
			if (pt == null)
				return;
			pt.SetProperty(m_propertyTableKey, GetPropertyTableValue(), true, PropertyTable.SettingsGroup.LocalSettings);
		}
Exemplo n.º 15
0
 protected void Set(string id, string label, object value)
 {
     m_propertyTable.SetProperty(GetPrefix(id) + "-" + label, value);
 }
Exemplo n.º 16
0
		/// <summary>
		/// Store in the property table what needs to be there so that we will use the specified set of scripture
		/// texts as 'interesting'.
		/// </summary>
		/// <param name="propertyTable"></param>
		public static void SetScriptureTextsInPropertyTable(PropertyTable propertyTable, IEnumerable<IStText> texts)
		{
			propertyTable.SetProperty(PersistPropertyName, MakeIdList(texts.Cast<ICmObject>()));
		}
Exemplo n.º 17
0
        protected void Set(string id, string label, object value)
        {
            var propertyName = GetPrefix(id) + "-" + label;

            m_propertyTable.SetProperty(propertyName, value, true);
        }