When inserting image in angular i want check image width and height.If width and height does not match i give an error
$scope.imageChanged = function(files,selected_creative_size)
{
$scope.backup_creative_size = '';
if (files != null) {
var file = files[0];
//Here i want to check image size and height
if()
{
//Add data into database
}
else
{
$scope.backup_creative_size = 'Please select' + file_prop[0]+' * '+file_prop[1];
}
}
};
Try using this method on the event onChange this will have maximum size as 3 mb
$scope.uplFile = angular.element("input[type='file']")[0].files[0];
if ($scope.uplFile.size < 3145728) {
if ( $scope.uplFile.type == "image/jpg" || $scope.uplFile.type == "image/jpeg") {
//your code
} else {
//your code
}
} else {
//your code
}
On html:
I get a character :
“The Theory of Everything,” may have a few more magic tricks up his sleeve. Sources tell Variety that Redmayne is the favorite to play Newt Scamander in Warner Bros.’ hotly-anticipated “Harry Potter” spin-off, “...
When I will process it by html agility pack(using LINQ) then It be show off:
“The Theory of Everything,” may have a few more magic tricks up his sleeve. Sources tell Variety that Redmayne is the favorite to play Newt Scamander in Warner Bros.’ hotly-anticipated “Harry Potter” spin-off, “...
I want these bold character on html when take down on my app then still keep bold character(or color). Can it be do that?
foreach(var pos in pos_block)
{
//get header, pronunciton
var pronuncationuk=pos.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "sound audio_play_button pron-icon uk");
var pronuncationus=pos.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "sound audio_play_button pron-icon us");
var pos_head = pos.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "pos-head");
////
////
////
var id = pos.Descendants("div").Where(x => x.GetAttributeValue("class", "") == "sense-block");
if(id!=null)
{
foreach(var node in id)
{
result = new ResultToSearch();
var span_h2 = node.Descendants("h2").FirstOrDefault(x => x.GetAttributeValue("class", "") == "");
var sense_body = node.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("class", "") == "sense-body");
if(j==1)
{
if(section_title!=null)
{
result.vocabulary = section_title.InnerText.Trim();
}
if(pronuncationuk!=null)
{
result.pronunciationuk = pronuncationuk.GetAttributeValue("class","");
result.iconuk = "/Photos/uk.png";
}
if(pronuncationus!=null)
{
result.pronunciationus = pronuncationuk.GetAttributeValue("class", "");
result.iconus = "/Photos/us.png";
}
if(pos_head!=null)
{
result.poshead = pos_head.InnerText.Trim();
}
}
if(span_h2!=null)
{
result.senseblockh2 = span_h2.InnerText.Trim();
}
if(sense_body!=null)
{
result.sensebody = sense_body.InnerText.Trim();
}
arrays.Add(result);
j++;
}
//
}
//
j=1;
Try property InnerHtml instead of InnerText.
InnerHtml gets the HTML between the start and end tags of the object.
Whereas InnerText strips all HTML tags and returns the pure text content.
I am using the WPF toolkit for its WatermarkTextBox control.
My application dynamically concatenates text strings and placeholders for a user to fill in the blanks.
foreach(var e in elements)
{
if (isText)
{
LetterText.Inlines.Add(new Run
{
Text = e,
BaselineAlignment = BaselineAlignment.Center
});
}
else
{
LetterText.Inlines.Add(new WatermarkTextBox
{
Watermark = e
});
}
isText = !isText;
}
This works quite well, but my problem occurs when I want to reassemble the text:
foreach(var inline in LetterText.Inlines)
{
if (inline.GetType() == typeof(Run))
{
sb.Append(((Run)inline).Text);
}
else if (inline.GetType() == typeof(WatermarkTextBox))
{
var wtb = inline as WatermarkTextBox;
sb.Append(wtb.Text);
}
}
This fails at compile time with 'Cannot convert Inline to WatermarkTextBox' (without the else clause, the conversion from Inline to Run works fine).
How can I get the text from the WatermarkTextBox?
This did the trick:
if (inline.GetType() == typeof(Run))
{
sb.Append(((Run)inline).Text);
}
else if (inline.GetType() == typeof(InlineUIContainer))
{
var container = inline as InlineUIContainer;
var wtb = container.Child as WatermarkTextBox;
if (wtb !=null)
sb.Append(wtb.Text);
}
I don't know why the InlineUIContainer does not also get implicitly created for Run elements
I am using the mp4Parser isoviewer-1.0-RC-35.jar to combine clips recorded with the android MediaRecorder. The clips seem to get combined correctly by listening to the audio tracks, but the video stays on one frame and the time code stays at zero on play back.
Media Recorder Code at time individual clips are created
mediaRecorder = new MediaRecorder();
myCamera.lock();
myCamera.unlock();
String clipLocation = file.getAbsolutePath();
_moviePaths.add(clipLocation);
// Please maintain sequence of following code.
// If you change sequence it will not work.
mediaRecorder.setCamera(myCamera);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
if (facingBack) {
mediaRecorder.setOrientationHint(90);
} else {
mediaRecorder.setOrientationHint(270);
}
// Log.v("cam","supported vid sizes: "+
// myCamera.getParameters().getSupportedVideoSizes());
CamcorderProfile profile = CamcorderProfile
.get(CamcorderProfile.QUALITY_720P);
// mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
//mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
// mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mediaRecorder.setMaxDuration(g.kMaxVideoDurationInMiliseconds);// 15seconds
mediaRecorder.setProfile(profile);
mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
mediaRecorder.setOutputFile(path + filename);
mediaRecorder.prepare();
startTimer();
mediaRecorder.start();
}
Method i am using to combine the clips:
protected void combineClips() throws IOException{
for(int i=0; i<_moviePaths.size();i++){
Movie tm = MovieCreator.build(_moviePaths.get(i));
_clips.add(tm);
}
List<Track> videoTracks = new LinkedList<Track>();
List<Track> audioTracks = new LinkedList<Track>();
for (Movie m : _clips) {
for (Track t : m.getTracks()) {
if (t.getHandler().equals("soun")) {
audioTracks.add(t);
}
if (t.getHandler().equals("vide")) {
videoTracks.add(t);
}
}
}
Movie result = new Movie();
Log.v("cam", "adding:"+audioTracks.size()+" audio tracks and "+videoTracks.size()+" video tracks");
if (audioTracks.size() > 0) {
result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));
}
if (videoTracks.size() > 0) {
result.addTrack(new AppendTrack(videoTracks.toArray(new Track[videoTracks.size()])));
}
Container out = new DefaultMp4Builder().build(result);
FileChannel fc = new RandomAccessFile(String.format(videoFolder.getPath()+"/output.mp4"), "rw").getChannel();
out.writeContainer(fc);
fc.close();
}
Apparently the problem had something to do with the library: isoviewer-1.0-RC-35.jar. I replaced it with isoviewer-1.0-RC-27.jar and now everything is just dandy!
I've been searching around and looking into the documentation, but I'm not sure how to activate filtering via the column drop down the way you have it in normal grid panels.
I've tried to implement the ux.Grid.FilterFeatures but when I apply it to the tree panel, my panel doesn't render properly (all blue panel). I thought it might have something to do with its deferred layout, but when I do a treegrid.hide()/treegrid.show()/treegrid.doLayout(), it doesn't make a difference.
Has anyone gotten the filter feature working with the treepanel? Or has anyone got any suggestions on how to rectify this problem?
I modified the filter example in the Ext-Js site to use it in tree grid.
Ext.define('TreeGridFilter', {
extend: 'Ext.grid.feature.Feature'
, alias: 'feature.treeGridFilter'
, collapseOnClear: true // collapse all nodes when clearing/resetting the filter
, allowParentFolders: false // allow nodes not designated as 'leaf' (and their child items) to be matched by the filter
, treeGrid: null
, filterPropertyNames: new Array()
, filterPropertyValues: new Array()
, filterColumnRenderers: new Array()
, init: function (tree) {
var me = this;
treeGrid = me.tree = tree;
var view = me.view;
var headerCt = view.headerCt;
// Listen for header menu being created
headerCt.on('menucreate', me.onMenuCreate, me);
tree.filter = Ext.Function.bind(me.filter, me);
tree.clearFilter = Ext.Function.bind(me.clearFilter, me);
}
,filter: function (value, property, re, columnRenderer) {
var me = this
, tree = me.tree
, matches = [] // array of nodes matching the search criteria
, root = tree.getRootNode() // root node of the tree
, property = property || 'text' // property is optional - will be set to the 'text' propert of the treeStore record by default
, visibleNodes = [] // array of nodes matching the search criteria + each parent non-leaf node up to root
, viewNode;
me.updateValueForName(property, value, columnRenderer);
if (me.filterPropertyNames.length == 0) { // if the search field is empty
me.clearFilter();
return;
}
tree.expandAll(); // expand all nodes for the the following iterative routines
//iterate over all nodes in the tree in order to evalute them against the search criteria
root.cascadeBy(function (node) {
var numberOfFiltersMatched = 0;
for (var index=0; index < me.filterPropertyNames.length; index++)
{
var propertyName = me.filterPropertyNames[index];
var propertyValue = me.filterPropertyValues[index]
var propertyValueOfNode = node.get(propertyName);
if(me.filterColumnRenderers[index] != false){
var renderingFunction = me.filterColumnRenderers[index];
propertyValueOfNode = renderingFunction(propertyValueOfNode); //Using the renderer function of the column
}
var regExpn = new RegExp(propertyValue, "ig") // the regExp could be modified to allow for case-sensitive, starts with, etc.
if(propertyValueOfNode != null && (propertyValueOfNode+'').match(regExpn)) {
numberOfFiltersMatched++;
}
}
if(numberOfFiltersMatched == me.filterPropertyNames.length){
matches.push(node); // add the node to the matches array
}
});
if (me.allowParentFolders === false) { // if me.allowParentFolders is false (default) then remove any non-leaf nodes from the regex match
Ext.each(matches, function (match) {
if (match == null || !match.isLeaf()) {
Ext.Array.remove(matches, match);
}
});
}
Ext.each(matches, function (item, i, arr) { // loop through all matching leaf nodes
root.cascadeBy(function (node) { // find each parent node containing the node from the matches array
if (node.contains(item) == true) {
visibleNodes.push(node); // if it's an ancestor of the evaluated node add it to the visibleNodes array
}
});
if (me.allowParentFolders === true && !item.isLeaf()) { // if me.allowParentFolders is true and the item is a non-leaf item
item.cascadeBy(function (node) { // iterate over its children and set them as visible
visibleNodes.push(node);
});
}
visibleNodes.push(item); // also add the evaluated node itself to the visibleNodes array
});
root.cascadeBy(function (node) { // finally loop to hide/show each node
viewNode = Ext.fly(tree.getView().getNode(node)); // get the dom element assocaited with each node
if (viewNode) { // the first one is undefined ? escape it with a conditional
viewNode.setVisibilityMode(Ext.Element.DISPLAY); // set the visibility mode of the dom node to display (vs offsets)
viewNode.setVisible(Ext.Array.contains(visibleNodes, node));
}
});
}
, clearFilter: function () {
var me = this
, tree = this.tree
, root = tree.getRootNode();
if (me.collapseOnClear) {
tree.collapseAll(); // collapse the tree nodes
}
root.cascadeBy(function (node) { // final loop to hide/show each node
viewNode = Ext.fly(tree.getView().getNode(node)); // get the dom element assocaited with each node
if (viewNode) { // the first one is undefined ? escape it with a conditional and show all nodes
viewNode.show();
}
});
},
onMenuCreate: function(headerCt, menu) {
var me = this;
menu.on('beforeshow', me.onMenuBeforeShow, me);
},
onMenuBeforeShow: function(menu) {
var me = this;
var currentHeaderFilter = menu.activeHeader.filter;
if(currentHeaderFilter == null){
if(me.menuItem == null){
return;
}
me.menuItem.hide();
me.menuSeparator.hide();
}else if(me.menuItem != null){
me.menuItem.show();
me.menuSeparator.show();
}
if(me.menuItem){
var perviousFilterValue = me.getValueForName(menu.activeHeader.dataIndex);
if(perviousFilterValue == null || perviousFilterValue == ''){
me.menuItem.setRawValue('');
}else{
me.menuItem.setRawValue(perviousFilterValue);
}
}else{
me.menuSeparator = menu.add('-');
var filterTextFiels = new Ext.form.TextField({
itemId: 'filterTextBox',
cls : 'find-icon',
listeners: {
'change': this.onFilterTextChange
}
});
me.menuItem = menu.add(filterTextFiels);
}
me.menuItem.activeDataIndex = menu.activeHeader.dataIndex;
me.menuItem.activeRenderer = menu.activeHeader.renderer;
me.menuItem.width = (currentHeaderFilter == null || currentHeaderFilter.width == null) ? 150 : currentHeaderFilter.width;
},
onFilterTextChange : function (searchMenuItem, value) {
treeGrid.filter(value,searchMenuItem.activeDataIndex, null, searchMenuItem.activeRenderer);
},
updateValueForName : function(property, value, columnRenderer){
var propertyIndex = -1;
for (var index=0; index < this.filterPropertyNames.length; index++)
{
if(property == this.filterPropertyNames[index]){
propertyIndex = index;
break;
}
}
if(propertyIndex >= 0){
if(value == null || value == ''){
this.filterPropertyNames.splice(propertyIndex, 1);
this.filterPropertyValues.splice(propertyIndex, 1);
this.filterColumnRenderers.splice(propertyIndex, 1);
}else{
this.filterPropertyValues[propertyIndex] = value;
}
}else{
propertyIndex = this.filterPropertyNames.length;
this.filterPropertyNames[propertyIndex] = property;
this.filterPropertyValues[propertyIndex] = value;
this.filterColumnRenderers[propertyIndex] = columnRenderer;
}
},
getValueForName : function(property){
var propertyIndex = -1;
for (var index=0; index < this.filterPropertyNames.length; index++)
{
if(property == this.filterPropertyNames[index]){
propertyIndex = index;
break;
}
}
if(propertyIndex >= 0){
return this.filterPropertyValues[propertyIndex];
}else{
return null;
}
}
});
This feature can be used in grid as
var treeGridFilter = {
ftype: "treeGridFilter"
};
var treeGrid= Ext.create('Ext.tree.Panel', {
id : 'tree-grid-id',
title: 'View Tree Grid',
features: [treeGridFilter],
store: store,
renderTo: 'grid-div',
columns: [{
text: 'Column One',
dataIndex: 'columnOne',
filter : {
width: 150
}
},{
text: 'Column Two',
dataIndex: 'columnTwo',
filter : {
width: 100
}
}]
});
Tree stores don't have a filtering function, but I had to create one for an earlier project. Here's an example.
So, as a suggestion you could create your own filter drop menus using Ext.grid.header.Container configs in the tree columns (as covered here in the docs) these could be set-up to call some kind of filter function on the treestore like the one I linked to above.