public void Dispose() { //TODO: implement this XControlContainer cCont = OuterScrlContr as XControlContainer; //remove all element inside the outer container if (cCont != null) { var controls = cCont.getControls(); foreach (var contr in controls) { contr.dispose(); } // FIXME: for fixing //var controls2 = cCont.getControls(); } if (MXDlgModelNameContainer != null) { try { OuterScrlContr.dispose(); } catch (System.Exception) { } try { (VerticalScrlBar as XControl).dispose(); } catch (System.Exception) { } try { (HorizontalScrlBar as XControl).dispose(); } catch (System.Exception) { } } }
public void CreateScrollableContainer(int _nPosX, int _nPosY, int _nWidth, int _nHeight, String sName) { try { // create a unique id by means of an own implementation... if (String.IsNullOrWhiteSpace(sName)) { sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLL_CONTAINER"); } else { sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName); } //XMultiServiceFactory _xMSF = OO.GetMultiServiceFactory(MXContext); XMultiComponentFactory _xMcf = OO.GetMultiComponentFactory(MXContext, true); #region Outer Container // create a UnoControlContainerModel. A thing which differs from other dialog-controls in many aspects // Position and size of the model have no effect, so we apply setPosSize() on it's view later. // Unlike a dialog-model the container-model can not have any control-models. // As an instance of a dialog-model it can have the property "Step"(among other things), // provided by service awt.UnoControlDialogElement, without actually supporting this service! // create a control model at the multi service factory of the dialog model... outerScrlContrModel = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER_Model, MXContext) as XControlModel; OuterScrlContr = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER, MXContext) as XControl; if (OuterScrlContr != null && outerScrlContrModel != null) { OuterScrlContr.setModel(outerScrlContrModel); } XMultiPropertySet xoScrlContMPSet = outerScrlContrModel as XMultiPropertySet; if (xoScrlContMPSet != null) { // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xoScrlContMPSet.setPropertyValues( new String[] { "Height", "Name", "PositionX", "PositionY", "State", "Width" }, Any.Get(new Object[] { 0, sName, 0, 0, ((short)0), 0, 0 })); } //add to the dialog XControlContainer xCntrCont = parentCnt as XControlContainer; if (xCntrCont != null) { xCntrCont.addControl(sName, OuterScrlContr as XControl); } #endregion #region Scroll bars //insert scroll bars HorizontalScrlBar = insertHorizontalScrollBar(this, _nPosX, _nPosY + _nHeight, _nWidth); VerticalScrlBar = insertVerticalScrollBar(this, _nPosX + _nWidth, _nPosY, _nHeight); #endregion #region Set Size of outer Container //make the outer container pos and size via the pos and size of the scroll bars if (HorizontalScrlBar is XWindow) { Rectangle hSBPos = ((XWindow)HorizontalScrlBar).getPosSize(); _width = hSBPos.Width; _posX = hSBPos.X; } if (VerticalScrlBar is XWindow) { Rectangle vSBPos = ((XWindow)VerticalScrlBar).getPosSize(); _height = vSBPos.Height; _posY = vSBPos.Y; } // Set the size of the surrounding container if (OuterScrlContr is XWindow) { ((XWindow)OuterScrlContr).setPosSize(PosX, PosY, Width, Height, PosSize.POSSIZE); ((XWindow)OuterScrlContr).addMouseListener(this); } #endregion #region inner Container // create a control model at the multi service factory of the dialog model... innerScrlContrModel = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER_Model, MXContext) as XControlModel; InnerScrlContr = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER, MXContext) as XControl; if (InnerScrlContr != null && innerScrlContrModel != null) { InnerScrlContr.setModel(innerScrlContrModel); } XMultiPropertySet xinnerScrlContMPSet = innerScrlContrModel as XMultiPropertySet; if (xinnerScrlContMPSet != null) { xinnerScrlContMPSet.setPropertyValues( new String[] { "Name", "State" }, Any.Get(new Object[] { sName + "_S", ((short)0) })); } //// FIXME: only for fixing //util.Debug.GetAllServicesOfObject(parentCnt); //Object oDialogModel = OO.GetMultiComponentFactory().createInstanceWithContext(OO.Services.AWT_CONTROL_DIALOG_MODEL, MXContext); //// The named container is used to insert the created controls into... //MXDlgModelNameContainer = (XNameContainer)oDialogModel; //System.Diagnostics.Debug.WriteLine("_________"); //util.Debug.GetAllServicesOfObject(MXDlgModelNameContainer); //// END //add inner container to the outer scroll container XControlContainer outerCntrCont = OuterScrlContr as XControlContainer; if (outerCntrCont != null) { outerCntrCont.addControl(sName + "_S", InnerScrlContr as XControl); InnerWidth = Width; InnerHeight = Height; // Set the size of the surrounding container if (InnerScrlContr is XWindow) { ((XWindow)InnerScrlContr).setPosSize(0, 0, InnerWidth, InnerHeight, PosSize.POSSIZE); ((XWindow)InnerScrlContr).addMouseListener(this); } } #endregion } catch (System.Exception) { } }