I try formatting text in richTextBox, something like in skype chat.
1.column-"Nick" 2.column-"Text of Messange" 3.column-"DateTime"
I want alling 1. column max left and 3. column max right.
What is the best way how can I do it? I am using WPF.
My solution:
Simple solution is create Table object and add to blocks of richtextbox, somothing like this:
var tab = new Table();
var gridLenghtConvertor = new GridLengthConverter();
tab.Columns.Add(new TableColumn() { Name = "colNick", Width = (GridLength)gridLenghtConvertor.ConvertFromString("*") });
tab.Columns.Add(new TableColumn { Name = "colMsg", Width = (GridLength)gridLenghtConvertor.ConvertFromString("5*") });
tab.Columns.Add(new TableColumn() { Name = "colDt", Width = (GridLength)gridLenghtConvertor.ConvertFromString("*") });
tab.RowGroups.Add(new TableRowGroup());
tab.RowGroups[0].Rows.Add(new TableRow());
var tabRow = tab.RowGroups[0].Rows[0];
tabRow.Cells.Add(new TableCell(new Paragraph(new Run(rpMsg.Nick))) { TextAlignment = TextAlignment.Left });
tabRow.Cells.Add(new TableCell(ConvertToRpWithEmoticons(rpMsg.RpText)));
tabRow.Cells.Add(new TableCell(new Paragraph(new Run("Cas"))) { TextAlignment = TextAlignment.Right });
RtbConversation.Document.Blocks.Add(tab);
Related
private List<Report> _reports = new List<Report>();
public Report CurrentReport
{
get { return _reports[_componentIterator]; }
set { _reports[_componentIterator] = value; }
}
I have a _reports field and it's a list of Report objects.
I use a CurrentReport property to access current Report object based on _componentIterator.
How do I bind to some of Report properties so that changing _componentIterator won't break my binding?
If I bind like this, every _componentIterator change breaks binding.
Binding designatorTextBlockBinding = new Binding(nameof(CurrentReport.Designator));
designatorTextBlockBinding.Source = CurrentReport;
_artifactControl.DesignatorTextBlock.SetBinding(Controls.TextBlock.TextProperty, designatorTextBlockBinding);
Declare the Binding like shown below, and make sure the CurrentReport property fires a change notification.
var designatorTextBlockBinding = new Binding
{
Path = new PropertyPath("CurrentReport.Designator"),
Source = this
};
or
var designatorTextBlockBinding = new Binding
{
Path = new PropertyPath(
nameof(CurrentReport) + "." + nameof(CurrentReport.Designator)),
Source = this
};
or
var designatorTextBlockBinding = new Binding(
nameof(CurrentReport) + "." + nameof(CurrentReport.Designator))
{
Source = this
};
I am building dynamically more paths in a canvas, and i want to add a tooltip with more details about the path shape. But it looks like the tolltip appears only when i hover the path points. I want it to appear also when i hover the filled area or the contour of it.
PolyLineSegment polySeg = new PolyLineSegment(new Point[] { new Point(triangleX - 8, triangleY - 20), new Point(triangleX + 8, triangleY - 20) }, true);
PathFigure pathFig = new PathFigure(new Point(triangleX, triangleY), new PathSegment[] { polySeg }, true);
PathGeometry pathGeo = new PathGeometry(new PathFigure[] { pathFig });
pathGeo.Transform = new RotateTransform(angleOfTheTriangleInGrades, triangleX, triangleY);
Path path = new Path();
path.Data = pathGeo;
path.Fill = Brushes.Yellow;
var sp = new StackPanel();
sp.Children.Add(new TextBlock
{
Text = "aaa"
});
sp.Children.Add(new Button
{
Height = 20,
Width = 100,
Content = "bbbaaa"
});
path.ToolTip = sp;
pathList.Add(path);
In Extjs, I want to know whether I can restrict the dragging of elements within a specific x,y co-ordinates, just like an option, containment in jQuery-UI.
Currently this is my code:
abc.prototype.initDrag = function(v) {
v.dragZone = new Ext.dd.DragZone(v.getEl(), {
containerScroll : false,
getDragData : function(e) {
var sourceEl = e.getTarget(v.itemSelector, 10);
var t = e.getTarget();
var rowIndex = abc.grid.getView().findRowIndex(t);
var columnIndex = abc.grid.getView().findCellIndex(t);
var abcDragZone = v.dragZone ; //Ext.getCmp('idabcDragZone');
var widthToScrollV = $(window).width()-((columnIndex-1)*100);
var widthToScrollH = $(window).height()-((5-rowIndex)*30);
abcDragZone.setXConstraint(0,widthToScrollV);
abcDragZone.setYConstraint(widthToScrollH,0);
if ((rowIndex !== false) && (columnIndex !== false)) {
if (sourceEl) {
abc.isDragged = true;
def.scriptGrid.isDraggableForObject = false;
def.scriptGrid.dragRowIndex = false;
d = sourceEl.cloneNode(true);
d.id = Ext.id();
d.textContent = "\$" + abc.grid.getColumnModel().getColumnHeader(columnIndex);
return {
ddel : d,
sourceEl : d,
sourceStore : v.store
}
}
}
},
getRepairXY : function() {
return this.dragData.repairXY;
},
});
}
But the problem is that the initdrag is called when the csv sheet is added to DOM. Only when its added that element can be accessed and the individual cells' drag limits can be set. So once I add a csv, the limits are not getting set. If I add it again to DOM then the limits work. Is there an option like the jQuery UI containment for draggable, here in extjs?
edit:
I even tried :
constrainTo( constrainTo, [pad], [inContent] )
body had an id of #abc
when I tried with
dragZoneObj.startDrag = function(){
this.constrainTo('abc');
};
which is a method of the DragZone class. It still did not cover the whole body tag.
I'm trying to create two panes inside a tab bar programmatically using the following code:
var middlePanel = new LayoutPanel
{
Orientation = Orientation.Vertical,
DockHeight = new GridLength(250)
};
rootPanel.Children.Add(middlePanel);
var paneGroup = new LayoutAnchorablePaneGroup
{
DockHeight = new GridLength(200)
};
middlePanel.Children.Add(new LayoutDocumentPane());
middlePanel.Children.Add(paneGroup);
var validationEditorPane = new LayoutAnchorablePane();
paneGroup.Children.Add(validationEditorPane);
validationEditorPane.Children.Add(new LayoutAnchorable { ContentId = "Validation", Title = "Validation" });
var searchEditorPane = new LayoutAnchorablePane();
paneGroup.Children.Add(searchEditorPane);
searchEditorPane.Children.Add(new LayoutAnchorable { ContentId = "Search", Title = "Search" });
However, the code above creates the two panes next to each other without tabs. During runtime I can drag the Search pane onto the Validation pane to move them into tabs. This suggests that it must be possible to achieve this programmatically, but I cannot see how.
Any suggestions?
This turned out to be easier than I thought. All I had to do was to add the LayoutAnchorables to the same LayoutAnchorablePane object:
var tabPane = new LayoutAnchorablePane();
paneGroup.Children.Add(tabPane);
tabPane.Children.Add(new LayoutAnchorable { ContentId = "Validation", Title = "Validation" });
tabPane.Children.Add(new LayoutAnchorable { ContentId = "Search", Title = "Search" });
I have a XtraGrid bound to a Datasource, where I want a single column to have a Check Box in it, and have a caption next to the Check Box in the same cell. I can get the Checked True or False from another column in the Datasource, and also I need to get the caption text from another column in the Datasource...That part is easy, once I get a handle on implementing the caption changes.
My question is:
How do I programmatically change the text that is displayed next to the CheckEdit in the same cell?
Similar to (Tick and Untick represent the check box state):
Tick Apples
Untick Bananas
However, my attempts only display the text 'Check' - obviously the default caption in the CheckEdit editor:
Tick Check
Untick Check
I have searched the DevExpress support centre and they only have instructions for the CheckEdit Repository item when used in the TreeList (not the XtraGrid). I understand it will involve managing the CustomDrawCell event and some others - which is fine.
I think, your instructions for XtraTreeList can be also applied to XtraGrid. But I can suggest to you the other way.
You can use GridView.CustomRowCellEdit event and two ResositoryItemCheckEdit objects:
private RepositoryItemCheckEdit editTick;
private RepositoryItemCheckEdit editUntick;
Just set your Tick text to editTick.Caption property and Untick text to editUntick.Caption property.
Here is example:
//Initialize repository items:
editTick = new RepositoryItemCheckEdit() { GlyphAlignment = HorzAlignment.Near, Caption = "Apples" };
editUntick = new RepositoryItemCheckEdit() { GlyphAlignment = HorzAlignment.Near, Caption = "Bananas" };
//Add handler for CheckedChanged event:
Action<object, EventArgs> action = (s, e) =>
{
var ownerEdit = s as CheckEdit;
if (ownerEdit == null)
return;
ownerEdit.Text = ownerEdit.Checked ? editTick.Caption : editUntick.Caption;
};
editTick.CheckedChanged += new EventHandler(action);
editUntick.CheckedChanged += new EventHandler(action);
//Some sample DataSource:
var table = new DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Bool", typeof(bool));
table.Rows.Add(0, false);
table.Rows.Add(1, false);
table.Rows.Add(2, true);
table.Rows.Add(3, false);
table.Rows.Add(4, true);
table.Rows.Add(5, true);
table.Rows.Add(6, false);
table.Rows.Add(7, true);
gridControl.DataSource = table;
//Here comes the CustomRowCellEdit:
gridView1.CustomRowCellEdit += (s, e) =>
{
if (e.Column.FieldName != "Bool" || e.CellValue == null) //Put your own field name here instead of "Bool".
return;
e.RepositoryItem = (bool)e.CellValue ? editTick : editUntick;
};
//Add CustomColumnDisplayText event, so you can see your "Apples" in group rows and filters:
gridView1.CustomColumnDisplayText += (s, e) =>
{
if (e.Column.FieldName != "Bool")
return;
e.DisplayText = (bool)e.Value ? editTick.Caption : editUntick.Caption;
};