Devexpress pivotgrid Customization CustomizationFormStyle - forms

I show fields in customization form. I choose Excel2007 as CustomizationFormStyle but I would like to show just Filter area. I want Column, Row and Data area to be invisible.
How can I manage this?
pivotGridControl1.OptionsCustomization.CustomizationFormStyle = DevExpress.XtraPivotGrid.Customization.CustomizationFormStyle.Excel2007;
pivotGridControl1.OptionsCustomization.CustomizationFormLayout = CustomizationFormLayout.BottomPanelOnly1by4;
pivotGridControl1.OptionsCustomization.CustomizationFormAllowedLayouts = CustomizationFormAllowedLayouts.BottomPanelOnly1by4;

You need to use PivotGridControl.ShowingCustomizationForm event and PivotGridControl.ShowCustomizationForm event. In PivotGridControl.ShowingCustomizationForm event you need to get CustomizationForm object from CustomizationFormShowingEventArgs.CustomizationForm property and use this object in PivotGridControl.ShowCustomizationForm event to customize the customization form. To get the filter area and other area objects, you need to use CustomizationForm.BottomPanel property and its GetAreaLabel, GetAreaIcon and GetAreaList methods.
Here is example:
private void pivotGridControl1_ShowingCustomizationForm(object sender, CustomizationFormShowingEventArgs e)
{
_customizationForm = e.CustomizationForm as CustomizationForm;
}
private void pivotGridControl1_ShowCustomizationForm(object sender, EventArgs e)
{
var bottomPanel = _customizationForm.BottomPanel as ExcelCustomizationFormBottomPanel;
var areas = new PivotArea[] { PivotArea.ColumnArea, PivotArea.RowArea, PivotArea.DataArea };
foreach (var area in areas)
{
bottomPanel.GetAreaLabel(area).Hide();
bottomPanel.GetAreaIcon(area).Hide();
bottomPanel.GetAreaList(area).Hide();
}
var filterAreaList = bottomPanel.GetAreaList(PivotArea.FilterArea);
var dataAreaList = bottomPanel.GetAreaList(PivotArea.DataArea);
filterAreaList.Height = dataAreaList.Bottom - filterAreaList.Top;
}

Related

Calling C# click event without actually clicking the button not working

I have below code written inside C# Form application where I am trying to get x,y and z co-ordinates from Leap Motion device.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//controller.EventContext = WindowsFormsSynchronizationContext.Current;
button1.Click += new EventHandler(button1_Click);
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
// Initialize the Controller object which connects to the Leap motion service
// and captures the hand tracking data
Controller controller = new Controller();
//Get the most recent tracking data using the Frame object
Frame frame = controller.Frame();
for (int h = 0; h < frame.Hands.Count; h++)
{
// Initialize the Hand in the given frame
Hand leapHand = frame.Hands[h];
// Get the "Pointer" finger of current hand which refers to where a person is pointing
Finger leapFinger = leapHand.Fingers[1];
// Prepare a vector which will store the co-ordinate values of the tip of the pointer
Vector currentPosition = leapFinger.StabilizedTipPosition;
textBox1.Text = Convert.ToString(currentPosition.x);
textBox2.Text = Convert.ToString(currentPosition.y);
textBox3.Text = Convert.ToString(currentPosition.z);
}
}
}
However, I need to explicitly click the button1 to display.
Any idea what's wrong ?
Here is an overly simple example of one way to do it. I'm not saying it's the best way, but you should be able to modify this sample code with your code.
In this example, there is a simple "HelloWorld" method that is called when the form is initialized as well as whenever you press the button. Let me know if this gets you close to what you're after.
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
button1.Click += new EventHandler(button1_Click);
HelloWorldTest();
}
private void button1_Click(object sender, EventArgs e)
{
HelloWorldTest();
}
private void HelloWorldTest()
{
MessageBox.Show("Hello World!");
}
}
}
For what it's worth, I didn't use your code because I don't have the Leap libraries installed and if there was a typo, I wouldn't be much help to resolve it. Nonetheless, hopefully it gets you going down the right path.

It is possible to issue java.lang.reflect.Field to javafx.scene.control.TextField?

It is possible to issue java.lang.reflect.Field to javafx.scene.control.TextField?
For example:
Field[] nodes;
nodes = clase.getDeclaredFields();
for (Field n : nodes)
if (n.getType().getSimpleName().equals("TextField"))
((TextField)((Object) n)).setText("Text");
If you want to modify the TextFields, you need to retrieve the value from those fields (and cast this value to TextField).
The following example should demonstrate the approach:
private TextField t1 = new TextField();
private TextField t2 = new TextField();
#Override
public void start(Stage primaryStage) {
Button btn = new Button("Say 'Hello World'");
btn.setOnAction((ActionEvent event) -> {
Object object = this;
Class clazz = object.getClass();
for (Field field : clazz.getDeclaredFields()) {
if (field.getType().getName().equals("javafx.scene.control.TextField")) {
try {
// get field value here
TextField textField = (TextField) field.get(object);
if (textField != null) {
textField.setText("Hello World");
}
} catch (IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(ReflectTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
VBox root = new VBox();
root.getChildren().addAll(btn, t1, t2);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
Reflection is probably a really bad approach to this. Among many problems is that you make the functionality dependent on how the code is written. Specifically, you assume that each text field is stored in a specific instance field in some class. If you change the implementation, e.g. so that you keep the text fields in a data structure instead of maintaining references to them yourself, then your functionality will break. It is bad practice to write code that is so tightly coupled to the actual implementation of the code, for obvious reasons.
One better approach would simply to be to put all the text fields in a list (or other data structure), so you can do whatever you need with them easily. E.g.
public class MyForm {
private GridPane view ;
private String[] messages = {"First name:", "Last name", "Email"} ;
private List<TextField> textFields ;
public MyForm {
view = new GridPane();
textFields = new ArrayList<>();
for (int r = 0; r < messages.length ; r++) {
view.addRow(r, new Label(messages[r]), createTextField(messages[r]));
}
}
private TextField createTextField(String text) {
TextField textField = new TextField();
textField.setPromptText(text);
textFields.add(textField);
return textField ;
}
public void processTextFields() {
textField.forEach(tf -> tf.setText("Hello"));
}
}
Another approach would be to use a CSS lookup. If myForm is some node that is an ancestor of all the text fields:
myForm.lookupAll(".text-field").forEach(node -> {
TextField textField = (TextField)node ;
textField.setText("Hello");
});
but note that CSS lookups will not work until after CSS has been applied (by default, this means after the scene has been rendered for the first time).
Another way, if all the text fields are all contained in a single direct parent (such as the grid pane in the first example), would be to iterate through the child nodes and filter the text fields:
textFieldParentNode.getChildrenUnmodifiable().stream()
.filter(TextField.class::isInstance)
.map(TextField.class::cast)
.forEach(tf -> tf.setText("Hello"));

Disabling a button in page editor (ribbon) for field-type image

I have used a custom image component which has image field-type ribbon when editing in page editor.
In core db, there are 3 webedit buttons for image which I need to hide/disable:
path: /sitecore/system/Field types/Simple Types/Image/WebEdit Buttons/
buttons:
1. Choose Image
2. Image Properties
3. Clear Image
Also, i am aware that this is possible by overriding Querystate() method but im unsure of its implementation as I am new to CommandState handling.
Instead of going through QueryState , I am trying this
I have set the property "DisableEdit" of image as:
<myImage:PictureFillImage Field="<%# MyImage.Constants.FieldNames.Image %>" DisableEdit="true" ID="UIImage" runat="server"/>
I am using a custom class as:
public class PictureFillImage : Sitecore.Web.UI.WebControls.FieldControl
And i am trying to disable web editing for the image as:
public bool DisableEdit { get; set; }
private Sitecore.Web.UI.WebControls.Image _smlImage;
private Sitecore.Data.Fields.ImageField _smlImageField;
private Sitecore.Web.UI.WebControls.FieldControl _fieldControl;
protected override void OnLoad(EventArgs e)
{
this.DataBind();
}
public override void DataBind()
{
// base.OnLoad(e);
this.Item = this.GetItem();
if ((this.Item != null) && (this.Field != null))
{
Sitecore.Data.Fields.Field field = this.Item.Fields[this.Field];
if (field != null)
{
this._smlImageField = (Sitecore.Data.Fields.ImageField)field;
this._smlImage = new Sitecore.Web.UI.WebControls.Image();
this._smlImage.Field = this.Field;
this._fieldControl = this._smlImage as Sitecore.Web.UI.WebControls.FieldControl;
this._smlImage.ID = this.ID;
this._smlImage.CssClass = this.CssClass;
this._smlImage.Parameters = "all=all";
this._fieldControl.Item = this.Item;
this._smlImage.DisableWebEditing = DisableEdit;
this._fieldControl.DisableWebEditing = DisableEdit;
}
}
base.DataBind();
}
I was hoping that the code would hide the three buttons: "Choose Image", "Image Properties" and "Clear Image" that appear in the floating ribbon in the page editor but I had negative result.
Please help.
You should override the query state method and return hidden or enabled
public override CommandState QueryState(CommandContext context)
{
// your logic here
//access current item
var item = context.Items[0];
// return either Commandstate.Hidden or Commandstate.Enabled
}
For each button you will have a command class declared so you can customize the behaviour for each button.
You can get access to the current item as well.
There's a good example here on how to overrride the querystate to affect the state of the buttons
https://briancaos.wordpress.com/2010/09/10/unlock-sitecore-items/

two level deep master-details for Entity Framework

I am using Entity Framework and DevExpress 10.5 XtraGrid.
Imagine that we have entities
So my point is to display them in Form using XtraGrids and master-details.
The Level tree of gridControl should look like this:
So I have implemented events for MainGrid like this
#region gridView1_enents
private void gridView1_MasterRowEmpty(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowEmptyEventArgs e)
{
districts c = (districts)gridView1.GetRow(e.RowHandle);
e.IsEmpty = c.districtparts.Count == 0;
}
private void gridView1_MasterRowGetRelationCount(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetRelationCountEventArgs e)
{
e.RelationCount = 1;
}
private void gridView1_MasterRowGetRelationName(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetRelationNameEventArgs e)
{
e.RelationName = "districtparts";
}
private void gridView1_MasterRowGetChildList(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetChildListEventArgs e)
{
districts c = (districts)gridView1.GetRow(e.RowHandle);
e.ChildList = new BindingSource(c, "districtparts");
}
#endregion
and that works fine: there is a grid, displaying my districts and I can expand each row and there displays another grid with districtparts
The question is: what should I do to display votecallers. The goal is to have two levels of master-detail hierarchy. That means that districts should have districtparts, and districtparts should have votecallers.
Thanks.
Found a solution here
And some irrelevant words to meet the requirement of 30 characters =)

How can I pass a listview from one form to another form?

I have 2 forms. form1 and form2. There is a button at form1 for me to access to form2 and in form2, I have a listview2 and some textboxes. I manage to input items into listview2. Then when I click on the OK button in form2, listview1 in form1 should show exactly like listview2. So guys, can anyone suggest me a way to do this? Thanks
Below are my codes. I hope I don't confuse you all.
Form1 code =>
namespace MainServerPage
{
public partial class MainServerPage : Form
{
public ListView LV;
public MainServerPage()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
AddItem Add = new AddItem(this); //to open form2
Add.ShowDialog();
}
}
}
Form2 code =>
namespace MainServerPage
{
public partial class AddItem : Form
{
MainServerPage currentform; //I learn this way of passing form to another but it's not working
public AddItem(MainServerPage incomingform)
{
currentform = incomingform;
InitializeComponent();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
ListViewItem item = new ListViewItem(txtCode.Text);
item.SubItems.Add(txtLocation.Text);
item.SubItems.Add(cbxStatus.Text);
item.SubItems.Add(txtWeatherHigh.ToString());
item.SubItems.Add(txtWeatherLow.ToString());
listView2.Items.Add(item); //send to listView2
txtCode.Text = "";
txtLocation.Text = "";
cbxStatus.Text = "";
txtWeatherHigh.Text = "";
txtWeatherLow.Text = "";
cbxZone.Text = "";
}
private void btnOk_Click(object sender, EventArgs e)
{
currentform.LV = load; //I got stuck here...do not know what to do
}
}
}
In general, it's not the list view you want to pass, it's the data that the list view is representing. You should probably rethink your design such that you btnUpdate_Click function builds a data object rather than building a ListViewItem directly. Then you can either pass the data object(s) back to your first form.