Is it possible to round the edges of a row in jetpack? - user-interface

This is what I'm trying to achieve:
So I have created 2 rounded buttons in a row and gave different background colors depending whether they're selected or not. The goal is to create a kind of an illusion of a tab/toggle.
The unselected button will have the same color as the row's background color. Unfortunately, since a row is a rectangle shape there comes a residue space at the corners that still shows the background color .
This is my code for the buttons
val cornerRadius = 20.dp
var selectedIndex by remember { mutableStateOf(0)}
val configuration = LocalConfiguration.current
val screenWidth = configuration.screenWidthDp.dp
val items = listOf(
OutlinedButton(onClick = { /*TODO*/ }) {
},
OutlinedButton(onClick = { /*TODO*/ }) {
})
Row(
modifier = Modifier
.padding(top = 8.dp)
.wrapContentHeight()
.width(screenWidth).background(color = Color.Gray).clip(shape = RoundedCornerShape(20.dp))
) {
// Spacer(modifier = Modifier.weight(1f))
items.forEachIndexed { index, item ->
OutlinedButton(modifier = Modifier
.wrapContentHeight()
.width(screenWidth/2),
shape = when (index) {
// left outer button
0 -> (if (selectedIndex == index) {
RoundedCornerShape(
topStart = cornerRadius,
topEnd = cornerRadius,
bottomStart = cornerRadius,
bottomEnd = cornerRadius
)
} else {
RoundedCornerShape(
topStart = cornerRadius,
topEnd = cornerRadius,
bottomStart = cornerRadius,
bottomEnd = cornerRadius
)
})
//rightouterbutton
else -> (if (selectedIndex == index) {
RoundedCornerShape(
topStart = cornerRadius,
topEnd = cornerRadius,
bottomStart = cornerRadius,
bottomEnd = cornerRadius
)
}
else{RoundedCornerShape(
topStart = 0.dp,
topEnd = cornerRadius,
bottomStart = 0.dp,
bottomEnd = cornerRadius
)})
},
border = BorderStroke(
1.dp, if (selectedIndex == index) {
Color.Transparent
} else {
Color.Transparent
}
),
colors = if (selectedIndex == index) {
// colors when selected
ButtonDefaults.outlinedButtonColors(
backgroundColor = Color.Yellow,
contentColor = Color.Black
)
} else {
// colors when not selected
ButtonDefaults.outlinedButtonColors(
backgroundColor = Color.Gray,
contentColor = Color.Black
)
},
onClick = { selectedIndex = index },
) {
if (index == 0) {
Text(
text = "In progress",
color = if (selectedIndex == index) {
Color.Black
} else {
Color.DarkGray.copy(alpha = 0.9f)
},
modifier = Modifier.padding(horizontal = 8.dp)
)
} else {
Text(
text = "Completed",
color = if (selectedIndex == index) {
MaterialTheme.colors.primary
} else {
Color.DarkGray.copy(alpha = 0.9f)
},
modifier = Modifier.padding(horizontal = 8.dp)
)
}
}
}
}

Modifier.clip applied after the Modifier.background has no effect in your case, you need to reverse the order. Read more about why the order of modifiers matters in this answer
.clip(shape = RoundedCornerShape(20.dp))
.background(color = Color.Gray)
Another option in the case of Modifier.background is that you can apply the shape specifically to the background color. Note that this solution will not clip other view content to the shape as Modifier.clip does, but in your case it fits.
.background(color = Color.Gray, shape = RoundedCornerShape(20.dp))

Related

In UITextfield, When applying color using NSMutableAttributedString the color is not applied correctly when unfocusing

Using NSMutableAttributedString, I applied color for a specific character in a string using UITextfield. My Code:
uITextField = new UITextField(); uITextField.BackgroundColor = UIColor.LightGray;
uITextField.Frame = new CGRect(10, 150, 350, 40);
uITextField.Text = "Hai i am ________________";
uITextField.TextColor = UIColor.Green;
uITextField.EditingChanged += UITextField_EditingChanged;
private void UITextField_EditingChanged(object sender, EventArgs e)
{
var promptStringAttributes = new UIStringAttributes
{
ForegroundColor = UIColor.Red
};
var promptString = new NSMutableAttributedString(uITextField.Text);
char[] mText = uITextField.Text.ToCharArray();
Char prchar = '_';
for (int i = 0; i < mText.Length; i++)
{
if (!string.IsNullOrEmpty(uITextField.Text) && prchar == mText[i])
{
promptString.SetAttributes(promptStringAttributes.Dictionary, new NSRange(i, 1));
}
}
uITextField.AttributedText = promptString;
}
Initially, the text will be in Green color. See the below image:
After deleting the last character in the UItextfield, I will change the color of some character to red
The problem which I am facing is after unfocusing the UITextfield, the Red color is applied to all the character in the UITextField and the text color is not displayed correctly. Only the set attribute color is applied for all the character in the string. See the below image:
Please give a possible solution to restrict of applying the set attribute color for all the string when unfocusing the UITextField in xamarin iOS.
Improve your method
var promptStringAttributes_Red = new UIStringAttributes
{
ForegroundColor = UIColor.Red
};
var promptStringAttributes_Green = new UIStringAttributes
{
ForegroundColor = UIColor.Green
};
var promptString = new NSMutableAttributedString(uITextField.Text);
char[] mText = uITextField.Text.ToCharArray();
Char prchar = '_';
for (int i = 0; i < mText.Length; i++)
{
if (!string.IsNullOrEmpty(uITextField.Text) && mText[i] ==prchar)
{
promptString.SetAttributes(promptStringAttributes_Red.Dictionary, new NSRange(i, 1));
}
else
{
promptString.SetAttributes(promptStringAttributes_Green.Dictionary, new NSRange(i, 1));
}
}
uITextField.AttributedText = promptString;

how to place two images on two different markers in mapKit using swift

I want to change marker image in my MKPointAnnotation() and I have successfully changed my image but problem is that I have 2 marker points and I want to place ignitionon.png on point one and ignitionof.png on point two and my logic place ignitionon.png on both the points.
Code
if(self.doubelLocation) {
var pointOff = CLLocationCoordinate2D()
var pointOn = CLLocationCoordinate2D()
if(self.dateTime.count > 0) {
for(var i : Int = 0 ; i < self.dateTime.count ; i++) {
// print("Real status = \(self.dateTime[i])")
var fixTime = self.dateTime[i]
if(fixTime == self.dateTimeTwo) {
pointOff = CLLocationCoordinate2DMake(self.latt[i], self.lngg[i]);
print("pointOff = \(pointOff)")
//points.append(pointOf)
}
if(fixTime == self.dateTimeOne){
pointOn = CLLocationCoordinate2DMake(self.latt[i], self.lngg[i]);
print("pointOn = \(pointOn)")
//points.append(pointOf)
}
}
var points: [CLLocationCoordinate2D]
points = [pointOn, pointOff]
dispatch_async(dispatch_get_main_queue(), {
let geodesic = MKGeodesicPolyline(coordinates: &points[0], count: 2)
self.theMapView.addOverlay(geodesic)
let latDelta:CLLocationDegrees = 0.03
let lnggDelta:CLLocationDegrees = 0.03
UIView.animateWithDuration(1.5, animations: { () -> Void in
let span = MKCoordinateSpanMake(latDelta, lnggDelta)
let region1 = MKCoordinateRegion(center: points[0], span: span)
self.theMapView.setRegion(region1, animated: true)
self.ActivityIndicator.stopAnimating()
for(var i : Int = 0 ;i < points.count; i++){
var st = self.reportText[i]
// let theMarker = MKPointAnnotation()
//how to change marker color
//https://stackoverflow.com/questions/33532883/add-different-pin-color-with-mapkit-in-swift-2-1
let theMarker = MKPointAnnotation()
theMarker.coordinate = points[i]
// if(st == "IGNITION ON"){
if(i == 0){
theMarker.title = "Status : IGNITION OFF"
theMarker.subtitle = "\(self.locationOff)"
// theMarker.subtitle = "Date = , Reg#: "
self.theMapView.addAnnotation(theMarker)
let anView1:MKAnnotationView = MKAnnotationView()
anView1.annotation = theMarker
anView1.image = UIImage(named:"ignitionof")
anView1.canShowCallout = true
anView1.enabled = true
}
if(i == 1){
// theMarker = UIColor.greenColor()
theMarker.title = "Status : IGNITION ON"
theMarker.subtitle = "\(self.locationOn)"
// theMarker.subtitle = "Date = , Reg#: "
self.theMapView.addAnnotation(theMarker)
//how to change image of marker
//https://stackoverflow.com/questions/24467408/swift-add-mkannotationview-to-mkmapview
let anView:MKAnnotationView = MKAnnotationView()
anView.annotation = theMarker
anView.image = UIImage(named:"ignitionon")
anView.canShowCallout = true
anView.enabled = true
}
// }
}
})
})
}
}
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if (annotation is MKUserLocation) {
//if annotation is not an MKPointAnnotation (eg. MKUserLocation),
//return nil so map draws default view for it (eg. blue dot)...
return nil
}
let reuseId = "test"
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if anView == nil {
anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
anView!.image = UIImage(named:"ignitionon")
anView!.canShowCallout = true
}
var anView1 = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if anView1 == nil {
anView1 = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
anView1!.image = UIImage(named:"ignitionof")
anView1!.canShowCallout = true
}
else {
//we are re-using a view, update its annotation reference...
anView!.annotation = annotation
}
return anView
}
I am following this Link:
Swift - Add MKAnnotationView To MKMapView
It's not the best way to handle multiple marker with different metadata.
You can't use mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) two times or more because in viewForAnnotation it is for only 1 view for each Point you have added in the stack.
Create a sub-class of MKPointAnnotation:
class CustomPointAnnotation: MKPointAnnotation {
var tag: String!
}
Create a Dictionary with all images:
var imagesPath : ["tag_1": "image_1.png", "tag_2": "image_2.jpg"]
Now in the delegate func, check Simply
if !(annotation is CustomPointAnnotation) {
return nil
}
and Handle the only one View you have:
let reuseId = "test"
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if anView == nil {
anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
var customannotation = annotation as! CustomPointAnnotation
anView!.image = UIImage(named: imagesPath(customannotation.tag))
anView!.canShowCallout = true
}
An example to add a new Custom point is:
let aPoint = CustomPointAnnotation()
aPoint.coordinate = CLLocationCoordinate2DMake(40.730872, -73.003066)
aPoint.title = "Info1"
aPoint.subtitle = "Subtitle"
aPoint.tag = "tag_1"
mapView.addAnnotation(aPoint)

Three.js - can I detect geometry 'islands' when importing?

I'm importing .3DS models into Blender 2.72b, then exporting them with the Three.js import/export addon. The models have multiple geometry 'islands' (separate groups of connected faces and vertices), each with its own material. I'd like to be able to pair each material with its corresponding island, without having to create separate THREE.Geometry objects. After some digging, I found this question which suggests using a THREE.MeshFaceMaterial to achieve multiple materials for one object. The only problem is that the geometry in that example is a simple cube, whereas my models have hundreds of faces spread across 2-5 islands.
Does Three.js have functionality for identifying geometry 'islands' in a mesh?
No. three.js does not have functionality for identifying geometry 'islands' in a mesh.
When using MeshFaceMaterial, WebGLRenderer breaks the geometry into chunks anyway -- one chunk for each material. It does that because WebGL supports one shader per geometry.
I would not merge all your geometries, and then use MeshFaceMaterial, only to have the renderer break the single geometry apart.
You can merge geometries that share a single material if you wish.
three.js r.69
I tried with a function but still is not accurate, it produce more geometries than non connected geometries:
If somebody could have a look on it, it would be grate.
function groupGeometryIntoNonConnectedGeometries(geometry) {
const material = new THREE.MeshBasicMaterial({
side: THREE.DoubleSide,
vertexColors: THREE.VertexColors
});
let geometryArray = [];
const indexArray = geometry.index.array;
const positionArray = geometry.attributes.position.array;
const positionCount = geometry.attributes.position.count;
const color = new THREE.Vector3(geometry.attributes.color.array[0], geometry.attributes.color.array[1], geometry.attributes.color.array[2]);
const totalTriangles = indexArray.length / 3;
let geometryCount = 0;
let indexValueAlreadyVisited = new Uint8Array(indexArray.length);
let structure = [];
/*
* indexValue: {
* child: [ [indexval0, indexval1], [] ],
* parent: null
* }
*/
// Initialize Structure:
for (var vextexIdx=0; vextexIdx<positionCount; vextexIdx++) {
structure[vextexIdx] = {
child: [],
parent: null
}
}
for (idx=0; idx<totalTriangles; idx++) {
const geoIndex1 = indexArray[idx*3];
const geoIndex2 = indexArray[idx*3+1];
const geoIndex3 = indexArray[idx*3+2];
const triangleIndexVertexArray = [ geoIndex1, geoIndex2, geoIndex3 ].sort(function(a, b) {
return a - b;
});
structure[ triangleIndexVertexArray[0] ].child.push(triangleIndexVertexArray[1], triangleIndexVertexArray[2]);
structure[ triangleIndexVertexArray[1] ].parent = triangleIndexVertexArray[0];
structure[ triangleIndexVertexArray[2] ].parent = triangleIndexVertexArray[0];
}
let count = 0;
let currentCount = 0;
let geometryStructureArray = [];
for (let strIdx=0; strIdx<structure.length; strIdx++) {
if (structure[strIdx].parent == null) {
currentCount = count;
geometryStructureArray[currentCount] = {
name: "G_" + currentCount,
indexMap: {},
currentIndex: 0,
indexArray: [],
positionArray: [],
colorArray: []
};
count += 1;
}
if (structure[strIdx].child.length > 0) {
const childLen = structure[strIdx].child.length / 2;
for (let childIdx=0; childIdx<childLen; childIdx++) {
const vertexIndex0 = strIdx;
const vertexIndex1 = structure[strIdx].child[childIdx*2];
const vertexIndex2 = structure[strIdx].child[childIdx*2+1];
const v0 = new THREE.Vector3( positionArray[strIdx*3], positionArray[strIdx*3+1], positionArray[strIdx*3+2] );
const v1 = new THREE.Vector3( positionArray[vertexIndex1*3], positionArray[vertexIndex1*3+1], positionArray[vertexIndex1*3+2] );
const v2 = new THREE.Vector3( positionArray[vertexIndex2*3], positionArray[vertexIndex2*3+1], positionArray[vertexIndex2*3+2] );
// check vertex0
if (geometryStructureArray[currentCount].indexMap[vertexIndex0] == undefined) {
geometryStructureArray[currentCount].indexMap[vertexIndex0] = geometryStructureArray[currentCount].currentIndex;
geometryStructureArray[currentCount].indexArray.push(geometryStructureArray[currentCount].currentIndex);
geometryStructureArray[currentCount].positionArray.push(v0.x, v0.y, v0.z);
geometryStructureArray[currentCount].colorArray.push(color.x, color.y, color.z);
geometryStructureArray[currentCount].currentIndex += 1;
} else {
geometryStructureArray[currentCount].indexArray.push(geometryStructureArray[currentCount].indexMap[vertexIndex0]);
}
// check vertex1
if (geometryStructureArray[currentCount].indexMap[vertexIndex1] == undefined) {
geometryStructureArray[currentCount].indexMap[vertexIndex1] = geometryStructureArray[currentCount].currentIndex;
geometryStructureArray[currentCount].indexArray.push(geometryStructureArray[currentCount].currentIndex);
geometryStructureArray[currentCount].positionArray.push(v1.x, v1.y, v1.z);
geometryStructureArray[currentCount].colorArray.push(color.x, color.y, color.z);
geometryStructureArray[currentCount].currentIndex += 1;
} else {
geometryStructureArray[currentCount].indexArray.push(geometryStructureArray[currentCount].indexMap[vertexIndex1]);
}
// check vertex1
if (geometryStructureArray[currentCount].indexMap[vertexIndex2] == undefined) {
geometryStructureArray[currentCount].indexMap[vertexIndex2] = geometryStructureArray[currentCount].currentIndex;
geometryStructureArray[currentCount].indexArray.push(geometryStructureArray[currentCount].currentIndex);
geometryStructureArray[currentCount].positionArray.push(v2.x, v2.y, v2.z);
geometryStructureArray[currentCount].colorArray.push(color.x, color.y, color.z);
geometryStructureArray[currentCount].currentIndex += 1;
} else {
geometryStructureArray[currentCount].indexArray.push(geometryStructureArray[currentCount].indexMap[vertexIndex2]);
}
}
}
}
// Convert to geometryArray:
const geometryStructureArrayLen = geometryStructureArray.length;
const object3d = new THREE.Object3D();
for (let geoIdx=0; geoIdx<geometryStructureArrayLen; geoIdx++) {
const geo = new THREE.BufferGeometry();
geo.name = "G_" + geoIdx;
const geoPositions = new Float32Array(geometryStructureArray[geoIdx].positionArray);
const geoColors = new Float32Array(geometryStructureArray[geoIdx].colorArray);
const geoIndices = new Uint32Array(geometryStructureArray[geoIdx].indexArray);
//console.log(geoIdx, "geoPositions: ", geoPositions);
//console.log(geoIdx, "geoColors: ", geoColors);
//console.log(geoIdx, "geoIndices: ", geoIndices);
geo.index = new THREE.BufferAttribute(geoIndices, 1, false);
geo.attributes.position = new THREE.BufferAttribute(geoPositions, 3, false);
geo.attributes.color = new THREE.BufferAttribute(geoColors, 3, true);
geo.computeBoundingSphere();
geo.computeBoundingBox();
const mesh = new THREE.Mesh(geo, material);
mesh.name = "M_" + geoIdx;
object3d.add(mesh);
}
//return [structure, geometryStructureArray, object3d, count];
return object3d;
}
Best regards
This is I think the correct way:
function unmergeGeometryArray(geometry) {
// Asumptions:
// geometry is BufferGeometry
// The geometry has no index duplicates (2 equal positions with different index) neither empty triangles, the geometry has been processed with mergeVertices function
// normal attribute is discarded, can be recomputed after, only color and position attributes are taken into account
const material = new THREE.MeshBasicMaterial({
side: THREE.DoubleSide,
vertexColors: THREE.VertexColors
});
const indexArray = geometry.index.array;
const positionArray = geometry.attributes.position.array;
const positionCount = geometry.attributes.position.count;
const totalTriangles = indexArray.length / 3;
let triangleVisitedArray = new Uint8Array(totalTriangles);
let indexVisitedArray = new Uint8Array(positionCount);
let indexToTriangleIndexMap = [];
let missingVertices = positionCount;
let missingTriangles = totalTriangles;
// Functions:
function computeTrianglesRecursive(index, out){
//console.log("- start of computeTriangles with index:", index);
if (indexVisitedArray[index] === 1 || missingVertices === 0 || missingTriangles === 0) {
return;
}
indexVisitedArray[index] = 1;
missingVertices -= 1;
let triangleIndexArray = indexToTriangleIndexMap[index];
for(let i=0; i<indexToTriangleIndexMap[index].length; i++) {
let triangleIndex = indexToTriangleIndexMap[index][i];
if (triangleVisitedArray[triangleIndex] === 0) {
triangleVisitedArray[triangleIndex] = 1
missingTriangles -= 1;
//console.log("-- index: ", index, "; i: ", i, "; triangleIndex: ", triangleIndex);
out.push(triangleIndex);
childIndex1 = indexArray[triangleIndex*3+1];
computeTriangles(childIndex1, out);
childIndex2 = indexArray[triangleIndex*3+2];
computeTriangles(childIndex2, out);
}
}
}
function computeTriangles(indexTocheck){
let out = [];
let startIndex = indexTocheck;
let indexToCheckArray = [indexTocheck];
let i = 0;
while (i<indexToCheckArray.length) {
let index = indexToCheckArray[i];
if (indexVisitedArray[index] == 0) {
indexVisitedArray[index] = 1;
missingVertices -= 1;
let triangleIndexArray = indexToTriangleIndexMap[index];
for(let j=0; j<indexToTriangleIndexMap[index].length; j++) {
let triangleIndex = indexToTriangleIndexMap[index][j];
if (triangleVisitedArray[triangleIndex] === 0) {
triangleVisitedArray[triangleIndex] = 1;
missingTriangles -= 1;
out.push(triangleIndex);
let rootIndex = indexArray[triangleIndex*3];
let child1Index = indexArray[triangleIndex*3+1];
let child2Index = indexArray[triangleIndex*3+2];
if (indexToCheckArray.indexOf(rootIndex) === -1) {
indexToCheckArray.push(rootIndex);
}
if (indexToCheckArray.indexOf(child1Index) === -1) {
indexToCheckArray.push(child1Index);
}
if (indexToCheckArray.indexOf(child2Index) === -1) {
indexToCheckArray.push(child2Index);
}
}
}
}
i +=1;
}
return out;
}
// In the first loop we reorder indices asc order + generate map
for (triangleIndex=0; triangleIndex<totalTriangles; triangleIndex++) {
const geoIndex1 = indexArray[triangleIndex*3];
const geoIndex2 = indexArray[triangleIndex*3+1];
const geoIndex3 = indexArray[triangleIndex*3+2];
const triangleIndexVertexArray = [ geoIndex1, geoIndex2, geoIndex3 ].sort(function(a, b) {
return a - b;
});
if (indexToTriangleIndexMap[geoIndex1] === undefined) {
indexToTriangleIndexMap[geoIndex1] = [triangleIndex];
} else {
indexToTriangleIndexMap[geoIndex1].push(triangleIndex);
}
if (indexToTriangleIndexMap[geoIndex2] === undefined) {
indexToTriangleIndexMap[geoIndex2] = [triangleIndex];
} else {
indexToTriangleIndexMap[geoIndex2].push(triangleIndex);
}
if (indexToTriangleIndexMap[geoIndex3] === undefined) {
indexToTriangleIndexMap[geoIndex3] = [triangleIndex];
} else {
indexToTriangleIndexMap[geoIndex3].push(triangleIndex);
}
//indexArray[triangleIndex*3] = triangleIndexVertexArray[0];
//indexArray[triangleIndex*3+1] = triangleIndexVertexArray[1];
//indexArray[triangleIndex*3+2] = triangleIndexVertexArray[2];
}
let geometryTriangleArray = [];
let index = 0;
while (index<indexToTriangleIndexMap.length && missingVertices>0 && missingTriangles>0){
let out = [];
if (indexVisitedArray[index] === 0) {
out = computeTriangles(index);
}
if (out.length > 0) {
geometryTriangleArray.push(out);
}
index += 1;
}
let geometryArray = [];
for (let i=0; i<geometryTriangleArray.length; i++) {
let out = {
positionArray: [],
colorArray: [],
indexArray: [],
indexMap: [],
currentIndex: 0
}
let triangleArray = geometryTriangleArray[i];
for (let j=0; j<triangleArray.length; j++) {
let triangleIndex = triangleArray[j];
let rootIndex = indexArray[triangleIndex*3];
if (out.indexMap[rootIndex] === undefined) {
out.indexMap[rootIndex] = out.currentIndex;
// add vertex position and color
out.positionArray.push(
geometry.attributes.position.array[rootIndex*3],
geometry.attributes.position.array[rootIndex*3+1],
geometry.attributes.position.array[rootIndex*3+2]
);
if (geometry.attributes.color != undefined) {
out.colorArray.push(
geometry.attributes.color.array[rootIndex*3],
geometry.attributes.color.array[rootIndex*3+1],
geometry.attributes.color.array[rootIndex*3+2]
);
}
out.currentIndex += 1;
}
let child1Index = indexArray[triangleIndex*3+1];
if (out.indexMap[child1Index] === undefined) {
out.indexMap[child1Index] = out.currentIndex;
// add vertex position and color
out.positionArray.push(
geometry.attributes.position.array[child1Index*3],
geometry.attributes.position.array[child1Index*3+1],
geometry.attributes.position.array[child1Index*3+2]
);
if (geometry.attributes.color != undefined) {
out.colorArray.push(
geometry.attributes.color.array[child1Index*3],
geometry.attributes.color.array[child1Index*3+1],
geometry.attributes.color.array[child1Index*3+2]
);
}
out.currentIndex += 1;
}
let child2Index = indexArray[triangleIndex*3+2];
if (out.indexMap[child2Index] === undefined) {
out.indexMap[child2Index] = out.currentIndex;
// add vertex position and color
out.positionArray.push(
geometry.attributes.position.array[child2Index*3],
geometry.attributes.position.array[child2Index*3+1],
geometry.attributes.position.array[child2Index*3+2]
);
if (geometry.attributes.color != undefined) {
out.colorArray.push(
geometry.attributes.color.array[child2Index*3],
geometry.attributes.color.array[child2Index*3+1],
geometry.attributes.color.array[child2Index*3+2]
);
}
out.currentIndex += 1;
}
// Add indices:
out.indexArray.push(out.indexMap[rootIndex], out.indexMap[child1Index], out.indexMap[child2Index]);
}
const geoPositions = new Float32Array(out.positionArray);
const geoColors = new Float32Array(out.colorArray);
const geoIndices = new Uint32Array(out.indexArray);
const geo = new THREE.BufferGeometry();
geo.name = "G_" + i;
geo.index = new THREE.BufferAttribute(geoIndices, 1, false);
geo.attributes.position = new THREE.BufferAttribute(geoPositions, 3, false);
geo.attributes.color = new THREE.BufferAttribute(geoColors, 3, true);
geo.computeBoundingSphere();
geo.computeBoundingBox();
geometryArray.push(geo);
}
return geometryArray;
}

Visifire.Charts How to disable vertical lines. WP

Chart is created by code. But I can't disable vertical lines in chart.
It is a code of creating chart:
public void CreateChart() {
CleanChart();
visiChart = new Chart()
{
ToolTipEnabled = true,
Width = 400,
Height = 200,
Padding = new Thickness(0),
Margin = new Thickness(0, 6, 0, -12),
Background = new SolidColorBrush(Colors.White),
};
ChartGrid grid = new ChartGrid()
{
Enabled = false
};
DataSeries dataSeries = new DataSeries();
DataPoint dataPoint;
Axis yAx = new Axis()
{
AxisLabels = new AxisLabels() { Enabled = false },
Grids = new ChartGridCollection() {grid}
};
int i = 0;
var deps = App.CurrentAgreement.Deposits.Deposit.Where(x => x.DepositIliv + x.DepositLink > 0).ToList();
foreach (var dep in deps) {
dataPoint = new DataPoint();
dataPoint.YValue = dep.DepositIliv + dep.DepositLink + dep.UValue + dep.WarrantyValue;
dataPoint.XValue = i;
i++;
dataPoint.LabelText = dataPoint.YValue.Out();
dataPoint.AxisXLabel = DateTime.Parse(dep.DepositDate).ToString("MMM yyyy");
dataPoint.MouseLeftButtonUp += dataPoint_MouseLeftButtonUp;
dataSeries.DataPoints.Add(dataPoint);
}
dataSeries.LabelEnabled = true;
dataSeries.RenderAs = RenderAs.Column;
dataSeries.Color = new SolidColorBrush(Colors.Green);
visiChart.Series.Add(dataSeries);
visiChart.AxesY.Add(yAx);
ChartPlaceHolder.Children.Add(visiChart);
}
But i dont need vertical lines visible. It is a screen of chart.
How i can disable lines??
Help me, please.
You have to disable the Grid lines from AxisX also.
Example:
ChartGrid grid = new ChartGrid()
{
Enabled = false
};
Axis xAx = new Axis();
xAx.Grids.Add(grid);
visiChart.AxesX.Add(xAx);

DataGrid of Gtk# or how can I use TreeView as DataGrid

I need to add object such as DataGrid to my Gtk# Forms. I had read some information about it and found next code:
protected ListStore SetupModel(TreeView aTreeView, String StartOfColumns, params Type[] TypesOfColumnsForListStore)
{
ListStore m = new ListStore(TypesOfColumnsForListStore);
CellRendererText textCell=new CellRendererText();
textCell.Editable=true;
for(Int32 i=1;i<=TypesOfColumnsForListStore.Length;i++)
{
TreeViewColumn nameCol = new TreeViewColumn( StartOfColumns + i, textCell, "text", 0);
//TreeViewColumn nameCol = new TreeViewColumn( StartOfColumns + i, new CellRendererText(), "text", 0);
aTreeView.AppendColumn( nameCol);
}
aTreeView.Model = m;
return m;
}
void PopulateData( ListStore model )
{
//model.Append();
model.AppendValues( "Fred", "Blue" );
model.AppendValues( "Bob", "Green" );
model.AppendValues( "Mary", "Yellow" );
model.AppendValues( "Alice", "Red" );
}
But if I use this code, all of the columns is readonly. Then I found other information's here, but next code isn't working too:
protected void OnButton1Clicked (object sender, EventArgs e)
{
CellRendererText renderer=new CellRendererText(); TreeViewColumn
treeColumn=new TreeViewColumn(); renderer.Height=40;
renderer.Width=90;
treeColumn.SetCellDataFunc (renderer, delegate (TreeViewColumn
col, CellRenderer cell, TreeModel model, TreeIter iter) {
var textCell = (CellRendererText) cell;
textCell.Text = (string) model.GetValue (iter, 0);
textCell.Editable = (bool) model.GetValue (iter, 4);
});
treeview2.AppendColumn(treeColumn);
ListStore model2=new ListStore(typeof(String));
model2.AppendValues("1"); model2.AppendValues("2");
treeview2.Model=model2;
}
May anyone explain to me how to use the TreeView as an editable DataGrid?
Gtk# is quite complex as soon as you get into TreeView.
Here is the code for read-only and editable columns.
var tvTable = new Gtk.TreeView();
tvTable.EnableGridLines = TreeViewGridLines.Both;
// Create liststore
var types = new System.Type[ 2 ];
types[ 0 ] = typeof( string );
types[ 1 ] = typeof( string );
Gtk.ListStore listStore = new Gtk.ListStore( types );
tvTable.Model = listStore;
// Create index column
var column = new Gtk.TreeViewColumn();
var cell = new Gtk.CellRendererText();
column.Title = "#";
column.PackStart( cell, true );
cell.Editable = false;
cell.Foreground = "black";
cell.Background = "light gray";
column.AddAttribute( cell, "text", 0 );
tvTable.AppendColumn( column );
// Data column
var column = new Gtk.TreeViewColumn();
column.Expand = true;
cell = new Gtk.CellRendererText();
column.Title = document.Headers[ columnNumber ];
column.PackStart( cell, true );
cell.Editable = true;
column.AddAttribute( cell, "text", columnNumber + 1 );
cell.Edited += OnTreeViewCellEdited;
tvTable.AppendColumn( column );
// Add data
listStore.AppendValues( new string[] { "1", "hello" } );
Hope this helps.

Resources