/// <summary> /// /// </summary> /// <param name="parent"></param> public override void Install(DataTree parent) { CheckDisposed(); base.Install(parent); var ctrl = (PhonologicalFeatureListDlgLauncher)Control; m_flid = GetFlid(m_configurationNode, m_obj); if (m_flid != 0) m_fs = GetFeatureStructureFromOwner(m_obj, m_flid); else { m_fs = m_obj as IFsFeatStruc; m_flid = FsFeatStrucTags.kflidFeatureSpecs; } ctrl.Initialize((FdoCache)Mediator.PropertyTable.GetValue("cache"), m_fs, m_flid, "Name", m_persistenceProvider, Mediator, "Name", XmlUtils.GetOptionalAttributeValue(m_configurationNode, "ws", "analysis")); // TODO: Get better default 'best ws'. }
/// <summary> /// /// </summary> /// <param name="parent"></param> public override void Install(DataTree parent) { CheckDisposed(); base.Install(parent); MsaInflectionFeatureListDlgLauncher ctrl = (MsaInflectionFeatureListDlgLauncher)Control; m_flid = MsaInflectionFeatureListDlgLauncherSlice.GetFlid(m_configurationNode, m_obj); if (m_flid != 0) m_fs = MsaInflectionFeatureListDlgLauncherSlice.GetFeatureStructureFromMSA(m_obj, m_flid); else { m_fs = m_obj as FsFeatStruc; m_flid = (int)FsFeatStruc.FsFeatStrucTags.kflidFeatureSpecs; } ctrl.Initialize((FdoCache)Mediator.PropertyTable.GetValue("cache"), m_fs, m_flid, "Name", ContainingDataTree.PersistenceProvder, Mediator, "Name", XmlUtils.GetOptionalAttributeValue(m_configurationNode, "ws", "analysis")); // TODO: Get better default 'best ws'. }
/// <summary>Helper</summary> private static Slice GenerateSlice(FdoCache cache, DataTree datatree) { var slice = new Slice(); var parts = DataTreeTests.GenerateParts(); var layouts = DataTreeTests.GenerateLayouts(); datatree.Initialize(cache, false, layouts, parts); slice.Parent = datatree; return slice; }
public override void Install(DataTree parent) { // JohnT: This is an awful way to make the button fit neatly, but I can't find a better one. Control.Height = Height; // It doesn't need most of the usual info, but the Mediator is important if the user // asks to Create a new lex entry from inside the first dialog (LT-9679). // We'd pass 0 and null for flid and fieldname, but there are Asserts to prevent this. (Control as ButtonLauncher).Initialize(m_cache, m_obj, 1, "nonsence", null, Mediator, null, null); base.Install(parent); }
/// <summary> /// used to associate menu commands with the slice that sent them /// </summary> //protected Slice m_sourceOfMenuCommandSlice=null; #endregion // Data members #region Construction and Removal /// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="VectorEditor"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public RecordEditView() { // This must be called before InitializeComponent() m_dataEntryForm = CreateNewDataTree(); // This call is required by the Windows.Forms Form Designer. InitializeComponent(); base.AccNameDefault = "RecordEditView"; // default accessibility name }
// // Overhaul Aug 05: want all Window backgrounds in Detail controls. // /// <summary> // /// This is passed the color that the XDE specified, if any, otherwise null. // /// The default is to use the normal window color for editable text. // /// Messages have a default already set in the constructor, so ignore // /// if null. // /// </summary> // /// <param name="clr"></param> // public override void OverrideBackColor(String backColorName) // { // CheckDisposed(); // // if (this.Control == null) // return; // if (backColorName != null) // this.Control.BackColor = Color.FromName(backColorName); // } /// <summary> /// /// </summary> /// <param name="parent"></param> public override void Install(DataTree parent) { CheckDisposed(); base.Install(parent); if (this.Control != null) { this.Control.AccessibilityObject.Value = this.Control.Text; } }
/// <summary> /// Called when the slice is first created, but also when it is /// "reused" (e.g. refresh or new target object) /// </summary> /// <param name="parent"></param> public override void Install(DataTree parent) { CheckDisposed(); base.Install(parent); if (m_cb.Dock != DockStyle.Left) m_cb.Dock = System.Windows.Forms.DockStyle.Left; if (m_cb.Width != 20) m_cb.Width = 20; // was taking whole length of slice m_sda = Cache.DomainDataByFlid; m_sda.AddNotification(this); }
/// <summary> /// factory method which creates the correct subclass based on the XML parameters /// </summary> /// <param name="dataEntryForm"></param> /// <param name="configuration"></param> /// <returns></returns> public static DTMenuHandler Create(DataTree dataEntryForm, XmlNode configuration) { DTMenuHandler h= null; if(configuration !=null) { XmlNode node = configuration.SelectSingleNode("menuHandler/dynamicloaderinfo"); if (node != null) { h = (DTMenuHandler) SIL.Utils.DynamicLoader.CreateObject(node); } } if(h==null) //no class specified, so just returned a generic DTMenuHandler h = new DTMenuHandler(); h.DtTree = dataEntryForm; return h; }
/// <summary> /// /// </summary> /// <param name="parent"></param> public override void Install(DataTree parent) { CheckDisposed(); base.Install(parent); MSADlgLauncher ctrl = (MSADlgLauncher)Control; this.Size = new System.Drawing.Size(208, 32); ctrl.Initialize((FdoCache)Mediator.PropertyTable.GetValue("cache"), Object, 1, // Maybe need a real flid? "InterlinearName", ContainingDataTree.PersistenceProvder, Mediator, "InterlinearName", XmlUtils.GetOptionalAttributeValue(m_configurationNode, "ws", "analysis")); // TODO: Get better default 'best ws'. MSADlglauncherView view = ctrl.MainControl as MSADlglauncherView; view.StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(Mediator); }
/// <summary/> public override void TestTearDown() { if (m_Slice != null) { m_Slice.Dispose(); m_Slice = null; } if (m_DataTree != null) { m_DataTree.Dispose(); m_DataTree = null; } if (m_Mediator != null) { m_Mediator.Dispose(); m_Mediator = null; } base.TestTearDown(); }
/// <summary> /// This needs to be a static method because typically the ghost slice has been disposed /// by the time it is called. /// /// Note that DataTree.AddAtomicNode either displays a layout of the object, or /// displays the ghost slice. If it displays a layout of the object, it adds /// to its input path first itself (the "obj" element), then the HVO of the object, /// then creates slices for the object. For ghost slice, it simply adds itself. /// Therefore, a slice created as part of a layout replacing a ghost slice will /// have a key matching the ghost slice's key, and followed by the ID of the new object. /// Next, anything in this layout will have the template used to display the object, /// and the particular part ref that invoked the part, then (for an interesting target) /// a slice node with editor 'string' or 'multistring' as appropriate. /// AddSeqNode is similar, except that it may display layouts of multiple objects. /// </summary> static void RestoreSelection(int ich, DataTree datatree, object[] key, int hvoNewObj, int flidObjProp, int flidStringProp, int ws) { // To be written. foreach (Slice slice in datatree.Controls) { if (!StartsWith(slice.Key, key)) continue; if (slice.Key.Length < key.Length + 2) continue; object nextKeyItem = slice.Key[key.Length]; // should be hvoNewObj if (!(nextKeyItem is int)) continue; if ((int)nextKeyItem != hvoNewObj) continue; XmlNode lastKeyNode = slice.Key[slice.Key.Length - 1] as XmlNode; if (lastKeyNode == null) continue; if (lastKeyNode.Name != "slice") continue; if (slice is StringSlice) { StringSlice ss = slice as StringSlice; if (ss.FieldId != flidStringProp) continue; if (ss.WritingSystemId != ws) continue; // For SelectAt to work, the rootbox must be constructed and visible. GetSliceReadyToFocus(ss); ss.SelectAt(ich); ss.Control.Focus(); break; } else if (slice is MultiStringSlice) { MultiStringSlice mss = slice as MultiStringSlice; if (mss.FieldId != flidStringProp) continue; // Enhance JohnT: add functions to MultiStringSlice and LabeledMultiStringControl // so we can check that it's displaying the right writing systems. // For SelectAt to work, the rootbox must be constructed and visible. GetSliceReadyToFocus(mss); mss.SelectAt(ws, ich); mss.Control.Focus(); break; } } }
public void CreateIndentedNodes_basic() { m_DataTree = new DataTree(); m_Slice = GenerateSlice(Cache, m_DataTree); // Data taken from a running Sena 3 var caller = CreateXmlElementFromOuterXmlOf("<part ref=\"AsLexemeForm\" label=\"Lexeme Form\" expansion=\"expanded\"><indent><part ref=\"IsAbstractBasic\" label=\"Is Abstract Form\" visibility=\"never\" /><!-- could use 'ifTrue' if we had it --><part ref=\"MorphTypeBasic\" visibility=\"ifdata\" /><part ref=\"PhoneEnvBasic\" visibility=\"ifdata\" /><part ref=\"StemNameForLexemeForm\" visibility=\"ifdata\" /></indent></part>"); var obj = Cache.ServiceLocator.GetInstance<IMoStemAllomorphFactory>().Create(); const int indent = 0; int insPos = 1; var path = GeneratePath(); var reuseMap = new ObjSeqHashMap(); // Data taken from a running Sena 3 var node = CreateXmlElementFromOuterXmlOf("<slice field=\"Form\" label=\"Form\" editor=\"multistring\" ws=\"all vernacular\" weight=\"light\" menu=\"mnuDataTree-LexemeForm\" contextMenu=\"mnuDataTree-LexemeFormContext\" spell=\"no\"><properties><bold value=\"on\" /><fontsize value=\"120%\" /></properties></slice>"); m_Slice.CreateIndentedNodes(caller, obj, indent, ref insPos, path, reuseMap, node); }
public override void Install(DataTree parent) { base.Install(parent); m_combo.Dock = DockStyle.Left; }
public void OwnedObjects() { m_dtree.Initialize(Cache, false, m_layouts, m_parts); m_dtree.ShowObject(m_entry, "OptSensesEty", null, m_entry, false); // With no etymology or senses, this view contains nothing at all. Assert.AreEqual(0, m_dtree.Controls.Count); m_parent.Close(); m_parent.Dispose(); m_parent = null; ILexSense sense1 = Cache.ServiceLocator.GetInstance<ILexSenseFactory>().Create(); m_entry.SensesOS.Add(sense1); ILexSense sense2 = Cache.ServiceLocator.GetInstance<ILexSenseFactory>().Create(); m_entry.SensesOS.Add(sense2); Cache.MainCacheAccessor.SetString(sense2.Hvo, LexSenseTags.kflidScientificName, TsStringUtils.MakeTss("blah blah", Cache.DefaultAnalWs)); m_parent = new Form(); m_dtree = new DataTree(); m_parent.Controls.Add(m_dtree); m_dtree.Initialize(Cache, false, m_layouts, m_parts); m_dtree.ShowObject(m_entry, "OptSensesEty", null, m_entry, false); // With two senses, we get a header slice, a gloss slice for // sense 1 (not optional), and both gloss and Scientific name // slices for sense 2. Assert.AreEqual(3, m_dtree.Controls.Count); //Assert.AreEqual("Senses", (m_dtree.Controls[0] as Slice).Label); Assert.AreEqual("Gloss", (m_dtree.Controls[0] as Slice).Label); Assert.AreEqual("Gloss", (m_dtree.Controls[1] as Slice).Label); Assert.AreEqual("ScientificName", (m_dtree.Controls[2] as Slice).Label); m_parent.Close(); m_parent.Dispose(); m_parent = null; ILexEtymology lm = Cache.ServiceLocator.GetInstance<ILexEtymologyFactory>().Create(); m_entry.EtymologyOA = lm; m_parent = new Form(); m_dtree = new DataTree(); m_parent.Controls.Add(m_dtree); m_dtree.Initialize(Cache, false, m_layouts, m_parts); m_dtree.ShowObject(m_entry, "OptSensesEty", null, m_entry, false); // Adding an etymology gets us just no more slices so far, // because it doesn't have a form or source Assert.AreEqual(3, m_dtree.Controls.Count); //Assert.AreEqual("Etymology", (m_dtree.Controls[3] as Slice).Label); m_parent.Close(); m_parent.Dispose(); m_parent = null; lm.Source = "source"; // Again set both because I'm not sure which it really // should be. lm.Form.VernacularDefaultWritingSystem = TsStringUtils.MakeTss("rubbish", Cache.DefaultVernWs); lm.Form.AnalysisDefaultWritingSystem = TsStringUtils.MakeTss("rubbish", Cache.DefaultAnalWs); m_parent = new Form(); m_dtree = new DataTree(); m_parent.Controls.Add(m_dtree); m_dtree.Initialize(Cache, false, m_layouts, m_parts); m_dtree.ShowObject(m_entry, "OptSensesEty", null, m_entry, false); // When the etymology has something we get two more. Assert.AreEqual(5, m_dtree.Controls.Count); Assert.AreEqual("Form", (m_dtree.Controls[3] as Slice).Label); Assert.AreEqual("Source", (m_dtree.Controls[4] as Slice).Label); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create DataTree and parent form /// </summary> /// ------------------------------------------------------------------------------------ public override void TestSetup() { base.TestSetup(); m_dtree = new DataTree(); m_parent = new Form(); m_parent.Controls.Add(m_dtree); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged /// resources; <c>false</c> to release only unmanaged resources. /// </param> /// ----------------------------------------------------------------------------------- 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 (m_dataEntryForm != null) { Controls.Remove(m_dataEntryForm); m_dataEntryForm.Dispose(); } if (m_cache != null) { m_cache.Dispose(); } if(components != null) { components.Dispose(); } } m_dataEntryForm = null; m_cache = null; base.Dispose(disposing); }
/// <summary> /// Called when the slice is first created, but also when it is /// "reused" (e.g. refresh or new target object) /// </summary> /// <param name="parent"></param> public override void Install(DataTree parent) { CheckDisposed(); base.Install(parent); UpdateDisplayFromDatabase(); Control.AccessibleName = Label; }
protected RecordEditView(DataTree dataEntryForm) { // This must be called before InitializeComponent() m_dataEntryForm = dataEntryForm; m_dataEntryForm.CurrentSliceChanged += m_dataEntryForm_CurrentSliceChanged; // This call is required by the Windows.Forms Form Designer. InitializeComponent(); AccNameDefault = "RecordEditView"; // default accessibility name }
public AutoDataTreeMenuHandler(DataTree dataEntryForm) { m_dataEntryForm = dataEntryForm; }
private void SetViewStylesheet(Control control, DataTree tc) { var rootSite = control as SimpleRootSite; if (rootSite != null && rootSite.StyleSheet == null) rootSite.StyleSheet = tc.StyleSheet; foreach (Control c in control.Controls) SetViewStylesheet(c, tc); }
public void Setup() { m_dtree = new DataTree(); m_parent = new Form(); m_parent.Controls.Add(m_dtree); }
public override void Install(DataTree parent) { base.Install(parent); // setup the visible writing systems for our control // (We should have called MakeRoot on our control by now) SetupWssToDisplay(); }
/// <summary> /// Called when the slice is first created, but also when it is /// "reused" (e.g. refresh or new target object) /// </summary> /// <param name="parent"></param> public override void Install(DataTree parent) { CheckDisposed(); base.Install(parent); UpdateDisplayFromDatabase(); //tc.AccessibilityObject.Name = this.Label; this.Control.AccessibilityObject.Name = this.Label; }
public override void Install(DataTree parent) { base.Install(parent); SplitCont.Panel2.SizeChanged += new EventHandler(SplitContPanel2_SizeChanged); }
/// <summary> /// /// </summary> /// <param name="parent"></param> public override void Install(DataTree parent) { CheckDisposed(); // Sometimes we get a spurious "out of memory" error while trying to create a handle for the // RootSite if its cache isn't set before we add it to its parent. RootSite rs = RootSite; rs.Cache = Cache; // JT: seems to actually cause a problem if we replace it with itself. RootSite probably needs a fix. if (rs.StyleSheet != parent.StyleSheet) rs.StyleSheet = parent.StyleSheet; base.Install(parent); rs.SetAccessibleName(this.Label); }
public void Collapse() { var obj = Cache.ServiceLocator.GetInstance<IMoStemAllomorphFactory>().Create(); m_DataTree = new DataTree(); m_Slice = GenerateSlice(Cache, m_DataTree); m_Slice.Key = GeneratePath().ToArray(); m_Slice.Object = obj; m_Mediator = GenerateMediator(); m_Slice.Mediator = m_Mediator; m_Slice.Collapse(); }
/// <summary></summary> public virtual void Install(DataTree parent) { CheckDisposed(); if (parent == null) // Parent == null || throw new InvalidOperationException("The slice '" + GetType().Name + "' must be placed in the Parent.Controls property before installing it."); SplitContainer sc = SplitCont; // prevents the controls of the new 'SplitContainer' being NAMELESS if (sc.Panel1.AccessibleName == null) sc.Panel1.AccessibleName = "Panel1"; if (sc.Panel2.AccessibleName == null) sc.Panel2.AccessibleName = "Panel2"; SliceTreeNode treeNode; bool isBeingReused = sc.Panel1.Controls.Count > 0; if (isBeingReused) { treeNode = (SliceTreeNode)sc.Panel1.Controls[0]; } else { // Make a standard SliceTreeNode now. treeNode = new SliceTreeNode(this); treeNode.SuspendLayout(); treeNode.Dock = DockStyle.Fill; sc.Panel1.Controls.Add(treeNode); sc.AccessibleName = "SplitContainer"; } if (!string.IsNullOrEmpty(Label)) { // Susanna wanted to try five, rather than the default of four // to see if wider and still invisble made it easier to work with. // It may end up being made visible in a light grey color, but then it would // go back to the default of four. // Being visible at four may be too overpowering, so we may have to // manually draw a thin line to give the user a que as to where the splitter bar is. // Then, if it gets to be visible, we will probably need to add a bit of padding between // the line and the main slice content, or its text will be connected to the line. sc.SplitterWidth = 5; // It was hard-coded to 40, but it isn't right for indented slices, // as they then can be shrunk so narrow as to completely cover up their label. sc.Panel1MinSize = (20 * (Indent + 1)) + 20; sc.Panel2MinSize = 0; // min size of right pane // This makes the splitter essentially invisible. sc.BackColor = Color.FromKnownColor(KnownColor.Window); //to make it invisible treeNode.MouseEnter += treeNode_MouseEnter; treeNode.MouseLeave += treeNode_MouseLeave; treeNode.MouseHover += treeNode_MouseEnter; } else { // SummarySlice is one of these kinds of Slices. //Debug.WriteLine("Slice gets no usable splitter: " + GetType().Name); sc.SplitterWidth = 1; sc.Panel1MinSize = LabelIndent(); sc.SplitterDistance = LabelIndent(); sc.IsSplitterFixed = true; // Just in case it was previously installed with a different label. treeNode.MouseEnter -= treeNode_MouseEnter; treeNode.MouseLeave -= treeNode_MouseLeave; treeNode.MouseHover -= treeNode_MouseEnter; } int newHeight; Control mainControl = Control; if (mainControl != null) { // Has SliceTreeNode and Control. // Set stylesheet on every view-based child control that doesn't already have one. SetViewStylesheet(mainControl, parent); mainControl.AccessibleName = string.IsNullOrEmpty(Label) ? "Slice_unknown" : Label; // By default the height of the slice comes from the height of the embedded // control. // Just store the new height for now, as actually settig it, will cause events, // and the slice has no parent yet, which will be bad for those event handlers. //this.Height = Math.Max(Control.Height, LabelHeight); newHeight = Math.Max(mainControl.Height, LabelHeight); mainControl.Dock = DockStyle.Fill; sc.FixedPanel = FixedPanel.Panel1; } else { // Has SliceTreeNode but no Control. // LexReferenceMultiSlice has no control, as of 12/30/2006. newHeight = LabelHeight; sc.Panel2Collapsed = true; sc.FixedPanel = FixedPanel.Panel2; } if (!isBeingReused) { parent.Controls.Add(this); // Parent will have to move it into the right place. parent.Slices.Add(this); } #if __MonoCS__ // FWNX-266 if (mainControl != null && mainControl.Visible == false) { // ensure Launcher Control is shown. mainControl.Visible = true; } #endif SetSplitPosition(); // Don'f fire off all those size changed event handlers, unless it is really needed. if (Height != newHeight) Height = newHeight; treeNode.ResumeLayout(false); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create the client windows and add correspnding stuff to the sidebar, View menu, /// etc. Subclasses must override this. /// </summary> /// ------------------------------------------------------------------------------------ public void InitAndShowClient() { CheckDisposed(); m_dataEntryForm = new DataTree(); SuspendLayout(); string partDirectory = Path.Combine(SIL.FieldWorks.Common.Utils.DirectoryFinder.FWCodeDirectory, @"Language Explorer\Configuration\Parts"); Dictionary<string, string[]> keyAttrs = new Dictionary<string, string[]>(); keyAttrs["layout"] = new string[] {"class", "type", "mode", "name" }; keyAttrs["group"] = new string[] {"label"}; keyAttrs["part"] = new string[] {"ref"}; Inventory layouts = new Inventory(new string[] {partDirectory}, "*Parts.xml", "/layoutInventory/*", keyAttrs); keyAttrs = new Dictionary<string, string[]>(); keyAttrs["part"] = new string[] {"id", "type", "mode"}; Inventory parts = new Inventory(new string[] {partDirectory}, "*Layouts.xml", "/PartInventory/*", keyAttrs); m_dataEntryForm.Initialize(m_cache, true, layouts, parts); m_dataEntryForm.Dock = System.Windows.Forms.DockStyle.Fill; Controls.Add(m_dataEntryForm); ResumeLayout(false); }
/// <summary> /// /// </summary> /// <param name="parent"></param> public override void Install(DataTree parent) { CheckDisposed(); base.Install(parent); AudioVisualLauncher ctrl = Control as AudioVisualLauncher; ctrl.Initialize( (FdoCache)Mediator.PropertyTable.GetValue("cache"), Media.MediaFileRA, CmFileTags.kflidInternalPath, "InternalPath", ContainingDataTree.PersistenceProvder, Mediator, "InternalPath", "user"); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged /// resources; <c>false</c> to release only unmanaged resources. /// </param> /// ----------------------------------------------------------------------------------- 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(); if (m_dataEntryForm != null) { m_dataEntryForm.CurrentSliceChanged -= m_dataEntryForm_CurrentSliceChanged; m_dataEntryForm.Dispose(); } if (!string.IsNullOrEmpty(m_titleField)) Cache.DomainDataByFlid.RemoveNotification(this); } m_dataEntryForm = null; base.Dispose(disposing); }