Search Results

Search found 4490 results on 180 pages for 'binding'.

Page 17/180 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • Swapping data binding in code

    - by Phil J Pearson
    I have two data-bound text boxes. One is bound to a string and the other to a number. The 'default' binding is set in XAML. Under some circumstances I need to reverse the bindings at runtime (the string is usually a prefix but sometimes it's a suffix). I have the following code in my view model, called when the window is loaded: Binding stringBinding = BindingOperations.GetBinding(view.seqLeft, TextBox.TextProperty); Binding numberBinding = BindingOperations.GetBinding(view.seqRight, TextBox.TextProperty); view.seqLeft.SetBinding(TextBlock.TextProperty, numberBinding); view.seqRight.SetBinding(TextBlock.TextProperty, stringBinding); After that the code loads the properties to which the binding refers. The problem is that the 'new' binding doesn't seem to work. What have I missed? Is there a better way?

    Read the article

  • Programmatic binding of accelerators in wxPython

    - by Inductiveload
    I am trying to programmatically create and bind a table of accelerators in wxPython in a loop so that I don't need to worry about getting and assigning new IDs to each accelerators (and with a view to inhaling the handler list from some external resource, rather than hard-coding them). I also pass in some arguments to the handler via a lambda since a lot of my handlers will be the same but with different parameters (move, zoom, etc). The class is subclassed from wx.Frame and setup_accelerators() is called during initialisation. def setup_accelerators(self): bindings = [ (wx.ACCEL_CTRL, wx.WXK_UP, self.on_move, 'up'), (wx.ACCEL_CTRL, wx.WXK_DOWN, self.on_move, 'down'), (wx.ACCEL_CTRL, wx.WXK_LEFT, self.on_move, 'left'), (wx.ACCEL_CTRL, wx.WXK_RIGHT, self.on_move, 'right'), ] accelEntries = [] for binding in bindings: eventId = wx.NewId() accelEntries.append( (binding[0], binding[1], eventId) ) self.Bind(wx.EVT_MENU, lambda event: binding[2](event, binding[3]), id=eventId) accelTable = wx.AcceleratorTable(accelEntries) self.SetAcceleratorTable(accelTable) def on_move(self, e, direction): print direction However, this appears to bind all the accelerators to the last entry, so that Ctrl+Up prints "right", as do all the other three. How to correctly bind multiple handlers in this way?

    Read the article

  • ASP.NET: Using conditionals in data binding expressions

    - by DigiMortal
    ASP.NET 2.0 has no support for using conditionals in data binding expressions but it will change in ASP.NET 4.0. In this posting I will show you how to implement Iif() function for ASP.NET 2.0 and how ASP.NET 4.0 solves this problem smoothly without any code. Problem Let’s say we have simple repeater. <asp:Repeater runat="server" ID="itemsList">     <HeaderTemplate>         <table border="1" cellspacing="0" cellpadding="5">     </HeaderTemplate>     <ItemTemplate>         <tr>         <td align="right"><%# Container.ItemIndex + 1 %>.</td>         <td><%# Eval("Title") %></td>         </tr>     </ItemTemplate>     <FooterTemplate>         </table>     </FooterTemplate> </asp:Repeater> Repeater is bound to data when form loads. protected void Page_Load(object sender, EventArgs e) {     var items = new[] {                     new { Id = 1, Title = "Headline 1" },                     new { Id = 2, Title = "Headline 2" },                     new { Id = 2, Title = "Headline 3" },                     new { Id = 2, Title = "Headline 4" },                     new { Id = 2, Title = "Headline 5" }                 };     itemsList.DataSource = items;     itemsList.DataBind(); } We need to format even and odd rows differently. Let’s say we want even rows to be with whitesmoke background and odd rows with white background. Just like shown on screenshot on right. Our first thought is to use some simple expression to avoid writing custom methods. We cannot use construct like this <%# Container.ItemIndex % 2==0 ? "white" : "whitesmoke"  %> because all we get are template compilation errors. ASP.NET 2.0: Iif() method For ASP.NET 2.0 pages and controls we can create Iif() method and call it from our templates. This is out Iif() method. protected object Iif(bool condition, object trueResult, object falseResult) {     return condition ? trueResult : falseResult; } And here you can see how to use it. <asp:Repeater runat="server" ID="itemsList">   <HeaderTemplate>     <table border="1" cellspacing="0" cellpadding="5">     </HeaderTemplate>   <ItemTemplate>     <tr style='background-color:'       <%# Iif(Container.ItemIndex % 2==0 ? "white" : "whitesmoke") %>'>       <td align="right">         <%# Container.ItemIndex + 1 %>.</td>       <td>         <%# Eval("Title") %></td>     </tr>   </ItemTemplate>   <FooterTemplate>     </table>   </FooterTemplate> </asp:Repeater> This method does not care about types because it works with all objects (and value-types). I had to define this method in code-behind file of my user control because using this method as extension method made it undetectable for ASP.NET template engine. ASP.NET 4.0: Conditionals are supported In ASP.NET 4.0 we will write … hmm … we will write nothing special. Here is solution. <asp:Repeater runat="server" ID="itemsList">   <HeaderTemplate>     <table border="1" cellspacing="0" cellpadding="5">     </HeaderTemplate>   <ItemTemplate>     <tr style='background-color:'       <%# Container.ItemIndex % 2==0 ? "white" : "whitesmoke" %>'>       <td align="right">         <%# Container.ItemIndex + 1 %>.</td>       <td>         <%# Eval("Title") %></td>     </tr>   </ItemTemplate>   <FooterTemplate>     </table>   </FooterTemplate> </asp:Repeater> Yes, it works well. :)

    Read the article

  • How can I highlight empty fields in ASP.NET MVC 2 before model binding has occurred?

    - by Richard Poole
    I'm trying to highlight certain form fields (let's call them important fields) when they're empty. In essence, they should behave a bit like required fields, but they should be highlighted if they are empty when the user first GETs the form, before POST & model validation has occurred. The user can also ignore the warnings and submit the form when these fields are empty (i.e. empty important fields won't cause ModelState.IsValid to be false). Ideally it needs to work server-side (empty important fields are highlighted with warning message on GET) and client-side (highlighted if empty when losing focus). I've thought of a few ways of doing this, but I'm hoping some bright spark can come up with a nice elegant solution... Just use a CSS class to flag important fields Update every view/template to render important fields with an important CSS class. Write some jQuery to highlight empty important fields when the DOM is ready and hook their blur events so highlights & warning messages can be shown/hidden as appropriate. Pros: Quick and easy. Cons: Unnecessary duplication of importance flags and warning messages across views & templates. Clients with JavaScript disabled will never see highlights/warnings. Custom data annotation and client-side validator Create classes similar to RequiredAttribute, RequiredAttributeAdapter and ModelClientValidationRequiredRule, and register the adapter with DataAnnotationsModelValidatorProvider.RegisterAdapter. Create a client-side validator like this that responds to the blur event. Pros: Data annotation follows DRY principle (Html.ValidationMessageFor<T> picks up field importance and warning message from attribute, no duplication). Cons: Must call TryValidateModel from GET actions to ensure empty fields are decorated. Not technically validation (client- & server-side rules don't match) so it's at the mercy of framework changes. Clients with JavaScript disabled will never see highlights/warnings. Clone the entire validation framework It strikes me that I'm trying to achieve exactly the same thing as validation but with warnings rather than errors. It needs to run before model binding (and therefore validation) has occurred. Perhaps it's worth designing a similar framework with annotations like Required, RegularExpression, StringLength, etc. that somehow cause Html.TextBoxFor<T> etc. to render the warning CSS class and Html.ValidationMessageFor<T> to emit the warning message and JSON needed to enable client-side blur checks. Pros: Sounds like something MVC 2 could do with out of the box. Cons: Way too much effort for my current requirement! I'm swaying towards option 1. Can anyone think of a better solution?

    Read the article

  • Proper binding data to combobox and handling its events.

    - by Wodzu
    Hi guys. I have a table in SQL Server which looks like this: ID Code Name Surname 1 MS Mike Smith 2 JD John Doe 3 UP Unknown Person and so on... Now I want to bind the data from this table into the ComboBox in a way that in the ComboBox I have displayed value from the Code column. I am doing the binding in this way: SqlDataAdapter sqlAdapter = new SqlDataAdapter("SELECT * FROM dbo.Users ORDER BY Code", MainConnection); sqlAdapter.Fill(dsUsers, "Users"); cbxUsers.DataSource = dsUsers.Tables["Users"]; cmUsers = (CurrencyManager)cbxUsers.BindingContext[dsUsers.Tables["Users"]]; cbxUsers.DisplayMember = "Code"; And this code seems to work. I can scroll through the list of Codes. Also I can start to write code by hand and ComboBox will autocomplete the code for me. However, I wanted to put a label at the top of the combobox to display Name and Surname of the currently selected user code. My line of though was like that: "So, I need to find an event which will fire up after the change of code in combobox and in that event I will get the current DataRow..." I was browsing through the events of combobox, tried many of them but without a success. For example: private void cbxUsers_SelectionChangeCommitted(object sender, EventArgs e) { if (cmUsers != null) { DataRowView drvCurrentRowView = (DataRowView)cmUsers.Current; DataRow drCurrentRow = drvCurrentRowView.Row; lblNameSurname.Text = Convert.ToString(drCurrentRow["Name"]) + " " + Convert.ToString(drCurrentRow["Surname"]); } } This give me a strange results. Firstly when I scroll via mouse scroll it doesn't return me the row wich I am expecting to obtain. For example on JD it shows me "Mike Smith", on MS it shows me "John Doe" and on UP it shows me "Mike Smith" again! The other problem is that when I start to type in ComboBox and press enter it doesn't trigger the event. However, everything works as expected when I bind data to lblNameSurname.Text in this way: lblNameSurname.DataBindings.Add("Text", dsusers.Tables["Users"], "Name"); The problem here is that I can bind only one column and I want to have two. I don't want to use two labels for it (one to display name and other to display surname). So, what is the solution to my problem? Also, I have one question related to the data selection in ComboBox. Now, when I type something in the combobox it allows me to type letters that are not existing in the list. For example, I start to type "J" and instead of finishing with "D" so I would have "JD", I type "Jsomerandomtexthere". Combobox will allow that but such item does not exists on the list. In other words, I want combobox to prevent user from typing code which is not on the list of codes. Thanks in advance for your time.

    Read the article

  • Item rendered via a DataTemplate with any Background Brush renders selection coloring behind item.

    - by Mike L
    I have a ListBox which uses a DataTemplate to render databound items. The XAML for the datatemplate is as follows: <DataTemplate x:Key="NameResultTemplate"> <WrapPanel x:Name="PersonResultWrapper" Margin="0" Orientation="Vertical" Background="{Binding Converter={StaticResource NameResultToColor}, Mode=OneWay}" > <i:Interaction.Triggers> <i:EventTrigger EventName="MouseDown"> <cmd:EventToCommand x:Name="SelectPersonEventCommand" Command="{Binding Search.SelectedPersonCommand, Mode=OneWay, Source={StaticResource Locator}}" CommandParameter="{Binding Mode=OneWay}" /> </i:EventTrigger> </i:Interaction.Triggers> <TextBlock x:Name="txtPersonName" TextWrapping="Wrap" Margin="0" VerticalAlignment="Top" Text="{Binding PersonName}" FontSize="24" Foreground="Black" /> <TextBlock x:Name="txtAgencyName" TextWrapping="Wrap" Text="{Binding AgencyName}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0" FontStyle="Italic" Foreground="Black" /> <TextBlock x:Name="txtPIDORI" TextWrapping="Wrap" Text="{Binding PIDORI}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0" FontStyle="Italic" Foreground="Black" /> <TextBlock x:Name="txtDescriptors" TextWrapping="Wrap" Text="{Binding DisplayDescriptors}" Margin="0" VerticalAlignment="Top" Foreground="Black"/> <Separator Margin="0" Width="400" /> </WrapPanel> </DataTemplate> Note that there is a value converter called NameResultToColor which changes the background brush of the rendered WrapPanel to gradient brush depending on certain scenarios. All of this works as I'd expect, except when you click on any of the rendered ListBox items. When you click one, there is only the slightest sign of the selection coloring (the default bluish color). I can see a trace bit of it underneath my gradient-brushed item. If I reset the background brush to "no brush" then the selection rendering works properly. If I set the background brush to a solid color, it also fails to render as I'd expect. How can I get the selection coloring to be on top? What is trumping the selection rendering?

    Read the article

  • Silverlight 4 DataBinding: Binding to ObservableCollection<string> not working anymore

    - by Kurt
    Upgrading from SL3 - SL4. First problem: this throws a parser exception: <StackPanel Name={Binding} /> (same with x:Name) Collection is ObservableCollection<string>. Worked fine in SL3. So it seems that SL4 doen't allow binding to the Name property. Huh? So: changed to <StackPanel Tag={Binding} /> ... since I just need to ID the control in code behind. So here's the bug ('cuz this has got to be a bug!): In this frag, AllAvailableItems is an ObservableCollection<string>: <ItemsControl Name="lbItems" ItemsSource="{Binding AllAvailableItems}" Height="Auto" Width="Auto" BorderBrush="Transparent" BorderThickness="0" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="12,6,0,0"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <CheckBox Tag="{Binding}" Checked="ItemChecked_Click" Unchecked="ItemUnchecked_Click" Style="{StaticResource CheckBoxStyle}" Grid.Row="0"> <CheckBox.Content> <TextBlock Text="{Binding}" Style="{StaticResource FormLJustStyle}" /> </CheckBox.Content> </CheckBox> <StackPanel Tag="{Binding}" Orientation="Vertical" Grid.Row="1"> <configControls:ucLanguage /> <!-- simple user control --> </StackPanel> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> In the code behind, I use a recursive function to find the Dependency object with either the Name or Tag property provided: public static T FindVisualChildByName<T>(DependencyObject parent, string name, DependencyProperty propToUse) where T : DependencyObject { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) { var child = VisualTreeHelper.GetChild(parent, i); string controlName = child.GetValue(propToUse) as string; if (controlName == name) { return child as T; } else { T result = FindVisualChildByName<T>(child, name, propToUse); if (result != null) return result; } } return null; } OK, get this: in the code behind, I can get the control that is ORDERED FIRST in the XAML! In other words, if I put the CheckBox first, I can retrieve the CheckBox, but no StackPanel. And vice-versa. This all worked fine in SL3. Any help, ideas ... ? Thanks - Kurt

    Read the article

  • WPF properties memory management

    - by mrpyo
    I'm trying to build binding system similar to the one that is used in WPF and I ran into some memory leaking problems, so here comes my question - how is memory managed in WPF property system? From what I know in WPF values of DependencyProperties are stored in external containers - what I wanna know is how are they collected when DependencyObject dies? Simplest solution would be to store them is some weak reference dictionary - but here comes the main problem I ran into - when there is a listener on property that needs reference to its (this property) parent it holds it (the parent) alive (when value of weak reference dictionary points somewhere, even indirectly, to key - it can't be collected). How is it avoided in WPF without the need of using weak references everywhere?

    Read the article

  • Bash script not working as required with xbindkeys

    - by RanRag
    I made a simple bash script to display a notification whenever my capslock key is pressed. It works fine when I call it like bash capsnotify.sh. The problem now is when I bind my above script to capslock key using xbindkeys tool it doesn't work as required. It shows a notification caps ON when my caps is on but it doesn't show caps OFF notification when my caps is off instead it again shows the caps ON notification. capsnotify.sh #!/bin/bash value=$(xset -q | awk '/Caps/ {print $4}') if [ "$value" == "on" ] then notify-send "caps ON" elif [ "$value" == "off" ] then notify-send "caps OFF" fi .xbindkeysrc "bash /home/ranveer/capsnotify.sh" m:0x2 + c:66 So, the problem is after binding my caps lock key on both events(on/off) it shows caps ON notification.

    Read the article

  • Combining Multiple Queries and Parameters into One Operation

    - by shay.shmeltzer
    This question came up twice this week and while the solution is explained in a couple of previous blog entries I did, I thought that showing off the complete solution in a single video would be nice. The scenario is that you have two VOs with queries that are based on a parameter, I showed in the past how to create a parameter form that executes the query - and you can do this for both. But what if you actually need just one value to drive both queries? How do you combine two parameter forms and two buttons into one? This is what this video shows you. The steps are: Creating two parameter forms Setting the value of a parameter in the binding tab Creating a backing bean to execute the code for one button Adding the code to execute another operation Remarking the parts that can be dropped from the screen Check it out here:

    Read the article

  • How we call an RPC that not only calls external functions but also updates data structures?

    - by Kabumbus
    I have a simple C++ RPC that lets you have remote class instances that support live members (data structures) update as well as method calls. For example I had a class declared like this (pseudocode): class Sum{ public: RPC_FIELD(int lastSum); RPC_METHOD(int summ(int a, int b)) { lastSum = a + b; return lastSum; } }; On machine A I had its instance. On machines B and C I had created its instances and connected them to machine A. So now they actually do all processing on machine A but machines B, C get lastSum class field updates automatically (and can subscribe to update event). How to call (Nice Name) such a functionality when we have binding over network done automatically by RPC library? How RPC library creator can announce such feature?

    Read the article

  • how to bind super+s to indicator applete complete? - gnome classic

    - by rrosa
    i use gnome classic, i'm not a mouse fan. when i get an email while i'm writing code, i i would super+s to get to the indicator-applet-complete and read it. also to write emails, or check unread instant messages. upgrading from 12.04 to 14.04 made super+s bind to applications menu rather than the indicator applet complete. i removed the binding from the applications using dconf-editor, navigating to: org-gnome-desktop-wm-keybindings and disabling (['disabled']) the panel-main-menu key. now, how do i bind super+s to the indicator applet complete? it seems to be some how binded, since if if press super+s and then move the cursor over the applet it'll open the drop down menus (and it won't if i hover without pressing super+s) but i don't want to have to use the mouse...

    Read the article

  • Data binding in an ASP.Net application with Entity Framework

    - by nikolaosk
    This is going to be the eighth post of a series of posts regarding ASP.Net and the Entity Framework and how we can use Entity Framework to access our datastore. You can find the first one here , the second one here , the third one here , the fourth one here , the fifth one here ,the sixth one here and the seventh one here . I have a post regarding ASP.Net and EntityDataSource . You can read it here .I have 3 more posts on Profiling Entity Framework applications. You can have a look at them here ...(read more)

    Read the article

  • LWJGL SlickUtil Texture Binding

    - by Matthew Dockerty
    I am making a 3D game using LWJGL and I have a texture class with static variables so that I only need to load textures once, even if I need to use them more than once. I am using Slick Util for this. When I bind a texture it works fine, but then when I try to render something else after I have rendered the model with the texture, the texture is still being bound. How do I unbind the texture and set the rendermode to the one that was in use before any textures were bound? Some of my code is below. The problem I am having is the player texture is being used in the box drawn around the player after it the model has been rendered. Model.java public class Model { public List<Vector3f> vertices = new ArrayList<Vector3f>(); public List<Vector3f> normals = new ArrayList<Vector3f>(); public ArrayList<Vector2f> textureCoords = new ArrayList<Vector2f>(); public List<Face> faces = new ArrayList<Face>(); public static Model TREE; public static Model PLAYER; public static void loadModels() { try { TREE = OBJLoader.loadModel(new File("assets/model/tree_pine_0.obj")); PLAYER = OBJLoader.loadModel(new File("assets/model/player.obj")); } catch (Exception e) { e.printStackTrace(); } } public void render(Vector3f position, Vector3f scale, Vector3f rotation, Texture texture, float shinyness) { glPushMatrix(); { texture.bind(); glColor3f(1, 1, 1); glTranslatef(position.x, position.y, position.z); glScalef(scale.x, scale.y, scale.z); glRotatef(rotation.x, 1, 0, 0); glRotatef(rotation.y, 0, 1, 0); glRotatef(rotation.z, 0, 0, 1); glMaterialf(GL_FRONT, GL_SHININESS, shinyness); glBegin(GL_TRIANGLES); { for (Face face : faces) { Vector2f t1 = textureCoords.get((int) face.textureCoords.x - 1); glTexCoord2f(t1.x, t1.y); Vector3f n1 = normals.get((int) face.normal.x - 1); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = vertices.get((int) face.vertex.x - 1); glVertex3f(v1.x, v1.y, v1.z); Vector2f t2 = textureCoords.get((int) face.textureCoords.y - 1); glTexCoord2f(t2.x, t2.y); Vector3f n2 = normals.get((int) face.normal.y - 1); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = vertices.get((int) face.vertex.y - 1); glVertex3f(v2.x, v2.y, v2.z); Vector2f t3 = textureCoords.get((int) face.textureCoords.z - 1); glTexCoord2f(t3.x, t3.y); Vector3f n3 = normals.get((int) face.normal.z - 1); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = vertices.get((int) face.vertex.z - 1); glVertex3f(v3.x, v3.y, v3.z); } texture.release(); } glEnd(); } glPopMatrix(); } } Textures.java public class Textures { public static Texture FLOOR; public static Texture PLAYER; public static Texture SKYBOX_TOP; public static Texture SKYBOX_BOTTOM; public static Texture SKYBOX_FRONT; public static Texture SKYBOX_BACK; public static Texture SKYBOX_LEFT; public static Texture SKYBOX_RIGHT; public static void loadTextures() { try { FLOOR = TextureLoader.getTexture("PNG", new FileInputStream(new File("assets/model/floor.png"))); FLOOR.setTextureFilter(GL11.GL_NEAREST); PLAYER = TextureLoader.getTexture("PNG", new FileInputStream(new File("assets/model/tree_pine_0.png"))); PLAYER.setTextureFilter(GL11.GL_NEAREST); SKYBOX_TOP = TextureLoader.getTexture("PNG", new FileInputStream(new File("assets/textures/skybox_top.png"))); SKYBOX_TOP.setTextureFilter(GL11.GL_NEAREST); SKYBOX_BOTTOM = TextureLoader.getTexture("PNG", new FileInputStream(new File("assets/textures/skybox_bottom.png"))); SKYBOX_BOTTOM.setTextureFilter(GL11.GL_NEAREST); SKYBOX_FRONT = TextureLoader.getTexture("PNG", new FileInputStream(new File("assets/textures/skybox_front.png"))); SKYBOX_FRONT.setTextureFilter(GL11.GL_NEAREST); SKYBOX_BACK = TextureLoader.getTexture("PNG", new FileInputStream(new File("assets/textures/skybox_back.png"))); SKYBOX_BACK.setTextureFilter(GL11.GL_NEAREST); SKYBOX_LEFT = TextureLoader.getTexture("PNG", new FileInputStream(new File("assets/textures/skybox_left.png"))); SKYBOX_LEFT.setTextureFilter(GL11.GL_NEAREST); SKYBOX_RIGHT = TextureLoader.getTexture("PNG", new FileInputStream(new File("assets/textures/skybox_right.png"))); SKYBOX_RIGHT.setTextureFilter(GL11.GL_NEAREST); } catch (Exception e) { e.printStackTrace(); } } } Player.java public class Player { private Vector3f position; private float yaw; private float moveSpeed; public Player(float x, float y, float z, float yaw, float moveSpeed) { this.position = new Vector3f(x, y, z); this.yaw = yaw; this.moveSpeed = moveSpeed; } public void update() { if (Keyboard.isKeyDown(Keyboard.KEY_W)) walkForward(moveSpeed); if (Keyboard.isKeyDown(Keyboard.KEY_S)) walkBackwards(moveSpeed); if (Keyboard.isKeyDown(Keyboard.KEY_A)) strafeLeft(moveSpeed); if (Keyboard.isKeyDown(Keyboard.KEY_D)) strafeRight(moveSpeed); if (Mouse.isButtonDown(0)) yaw += Mouse.getDX(); LowPolyRPG.getInstance().getCamera().setPosition(-position.x, -position.y, -position.z); LowPolyRPG.getInstance().getCamera().setYaw(yaw); } public void walkForward(float distance) { position.setX(position.getX() + distance * (float) Math.sin(Math.toRadians(yaw))); position.setZ(position.getZ() - distance * (float) Math.cos(Math.toRadians(yaw))); } public void walkBackwards(float distance) { position.setX(position.getX() - distance * (float) Math.sin(Math.toRadians(yaw))); position.setZ(position.getZ() + distance * (float) Math.cos(Math.toRadians(yaw))); } public void strafeLeft(float distance) { position.setX(position.getX() + distance * (float) Math.sin(Math.toRadians(yaw - 90))); position.setZ(position.getZ() - distance * (float) Math.cos(Math.toRadians(yaw - 90))); } public void strafeRight(float distance) { position.setX(position.getX() + distance * (float) Math.sin(Math.toRadians(yaw + 90))); position.setZ(position.getZ() - distance * (float) Math.cos(Math.toRadians(yaw + 90))); } public void render() { Model.PLAYER.render(new Vector3f(position.x, position.y + 12, position.z), new Vector3f(3, 3, 3), new Vector3f(0, -yaw + 90, 0), Textures.PLAYER, 128); GL11.glPushMatrix(); GL11.glTranslatef(position.getX(), position.getY(), position.getZ()); GL11.glRotatef(-yaw, 0, 1, 0); GL11.glScalef(5.8f, 21, 2.2f); GL11.glDisable(GL11.GL_LIGHTING); GL11.glLineWidth(3); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glColor3f(1, 1, 1); glVertex3f(1f, 0f, -1f); glVertex3f(-1f, 0f, -1f); glVertex3f(-1f, 1f, -1f); glVertex3f(1f, 1f, -1f); glVertex3f(-1f, 0f, 1f); glVertex3f(1f, 0f, 1f); glVertex3f(1f, 1f, 1f); glVertex3f(-1f, 1f, 1f); glVertex3f(1f, 1f, -1f); glVertex3f(-1f, 1f, -1f); glVertex3f(-1f, 1f, 1f); glVertex3f(1f, 1f, 1f); glVertex3f(1f, 0f, 1f); glVertex3f(-1f, 0f, 1f); glVertex3f(-1f, 0f, -1f); glVertex3f(1f, 0f, -1f); glVertex3f(1f, 0f, 1f); glVertex3f(1f, 0f, -1f); glVertex3f(1f, 1f, -1f); glVertex3f(1f, 1f, 1f); glVertex3f(-1f, 0f, -1f); glVertex3f(-1f, 0f, 1f); glVertex3f(-1f, 1f, 1f); glVertex3f(-1f, 1f, -1f); GL11.glEnd(); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } public Vector3f getPosition() { return new Vector3f(-position.x, -position.y, -position.z); } public float getX() { return position.getX(); } public float getY() { return position.getY(); } public float getZ() { return position.getZ(); } public void setPosition(Vector3f position) { this.position = position; } public void setPosition(float x, float y, float z) { this.position.setX(x); this.position.setY(y); this.position.setZ(z); } } Thanks for the help.

    Read the article

  • A design pattern for data binding an object (with subclasses) to asp.net user control

    - by Rohith Nair
    I have an abstract class called Address and I am deriving three classes ; HomeAddress, Work Address, NextOfKin address. My idea is to bind this to a usercontrol and based on the type of Address it should bind properly to the ASP.NET user control. My idea is the user control doesn't know which address it is going to present and based on the type it will parse accordingly. How can I design such a setup, based on the fact that, the user control can take any type of address and bind accordingly. I know of one method like :- Declare class objects for all the three types (Home,Work,NextOfKin). Declare an enum to hold these types and based on the type of this enum passed to user control, instantiate the appropriate object based on setter injection. As a part of my generic design, I just created a class structure like this :- I know I am missing a lot of pieces in design. Can anybody give me an idea of how to approach this in proper way.

    Read the article

  • Problem in Addon Domain name binding with existing directory in my webspace

    - by articlestack
    I recently purchased a domain thinkzarahatke.com. At the time of purchasing i selected an option, say url redirect, to my existing site. Further I had entered Naming server detail. But I dint find any other option to change URL rewrite parameters under Domain Name Manager. From the cPanel of my hosting space, I had added new domain as addon and set a sundirectory for it. Now If I am trying to access my new domain directly, it is automatically redirecting to my old website. While if i access some inside directory, like thinkzarahatke.com/blog, then i am able to access to my new site. What wrong i done? Please tell me if i need to do some more settings with addon domain.

    Read the article

  • Qt Jambi : codons notre première fenêtre avec le binding Java de Qt, un tutoriel de Natim

    Vous avez envie d'avoir des interfaces qui s'adaptent à votre environnement de travail ? Et, en plus, pour tout un tas de raisons, vous souhaitez le faire en Java plutôt qu'en C++ ? Allons-y, je vais vous expliquer pas à pas ma démarche. Ce tutoriel n'a pas pour vocation d'être la bible du Qt Jambi mais plutôt de vous aider à vous jeter dans la gueule du loup relativement simplement (ce qui est écrit juste après est le fruit de plusieurs heures de recherches). Du Qt en Java avec Qt Jambi...

    Read the article

  • Templates and Cross-domain client-side binding with RadGrid for ASP.NET AJAX

    Or yet another Twitter grid Yesterday, while I was playing around with this example of our MVC Grid, I thought that the RadGrid for ASP.NET AJAX deserves one too. What I like about this sample scenario is that it gives a perfect opportunity to demonstrate both how to do client cross-site request (as we have received a few questions through our support channels) and to check the future ASP.NET AJAX/jQuery client-side templates prototype.     A wiser guy once said a code sample is worth more than a 1000 words ;) That is why Ill keep it short and let you check the sample project.   Enjoy.Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Binding BoundingSpheres to a world matrix in XNA

    - by NDraskovic
    I made a program that loads the locations of items on the scene from a file like this: using (StreamReader sr = new StreamReader(OpenFileDialog1.FileName)) { String line; while ((line = sr.ReadLine()) != null) { red = line.Split(','); model = row[0]; x = row[1]; y = row[2]; z = row[3]; elements.Add(Convert.ToInt32(model)); data.Add(new Vector3(Convert.ToSingle(x), Convert.ToSingle(y), Convert.ToSingle(z))); sfepheres.Add(new BoundingSphere(new Vector3(Convert.ToSingle(x), Convert.ToSingle(y), Convert.ToSingle(z)), 1f)); } I also have a list of BoundingSpheres (called spheres) that adds a new bounding sphere for each line from the file. In this program I have one item (a simple box) that moves (it has its world matrix called matrixBox), and other items are static entire time (there is a world matrix that holds those elements called simply world). The problem i that when I move the box, bounding spheres move with it. So how can I bind all BoundingSpheres (except the one corresponding to the box) to the static world matrix so that they stay in their place when the box moves?

    Read the article

  • Binding in the view or the controller?

    - by da_b0uncer
    I've seen 2 different approaches with MVC on the web. One, like in ExtJS, is to bind the callbacks to the view via the controller. Finding every element on the view and adding the functionallity. The other, like in angular.js and in the lift-framework server-side, too, is to bind in the views and just write the functionallity in the controller. Which is better and cleaner? The ExtJS approach has dumb views and all the logic in the controller. Which seems clean to me. I had problems with global IDs for GUI-elements or relative navigation to GUI-elements in this approach. When I changed the view, the controller couldn't find the buttons anymore or I had multiple instances of one button with the same ID on a single application, because of the global ID. But I solved this with IDs that are only global in a view and can be on the application multiple times. So I could mess with the (dumb) views layout and design and the functionallity wouldn't break. The angular.js approach with the bindings in the view don't has the problem with global IDs. Also, the person who changes something in the view layout has to know the IDs anyway, so the controller can put the data at the right spot. So if I write <a ng-click="doThis()" /> for angular.js and implement doThis() or <a lid="buttonwhichdoesthis" /> for extjs and find the element with the local id and add doThis() as handler on the controller side, seems to be not so different. The only thing is, the second one has one more layer of indirection, which seems cleaner. The first one seems somehow to cost less effort.

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >