How do i separate a video into frames without displaying all the frames in different figures? |
Not sure whether it is a full solution, but one improvement in your code
would definately be to move the figure() command out of the loop.
Maybe this is already sufficient, or maybe you need to assign your image
command to a handle as described in this related question , allowing you to
remove the last plotted image before you plot a new one.
|
Selecting data.frames in a list of data.frames, based on numbers of rows, with R |
What you want is
lizlist[sapply(lizlist, nrow)==14]
Keep in mind this will return a list of all data.frames meeting the
criteria (which is generally a good thing). You can use [[ and which if you
know the list will only contain one such data.frame.
|
Match columns of two data frames according to a reference column that is common on both data frames in R |
How about this?
merge(df.1,df.2,by="V1",all=TRUE)
V1 V2.x V2.y
1 1 0.9169835 0.9658816
2 2 1.0327111 1.0618083
3 3 0.8368222 NA
4 4 NA 1.2700018
5 5 1.0061137 1.0186826
6 6 1.0086698 1.1848159
7 7 1.0362074 NA
8 8 1.0979917 1.0730377
9 9 NA 1.0394662
10 10 1.0029076 0.8488569
11 11 1.1081483 0.8396724
12 12 1.0920723 0.8025356
When the all argument is set to TRUE, it keeps all the rows even though one
of the data.frames does not contain a matching row. When a data.frame does
not contain a matching row, NA is filled in.
To get the variable names V2 and V3 you can either rename V2 to V3 in the
second data.frame (here defined as df.2) beforehand or rename V2.x and V2.y
after merging.
|
Manipulating matrices and data frames into 3-column data frames with same R script |
Two points:
While as.numeric will create a simple vector from a matrix, it won't do the
same for a data.frame. A data.frame is a list of vectors, while a matrix is
a vector with a dimensional attribute. As such, an alternative would be to
use unlist first:
as.numeric(unlist(ds, use.names = FALSE))
It seems like you're actually just trying to create a "long" form of your
data. In this case, explore stack from base R and melt from "reshape2". A
possible approach would be:
out <- cbind(rownames(ds), stack(as.data.frame(ds)))
names(out) <- c("vector", "of", "names") ## Replace as required :)
or
library(reshape2)
out <- melt(as.matrix(ds))
|
Making a match between two variables from diferent data frames and showing others variables from both data frames |
# input data
df1 = read.table(text = ' Num.Op Bonus
381942 Y
382181 Z
382260 A
382266 A', header = T)
df2 = read.table(text = ' Num.Op1 Site
381942 "Ecua Auto S.A."
382181 "Vallejo Araujo S.A."
382260 "Automotores de la Sierra"
382266 "Automotores de la Sierra"
382310 "Vallejo Araujo S.A."
382619 "Vallejo Araujo S.A."', header = T)
# load data.table, convert to data.table and set keys for merging
library(data.table)
dt1 = data.table(df1, key = "Num.Op")
dt2 = data.table(df2, key = "Num.Op1")
# the merge - add a v1 column to dt1, merge with dt2, whenever the merge
fails,
# i.e. v1 is NA, set v1 to 0 and Site to NA (Bonus will be set to NA
automatically)
result = dt1[, v1 := 1][dt2][is.na(v1), `:=`(v1 = 0, Site = NA_c
|
how to add picture box control and label control dynamically in list view control |
Did you google around?
There are lot of links that can help you
http://geekswithblogs.net/dotNETvinz/archive/2009/04/24/faq-displaying-image-from-database-to-gridview-control.aspx
http://weblogs.asp.net/aghausman/archive/2009/05/26/show-images-on-grid-view-from-file-stream.aspx
http://www.codeproject.com/Articles/20782/Displaying-Images-from-a-Database-in-a-GridView
http://www.codeproject.com/Articles/20971/Thumbnail-Images-in-GridView-using-C
|
Subset a list of data.frames and return list of data.frames |
This should do it for you:
subsetl <- lapply(l,function(x) {
x[x<4] <- NA
return(x)
})
Result:
>subsetl
[[1]]
a b c
1 NA 4 NA
2 NA 5 4
3 NA 6 5
4 4 5 6
5 5 5 7
6 6 5 8
[[2]]
a b c
1 NA 4 NA
2 4 5 NA
3 5 6 NA
4 6 5 4
5 7 5 5
6 8 5 6
[[3]]
a b c
1 4 NA NA
2 5 4 NA
3 6 5 NA
4 5 6 4
5 5 7 5
6 5 8 6
|
How to add an html control inside a div or crate a new control beside another control |
var myA=document.createElement("a"); would create an element, you can set
it's text by myA.innerHTML and src with myA.src="http://www.google.com"
To add it to the page you can do:
document.getElmentById("mydiv").appendChild(myA);
to remove:
var As=document.getElmentById("mydiv").getElementsByTagName("a");
var a = As[As.length-1];
a.parentElement.removeChild(a);
|
How can I use wildcards or regular expressions to control Path-based authorization / access control for svn? |
as of June 2013 it is impossible to do this. So, the solution to the
problem is to re-organize the repository so this isn't necessary. When a
thing is too difficult it usually leads to a large rethink of the design or
approach.
At present maven structure leads to this requirement:
root/pom.xml
root/project1/pom.xml
root/project2/pom.xml
etc..
We can replace this with
/root/pom.xml
/project1/pom.xml
/project2/pom.xml
etc..
We can set the svn perms as follows granting all read access to the top
level project and read write to their project. If an continuous
integration build server populates an internal maven repo with the root
snapshot then the users only need to checkout specific projects.
[repo:/root]
* = r
@releng = rw
[repo:/project1]
@teamOne = rw
[repo:/project2]
@teamTwo =
|
Update parent control when the child control is manually removed in the designer |
To wrap it up, I found a solution to my problem. Like a TabControl, my
ButtonList contains two collections:
ControlCollection inherited from the Control class
ButtonListItemCollection (TabControl has TabPageCollection)
Adding ButtonListItems is done via the collection editor in the properties.
Removing can be done either in the collection editor or just by selecting
the ButtonListItem in the designer and pressing the DEL button on the
keyboard (manual deletion).
When using the collection editor, ButtonListItems are added/removed to/from
the ButtonListItemCollection and then to/from the ControlCollection.
However, when a ButtonListItem is manually deleted it is only deleted from
the ControlCollection not from the ButtonListItemCollection. So what needs
to be done is to detect when the
|
Tap event on dynamically added custom control is handled by another control of same type |
I figured out the problem, and I am chocking it up to lack of experience
with WPF.
When I made my Waypoints I created them like to
var newWaypoint = new Waypoint(waypointNumber, latitude, longitude);
newWaypoint.Name = "wayPoint" + waypointNumber;
newWaypoint.Opacity = 100;
double leftMargin = CalculateLeftMargin(longitude);
double topMargin = CalculateTopMargin(latitude);
newWaypoint.Margin = new Thickness(leftMargin, topMargin, 0, 0);
LayoutRoot.Children.Add(newWaypoint);
The problem with that was that I was setting the Margin of the control.
When I set the Margin it was actually stretching out my Waypoint so I was
having Waypoints on top of Waypoints.
After some research I came across this article Changing Position of an
Element Programmatically in WPF which showed me how to prope
|
how to restrict child control inside Parent control in Winform application? |
if you add the label to the panel dynamically then you must do:
this.panel1.Controls.Add(this.button1);
if you don't, that the mistake. On top of that, when you move the label,
make sure that the new values are inside the range of the panel, using
panel1.Location.X
panel1.Location.Y
and share your code for more help if needed
|
Button sizes changing on user control when control is added to window |
You have don't have your LastChildFill property set to False on your top
DockPanel. This is the reason "Ent" is changing size and moving your
screen.
You also have the HorizontalAlignment on "Del" set to stretch. Try setting
that to Left, but might be moot with the LastChildFill correction.
The overall resizing is do to HorizontalAlignment set to Stretch set that
to Left.
|
jump to search result in a repeat control with a pager control in a xpages |
A few pointers that might help you to go ahead:
stop paging in repeats. The extlib has a nice sample of "show more", so
instead of showing 1-20, 21-40 etc. you show until the record you found
(might not work for large datasets)
Open the search page with URL parameters that indicate the position number
of the document (e.g. 498). Then use that parameter to let the repeat
control figure out the starting position (which depends on the number of
documents the repeat is configured for (default is 30, but you don't know).
Just make sure not to use the passed parameter unchecked.
you can add <a name="[unid]"> (or id=) tags to the repeat and then
[directly navigate] (http://reference.sitepoint.com/html/a) to them
....nsf/searchResults.xsp#unid?moreParameters
Let us know how it goes
|
Border doesn't inherit Control, so how does a setter on Control.Background work? |
Background dependency property in WPF is shared by many classes. It is
defined in the Panel class, other classes just call AddOwner on it.
Border.cs
[CommonDependencyProperty]
public static readonly DependencyProperty BackgroundProperty =
Panel.BackgroundProperty.AddOwner(
typeof (Border),
new FrameworkPropertyMetadata(null,
FrameworkPropertyMetadataOptions.AffectsRender |
FrameworkPropertyMetadataOptions.SubPropertiesDoNotAffectRender));
Panel.cs
[CommonDependencyProperty]
public static readonly DependencyProperty BackgroundProperty =
DependencyProperty.Register("Background",
typeof(Brush),
typeof(Panel),
new FrameworkPropertyMetadata((Brush)null,
FrameworkPropertyMetadataOptions.AffectsRender |
|
adding Control to form but gap keeps doubling when added at Bottom of previous control |
this is more of a hack but it works.
sharpUserX.Size = sharpUserSize
PnlSharpUsers.Controls.Add(sharpUserX)
sharpUserX.Location = pnlAddBtn.Location
if i set the size before i add the control, then set the location after it
seems to apply the font scaling to the size, but not the location, which
works perfectly for me.
|
Black lines when adding custom control to a panel with Control's DockStyle set to Top |
Finally I found the solution to my problem. I was setting the Comment
control's AutoSize property to true. When I set it false, it worked. Thanks
@Sayse, your comment gave me hint about it.
|
ms-access 2007 form datetime control : if control length smaller than the size of the value it shows ### |
Access doesn't behave like this. You can either
increase the width of the control (the best solution)
specify a shorter Format for the date
reduce the font size
An odd approach would be to add a label which obscures some of the
date-control, but such that you can still see part of the date in the
background.
You might consider using an event such as Focus to change the Format of the
control, but this won't work as the Format only applies when you move away
from the control.
You could, I suppose, use two controls; one for display and one for
editing.
|
How to make binding from user control to property of parent control? |
ElementName binding works within in same XAML scope. This will work -
<Grid>
<CheckBox Name="checkBox1"/>
<Label Content="{Binding ElementName=checkBox1, Path=Name}"/>
</Grid>
But if you want to do it in different UserControl, you have to tweak a bit
your code and use Tag to hold name -
<Grid>
<CheckBox Name="checkBox1">
<local:UserControl1 Tag="{Binding ElementName=checkBox1,
Path=Name}"/>
</CheckBox>
</Grid>
UserControl.xaml
<Canvas>
<Label Content="{Binding Path=Tag, RelativeSource={RelativeSource
Mode=FindAncestor, AncestorType=UserControl}}"/>
</Canvas>
On a sidenote, in your UserControl, you know you need to bind with
ElementName = checkBox1 and that's
|
Access Parent Page Control in Child User Control |
You will have something like this in tab control.
<cc1:TabContainer ID="TabContainer1" runat="server">
<cc1:TabPanel ID="TabPanel1" runat="server">
<ContentTemplate>
<asp:DropDownList id="dropdownlist1" runat="Server"/>
</ContentTemplate>
</cc1:TabPanel>
So first you need to find tabPanel1 then find dropdownlist1 like following.
TabContainer TabContainer1=
(TabContainer)(this.Page.FindControl("TabContainer1");
if (TabContainer1!=null){
TabPanel TabPanel1= (TabPanel)(this.TabContainer1.FindControl("TabPanel1");
if(TabPanel1 !=null){
DropDownList dropdownlist1=
(DropDownList)(this.TabPanel1.FindControl("dropdownlist1");
}}
|
Retaining ASP.NET Control values througn their ID does NOT work for FileUpload control |
You can get the uploaded file collection using this code :
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(Server.MapPath("MyFiles") + "\" +
System.IO.Path.GetFileName(hpf.FileName));
Response.Write("<b>File: </b>" + hpf.FileName + "
<b>Size:</b> " +
hpf.ContentLength + " <b>Type:</b> " +
hpf.ContentType + " Uploaded Successfully <br/>");
}
}
|
How to access the main page control values in user control |
To retrieve, for example, a textbox defined in the aspx page from an ascx
control contained in it you could try:
Dim myTextBox As TextBox = Ctype(Me.Parent.FindControl("myTextBoxName"),
TextBox)
Note that the control you want to retrieve must have a runat="server"
attribute otherwise it can not be seen server side.
In your question you posted three controls without runat="server"; you
could use instead:
<asp:HiddenField ID="HiddenField1" runat="server" Value="1" />
<asp:HiddenField ID="HiddenField2" runat="server" Value="2" />
<asp:HiddenField ID="HiddenField3" runat="server" Value="3" />
In this case the above command would become:
Dim myHiddenField As HiddenField =
Ctype(Me.Parent.FindControl("myHiddenFieldName"), HiddenField)
|
Custom Control: Scripts not loaded when control is hidden on pageload |
I had a very similar problem earlier and came across your question.
I was loading javascript for my custom control by overriding the
OnPreRender method.
protected override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
Page.ClientScript.RegisterClientScriptInclude("MyJavascript",
"MyURL");
}
This had worked when using the control in a normal page environment, but in
this case I was using it inside an update panel and initially hiding it.
Ajax post backs from the update panel would then update the Visible
property to true. At this point of course ASP.NET has no opportunity to
automatically inject the client script into the <head> of the page.
The solution
Instead of overriding OnPreRender you can override OnInit (which should
always fire even when t
|
FlowLayout Control With User Control Item Template Not Binding |
Try:
public UserControl2() {
InitializeComponent();
Loaded += (sender, args) => {
var obj = (ViewMod)this.DataContext;
if (obj == null || obj.Prop == null)
return;
var d = obj.Prop;
if (d == null)
return;
grd2.Children.Add(new TextBlock { Text = d.Name });
};
}
DataContext is not set instantly. Hence we use the Loaded event and add a
lambda to it to do your corresponding steps.
side-note:
even-though this works, please do search and look at some MVVM examples.
While having no code-behind is not really an MVVM requirement, I think your
taking it a bit too far adding Grid children and stuff from code-behind
when you can do it perfectly fine from xaml.
|
dynamically created wpf control doesn't work the same as the control it is based on |
You aren't setting IsHiteTestVisible = false on your Rectangle. That is the
problem, because your ContentPresenter is on top of the MoveThumb in your
template. I'm not sure what the MoveThumb looks like, but if it is just a
transparent rectangle, I'd put that on top of the ContentPresenter so you
don't have to worry about setting IsHitTestVisible on all the children you
add.
|
Custom control events don't fire when control collection is cached? |
The reason this doesn't work is because the controls must be recreated on
the post back, and events wired up, for them to fire.
See, since the server is stateless, to fire an event on an object, that
object needs recreated AND readded to the form.
How about cache the database result instead and continue the loop otherwise
to build new, add, and hookup the controls?
|
How can I bind a parent control's TextBox from inside a user control |
You can declare the DataContext property of the <TextBlockControl />
as the Text property of the "editor" <TextBox />:
<wpfSandbox:TextBlockControl DataContext="{Binding Text,
ElementName=editor}" />
and inside your control:
<Grid>
<TextBlock Text="{Binding}" />
</Grid>
|
How to copy an ActiveX control over to another sheet preventing the name change of the control |
ActiveX
You can copy an ActiveX Control from one sheet to another with the below
code.
Note: you cannot have two objects of the same name on one spreadsheet.
Sub CopyActiveX()
Application.ScreenUpdating = False
Dim x As OLEObject, y As OLEObject
Set x = Sheets("SRC").OLEObjects("HasCustomName")
Set y = x.Duplicate
Dim xName As String
xName = x.Name
y.Cut
With Sheets("TRGT")
.Paste
.OLEObjects(.OLEObjects.Count).Name = xName
.Activate
End With
Application.ScreenUpdating = True
End Sub
Form Control
To copy a button from one sheet to another preventing the automatic name
change use the below code. Excel by default gives a new name to a copied
button (even on a different sheet) so you have to rename it to match the
name o
|
Horizontal scrollbar control for child div outside parent div/ floating div control |
You could do this with some JQuery.
Just include the library:
<script
src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
See JSfiddle: http://jsfiddle.net/V4T4V/
Using the scroll function you can detect when wrapper1 is being scrolled
and then move wrapper2.
$(function(){
$(".wrapper1").scroll(function(){
$(".wrapper2")
.scrollLeft($(".wrapper1").scrollLeft());
});
$(".wrapper2").scroll(function(){
$(".wrapper1")
.scrollLeft($(".wrapper2").scrollLeft());
});
});
You can then place this bar outside the div, at the top etc.
Simply place this where you want the scrollbar (note the wrapper's css must
be the same width):
<div class="wrapper1">
<div class="div1">
</div>
|
Edit Control showing a readout of Slider Control's position |
What happens if you try extracting the position of the slider directly with
GetPos rather than using the nPos parameter?
|
How to put control id based on parent control reference/ID to avoid conflict |
I think you can differentiate by using the id edit-issue-dialog
if($("#edit-issue-dialog").length){
//u r in edit form, and do your stuff
}else{
//in create form do your stuff
}
|
I can not display binding value of a custom control's property when control loads |
Try binding SelectedItem property to ControlTemplate
<ScrollViewer x:Name="PART_ContentHost"
Content={TemplateBinding SelectedItem}
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalAlignment="Stretch"/>
|
Find radio button control in nested repeater control in asp.net? |
I found the answer. Thanks
foreach (RepeaterItem repeater in TabRepeater.Items)
{
Repeater repeater1 =
(Repeater)repeater.FindControl("ContentRepeater");
foreach (RepeaterItem repItem in repeater1.Items)
{
for (int i = 1; i <= 4; i++)
{
string rdboption = ds.Tables[0].Rows[c][0].ToString() +
"_" + ds.Tables[0].Rows[i - 1][2].ToString() + "_" + "Option" + i + "_" +
i;
PlaceHolder PlPreview =
(PlaceHolder)repItem.FindControl("PlPreview");
rbt = (RadioButton)PlPreview.FindControl(rdboption);
if (rbt.Checked)
{
// statement
}
}
}
|
Retrieving ascx control value from a callback registered on master page. Control added to Repeater's PlaceHolder during OnItemCreated |
I'm not sure what changed, maybe it was taking the break to rubber duck
debug using all of the above. I've gone back and tried tweaking some of the
things I had before (order of insertion, which call to use, etc) to see if
they make a difference, but either way, the Control is now being persisted
in the ViewState properly with the above code. It is available on postback
from the master page call so long as the following is added (bullet #1 of
what I tried before):
protected override void LoadViewState(object savedState)
{
base.LoadViewState(savedState);
RefreshOptions();
}
Earlier, savedState was only showing the List<int> added to it to
maintain selected options. At some point in tweaking and debugging, I saw
that the controls I created were now in the
|
How to control volumes of file playing using System Sound Services by side volume control buttons in iPhone |
use this simple code for control system sound,it not work in simulator,only
work in device
[[MPMusicPlayerController applicationMusicPlayer] setVolume:0];//set values
0-1
|
How to pass data from user control to main control in wpf |
You can set the DataContext(viewmodel) of the user control same as that of
Main Window. Keep a property in viewModel and Bind that Property in the
user control. So whenever anything changes in the Control that property
will automatically be updated in the View Model which can be used by the
Main
|
ASP.NET button on a web control has click event, but isn't recognized by control |
You have to declare the code behind class as partial and remove the button
declaration, because visual studio generates some code as well.
namespace MyNamespace
{
public partial class MyControl : UserControl
{
protected void btSubmit_Click(object sender, EventArgs e) { ... }
}
}
If that doesn't work, create a new UserControl and copy-paste the code
inside the class and the HTML.
|
Raising an event from child control to parent control |
Try it :
public Rectangle
{
this.Click += new System.EventHandler(Function);
}
private void Function(object sender, System.EventArgs e)
{
if (((MouseEventArgs)e).Button == MouseButtons.Right)
{
//Your code
}
}
|
Wizard control inside an AJAX ModalPopUp control? |
I was searching for something else and I found this question unanswered.
So... if you have not found a solution for it. Try following,
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:LinkButton ID="LinkButton1"
runat="server">LinkButton</asp:LinkButton>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
PopupControlID="Panel1" TargetControlID="LinkButton1" >
</cc1:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Wizard ID="Wizard1" runat="server">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server"
Title="Step 1">
|
Is it possible to modify a control property's get and set methods without extending the control? |
You can add an extension method to your HiddenField control--it doesn't
require inheritance for it to work. But the solution is also limited,
since you'll have to change the code to reference the extension method by
default.
public static void SetValue(this HiddenField c, string text)
{
c.Value = HttpUtility.HtmlEncode(text);
}
public static string GetValue(this HiddenField c)
{
return HttpUtility.HtmlDecode(c.Value);
}
|