/// <summary> /// Handle changes in the size of the underlying view. /// </summary> protected void OnViewSizeChanged(object sender, FwViewSizeEventArgs e) { // For now, just handle changes in the height. PhoneEnvReferenceLauncher rl = (PhoneEnvReferenceLauncher)this.Control; PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; if (ContainingDataTree == null) { return; // called too soon, from initial layout before connected. } int hMin = ContainingDataTree.GetMinFieldHeight(); int h1 = view.RootBox.Height; Debug.Assert(e.Height == h1); int hOld = TreeNode == null ? 0 : TreeNode.Height; int hNew = Math.Max(h1, hMin) + 3; if (hNew != hOld) { if (TreeNode != null) { TreeNode.Height = hNew; } Height = hNew - 1; } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.m_phoneEnvRefView = new PhoneEnvReferenceView(); this.SuspendLayout(); // // m_panel // this.m_panel.Name = "m_panel"; // // m_btnLauncher // this.m_btnLauncher.Name = "m_btnLauncher"; // // m_phoneEnvRefView // this.m_phoneEnvRefView.AutoScroll = false; this.m_phoneEnvRefView.EditingHelper.DefaultCursor = null; this.m_phoneEnvRefView.Location = new System.Drawing.Point(0, 0); this.m_phoneEnvRefView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; this.m_phoneEnvRefView.Name = "m_phoneEnvRefView"; this.m_phoneEnvRefView.Size = new System.Drawing.Size(150, 20); this.m_phoneEnvRefView.TabIndex = 2; // // PhoneEnvReferenceLauncher // this.Controls.Add(this.m_phoneEnvRefView); this.MainControl = this.m_phoneEnvRefView; this.Name = "PhoneEnvReferenceLauncher"; this.Size = new System.Drawing.Size(150, 20); this.Controls.SetChildIndex(this.m_phoneEnvRefView, 0); this.Controls.SetChildIndex(this.m_panel, 0); this.ResumeLayout(false); }
/// <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 override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. PhoneEnvReferenceLauncher rl = Control as PhoneEnvReferenceLauncher; if (rl != null) { rl.ViewSizeChanged -= new FwViewSizeChangedEventHandler(this.OnViewSizeChanged); PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; view.ViewSizeChanged -= new FwViewSizeChangedEventHandler(this.OnViewSizeChanged); } } // Dispose unmanaged resources here, whether disposing is true or false. base.Dispose(disposing); }
// JohnT: this is the proper way to detect changes in height that come from editing within the view. // Probably the private ViewSizeChanged event isn't really needed but I'm leaving it for now just in case. void view_LayoutSizeChanged(object sender, EventArgs e) { PhoneEnvReferenceLauncher rl = Control as PhoneEnvReferenceLauncher; PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; this.OnViewSizeChanged(this, new FwViewSizeEventArgs(view.RootBox.Height, view.RootBox.Width)); }
public bool OnShowEnvironmentError(object args) { CheckDisposed(); PhoneEnvReferenceLauncher rl = (PhoneEnvReferenceLauncher)this.Control; PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; view.ShowEnvironmentError(); return(true); }
public bool OnInsertNaturalClass(object args) { CheckDisposed(); PhoneEnvReferenceLauncher rl = (PhoneEnvReferenceLauncher)this.Control; PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; return(SimpleListChooser.ChooseNaturalClass(view.RootBox, m_cache, m_persistenceProvider, Mediator)); }
public bool OnInsertHashMark(object args) { CheckDisposed(); PhoneEnvReferenceLauncher rl = (PhoneEnvReferenceLauncher)this.Control; PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; view.RootBox.OnChar((int)'#'); return(true); }
public bool OnInsertOptionalItem(object args) { CheckDisposed(); PhoneEnvReferenceLauncher rl = (PhoneEnvReferenceLauncher)this.Control; PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; IVwRootBox rootb = view.RootBox; InsertOptionalItem(rootb); return(true); }
/// <summary> /// This menu item is on if a slash already exists in the environment. /// </summary> /// <param name="commandObject"></param> /// <param name="display"></param> /// <returns></returns> public bool OnDisplayInsertHashMark(object commandObject, ref UIItemDisplayProperties display) { CheckDisposed(); PhoneEnvReferenceLauncher rl = (PhoneEnvReferenceLauncher)this.Control; PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; display.Enabled = view.CanInsertHashMark(); return(true); }
/// <summary> /// This action is needed whenever we leave the slice, not just when we move to another /// slice but also when we move directly to another tool. /// </summary> /// <param name="e"></param> protected override void OnLeave(EventArgs e) { PhoneEnvReferenceLauncher rl = (PhoneEnvReferenceLauncher)this.Control; PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; view.ConnectToRealCache(); if (view.RootBox != null) { view.RootBox.DestroySelection(); } base.OnLeave(e); }
/// <summary> /// This method is called to handle Undo/Redo operations on this slice. /// </summary> /// <param name="hvo"></param> /// <param name="tag"></param> /// <returns></returns> protected internal override bool UpdateDisplayIfNeeded(int hvo, int tag) { if (tag == Flid) { PhoneEnvReferenceLauncher rl = Control as PhoneEnvReferenceLauncher; if (rl != null) { PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; view.ResynchListToDatabaseAndRedisplay(); return(true); } } return(base.UpdateDisplayIfNeeded(hvo, tag)); }
/// <summary> /// Override method to add the Sets up the PhoneEnvReferenceView control. /// </summary> protected override void SetupControls(IPersistenceProvider persistenceProvider, Mediator mediator, StringTable stringTbl) { Debug.Assert(m_obj != null); PhoneEnvReferenceLauncher rl = new PhoneEnvReferenceLauncher(); rl.Initialize(m_cache, m_obj, m_flid, m_fieldName, persistenceProvider, mediator, null, null); rl.ConfigurationNode = ConfigurationNode; this.Control = rl; rl.ViewSizeChanged += new FwViewSizeChangedEventHandler(this.OnViewSizeChanged); PhoneEnvReferenceView view = (PhoneEnvReferenceView)rl.MainControl; view.ViewSizeChanged += new FwViewSizeChangedEventHandler(this.OnViewSizeChanged); view.LayoutSizeChanged += new EventHandler(view_LayoutSizeChanged); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if ( disposing ) { if (components != null) { components.Dispose(); } } m_phoneEnvRefView = null; // Disposed automatically, since it is in the Controls collection. base.Dispose( disposing ); }
public void EnvsBeingRequestedForThisEntry_HandlesItemFollowingEmptyString() { var sda = new PhoneEnvReferenceView.PhoneEnvReferenceSda(Cache.DomainDataByFlid as ISilDataAccessManaged); var entry = Cache.ServiceLocator.GetInstance<ILexEntryFactory>().Create(); var form = Cache.ServiceLocator.GetInstance<IMoStemAllomorphFactory>().Create(); entry.LexemeFormOA = form; var root = form.Hvo; var hvos = new [] {-5000, -5001, -5002}; sda.CacheVecProp(root, PhoneEnvReferenceView.kMainObjEnvironments, hvos, hvos.Length); sda.SetString(hvos[1], PhoneEnvReferenceView.kEnvStringRep, TsStrFactoryClass.Create().MakeString("abc", 6)); using (var view = new PhoneEnvReferenceView()) { view.SetSda(sda); view.SetRoot(form); view.SetCache(Cache); var results = view.EnvsBeingRequestedForThisEntry(); Assert.That(results, Has.Count.EqualTo(1)); } }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { if (components != null) { components.Dispose(); } } m_phoneEnvRefView = null; // Disposed automatically, since it is in the Controls collection. base.Dispose(disposing); }
public void EnvsBeingRequestedForThisEntry_HandlesItemFollowingEmptyString() { var sda = new PhoneEnvReferenceView.PhoneEnvReferenceSda(Cache.DomainDataByFlid as ISilDataAccessManaged); var entry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create(); var form = Cache.ServiceLocator.GetInstance <IMoStemAllomorphFactory>().Create(); entry.LexemeFormOA = form; var root = form.Hvo; var hvos = new [] { -5000, -5001, -5002 }; sda.CacheVecProp(root, PhoneEnvReferenceView.kMainObjEnvironments, hvos, hvos.Length); sda.SetString(hvos[1], PhoneEnvReferenceView.kEnvStringRep, TsStrFactoryClass.Create().MakeString("abc", 6)); using (var view = new PhoneEnvReferenceView()) { view.SetSda(sda); view.SetRoot(form); view.SetCache(Cache); var results = view.EnvsBeingRequestedForThisEntry(); Assert.That(results, Has.Count.EqualTo(1)); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.m_phoneEnvRefView = new PhoneEnvReferenceView(); this.SuspendLayout(); // // m_panel // this.m_panel.Name = "m_panel"; // // m_btnLauncher // this.m_btnLauncher.Name = "m_btnLauncher"; // // m_phoneEnvRefView // this.m_phoneEnvRefView.AutoScroll = false; this.m_phoneEnvRefView.EditingHelper.DefaultCursor = null; this.m_phoneEnvRefView.Location = new System.Drawing.Point(0, 0); this.m_phoneEnvRefView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom |AnchorStyles.Left; this.m_phoneEnvRefView.Name = "m_phoneEnvRefView"; this.m_phoneEnvRefView.Size = new System.Drawing.Size(150, 20); this.m_phoneEnvRefView.TabIndex = 2; // // PhoneEnvReferenceLauncher // this.Controls.Add(this.m_phoneEnvRefView); this.MainControl = this.m_phoneEnvRefView; this.Name = "PhoneEnvReferenceLauncher"; this.Size = new System.Drawing.Size(150, 20); this.Controls.SetChildIndex(this.m_phoneEnvRefView, 0); this.Controls.SetChildIndex(this.m_panel, 0); this.ResumeLayout(false); }