/// <summary> /// Adds a control element to the scrollable container. /// ATTENTION: The pos and size you have given to the control are getting lost! /// The position and the size have to be set after adding the control inside the container. /// The values of position and size are pixel based values. The position is relative to /// the top left corner of the container. /// </summary> /// <param id="cntrl">The XControll you want to add.</param> /// <param id="sName">The supposed id of the controll - will be changed if it is not unique!.</param> /// <param id="posX">The x position - pixel based value relative to the top left corner of the container.</param> /// <param id="posY">The y position - pixel based value relative to the top left corner of the container..</param> /// <param id="width">The width in pixel.</param> /// <param id="height">The height in pixel.</param> public XControl addElement(XControl cntrl, String sName, int posX, int posY, int width, int height) { //System.Diagnostics.Debug.WriteLine("added control: ____________________________"); //Debug.GetAllInterfacesOfObject(cntrl); //Debug.GetAllServicesOfObject(cntrl); //Debug.GetAllProperties(cntrl); if (cntrl != null && innerScrlContr != null) { if (innerScrlContr is XControlContainer) { ((XControlContainer)innerScrlContr).addControl(sName, cntrl); OoUtils.SetProperty(cntrl, "Name", sName); } if (cntrl is XWindow) { ((XWindow)cntrl).setPosSize(posX, posY, width, height, PosSize.POSSIZE); Rectangle contrPos = ((XWindow)cntrl).getPosSize(); if (innerWidth < (contrPos.X + contrPos.Width)) { innerWidth = contrPos.X + contrPos.Width; } if (innerHeight < (contrPos.Y + contrPos.Height)) { innerHeight = contrPos.Y + contrPos.Height; } } } return(cntrl); }
public ResizingContainer(int width, int height, string sName) { #region inner Container // create a control model at the multi service factory of the dialog model... innerScrlContrModel = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER_Model) as XControlModel; innerScrlContr = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER) 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, ((short)0) })); } innerWidth = width; innerHeight = height; // Set the size of the surrounding container if (innerScrlContr is XWindow) { ((XWindow)innerScrlContr).setPosSize(0, 0, innerWidth, innerHeight, PosSize.POSSIZE); } #endregion }
public XControl AddElementToTheEndAndAdoptTheSize(XControl cntrl, String sName, int posX, int topMargin, int width, int height) { //get all elements in the container if (cntrl != null) { if (InnerScrlContr != null && InnerScrlContr is XControlContainer) { XControl[] ctrls = ((XControlContainer)InnerScrlContr).getControls(); Rectangle p = new Rectangle(); p.X = posX; if (ctrls != null && ctrls.Length > 0) { foreach (var item in ctrls) { if (item != null && item is XWindow) { Rectangle pos = ((XWindow)item).getPosSize(); p.Width = Math.Max(p.Width, pos.X + pos.Width); p.Height = Math.Max(p.Height, pos.Y + pos.Height); } } } return(AddElementAndAdoptTheSize(cntrl, sName, posX, p.Height + topMargin, width, height)); } } return(cntrl); }
/// <summary> /// Copies the text. /// </summary> /// <param name="xDialog">The x dialog.</param> /// <param name="aEvent">A event object.</param> public void CopyText(XDialog xDialog, Object aEvent) { XControlContainer xControlContainer = (XControlContainer)xDialog; String aTextPropertyStr = "Text"; String aText = ""; XControl xTextField1Control = xControlContainer.getControl("TextField1"); XControlModel xControlModel1 = xTextField1Control.getModel(); XPropertySet xPropertySet1 = (XPropertySet)xControlModel1; try { aText = (String)xPropertySet1.getPropertyValue(aTextPropertyStr).Value; } catch (unoidl.com.sun.star.uno.Exception e) { Console.WriteLine("copyText caught exception! " + e); } XControl xTextField2Control = xControlContainer.getControl("TextField2"); XControlModel xControlModel2 = xTextField2Control.getModel(); XPropertySet xPropertySet2 = (XPropertySet)xControlModel2; try { xPropertySet2.setPropertyValue(aTextPropertyStr, new uno.Any(aText)); } catch (unoidl.com.sun.star.uno.Exception e) { Console.WriteLine("copyText caught exception! " + e); } global::System.Windows.Forms.MessageBox.Show("DialogComponent", "copyText() called"); }
public static XPropertySet GetPropertysetOfControl(XControl xCtr) { if (xCtr != null) { XControlModel model = xCtr.getModel(); if (model != null && model is XPropertySet) { return(model as XPropertySet); } } return(null); }
/// <summary> /// Gets the name of a control. /// </summary> /// <param name="xCtr">The XControl.</param> /// <returns>the name or the empty String</returns> public static String GetNameOfControl(XControl xCtr) { if (xCtr != null) { Object nameObj = GetProperty(xCtr, "Name"); if (nameObj != null && nameObj is String) { return(nameObj.ToString()); } } return(String.Empty); }
public XControl AddElementAndAdoptTheSize(XControl cntrl, String sName, int posX, int posY, int width, int height) { Size s = new Size(width, height); if (cntrl is XLayoutConstrains) { s = ((XLayoutConstrains)cntrl).calcAdjustedSize(s); s.Width = Math.Max(width, s.Width); s.Height = Math.Max(height, s.Height); } return(AddElement(cntrl, sName, posX, posY, s.Width, s.Height)); }
/// <summary> /// Adds a control element to the scrollable container. /// ATTENTION: The pos and size you have given to the control are getting lost! /// The position and the size have to be set after adding the control inside the container. /// The values of position and size are pixel based values. The position is relative to /// the top left corner of the container. /// </summary> /// <param id="cntrl">The XControll you want to add.</param> /// <param id="sName">The supposed id of the controll - will be changed if it is not unique!.</param> /// <param id="posX">The x position - pixel based value relative to the top left corner of the container.</param> /// <param id="posY">The y position - pixel based value relative to the top left corner of the container..</param> /// <param id="width">The width in pixel.</param> /// <param id="height">The height in pixel.</param> public XControl AddElement(XControl cntrl, String sName, int posX, int posY, int width, int height) { // create a unique id by means of an own implementation... if (String.IsNullOrWhiteSpace(sName)) { sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLLABLE_CONTROL_ENTRY"); } else { sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName); } //System.Diagnostics.Debug.WriteLine("added control: ____________________________"); //Debug.GetAllInterfacesOfObject(cntrl); //Debug.GetAllServicesOfObject(cntrl); //Debug.GetAllProperties(cntrl); if (cntrl != null && InnerScrlContr != null) { if (InnerScrlContr is XControlContainer) { ((XControlContainer)InnerScrlContr).addControl(sName, cntrl); OoUtils.SetProperty(cntrl, "Name", sName); } if (cntrl is XWindow) { ((XWindow)cntrl).setPosSize(posX, posY, width, height, PosSize.POSSIZE); Rectangle contrPos = ((XWindow)cntrl).getPosSize(); if (InnerWidth < (contrPos.X + contrPos.Width)) { InnerWidth = contrPos.X + contrPos.Width; } if (InnerHeight < (contrPos.Y + contrPos.Height)) { InnerHeight = contrPos.Y + contrPos.Height; } } } return(cntrl); }
/// <summary> /// Inserts the scroll bar. /// </summary> /// <param id="_nPosX">The X position.</param> /// <param id="_nPosY">The Y position.</param> /// <param id="_nHeight">Height of the Scrollbar.</param> /// <param id="_nWidth">Width of the Scrollbar.</param> /// <param id="sName">Name of the XControl - can be empty.</param> private XScrollBar insertScrollBar(XAdjustmentListener _xAdjustmentListener, int _nPosX, int _nPosY, int _nHeight, int _nWidth, int orientation = unoidl.com.sun.star.awt.ScrollBarOrientation.VERTICAL, String sName = "", bool liveScroll = true) { try { // create a unique id by means of an own implementation... if (String.IsNullOrWhiteSpace(sName)) { sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLLBAR"); } else { sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName); } // create a control model at the multiservicefactory of the dialog model... Object oSBModel = parentMCF.createInstanceWithContext(OO.Services.AWT_CONTROL_SCROLLBAR_MODEL, _mXContext); XMultiPropertySet xRBMPSet = (XMultiPropertySet)oSBModel; // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xRBMPSet.setPropertyValues( new String[] { "BlockIncrement", "Height", "LineIncrement", "LiveScroll", "Name", "Orientation", "PositionX", "PositionY", "Width" }, Any.Get(new Object[] { 30, _nHeight, 10, liveScroll, sName, orientation, _nPosX, _nPosY, _nWidth })); // add the model to the NameContainer of the dialog model MXDlgModelNameContainer.insertByName(sName, Any.Get(oSBModel)); XControl xSBControl = (parentCnt != null) ? parentCnt.getControl(sName) : null; if (xSBControl != null && xSBControl is XScrollBar && _xAdjustmentListener != null) { ((XScrollBar)xSBControl).addAdjustmentListener(_xAdjustmentListener); } return(xSBControl as XScrollBar); } catch { } return(null); }
public XControl addElementToTheEndAndAdoptTheSize(XControl cntrl, String sName, int posX, int topMargin) { return addElementToTheEndAndAdoptTheSize(cntrl, sName, posX, topMargin, innerWidth - posX); }
public XControl AddElementToTheEndAndAdoptTheSize(XControl cntrl, String sName, int posX, int topMargin, int width) { return(AddElementToTheEndAndAdoptTheSize(cntrl, sName, posX, topMargin, width, 10)); }
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) { } }
public XControl addElementToTheEndAndAdoptTheSize(XControl cntrl, String sName, int posX, int topMargin) { return(addElementToTheEndAndAdoptTheSize(cntrl, sName, posX, topMargin, innerWidth - posX)); }
public XControl AddElementTryToKeeptheWidth(XControl cntrl, String sName, int posX, int posY, int width) { return AddElementAndAdoptTheSize(cntrl, sName, posX, posY, width, 15); }
public XControl AddElementTryToKeeptheHeight(XControl cntrl, String sName, int posX, int posY, int height) { return AddElementAndAdoptTheSize(cntrl, sName, posX, posY, Width - posX, height); }
public XControl AddElementToTheEndAndAdoptTheSize(XControl cntrl, String sName, int posX, int topMargin, int width, int height) { //get all elements in the container if (cntrl != null) { if (InnerScrlContr != null && InnerScrlContr is XControlContainer) { XControl[] ctrls = ((XControlContainer)InnerScrlContr).getControls(); Rectangle p = new Rectangle(); p.X = posX; if (ctrls != null && ctrls.Length > 0) { foreach (var item in ctrls) { if (item != null && item is XWindow) { Rectangle pos = ((XWindow)item).getPosSize(); p.Width = Math.Max(p.Width, pos.X + pos.Width); p.Height = Math.Max(p.Height, pos.Y + pos.Height); } } } return AddElementAndAdoptTheSize(cntrl, sName, posX, p.Height + topMargin, width, height); } } return cntrl; }
public XControl AddElementToTheEndAndAdoptTheSize(XControl cntrl, String sName, int posX, int topMargin, int width) { return AddElementToTheEndAndAdoptTheSize(cntrl, sName, posX, topMargin, width, 10); }
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) { } }
/// <summary> /// Adds a control element to the scrollable container. /// ATTENTION: The pos and size you have given to the control are getting lost! /// The position and the size have to be set after adding the control inside the container. /// The values of position and size are pixel based values. The position is relative to /// the top left corner of the container. /// </summary> /// <param id="cntrl">The XControll you want to add.</param> /// <param id="sName">The supposed id of the controll - will be changed if it is not unique!.</param> /// <param id="posX">The x position - pixel based value relative to the top left corner of the container.</param> /// <param id="posY">The y position - pixel based value relative to the top left corner of the container..</param> /// <param id="width">The width in pixel.</param> /// <param id="height">The height in pixel.</param> public XControl addElement(XControl cntrl, String sName, int posX, int posY, int width, int height) { //System.Diagnostics.Debug.WriteLine("added control: ____________________________"); //Debug.GetAllInterfacesOfObject(cntrl); //Debug.GetAllServicesOfObject(cntrl); //Debug.GetAllProperties(cntrl); if (cntrl != null && innerScrlContr != null) { if (innerScrlContr is XControlContainer) { ((XControlContainer)innerScrlContr).addControl(sName, cntrl); OoUtils.SetProperty(cntrl, "Name", sName); } if (cntrl is XWindow) { ((XWindow)cntrl).setPosSize(posX, posY, width, height, PosSize.POSSIZE); Rectangle contrPos = ((XWindow)cntrl).getPosSize(); if (innerWidth < (contrPos.X + contrPos.Width)) innerWidth = contrPos.X + contrPos.Width; if (innerHeight < (contrPos.Y + contrPos.Height)) innerHeight = contrPos.Y + contrPos.Height; } } return cntrl; }
public XControl addElementTryToKeeptheHeight(XControl cntrl, String sName, int posX, int posY, int height) { return(addElementAndAdoptTheSize(cntrl, sName, posX, posY, innerWidth - posX, height)); }
public XControl AddElementTryToKeeptheWidth(XControl cntrl, String sName, int posX, int posY, int width) { return(AddElementAndAdoptTheSize(cntrl, sName, posX, posY, width, 15)); }
public XControl AddElementAndAdoptTheSize(XControl cntrl, String sName, int posX, int posY) { return(AddElementTryToKeeptheWidth(cntrl, sName, posX, posY, Width - posX)); }
/// <summary> /// Inserts a fixed text label. /// Properties: Height, Name, PositionX, PositionY, Step, TabIndex, Tag, Width, Align, BackgroundColor, Border, BorderColor, Enabled, FontDescriptor, FontEmphasisMark, FontRelief, HelpText, HelpURL, Label, MultiLine, Printable, TextColor, TextLineColor, VerticalAlign /// </summary> /// <param name="name">The base name of the element - will be set to a unique one by this function.</param> /// <param name="text">The text that should be insert.</param> /// <param name="_nPosX">The x position of the element.</param> /// <param name="_nPosY">The y posistion of the elemnt.</param> /// <param name="_nWidth">The width of the element.</param> /// <param name="_nHeight">The Height of the element.</param> /// <param name="_nStep">The step index.</param> /// <param name="_xMouseListener">A mouse listener.</param> /// <returns>XFixedText object</returns> public virtual XFixedText InsertFixedLabel(String text, int _nPosX, int _nPosY, int _nWidth, int _nHeight, int _nStep, XMouseListener _xMouseListener, String sName = "") { XFixedText xFixedText = null; try { // create a unique name by means of an own implementation... if (String.IsNullOrWhiteSpace(sName)) { sName = createUniqueName(MXDlgModelNameContainer, "TEXT_FIXED"); } else { sName = createUniqueName(MXDlgModelNameContainer, sName); } // create a controlmodel at the multiservicefactory of the dialog model... Object oFTModel = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_TEXT_FIXED_MODEL, MXContext); XMultiPropertySet xFTModelMPSet = (XMultiPropertySet)oFTModel; // Set the properties at the model - keep in mind to pass the property names in alphabetical order! String[] valueNames = new String[] { "Height", "Name", "PositionX", "PositionY", "Step", "Width", "Label" }; var valueVals = Any.Get(new Object[] { _nHeight, sName, _nPosX, _nPosY, _nStep, _nWidth, text }); xFTModelMPSet.setPropertyValues( valueNames, valueVals ); // add the model to the NameContainer of the dialog model MXDlgModelNameContainer.insertByName(sName, Any.Get(oFTModel)); var element = MXDlgModelNameContainer.getByName(sName).Value; if (element != null) { OoUtils.SetProperty(element, "PositionX", _nPosX); OoUtils.SetProperty(element, "PositionY", _nPosY); OoUtils.SetProperty(element, "Width", _nWidth); //if (element is XControl) //{ // ((XControl)element).getModel(); //} //if (element is XMultiPropertySet) //{ // ((XMultiPropertySet)element).setPropertyValues(valueNames, valueVals); //} } // reference the control by the Name XControl xFTControl = GetControlByName(sName); xFixedText = (XFixedText)xFTControl; if (_xMouseListener != null) { XWindow xWindow = (XWindow)xFTControl; xWindow.addMouseListener(_xMouseListener); } } catch (unoidl.com.sun.star.uno.Exception ex) { System.Diagnostics.Debug.WriteLine("uno.Exception:"); System.Diagnostics.Debug.WriteLine(ex); } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine("System.Exception:"); System.Diagnostics.Debug.WriteLine(ex); } return(xFixedText); }
/// <summary> /// Gets the name of a control. /// </summary> /// <param name="xCtr">The XControl.</param> /// <returns>the name or the empty String</returns> public static String GetNameOfControl(XControl xCtr) { if (xCtr != null) { Object nameObj = GetProperty(xCtr, "Name"); if (nameObj != null && nameObj is String) return nameObj.ToString(); } return String.Empty; }
public static XControlContainer createDialog(XMultiComponentFactory xMultiComponentFactory, XComponentContext xContext, int posX, int posY, int width, int height, string title ) { //dialog model Object oDialogModel = xMultiComponentFactory.createInstanceWithContext( "com.sun.star.awt.UnoControlDialogModel", xContext); XPropertySet xPSetDialog = (XPropertySet)oDialogModel; xPSetDialog.setPropertyValue("PositionX", Any.Get(posX)); xPSetDialog.setPropertyValue("PositionY", Any.Get(posY)); xPSetDialog.setPropertyValue("Width", Any.Get(width)); xPSetDialog.setPropertyValue("Height", Any.Get(height)); xPSetDialog.setPropertyValue("Title", Any.Get(title)); // get service manager from dialog model XMultiServiceFactory MXMsfDialogModel = (XMultiServiceFactory)oDialogModel; // dialog control model Object oUnoDialog = xMultiComponentFactory.createInstanceWithContext( "com.sun.star.awt.UnoControlDialog", xContext); XControl MXDialogControl = (XControl)oUnoDialog; XControlModel xControlModel = (XControlModel)oDialogModel; MXDialogControl.setModel(xControlModel); XToolkit xToolkit = (XToolkit)xMultiComponentFactory .createInstanceWithContext("com.sun.star.awt.Toolkit", xContext); WindowDescriptor aDescriptor = new WindowDescriptor(); aDescriptor.Type = WindowClass.TOP; aDescriptor.WindowServiceName = ""; aDescriptor.ParentIndex = -1; aDescriptor.Parent = xToolkit.getDesktopWindow(); aDescriptor.Bounds = new Rectangle(100, 200, 300, 400); aDescriptor.WindowAttributes = WindowAttribute.BORDER | WindowAttribute.MOVEABLE | WindowAttribute.SIZEABLE | WindowAttribute.CLOSEABLE; XWindowPeer xPeer = xToolkit.createWindow(aDescriptor); XWindow xWindow = (XWindow)xPeer; xWindow.setVisible(false); MXDialogControl.createPeer(xToolkit, xPeer); // execute the dialog XDialog xDialog = (XDialog)oUnoDialog; xDialog.execute(); // dispose the dialog XComponent xComponent = (XComponent)oUnoDialog; xComponent.dispose(); return(oUnoDialog as XControlContainer); }
public override void ExecuteResult(ControllerContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (String.IsNullOrEmpty(this.ViewName)) { ViewName = context.RouteData.GetRequiredString("action"); } string id = this.ControlId ?? "ID_" + Guid.NewGuid().ToString().Replace("-", ""); string ct = this.ContainerId ?? "Ext.getBody()"; ViewDataDictionary dict = new ViewDataDictionary(ViewData); ViewEngineResult result = null; if (View == null) { result = this.ViewEngineCollection.FindPartialView(context, this.ViewName); //result = this.FindView(context); View = result.View; } string path = ((WebFormView)View).ViewPath; ViewContext viewContext = new ViewContext(context, View, ViewData, TempData, context.HttpContext.Response.Output); PartialViewPage pageHolder = new PartialViewPage { ViewData = dict, ViewContext = viewContext }; var curRM = HttpContext.Current.Items[typeof(ResourceManager)]; HttpContext.Current.Items[typeof(ResourceManager)] = null; ResourceManager rm = new ResourceManager(); rm.RenderScripts = ResourceLocationType.None; rm.RenderStyles = ResourceLocationType.None; rm.IDMode = this.IDMode; pageHolder.Controls.Add(rm); ViewUserControl uc = (ViewUserControl)pageHolder.LoadControl(path); uc.ID = id + "_UC"; uc.ViewData = ViewData; XControl controlToRender = null; if (this.ControlToRender.IsEmpty() && !this.SingleControl) { Panel p; if (this.PanelConfig != null) { p = new Panel(this.PanelConfig); p.ID = id; p.IDMode = this.IDMode; } else { p = new Panel { ID = id, IDMode = this.IDMode, Border = false, Header = false }; } pageHolder.Controls.Add(p); p.ContentControls.Add(uc); controlToRender = p; } else { pageHolder.Controls.Add(uc); XControl c = null; if (this.SingleControl) { c = Ext.Net.Utilities.ControlUtils.FindControl <XControl>(uc); } else { c = Ext.Net.Utilities.ControlUtils.FindControl <XControl>(pageHolder, this.ControlToRender); } if (c == null) { if (this.SingleControl) { throw new Exception("Cannot find the Ext.Net control in the view"); } else { throw new Exception("Cannot find the control with ID=" + this.ControlToRender); } } controlToRender = c; if (controlToRender.IDMode == IDMode.Inherit) { controlToRender.IDMode = this.IDMode; } } pageHolder.InitHelpers(); string script = controlToRender.ToScript(this.RenderMode, ct, true); if (X.IsAjaxRequest) { script = "<Ext.Net.Direct.Response>" + script + "</Ext.Net.Direct.Response>"; } else if (this.WrapByScriptTag) { script = "<script type=\"text/javascript\">" + script + "</script>"; } IDisposable disposable = View as IDisposable; if (disposable != null) { disposable.Dispose(); } HttpContext.Current.Items[typeof(ResourceManager)] = curRM; context.HttpContext.Response.Write(script); }
public XForm(XmlElement node) : base(node) { XControl obj; foreach (XmlElement cn in node.GetElementsByTagName("XControl")) { obj = new XControl(cn); obj.parent = this; childsdic.Add(obj.name, obj); if (!obj.RawAttrs.ContainsKey("Parent")) childs.Add(obj); } foreach (XControl ctl in childsdic.Values) { string par; if (ctl.RawAttrs.TryGetValue("Parent", out par)) { obj = childsdic[par]; ctl.parent = obj; obj.childs.Add(ctl); } } foreach (XControl ctl in childsdic.Values) { try { if ("100".Equals(ctl.RawAttrs["ControlType"]) && (!"124".Equals(ctl.parent.RawAttrs["ControlType"]))) { obj = (XControl)ctl.parent; obj.childs.Remove(ctl); ctl.parent = obj.parent; obj.parent.childs.Add(ctl); } } catch (KeyNotFoundException) { } } }
public XControl AddElementAndAdoptTheSize(XControl cntrl, String sName, int posX, int posY) { return AddElementTryToKeeptheWidth(cntrl, sName, posX, posY, Width - posX); }
public ResizingContainer(int width, int height, string sName) { #region inner Container // create a control model at the multi service factory of the dialog model... innerScrlContrModel = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER_Model) as XControlModel; innerScrlContr = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER) 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 , ((short)0) })); } innerWidth = width; innerHeight = height; // Set the size of the surrounding container if (innerScrlContr is XWindow) { ((XWindow)innerScrlContr).setPosSize(0, 0, innerWidth, innerHeight, PosSize.POSSIZE); } #endregion }
public XTextComponent InsertEditField(String defaultText, int _nPosX, int _nPosY, int _nWidth, int _nHeight, String echoChar, XTextListener _xTextListener, XFocusListener _xFocusListener, XKeyListener _xKeyListener, String sName = "") { XTextComponent xTextComponent = null; try { // create a unique name by means of an own implementation... if (String.IsNullOrWhiteSpace(sName)) { sName = createUniqueName(MXDlgModelNameContainer, "EDIT"); } else { sName = createUniqueName(MXDlgModelNameContainer, sName); } // create a controlmodel at the multiservicefactory of the dialog model... Object oTFModel = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_EDIT_MODEL, MXContext); XMultiPropertySet xTFModelMPSet = (XMultiPropertySet)oTFModel; // Set the properties at the model - keep in mind to pass the property names in alphabetical order! xTFModelMPSet.setPropertyValues( new String[] { "Height", "Name", "PositionX", "PositionY", "Text", "Width" }, Any.Get(new Object[] { _nHeight, sName, _nPosX, _nPosY, defaultText, _nWidth })); // The controlmodel is not really available until inserted to the Dialog container MXDlgModelNameContainer.insertByName(sName, Any.Get(oTFModel)); if (!echoChar.Equals(String.Empty)) { XPropertySet xTFModelPSet = (XPropertySet)oTFModel; // The following property may also be set with XMultiPropertySet but we // use the XPropertySet interface merely for reasons of demonstration xTFModelPSet.setPropertyValue("EchoChar", Any.Get((short)echoChar.ToCharArray(0, 1)[0])); } if (_xFocusListener != null || _xTextListener != null || _xKeyListener != null) { XControl xTFControl = GetControlByName(sName); // add a textlistener that is notified on each change of the controlvalue... xTextComponent = (XTextComponent)xTFControl; XWindow xTFWindow = (XWindow)xTFControl; if (_xFocusListener != null) { xTFWindow.addFocusListener(_xFocusListener); } if (_xTextListener != null) { xTextComponent.addTextListener(_xTextListener); } if (_xKeyListener != null) { xTFWindow.addKeyListener(_xKeyListener); } } } catch (unoidl.com.sun.star.uno.Exception ex) { System.Diagnostics.Debug.WriteLine("uno.Exception:"); System.Diagnostics.Debug.WriteLine(ex); } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine("System.Exception:"); System.Diagnostics.Debug.WriteLine(ex); } return(xTextComponent); }
public XControl AddElementAndAdoptTheSize(XControl cntrl, String sName, int posX, int posY, int width, int height) { Size s = new Size(width, height); if (cntrl is XLayoutConstrains) { s = ((XLayoutConstrains)cntrl).calcAdjustedSize(s); s.Width = Math.Max(width, s.Width); s.Height = Math.Max(height, s.Height); } return AddElement(cntrl, sName, posX, posY, s.Width, s.Height); }
public static XPropertySet GetPropertysetOfControl(XControl xCtr){ if (xCtr != null) { XControlModel model =xCtr.getModel(); if (model != null && model is XPropertySet) { return model as XPropertySet; } } return null; }
/// <summary> /// Adds a control element to the scrollable container. /// ATTENTION: The pos and size you have given to the control are getting lost! /// The position and the size have to be set after adding the control inside the container. /// The values of position and size are pixel based values. The position is relative to /// the top left corner of the container. /// </summary> /// <param id="cntrl">The XControll you want to add.</param> /// <param id="sName">The supposed id of the controll - will be changed if it is not unique!.</param> /// <param id="posX">The x position - pixel based value relative to the top left corner of the container.</param> /// <param id="posY">The y position - pixel based value relative to the top left corner of the container..</param> /// <param id="width">The width in pixel.</param> /// <param id="height">The height in pixel.</param> public XControl AddElement(XControl cntrl, String sName, int posX, int posY, int width, int height) { // create a unique id by means of an own implementation... if (String.IsNullOrWhiteSpace(sName)) sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLLABLE_CONTROL_ENTRY"); else sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName); //System.Diagnostics.Debug.WriteLine("added control: ____________________________"); //Debug.GetAllInterfacesOfObject(cntrl); //Debug.GetAllServicesOfObject(cntrl); //Debug.GetAllProperties(cntrl); if (cntrl != null && InnerScrlContr != null) { if (InnerScrlContr is XControlContainer) { ((XControlContainer)InnerScrlContr).addControl(sName, cntrl); OoUtils.SetProperty(cntrl, "Name", sName); } if (cntrl is XWindow) { ((XWindow)cntrl).setPosSize(posX, posY, width, height, PosSize.POSSIZE); Rectangle contrPos = ((XWindow)cntrl).getPosSize(); if (InnerWidth < (contrPos.X + contrPos.Width)) InnerWidth = contrPos.X + contrPos.Width; if (InnerHeight < (contrPos.Y + contrPos.Height)) InnerHeight = contrPos.Y + contrPos.Height; } } return cntrl; }